X-Git-Url: http://git.onelab.eu/?p=sfa-gui.git;a=blobdiff_plain;f=SfaBrowser.py;h=30442e8b8d30c11c4d1895251403c867bf36e88e;hp=14e8fc001a3e51165c11bbc79ca43769897223d4;hb=743fb4d29bdf0e58bffb84b420f922c722a8d8cb;hpb=4c3865f7bc1d92a5598dc1d62f13b293f2d0fe9f
diff --git a/SfaBrowser.py b/SfaBrowser.py
index 14e8fc0..30442e8 100644
--- a/SfaBrowser.py
+++ b/SfaBrowser.py
@@ -4,6 +4,9 @@ from pyjamas.ui.PopupPanel import PopupPanel
from pyjamas.ui.HTML import HTML
from SfaData import PlanetLabData
+def alwaysDelegateFocus(elem):
+ return True
+
class PopupRecord(PopupPanel):
def __init__(self, record):
PopupPanel.__init__(self, True)
@@ -13,14 +16,23 @@ 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, truncate = True):
+ self.kind = kind
self.hrn = hrn
- last = hrn.split('.')[-1]
- self.label = last
+ if truncate:
+ hrn = hrn.split('.')[-1]
+ if self.kind == "(authority)":
+ self.label = "%s" % hrn
+ elif self.kind == "(slice)":
+ self.label = "%s" % hrn
+ elif self.kind == "(user)":
+ self.label = "%s" % hrn
+ else:
+ self.label = "%s" % hrn
+
TreeItem.__init__(self, self.label)
- if self.isAuthority:
+ if self.kind == "(authority)":
self.addItem(PendingItem())
class PendingItem(TreeItem):
@@ -38,11 +50,21 @@ class SfaBrowser(Sink):
self.data = PlanetLabData()
self.tree = Tree()
+ self.tree.shouldTreeDelegateFocusToElement = alwaysDelegateFocus
- item = SfaItem("plc", True)
+ item = SfaItem("plc", "(authority)", truncate = False)
+ self.tree.addItem(item)
+
+ item = SfaItem("plc.glc", "(authority)", truncate = False)
+ self.tree.addItem(item)
+
+ item = SfaItem("plc.vini", "(authority)", truncate = False)
+ self.tree.addItem(item)
+
+ item = SfaItem("ple", "(authority)", truncate = False)
self.tree.addItem(item)
- item = SfaItem("ple", True)
+ item = SfaItem("plj", "(authority)", truncate = False)
self.tree.addItem(item)
self.tree.addTreeListener(self)
@@ -62,9 +84,10 @@ class SfaBrowser(Sink):
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