Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 110 lines (80 sloc) 2.797 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()
64eff55 @xtfxme find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
16
be119eb add an info display example using split panel, treeview and grid sele…
lkcl authored
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)
64eff55 @xtfxme find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
21
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
22 def protoise_tree(self, data):
23
f82251d fix examples, infohierarchy and employeeadmin
lkcl authored
24 if not data:
25 return []
26
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
27 res = []
28 for i in range(len(data)):
29 d = data[i]
30 name = d[0]
31 children = d[1]
32
33 res.append(Proto(name, self.protoise_tree(children)))
34 return res
35
36 def create_tree(self, data):
37
38 self.fProto = self.protoise_tree(data)
64eff55 @xtfxme find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
39
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
40 for i in range(len(self.fProto)):
41 p = self.fProto[i]
42 p.pathify()
43 self.createItem(p)
44 self.fTree.addItem(p.item)
45
46 def onRemoteResponse(self, response, request_info):
47 if request_info.method == "index":
48 self.create_tree(response)
49
50 def onRemoteError(self, code, message, request_info):
43c6ee0 @keesbos Minor error handling fix in infohierarchy example
keesbos authored
51 RootPanel().add(HTML(
52 "Server Error or Invalid Response: ERROR %s - %s" % (
53 code, message,
54 ),
55 ))
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
56
be119eb add an info display example using split panel, treeview and grid sele…
lkcl authored
57 def onTreeItemSelected(self, item):
58 pass
64eff55 @xtfxme find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
59
be119eb add an info display example using split panel, treeview and grid sele…
lkcl authored
60 def onTreeItemStateChanged(self, item):
61 child = item.getChild(0)
62 if hasattr(child, "isPendingItem"):
63 item.removeItem(child)
64eff55 @xtfxme find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
64
be119eb add an info display example using split panel, treeview and grid sele…
lkcl authored
65 proto = item.getUserObject()
66 for i in range(len(proto.children)):
67 self.createItem(proto.children[i])
68 item.addItem(proto.children[i].item)
69
70 def createItem(self, proto):
71 proto.item = TreeItem(proto.text)
72 proto.item.setUserObject(proto)
73 if len(proto.children) > 0:
74 proto.item.addItem(PendingItem())
75
76
77 class Proto:
78 def __init__(self, text, children=None):
79 self.children = []
80 self.item = None
81 self.text = text
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
82 self.root = '/'
64eff55 @xtfxme find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
83
7b39338 general cleanup from stefan, != None must be is not None etc.
lkcl authored
84 if children is not None:
be119eb add an info display example using split panel, treeview and grid sele…
lkcl authored
85 self.children = children
86
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
87 def pathify(self):
88 """ cascade setup of full path
89 """
90
91 for c in self.children:
92 c.root = self.root + self.text + "/"
93 c.pathify()
94
be119eb add an info display example using split panel, treeview and grid sele…
lkcl authored
95
96 class PendingItem(TreeItem):
97 def __init__(self):
98 TreeItem.__init__(self, "Please wait...")
99
100 def isPendingItem(self):
101 return True
102
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
103
104 class InfoServicePython(JSONProxy):
105 def __init__(self):
99d68fe @keesbos Minor fix for infoservices example (directory name changed)
keesbos authored
106 JSONProxy.__init__(self, "services/EchoService.py",
64b770b use cgi-bin JSONRPC to read data from filesystem
lkcl authored
107 ["index"])
108
109
Something went wrong with that request. Please try again.