X-Git-Url: http://git.onelab.eu/?p=sfa-gui.git;a=blobdiff_plain;f=SfaBrowser.py;h=fe3f4acae5613bf7dfee6770d2f02acc784d417a;hp=14e8fc001a3e51165c11bbc79ca43769897223d4;hb=978dcbb57286e221bf3499068dc7fbabbfdace1c;hpb=4c3865f7bc1d92a5598dc1d62f13b293f2d0fe9f diff --git a/SfaBrowser.py b/SfaBrowser.py index 14e8fc0..fe3f4ac 100644 --- a/SfaBrowser.py +++ b/SfaBrowser.py @@ -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 = "%s" % last + elif self.kind == "(slice)": + self.label = "%s" % last + elif self.kind == "(user)": + self.label = "%s" % last + else: + self.label = "%s" % 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