svn commit: samba r22487 - in	branches/SAMBA_4_0/webapps/swat/source/class/swat/module/netmgr: . Author: mimir
Date: 2007-04-23 13:37:33 +0000 (Mon, 23 Apr 2007)
New Revision: 22487

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22487

Log:
Add a separate widget class for listing users and reposition
things on NetManager's screen. Qooxdoo layout positioning can
be tricky sometimes...


rafal


Added:
   branches/SAMBA_4_0/webapps/swat/source/class/swat/module/netmgr/UsersView.js
Modified:
   branches/SAMBA_4_0/webapps/swat/source/class/swat/module/netmgr/Gui.js


Changeset:
Modified: branches/SAMBA_4_0/webapps/swat/source/class/swat/module/netmgr/Gui.js
===================================================================
--- branches/SAMBA_4_0/webapps/swat/source/class/swat/module/netmgr/Gui.js	2007-04-23 12:31:12 UTC (rev 22486)
+++ branches/SAMBA_4_0/webapps/swat/source/class/swat/module/netmgr/Gui.js	2007-04-23 13:37:33 UTC (rev 22487)
@@ -2,6 +2,7 @@
  * Copyright (C)  Rafal Szczesniak 2007
  */
 
+
 /**
  * Swat Net Manager class graphical user interface
  */
@@ -14,7 +15,6 @@
 
 //qx.OO.addProperty({ name : "_tree", type : "object" });
 //qx.OO.addProperty({ name : "_panel", type : "object" });
-//qx.OO.addProperty({ name : "_view", type : "object" });
 //qx.OO.addProperty({ name : "_txtDomain", type : "object" });
 //qx.OO.addProperty({ name : "_txtUsername", type : "object" });
 
@@ -30,9 +30,9 @@
   // Main layout composing the whole form
   var vlayout = new qx.ui.layout.VerticalBoxLayout();
   vlayout.set({
-                top: 20,
-                left: 20,
-                width: "100%",
+                top: 10,
+                left: 10,
+                right: 10,
                 bottom: 20
               });
 
@@ -70,37 +70,17 @@
   // "Panel" for list view
   this._panel = new qx.ui.layout.VerticalBoxLayout();
   var panel = this._panel;
-  
+
+  // TODO: Find out what's causing this bug - specifying 'width' works fine,
+  // but setting 'right' instead does not which makes impossible to position
+  // the panel against right boundary of a box
   panel.set({
               top: 0,
               left: 10,
-              width: "80%",
+              width:"80%",
               height: "100%"
             });
 
-  // Setup some initial columns and (empty) item list - to be replaced soon
-  // with default view loading
-  var columns = { name : { label: "Name", width: 120, type: "text" }};
-  var items = [];
-
-  // Setup the list view
-  this._view = new qx.ui.listview.ListView(items, columns);
-  var view = this._view;
-  view.setBorder(qx.renderer.border.BorderPresets.getInstance().shadow);
-  view.setBackgroundColor("white");
-  view.set({
-             top: 0,
-             left: 0,
-             width: "80%",
-             height: "100%"
-           });
-
-  // Give a list view name to handle
-  fsm.addObject("view", view);
-
-  // and the list view to the panel
-  panel.add(view);
-  
   // Add the tree view and panel for list view to the layout
   hlayout.add(tree);
   hlayout.add(panel);
@@ -110,8 +90,8 @@
   statusLayout.set({
                      top: 10,
                      left: 0,
-                     right: 0,
-                     height: "100%"
+                     width: "100%",
+                     height: "20%"
                    });
 
   // First "column" of status fields
@@ -119,13 +99,13 @@
   colALayout.set({
                   top: 0,
                   left: 0,
-                  width: 150,
+                  width: "25%",
                   height: "100%"
                 });
 
   // Domain name (credentials) - label and text box
   var statusDomain = new qx.ui.layout.HorizontalBoxLayout();
