1 from pyjamas.ui.VerticalPanel import VerticalPanel
2 from pyjamas.ui.HorizontalPanel import HorizontalPanel
3 from pyjamas.ui.CaptionPanel import CaptionPanel
4 from pyjamas.ui.ListBox import ListBox
5 from pyjamas.ui.TextBox import TextBox
6 from pyjamas.ui.Button import Button
7 from pyjamas.ui.HTML import HTML
8 from pyjamas.ui import HasAlignment
10 class AddPanel(CaptionPanel):
11 def __init__(self, top):
12 CaptionPanel.__init__(self, "Add virtual link")
15 hp = HorizontalPanel()
17 self.end1.addItem("Endpoint 1")
18 for sliver in self.top.rspec.get_sliver_list():
19 self.end1.addItem(sliver)
22 self.end2.addItem("Endpoint 2")
23 for sliver in self.top.rspec.get_sliver_list():
24 self.end2.addItem(sliver)
27 self.bw.setText("1000")
32 hp.add(Button("Add", self.go))
37 end1 = self.end1.getItemText(self.end1.getSelectedIndex())
38 end2 = self.end2.getItemText(self.end2.getSelectedIndex())
39 bw = self.bw.getText()
44 class VlinkPanel(HorizontalPanel):
45 def __init__(self, top, description, bw):
46 HorizontalPanel.__init__(self)
47 self.description = description
52 self.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
53 b = Button("X", self.delete)
55 self.add(HTML("%s (%s kbps)" % (self.description, self.bw)))
57 def delete(self, sender):
61 class LinkPanel(VerticalPanel):
62 def __init__(self, sfadata, rspec):
63 VerticalPanel.__init__(self)
71 self.add(AddPanel(self))
73 cp = CaptionPanel("Virtual links")
75 vlinks = self.rspec.get_vlink_list()
76 for (desc, bw) in vlinks:
77 vp.add(VlinkPanel(self, desc, bw))