Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 103 lines (74 sloc) 2.747 kB
7a39225 merge dynamic branch manually
lkcl authored
1 from pyjamas.ui.Tree import Tree
2 from pyjamas.ui.TreeItem import TreeItem
3 from pyjamas.ui.Composite import Composite
4 from pyjamas.ui.RootPanel import RootPanel
5 from pyjamas.ui.HTML import HTML
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
6 from pyjamas import Window
7
8 from pyjamas.JSONService import JSONProxy
be119eb add an info display example using split panel, treeview and grid sele…
lkcl authored
9
10 class Trees(Composite):
11 def __init__(self):
12 Composite.__init__(self)
13
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
14 self.fProto = []
be119eb add an info display example using split panel, treeview and grid sele…
lkcl authored
15 self.fTree = Tree()
16
17 self.fTree.addTreeListener(self)
18 self.initWidget(self.fTree)
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
19 self.remote = InfoServicePython()
20 self.remote.index("", 1, self)
21
22 def protoise_tree(self, data):
23
24 res = []
25 for i in range(len(data)):
26 d = data[i]
27 name = d[0]
28 children = d[1]
29
30 res.append(Proto(name, self.protoise_tree(children)))
31 return res
32
33 def create_tree(self, data):
34
35 self.fProto = self.protoise_tree(data)
be119eb add an info display example using split panel, treeview and grid sele…
lkcl authored
36
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
37 for i in range(len(self.fProto)):
38 p = self.fProto[i]
39 p.pathify()
40 self.createItem(p)
41 self.fTree.addItem(p.item)
42
43 def onRemoteResponse(self, response, request_info):
44 if request_info.method == "index":
45 self.create_tree(response)
46
47 def onRemoteError(self, code, message, request_info):
48 RootPanel().add(HTML("Server Error or Invalid Response: ERROR " + code + " - " + message))
49
be119eb add an info display example using split panel, treeview and grid sele…
lkcl authored
50 def onTreeItemSelected(self, item):
51 pass
52
53 def onTreeItemStateChanged(self, item):
54 child = item.getChild(0)
55 if hasattr(child, "isPendingItem"):
56 item.removeItem(child)
57
58 proto = item.getUserObject()
59 for i in range(len(proto.children)):
60 self.createItem(proto.children[i])
61 item.addItem(proto.children[i].item)
62
63 def createItem(self, proto):
64 proto.item = TreeItem(proto.text)
65 proto.item.setUserObject(proto)
66 if len(proto.children) > 0:
67 proto.item.addItem(PendingItem())
68
69
70 class Proto:
71 def __init__(self, text, children=None):
72 self.children = []
73 self.item = None
74 self.text = text
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
75 self.root = '/'
be119eb add an info display example using split panel, treeview and grid sele…
lkcl authored
76
7b39338 general cleanup from stefan, != None must be is not None etc.
lkcl authored
77 if children is not None:
be119eb add an info display example using split panel, treeview and grid sele…
lkcl authored
78 self.children = children
79
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
80 def pathify(self):
81 """ cascade setup of full path
82 """
83
84 for c in self.children:
85 c.root = self.root + self.text + "/"
86 c.pathify()
87
be119eb add an info display example using split panel, treeview and grid sele…
lkcl authored
88
89 class PendingItem(TreeItem):
90 def __init__(self):
91 TreeItem.__init__(self, "Please wait...")
92
93 def isPendingItem(self):
94 return True
95
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
96
97 class InfoServicePython(JSONProxy):
98 def __init__(self):
99 JSONProxy.__init__(self, "/infoservice/EchoService.py",
100 ["index"])
101
102
Something went wrong with that request. Please try again.