-  statusDomain.set({ top: 0, left: 0, width: "100%", height: 20,
+  statusDomain.set({ top: 0, left: 0, width: "100%", height: "auto",
 		       verticalChildrenAlign: "middle" });
   
   var lblDomain = new qx.ui.basic.Atom();
@@ -141,7 +121,7 @@
   
   // Username (credentials) - label and text box
   var statusUsername = new qx.ui.layout.HorizontalBoxLayout();
-  statusUsername.set({ top: 0, left: 0, width: "100%", height: 20,
+  statusUsername.set({ top: 0, left: 0, width: "100%", height: "auto",
                        verticalChildrenAlign: "middle" });
 
   var lblUsername = new qx.ui.basic.Atom();
@@ -281,7 +261,13 @@
 qx.Proto._initUserManager = function(module, rpcRequest)
 {
   // Get obtained UsrCtx handle
-  var result = rpcRequest.getUserData("result").data;
+  var usrCtx = rpcRequest.getUserData("result").data;
+
+  // Create user view and pass the context
+  var view = new swat.module.netmgr.UsersView(module.fsm);
+  view.setUsrCtx(usrCtx);
+  
+  this._panel.add(view);
 };
 
 

Added: branches/SAMBA_4_0/webapps/swat/source/class/swat/module/netmgr/UsersView.js
===================================================================
--- branches/SAMBA_4_0/webapps/swat/source/class/swat/module/netmgr/UsersView.js	2007-04-23 12:31:12 UTC (rev 22486)
+++ branches/SAMBA_4_0/webapps/swat/source/class/swat/module/netmgr/UsersView.js	2007-04-23 13:37:33 UTC (rev 22487)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C)  Rafal Szczesniak 2007
+ */
+
+//qx.OO.addProperty({ name: "_fsm", type: "object"});
+//qx.OO.addProperty({ name: "_columns", type: "object"});
+//qx.OO.addProperty({ name: "_items", type: "object"});
+//qx.OO.addProperty({ name: "_view", type: "object" });
+
+/**
+ * Users View 
+ */
+qx.OO.defineClass("swat.module.netmgr.UsersView", qx.ui.layout.HorizontalBoxLayout,
+function(fsm)
+{
+  qx.ui.layout.HorizontalBoxLayout.call(this);
+
+  this._fsm = fsm;
+  
+  // Set the whole view panel size and spacing between boxes
+  this.set({ top: 0, left: 0, width: "100%", height: "100%" });
+  this.setSpacing(5);
+
+  // Provide vertical positioning of combo box and list view
+  var innerBox = new qx.ui.layout.VerticalBoxLayout();
+  innerBox.set({ top: 0, left: 0, width: "100%", height: "100%"});
+
+  // horizontal box for domain selection label and combo box
+  var selectDomainBox = new qx.ui.layout.HorizontalBoxLayout();
+  selectDomainBox.set({ top: 0, left: 0, width: "auto", height: "10%" });
+  selectDomainBox.setVerticalChildrenAlign("middle");
+  selectDomainBox.setSpacing(5);
+  
+  // Setup domain selection combo box
+  var lblDomain = new qx.ui.basic.Atom("Domain:");
+  lblDomain.setHorizontalChildrenAlign("right");
+  
+  var cmbDomain = new qx.ui.form.ComboBox();
+  cmbDomain.setEditable(false);
+
+  // Create an empty list view with sample column
+  this._columns = { username : { label: "Username", width: 150, type: "text" }};
+  this._items = [];
+  this._view = new qx.ui.listview.ListView(this._items, this._columns);
+  var view = this._view;
+  view.set({ top: 0, left: 0, width: "90%", height: "90%" });
+  view.setBorder(qx.renderer.border.BorderPresets.getInstance().shadow);
+
+  // Arrange widgets and boxes
+  selectDomainBox.add(lblDomain);
+  selectDomainBox.add(cmbDomain);
+
+  innerBox.add(selectDomainBox);
+  innerBox.add(view);
+
+  // place the inner box in the UsersView box
+  this.add(innerBox);
+});
+
+
+// UsrMgr context is required for any operation on user accounts
+qx.OO.addProperty({ name : "usrCtx", type : "number" });

