Tweaks for first demo of GUI
Andy Bavier [Thu, 10 Jun 2010 15:08:30 +0000 (11:08 -0400)]
SfaBrowser.py
SfaGUI.py

index 14e8fc0..fe3f4ac 100644 (file)
@@ -13,14 +13,22 @@ class PopupRecord(PopupPanel):
         self.setStyleName("ks-popups-Popup")
 
 class SfaItem(TreeItem):
-    def __init__(self, hrn, authority = False):
-        self.isAuthority = authority
+    def __init__(self, hrn, kind):
+        self.kind = kind
         self.hrn = hrn
         last = hrn.split('.')[-1]
-        self.label = last
+        if self.kind == "(authority)":
+            self.label = "<b>%s</b>" % last
+        elif self.kind == "(slice)":
+            self.label = "<u><i>%s</i></u>" % last
+        elif self.kind == "(user)":
+            self.label = "%s" % last
+        else:
+            self.label = "<b>%s</b>" % last
+
         TreeItem.__init__(self, self.label)
 
-        if self.isAuthority:
+        if self.kind == "(authority)":
             self.addItem(PendingItem())
 
 class PendingItem(TreeItem):
@@ -39,10 +47,10 @@ class SfaBrowser(Sink):
 
         self.tree = Tree()
         
-        item = SfaItem("plc", True)
+        item = SfaItem("plc", "(authority)")
         self.tree.addItem(item)
 
-        item = SfaItem("ple", True)
+        item = SfaItem("ple", "(authority)")
         self.tree.addItem(item)
 
         self.tree.addTreeListener(self)
@@ -59,12 +67,14 @@ class SfaBrowser(Sink):
         p.show()
 
     def onTreeItemStateChanged(self, item):
+        self.tree.moveFocus(item)
         child = item.getChild(0)
         if hasattr(child, "isPendingItem"):
             item.removeItem(child)
-            hrns = self.data.listChildren(item.hrn)
+            hrns = sorted(self.data.listChildren(item.hrn), 
+                          key=lambda hrn: hrn[0])
             for (hrn, kind) in hrns:
-                item.addItem(SfaItem(hrn, (kind=="(authority)")))
+                item.addItem(SfaItem(hrn, kind))
 
     def onShow(self):
         pass
index aa23ace..11f9a32 100644 (file)
--- a/SfaGUI.py
+++ b/SfaGUI.py
@@ -90,11 +90,11 @@ class SfaGUI:
         
     def loadSinks(self):
         self.sink_list.addSink(Welcome.init())
-        self.sink_list.addSink(Identities.init())
+        #self.sink_list.addSink(Identities.init())
         # self.sink_list.addSink(Slices.init())
         self.sink_list.addSink(PlanetLab.init())
         self.sink_list.addSink(VINI.init())
-        self.sink_list.addSink(OpenCirrus.init())
+        #self.sink_list.addSink(OpenCirrus.init())
         self.sink_list.addSink(SfaBrowser.init())
         self.sink_list.addSink(Configure.init())