Package library :: Package pyjamas :: Package ui :: Module Sink
[hide private]
[frames] | no frames]

Source Code for Module library.pyjamas.ui.Sink

 1  from pyjamas.ui.Composite import Composite 
 2  from pyjamas.ui.VerticalPanel import VerticalPanel 
 3  from pyjamas.ui.Hyperlink import Hyperlink 
 4   
5 -class SinkList(Composite):
6 - def __init__(self):
7 Composite.__init__(self) 8 9 self.vp_list=VerticalPanel() 10 self.sinks=[] 11 self.selectedSink=-1 12 13 self.initWidget(self.vp_list) 14 self.setStyleName("ks-List")
15
16 - def add(self, info):
17 name = info.getName() 18 link = Hyperlink(name, False, TargetHistoryToken=name) 19 link.setStyleName("ks-SinkItem") 20 self.vp_list.add(link) 21 self.sinks.append(info)
22
23 - def find(self, sinkName):
24 for info in self.sinks: 25 if info.getName()==sinkName: 26 return info 27 return None
28
29 - def setSinkSelection(self, name):
30 if self.selectedSink <> -1: 31 self.vp_list.getWidget(self.selectedSink).removeStyleName("ks-SinkItem-selected") 32 33 for i in range(len(self.sinks)): 34 info = self.sinks[i] 35 if (info.getName()==name): 36 self.selectedSink = i 37 widget=self.vp_list.getWidget(self.selectedSink) 38 widget.addStyleName("ks-SinkItem-selected") 39 return
40 41
42 -class Sink(Composite):
43 - def __init__(self):
45
46 - def onHide(self):
47 pass
48
49 - def onShow(self):
50 pass
51
52 - def baseURL(self):
53 return ""
54
55 -class SinkInfo:
56 - def __init__(self, name, desc, object_type):
57 self.name=name 58 self.description=desc 59 self.object_type=object_type 60 self.instance=None
61
62 - def createInstance(self):
63 obj = self.object_type() 64 obj.name = self.name 65 return obj
66
67 - def getDescription(self):
68 return self.description
69
70 - def getInstance(self):
71 if self.instance is None: 72 self.instance = self.createInstance() 73 return self.instance
74
75 - def getName(self):
76 return self.name
77