1 import string
2 from Tkinter import *
3 import Pmw
4 from teamwork.widgets.TreeEditor import TreeEditor
5
7
9 optiondefs = (
10 ('entity', None, Pmw.INITOPT),
11 )
12 self.defineoptions(kw, optiondefs)
13 TreeEditor.__init__(self,parent)
14 widget = self.createcomponent('Entry',(),None,
15 Pmw.EntryField,
16 (self.pane('editorPane'),),
17 )
18 widget.pack_forget()
19 self.component('box').add('Test...',command=self.generate)
20 self.configure(tree=self['entity'].actions)
21 self.initialiseoptions()
22
24 tree = self.selectedTree()
25 if leafType == 'relationship':
26 widget = self.component('feature0')
27 widget.setitems(self['entity'].getRelationships())
28 widget.pack(fill='x')
29 widget.configure(menubutton_state='normal')
30 if tree.split == leafType:
31 widget.invoke(tree._children[0])
32 widget = self.component('feature1')
33 widget.setitems(['object'])
34 widget.pack(fill='x')
35 widget.configure(menubutton_state='normal')
36 if tree.split == leafType:
37 widget.invoke(tree.key)
38 self.component('Entry').pack_forget()
39 elif leafType == 'generic':
40 widget = self.component('feature0')
41 itemList = self['entity'].hierarchy.keys()
42 itemList.sort()
43 widget.setitems(itemList)
44 widget.pack(fill='x')
45 widget.configure(menubutton_state='normal')
46 if tree.split == leafType:
47 widget.invoke(tree._children[0])
48 widget = self.component('feature1')
49 widget.setitems(['object'])
50 widget.pack(fill='x')
51 widget.configure(menubutton_state='normal')
52 if tree.split == leafType:
53 widget.invoke(tree.key)
54 self.component('Entry').pack_forget()
55 elif leafType == 'literal':
56 self.component('feature1').pack_forget()
57 widget = self.component('feature0')
58 widget.setitems(['object','type'])
59 widget.pack(fill='x')
60 widget.configure(menubutton_state='normal')
61 if tree.split == leafType:
62 widget.invoke(tree.key)
63 widget = self.component('Entry')
64 widget.pack(after=self.component('feature0'),side='top',
65 fill='x',expand='yes')
66 if tree.split == leafType:
67 widget.setvalue(tree._children[0])
68 else:
69 raise NotImplementedError,'Unable to edit leaves of type %s' % \
70 (leafType)
71
73 self.component('feature0').pack_forget()
74 self.component('feature1').pack_forget()
75 self.component('Entry').pack_forget()
76
78 names = ['generic','literal','relationship']
79 self.component('type').setitems(names)
80 tree = self.selectedTree()
81 self.component('type').invoke(tree.split)
82
87
105
107 tree = self.selectedTree()
108 if tree:
109 tree.generateOptions(debug=True)
110 actions = tree.getOptions()
111 else:
112 actions = self['entity'].actions.getOptions()
113 if len(actions) == 0:
114 msg = 'No actions.'
115 else:
116 msg = string.join(map(lambda a:str(a),actions),'\n')
117 dialog = Pmw.MessageDialog(self.component('hull'),
118 title='Actions for %s' % \
119 (self['entity'].ancestry()),
120 message_text=msg)
121 dialog.activate()
122
130
132 tkMessageBox.showerror('Delete Node','Not implemented')
133