SFA browser basic functionality
[sfa-gui.git] / SinkList.py
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 addSink(self, info):
17         name = info.getName()
18         link = Hyperlink(name, False, 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