def __init__(self, owner): self.owner = owner self.bar = DockPanel() self.gotoFirst = Button("<<", self) self.gotoNext = Button(">", self) self.gotoPrev = Button("<", self) self.status = HTML() self.initWidget(self.bar) self.bar.setStyleName("navbar") self.status.setStyleName("status") buttons = HorizontalPanel() buttons.add(self.gotoFirst) buttons.add(self.gotoPrev) buttons.add(self.gotoNext) self.bar.add(buttons, DockPanel.EAST) self.bar.setCellHorizontalAlignment(buttons, HasAlignment.ALIGN_RIGHT) self.bar.add(self.status, DockPanel.CENTER) self.bar.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) self.bar.setCellHorizontalAlignment(self.status, HasAlignment.ALIGN_RIGHT) self.bar.setCellVerticalAlignment(self.status, HasAlignment.ALIGN_MIDDLE) self.bar.setCellWidth(self.status, "100%") self.gotoPrev.setEnabled(False) self.gotoFirst.setEnabled(False)
def __init__(self): DialogBox.__init__(self) # Use this opportunity to set the dialog's caption. self.setText("About the Mail Sample") # Create a DockPanel to contain the 'about' label and the 'OK' button. outer = DockPanel() outer.setSpacing(4) outer.add(Image(AboutDialog.LOGO_IMAGE), DockPanel.WEST) # Create the 'OK' button, along with a listener that hides the dialog # when the button is clicked. Adding it to the 'south' position within # the dock causes it to be placed at the bottom. buttonPanel = HorizontalPanel() buttonPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) buttonPanel.add(Button("Close", self)) outer.add(buttonPanel, DockPanel.SOUTH) # Create the 'about' label. Placing it in the 'rest' position within the # dock causes it to take up any remaining space after the 'OK' button # has been laid out. textplain = "This sample application demonstrates the construction " textplain += "of a complex user interface using pyjamas' built-in widgets. Have a look " textplain += "at the code to see how easy it is to build your own apps!" text = HTML(textplain) text.setStyleName("mail-AboutText") outer.add(text, DockPanel.CENTER) # Add a bit of spacing and margin to the dock to keep the components from # being placed too closely together. outer.setSpacing(8) self.setWidget(outer)
def __init__(self, calendar): Composite.__init__(self) self.calendar = calendar self.dayCheckBoxListener = DayCheckBoxListener(calendar) self.outer = VerticalPanel() self.setWidget(self.outer) self.setStyleName("DynaTable-DayFilterWidget") self.outer.add(DayCheckBox(self, "Sunday", 0)) self.outer.add(DayCheckBox(self, "Monday", 1)) self.outer.add(DayCheckBox(self, "Tuesday", 2)) self.outer.add(DayCheckBox(self, "Wednesday", 3)) self.outer.add(DayCheckBox(self, "Thursday", 4)) self.outer.add(DayCheckBox(self, "Friday", 5)) self.outer.add(DayCheckBox(self, "Saturday", 6)) self.buttonAll = Button("All", self) self.buttonNone = Button("None", self) hp = HorizontalPanel() hp.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) hp.add(self.buttonAll) hp.add(self.buttonNone) self.outer.add(hp) self.outer.setCellVerticalAlignment(hp, HasAlignment.ALIGN_BOTTOM) self.outer.setCellHorizontalAlignment(hp, HasAlignment.ALIGN_CENTER)
def createTextThing(self, textBox): p = HorizontalPanel() p.setSpacing(4) p.add(textBox) echo = HTML() select_all = Button("select all") p.add(select_all) p.add(echo) listener=TextBoxListener(self, textBox, echo, select_all) select_all.addClickListener(listener) textBox.addKeyboardListener(listener) textBox.addClickListener(listener) return p
def onModuleLoad(self): self.TEXT_WAITING = "Waiting for response..." self.TEXT_ERROR = "Server Error" self.remote_php = EchoServicePHP() self.remote_py = EchoServicePython() self.status=Label() self.text_area = TextArea() self.text_area.setText(r"{'Test'} [\"String\"]") self.text_area.setCharacterWidth(80) self.text_area.setVisibleLines(8) self.button_php = Button("Send to PHP Service", self) self.button_py = Button("Send to Python Service", self) buttons = HorizontalPanel() buttons.add(self.button_php) buttons.add(self.button_py) buttons.setSpacing(8) info = r"<h2>JSON-RPC Example</h2><p>This example demonstrates the calling of server services with <a href=\"http://json-rpc.org/\">JSON-RPC</a>." info += "<p>Enter some text below, and press a button to send the text to an Echo service on your server. An echo service simply sends the exact same text back that it receives." panel = VerticalPanel() panel.add(HTML(info)) panel.add(self.text_area) panel.add(buttons) panel.add(self.status) RootPanel().add(panel)
def __init__(self, calendar): Composite.__init__(self) self.calendar = calendar self.dayCheckBoxListener = DayCheckBoxListener(calendar) self.outer = VerticalPanel() self.initWidget(self.outer) self.setStyleName("DynaTable-DayFilterWidget") self.outer.add(DayCheckBox(self, "Sunday", 0)) self.outer.add(DayCheckBox(self, "Monday", 1)) self.outer.add(DayCheckBox(self, "Tuesday", 2)) self.outer.add(DayCheckBox(self, "Wednesday", 3)) self.outer.add(DayCheckBox(self, "Thursday", 4)) self.outer.add(DayCheckBox(self, "Friday", 5)) self.outer.add(DayCheckBox(self, "Saturday", 6)) self.buttonAll = Button("All", self) self.buttonNone = Button("None", self) hp = HorizontalPanel() hp.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) hp.add(self.buttonAll) hp.add(self.buttonNone) self.outer.add(hp) self.outer.setCellVerticalAlignment(hp, HasAlignment.ALIGN_BOTTOM) self.outer.setCellHorizontalAlignment(hp, HasAlignment.ALIGN_CENTER)
def __init__(self): DialogBox.__init__(self) # Use this opportunity to set the dialog's caption. self.setText("About the Mail Sample") # Create a DockPanel to contain the 'about' label and the 'OK' button. outer = DockPanel() outer.setSpacing(4) outer.add(Image(AboutDialog.LOGO_IMAGE), DockPanel.WEST) # Create the 'OK' button, along with a listener that hides the dialog # when the button is clicked. Adding it to the 'south' position within # the dock causes it to be placed at the bottom. buttonPanel = HorizontalPanel() buttonPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) buttonPanel.add(Button("Close", self)) outer.add(buttonPanel, DockPanel.SOUTH) # Create the 'about' label. Placing it in the 'rest' position within the # dock causes it to take up any remaining space after the 'OK' button # has been laid out. textplain = "This sample application demonstrates the construction " textplain += "of a complex user interface using pyjamas' built-in widgets. Have a look " textplain += "at the code to see how easy it is to build your own apps!" text = HTML(textplain) text.setStyleName("mail-AboutText") outer.add(text, DockPanel.CENTER) # Add a bit of spacing and margin to the dock to keep the components from # being placed too closely together. outer.setSpacing(8) self.add(outer)
def __init__(self, owner): self.owner = owner self.bar = DockPanel() self.gotoFirst = Button("<<", self) self.gotoNext = Button(">", self) self.gotoPrev = Button("<", self) self.status = HTML() self.setWidget(self.bar) self.bar.setStyleName("navbar") self.status.setStyleName("status") buttons = HorizontalPanel() buttons.add(self.gotoFirst) buttons.add(self.gotoPrev) buttons.add(self.gotoNext) self.bar.add(buttons, DockPanel.EAST) self.bar.setCellHorizontalAlignment(buttons, HasAlignment.ALIGN_RIGHT) self.bar.add(self.status, DockPanel.CENTER) self.bar.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) self.bar.setCellHorizontalAlignment(self.status, HasAlignment.ALIGN_RIGHT) self.bar.setCellVerticalAlignment(self.status, HasAlignment.ALIGN_MIDDLE) self.bar.setCellWidth(self.status, "100%") self.gotoPrev.setEnabled(False) self.gotoFirst.setEnabled(False)
def __init__(self): colours = ['Azure', 'Red', 'Rust', 'Green', 'Beige', 'Brass', 'Brown', 'Bronze', 'Blue', 'Black', 'Burgundy', 'Pink', 'Gold', 'Gray', 'Purple', 'Yellow', 'White'] self.colour_input = AutoCompleteTextBox() self.colour_input.setCompletionItems(colours) panel = HorizontalPanel() panel.add(HTML("Enter a colour: ")) panel.add(self.colour_input) panel.setSpacing(8) self.setWidget(panel)
def __init__(self): colours = [ 'Azure', 'Red', 'Rust', 'Green', 'Beige', 'Brass', 'Brown', 'Bronze', 'Blue', 'Black', 'Burgundy', 'Pink', 'Gold', 'Gray', 'Purple', 'Yellow', 'White' ] self.colour_input = AutoCompleteTextBox() self.colour_input.setCompletionItems(colours) panel = HorizontalPanel() panel.add(HTML("Enter a colour: ")) panel.add(self.colour_input) panel.setSpacing(8) self.setWidget(panel)
def __init__(self): self.sStrings=[["foo0", "bar0", "baz0", "toto0", "tintin0"], ["foo1", "bar1", "baz1", "toto1", "tintin1"], ["foo2", "bar2", "baz2", "toto2", "tintin2"], ["foo3", "bar3", "baz3", "toto3", "tintin3"], ["foo4", "bar4", "baz4", "toto4", "tintin4"]] self.combo=ListBox() self.list=ListBox() self.echo=Label() self.combo.setVisibleItemCount(1) self.combo.addChangeListener(self) self.list.setVisibleItemCount(10) self.list.setMultipleSelect(True) for i in range(len(self.sStrings)): self.combo.addItem("List " + i) self.combo.setSelectedIndex(0) self.fillList(0) self.list.addChangeListener(self) horz = HorizontalPanel() horz.setVerticalAlignment(HasAlignment.ALIGN_TOP) horz.setSpacing(8) horz.add(self.combo) horz.add(self.list) panel = VerticalPanel() panel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT) panel.add(horz) panel.add(self.echo) self.setWidget(panel) self.echoSelection()
def __init__(self): Sink.__init__(self) self.sStrings = [["foo0", "bar0", "baz0", "toto0", "tintin0"], ["foo1", "bar1", "baz1", "toto1", "tintin1"], ["foo2", "bar2", "baz2", "toto2", "tintin2"], ["foo3", "bar3", "baz3", "toto3", "tintin3"], ["foo4", "bar4", "baz4", "toto4", "tintin4"]] self.combo = ListBox() self.list = ListBox() self.echo = Label() self.combo.setVisibleItemCount(1) self.combo.addChangeListener(self) self.list.setVisibleItemCount(10) self.list.setMultipleSelect(True) for i in range(len(self.sStrings)): self.combo.addItem("List %d" % i) self.combo.setSelectedIndex(0) self.fillList(0) self.list.addChangeListener(self) horz = HorizontalPanel() horz.setVerticalAlignment(HasAlignment.ALIGN_TOP) horz.setSpacing(8) horz.add(self.combo) horz.add(self.list) panel = VerticalPanel() panel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT) panel.add(horz) panel.add(self.echo) self.initWidget(panel) self.echoSelection()
def __init__(self, contact): # The popup's constructor's argument is a boolean specifying that it # auto-close itself when the user clicks outside of it. PopupPanel.__init__(self, True) inner = VerticalPanel() nameLabel = Label(contact.name) emailLabel = Label(contact.email) inner.add(nameLabel) inner.add(emailLabel) panel = HorizontalPanel() panel.setSpacing(4) panel.add(Image(contact.photo)) panel.add(inner) self.add(panel) self.setStyleName("mail-ContactPopup") nameLabel.setStyleName("mail-ContactPopupName") emailLabel.setStyleName("mail-ContactPopupEmail")
def __init__(self): img = Image("images/num1.png") img.addMouseListener(TooltipListener("An image: " + img.getUrl())) img2 = Image("images/num2.png") img2.addMouseListener(TooltipListener("An image: " + img2.getUrl())) html = HTML("Some <i>HTML</i> text.") html.addMouseListener(TooltipListener("An HTML component.")) panel_h = HorizontalPanel() panel_h.add(img) panel_h.add(img2) panel_h.setSpacing(8) panel = VerticalPanel() panel.add(panel_h) panel.add(html) panel.setSpacing(8) self.setWidget(panel)
def __init__(self): disabledButton = Button("Disabled Button") disabledCheck = CheckBox("Disabled Check") normalButton = Button("Normal Button") normalCheck = CheckBox("Normal Check") panel = VerticalPanel() radio0 = RadioButton("group0", "Choice 0") radio1 = RadioButton("group0", "Choice 1") radio2 = RadioButton("group0", "Choice 2 (Disabled)") radio3 = RadioButton("group0", "Choice 3") hp=HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(normalButton) hp.add(disabledButton) hp=HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(normalCheck) hp.add(disabledCheck) hp=HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(radio0) hp.add(radio1) hp.add(radio2) hp.add(radio3) disabledButton.setEnabled(False) disabledCheck.setEnabled(False) radio2.setEnabled(False) panel.setSpacing(8) self.initWidget(panel)
def __init__(self): colour_grid = ColourGridCanvas() rotated = RotatedCanvas() spheres = SpheresCanvas() pattern = PatternCanvas() spiro = SpiroCanvas() self.solar = SolarCanvas() row0 = HorizontalPanel() row0.setSpacing(8) row0.add(colour_grid) row0.add(rotated) row0.add(spheres) row0.add(pattern) row1 = HorizontalPanel() row1.setSpacing(8) row1.add(self.solar) row1.add(spiro) panel = VerticalPanel() panel.add(row0) panel.add(row1) self.setWidget(panel)
def __init__(self, mailObject): self.countLabel = HTML() self.newerButton = HTML("<a href='javascript:;'>< newer</a>", True) self.olderButton = HTML("<a href='javascript:;'>older ></a>", True) self.startIndex = 0 self.selectedRow = -1 self.table = FlexTable() self.navBar = HorizontalPanel() self.mailObject = mailObject # Setup the table. self.table.setCellSpacing(0) self.table.setCellPadding(2) self.table.setWidth("100%") # Hook up events. self.table.addTableListener(self) self.newerButton.addClickListener(self) self.olderButton.addClickListener(self) # Create the 'navigation' bar at the upper-right. innerNavBar = HorizontalPanel() innerNavBar.setStyleName("mail-ListNavBar") innerNavBar.setSpacing(8) innerNavBar.add(self.newerButton) innerNavBar.add(self.countLabel) innerNavBar.add(self.olderButton) self.navBar.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) self.navBar.add(innerNavBar) self.navBar.setWidth("100%") self.setWidget(self.table) self.setStyleName("mail-List") self.initTable() self.update()
def __init__(self): disabledButton = Button("Disabled Button") disabledCheck = CheckBox("Disabled Check") normalButton = Button("Normal Button") normalCheck = CheckBox("Normal Check") panel = VerticalPanel() radio0 = RadioButton("group0", "Choice 0") radio1 = RadioButton("group0", "Choice 1") radio2 = RadioButton("group0", "Choice 2 (Disabled)") radio3 = RadioButton("group0", "Choice 3") hp = HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(normalButton) hp.add(disabledButton) hp = HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(normalCheck) hp.add(disabledCheck) hp = HorizontalPanel() panel.add(hp) hp.setSpacing(8) hp.add(radio0) hp.add(radio1) hp.add(radio2) hp.add(radio3) disabledButton.setEnabled(False) disabledCheck.setEnabled(False) radio2.setEnabled(False) panel.setSpacing(8) self.setWidget(panel)
def __init__(self): text="This is a <code>ScrollPanel</code> contained at " text+= "the center of a <code>DockPanel</code>. " text+= "By putting some fairly large contents " text+= "in the middle and setting its size explicitly, it becomes a " text+= "scrollable area within the page, but without requiring the use of " text+= "an IFRAME." text+= "Here's quite a bit more meaningless text that will serve primarily " text+= "to make this thing scroll off the bottom of its visible area. " text+= "Otherwise, you might have to make it really, really small in order " text+= "to see the nifty scroll bars!" contents = HTML(text) scroller = ScrollPanel(contents) scroller.setStyleName("ks-layouts-Scroller") dock = DockPanel() dock.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) north0 = HTML("This is the <i>first</i> north component", True) east = HTML("<center>This<br>is<br>the<br>east<br>component</center>", True) south = HTML("This is the south component") west = HTML("<center>This<br>is<br>the<br>west<br>component</center>", True) north1 = HTML("This is the <b>second</b> north component", True) dock.add(north0, DockPanel.NORTH) dock.add(east, DockPanel.EAST) dock.add(south, DockPanel.SOUTH) dock.add(west, DockPanel.WEST) dock.add(north1, DockPanel.NORTH) dock.add(scroller, DockPanel.CENTER) Logger.write("Layouts", "TODO: flowpanel") flow = FlowPanel() for i in range(8): flow.add(CheckBox("Flow " + i)) horz = HorizontalPanel() horz.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) horz.add(Button("Button")) horz.add(HTML("<center>This is a<br>very<br>tall thing</center>", True)) horz.add(Button("Button")) vert = VerticalPanel() vert.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) vert.add(Button("Small")) vert.add(Button("--- BigBigBigBig ---")) vert.add(Button("tiny")) menu = MenuBar() menu0 = MenuBar(True) menu1 = MenuBar(True) menu.addItem("menu0", menu0) menu.addItem("menu1", menu1) menu0.addItem("child00") menu0.addItem("child01") menu0.addItem("child02") menu1.addItem("child10") menu1.addItem("child11") menu1.addItem("child12") Logger.write("Layouts", "TODO: htmlpanel") id = HTMLPanel.createUniqueId() text="This is an <code>HTMLPanel</code>. It allows you to add " text+="components inside existing HTML, like this:" + "<span id='" + id text+="'></span>" + "Notice how the menu just fits snugly in there? Cute." html = HTMLPanel(text) DOM.setStyleAttribute(menu.getElement(), "display", "inline") html.add(menu, id) panel = VerticalPanel() panel.setSpacing(8) panel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) panel.add(self.makeLabel("Dock Panel")) panel.add(dock) panel.add(self.makeLabel("Flow Panel")) panel.add(flow) panel.add(self.makeLabel("Horizontal Panel")) panel.add(horz) panel.add(self.makeLabel("Vertical Panel")) panel.add(vert) panel.add(self.makeLabel("HTML Panel")) panel.add(html) self.initWidget(panel) self.setStyleName("ks-layouts")
def onModuleLoad(self): self.TEXT_WAITING = "Waiting for response..." self.TEXT_ERROR = "Server Error" self.METHOD_ECHO = "Echo" self.METHOD_REVERSE = "Reverse" self.METHOD_UPPERCASE = "UPPERCASE" self.METHOD_LOWERCASE = "lowercase" self.methods = [self.METHOD_ECHO, self.METHOD_REVERSE, self.METHOD_UPPERCASE, self.METHOD_LOWERCASE] self.remote_php = EchoServicePHP() self.remote_py = EchoServicePython() self.status=Label() self.text_area = TextArea() self.text_area.setText(r"{'Test'} [\"String\"]") #self.text_area.setCharacterWidth(80) self.text_area.setVisibleLines(8) self.method_list = ListBox() #self.method_list.setMultipleSelect(True) self.method_list.setVisibleItemCount(1) for method in self.methods: self.method_list.addItem(method) self.method_list.setSelectedIndex(0) method_panel = HorizontalPanel() method_panel.add(HTML("Remote string method to call: ")) method_panel.add(self.method_list) method_panel.setSpacing(8) self.button_php = Button("Send to PHP Service", self) self.button_py = Button("Send to Python Service", self) buttons = HorizontalPanel() buttons.add(self.button_php) buttons.add(self.button_py) buttons.setSpacing(8) info = r"<h2>JSON-RPC Example</h2><p>This example demonstrates the calling of server services with <a href=\"http://json-rpc.org/\">JSON-RPC</a>." info += "<p>Enter some text below, and press a button to send the text to an Echo service on your server. An echo service simply sends the exact same text back that it receives.</p>" panel = VerticalPanel() panel.add(HTML(info)) panel.add(self.text_area) panel.add(method_panel) panel.add(buttons) panel.add(self.status) RootPanel().add(panel)
class MailList(Composite): VISIBLE_EMAIL_COUNT = 10 def __init__(self, mailObject): self.countLabel = HTML() self.newerButton = HTML("<a href='javascript:;'>< newer</a>", True) self.olderButton = HTML("<a href='javascript:;'>older ></a>", True) self.startIndex = 0 self.selectedRow = -1 self.table = FlexTable() self.navBar = HorizontalPanel() self.mailObject = mailObject # Setup the table. self.table.setCellSpacing(0) self.table.setCellPadding(2) self.table.setWidth("100%") # Hook up events. self.table.addTableListener(self) self.newerButton.addClickListener(self) self.olderButton.addClickListener(self) # Create the 'navigation' bar at the upper-right. innerNavBar = HorizontalPanel() innerNavBar.setStyleName("mail-ListNavBar") innerNavBar.setSpacing(8) innerNavBar.add(self.newerButton) innerNavBar.add(self.countLabel) innerNavBar.add(self.olderButton) self.navBar.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) self.navBar.add(innerNavBar) self.navBar.setWidth("100%") self.initWidget(self.table) self.setStyleName("mail-List") self.initTable() self.update() def onCellClicked(self, sender, row, cell): # Select the row that was clicked (-1 to account for header row). if (row > 0): self.selectRow(row - 1) def onClick(self, sender): if (sender == self.olderButton): # Move forward a page. self.startIndex = self.startIndex + MailList.VISIBLE_EMAIL_COUNT if (self.startIndex >= MailItems().getMailItemCount()): self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT else: self.styleRow(self.selectedRow, False) self.selectedRow = -1 self.update() elif (sender == self.newerButton): # Move back a page. self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT if (self.startIndex < 0): self.startIndex = 0 else: self.styleRow(self.selectedRow, False) self.selectedRow = -1 self.update() def initTable(self): # Create the header row. self.table.setText(0, 0, "sender") self.table.setText(0, 1, "email") self.table.setText(0, 2, "subject") self.table.setWidget(0, 3, self.navBar) self.table.getRowFormatter().setStyleName(0, "mail-ListHeader") # Initialize the rest of the rows. i = 0 while i < MailList.VISIBLE_EMAIL_COUNT: self.table.setText(i + 1, 0, "") self.table.setText(i + 1, 1, "") self.table.setText(i + 1, 2, "") self.table.getCellFormatter().setWordWrap(i + 1, 0, False) self.table.getCellFormatter().setWordWrap(i + 1, 1, False) self.table.getCellFormatter().setWordWrap(i + 1, 2, False) self.table.getFlexCellFormatter().setColSpan(i + 1, 2, 2) i = i + 1 def selectRow(self, row): # When a row (other than the first one, which is used as a header) is # selected, display its associated MailItem. item = MailItems().getMailItem(self.startIndex + row) if (item == None): return self.styleRow(self.selectedRow, False) self.styleRow(row, True) item.read = True self.selectedRow = row self.mailObject.get().displayItem(item) def styleRow(self, row, selected): if (row != -1): if (selected): self.table.getRowFormatter().addStyleName(row + 1, "mail-SelectedRow") else: self.table.getRowFormatter().removeStyleName(row + 1, "mail-SelectedRow") def update(self): # Update the older/newer buttons & label. count = MailItems().getMailItemCount() max = self.startIndex + MailList.VISIBLE_EMAIL_COUNT if (max > count): max = count self.newerButton.setVisible(self.startIndex != 0) self.olderButton.setVisible(self.startIndex + MailList.VISIBLE_EMAIL_COUNT < count) startIndexPlusOne = self.startIndex + 1 self.countLabel.setText("" + startIndexPlusOne + " - " + max + " of " + count) # Show the selected emails. i = 0 while (i < MailList.VISIBLE_EMAIL_COUNT): # Don't read past the end. if (self.startIndex + i >= MailItems().getMailItemCount()): break item = MailItems().getMailItem(self.startIndex + i) # Add a row to the table, then set each of its columns to the # email's sender and subject values. self.table.setText(i + 1, 0, item.sender) self.table.setText(i + 1, 1, item.email) self.table.setText(i + 1, 2, item.subject) i = i + 1 # Clear any remaining slots. while (i < MailList.VISIBLE_EMAIL_COUNT): self.table.setHTML(i + 1, 0, " ") self.table.setHTML(i + 1, 1, " ") self.table.setHTML(i + 1, 2, " ") i = i + 1 # Select the first row if none is selected. if (self.selectedRow == -1): self.selectRow(0)
def __init__(self, mailObject): self.countLabel = HTML() self.newerButton = HTML("<a href='javascript:;'>< newer</a>", True) self.olderButton = HTML("<a href='javascript:;'>older ></a>", True) self.startIndex = 0 self.selectedRow = -1 self.table = FlexTable() self.navBar = HorizontalPanel() self.mailObject = mailObject # Setup the table. self.table.setCellSpacing(0) self.table.setCellPadding(2) self.table.setWidth("100%") # Hook up events. self.table.addTableListener(self) self.newerButton.addClickListener(self) self.olderButton.addClickListener(self) # Create the 'navigation' bar at the upper-right. innerNavBar = HorizontalPanel() innerNavBar.setStyleName("mail-ListNavBar") innerNavBar.setSpacing(8) innerNavBar.add(self.newerButton) innerNavBar.add(self.countLabel) innerNavBar.add(self.olderButton) self.navBar.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) self.navBar.add(innerNavBar) self.navBar.setWidth("100%") self.initWidget(self.table) self.setStyleName("mail-List") self.initTable() self.update()
def __init__(self): self.signOutLink = HTML("<a href='javascript:;'>Sign Out</a>") self.aboutLink = HTML("<a href='javascript:;'>About</a>") outer = HorizontalPanel() inner = VerticalPanel() outer.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) inner.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) links = HorizontalPanel() links.setSpacing(4) links.add(self.signOutLink) links.add(self.aboutLink) outer.add(inner) inner.add(HTML("<b>Welcome back, [email protected]</b>")) inner.add(links) self.signOutLink.addClickListener(self) self.aboutLink.addClickListener(self) self.setWidget(outer) inner.setStyleName("mail-TopPanel") links.setStyleName("mail-TopPanelLinks")
def __init__(self): text = "This is a <code>ScrollPanel</code> contained at " text += "the center of a <code>DockPanel</code>. " text += "By putting some fairly large contents " text += "in the middle and setting its size explicitly, it becomes a " text += "scrollable area within the page, but without requiring the use of " text += "an IFRAME." text += "Here's quite a bit more meaningless text that will serve primarily " text += "to make this thing scroll off the bottom of its visible area. " text += "Otherwise, you might have to make it really, really small in order " text += "to see the nifty scroll bars!" contents = HTML(text) scroller = ScrollPanel(contents) scroller.setStyleName("ks-layouts-Scroller") dock = DockPanel() dock.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) north0 = HTML("This is the <i>first</i> north component", True) east = HTML("<center>This<br>is<br>the<br>east<br>component</center>", True) south = HTML("This is the south component") west = HTML("<center>This<br>is<br>the<br>west<br>component</center>", True) north1 = HTML("This is the <b>second</b> north component", True) dock.add(north0, DockPanel.NORTH) dock.add(east, DockPanel.EAST) dock.add(south, DockPanel.SOUTH) dock.add(west, DockPanel.WEST) dock.add(north1, DockPanel.NORTH) dock.add(scroller, DockPanel.CENTER) Logger("Layouts", "TODO: flowpanel") flow = FlowPanel() for i in range(8): flow.add(CheckBox("Flow " + i)) horz = HorizontalPanel() horz.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE) horz.add(Button("Button")) horz.add(HTML("<center>This is a<br>very<br>tall thing</center>", True)) horz.add(Button("Button")) vert = VerticalPanel() vert.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) vert.add(Button("Small")) vert.add(Button("--- BigBigBigBig ---")) vert.add(Button("tiny")) menu = MenuBar() menu0 = MenuBar(True) menu1 = MenuBar(True) menu.addNewItem("menu0", False, None, menu0) menu.addNewItem("menu1", False, None, menu1) menu0.addNewItem("child00") menu0.addNewItem("child01") menu0.addNewItem("child02") menu1.addNewItem("child10") menu1.addNewItem("child11") menu1.addNewItem("child12") Logger("Layouts", "TODO: htmlpanel") id = HTMLPanel.createUniqueId() text = "This is an <code>HTMLPanel</code>. It allows you to add " text += "components inside existing HTML, like this:" + "<span id='" + id text += "'></span>" + "Notice how the menu just fits snugly in there? Cute." html = HTMLPanel(text) DOM.setStyleAttribute(menu.getElement(), "display", "inline") html.add(menu, id) panel = VerticalPanel() panel.setSpacing(8) panel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) panel.add(self.makeLabel("Dock Panel")) panel.add(dock) panel.add(self.makeLabel("Flow Panel")) panel.add(flow) panel.add(self.makeLabel("Horizontal Panel")) panel.add(horz) panel.add(self.makeLabel("Vertical Panel")) panel.add(vert) panel.add(self.makeLabel("HTML Panel")) panel.add(html) self.setWidget(panel) self.setStyleName("ks-layouts")
def __init__(self): Composite.__init__(self) self.signOutLink = HTML("<a href='javascript:;'>Sign Out</a>") self.aboutLink = HTML("<a href='javascript:;'>About</a>") outer = HorizontalPanel() inner = VerticalPanel() outer.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) inner.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) links = HorizontalPanel() links.setSpacing(4) links.add(self.signOutLink) links.add(self.aboutLink) outer.add(inner) inner.add(HTML("<b>Welcome back, [email protected]</b>")) inner.add(links) self.signOutLink.addClickListener(self) self.aboutLink.addClickListener(self) self.initWidget(outer) inner.setStyleName("mail-TopPanel") links.setStyleName("mail-TopPanelLinks")
class MailList(Composite): VISIBLE_EMAIL_COUNT = 10 def __init__(self, mailObject): self.countLabel = HTML() self.newerButton = HTML("<a href='javascript:;'>< newer</a>", True) self.olderButton = HTML("<a href='javascript:;'>older ></a>", True) self.startIndex = 0 self.selectedRow = -1 self.table = FlexTable() self.navBar = HorizontalPanel() self.mailObject = mailObject # Setup the table. self.table.setCellSpacing(0) self.table.setCellPadding(2) self.table.setWidth("100%") # Hook up events. self.table.addTableListener(self) self.newerButton.addClickListener(self) self.olderButton.addClickListener(self) # Create the 'navigation' bar at the upper-right. innerNavBar = HorizontalPanel() innerNavBar.setStyleName("mail-ListNavBar") innerNavBar.setSpacing(8) innerNavBar.add(self.newerButton) innerNavBar.add(self.countLabel) innerNavBar.add(self.olderButton) self.navBar.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT) self.navBar.add(innerNavBar) self.navBar.setWidth("100%") self.setWidget(self.table) self.setStyleName("mail-List") self.initTable() self.update() def onCellClicked(self, sender, row, cell): # Select the row that was clicked (-1 to account for header row). if (row > 0): self.selectRow(row - 1) def onClick(self, sender): if (sender == self.olderButton): # Move forward a page. self.startIndex = self.startIndex + MailList.VISIBLE_EMAIL_COUNT if (self.startIndex >= MailItems().getMailItemCount()): self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT else: self.styleRow(self.selectedRow, False) self.selectedRow = -1 self.update() elif (sender == self.newerButton): # Move back a page. self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT if (self.startIndex < 0): self.startIndex = 0 else: self.styleRow(self.selectedRow, False) self.selectedRow = -1 self.update() def initTable(self): # Create the header row. self.table.setText(0, 0, "sender") self.table.setText(0, 1, "email") self.table.setText(0, 2, "subject") self.table.setWidget(0, 3, self.navBar) self.table.getRowFormatter().setStyleName(0, "mail-ListHeader") # Initialize the rest of the rows. i = 0 while i < MailList.VISIBLE_EMAIL_COUNT: self.table.setText(i + 1, 0, "") self.table.setText(i + 1, 1, "") self.table.setText(i + 1, 2, "") self.table.getCellFormatter().setWordWrap(i + 1, 0, False) self.table.getCellFormatter().setWordWrap(i + 1, 1, False) self.table.getCellFormatter().setWordWrap(i + 1, 2, False) self.table.getFlexCellFormatter().setColSpan(i + 1, 2, 2) i = i + 1 def selectRow(self, row): # When a row (other than the first one, which is used as a header) is # selected, display its associated MailItem. item = MailItems().getMailItem(self.startIndex + row) if (item == None): return self.styleRow(self.selectedRow, False) self.styleRow(row, True) item.read = True self.selectedRow = row self.mailObject.get().displayItem(item) def styleRow(self, row, selected): if (row != -1): if (selected): self.table.getRowFormatter().addStyleName(row + 1, "mail-SelectedRow") else: self.table.getRowFormatter().removeStyleName(row + 1, "mail-SelectedRow") def update(self): # Update the older/newer buttons & label. count = MailItems().getMailItemCount() max = self.startIndex + MailList.VISIBLE_EMAIL_COUNT if (max > count): max = count self.newerButton.setVisible(self.startIndex != 0) self.olderButton.setVisible(self.startIndex + MailList.VISIBLE_EMAIL_COUNT < count) startIndexPlusOne = self.startIndex + 1 self.countLabel.setText("" + startIndexPlusOne + " - " + max + " of " + count) # Show the selected emails. i = 0 while (i < MailList.VISIBLE_EMAIL_COUNT): # Don't read past the end. if (self.startIndex + i >= MailItems().getMailItemCount()): break item = MailItems().getMailItem(self.startIndex + i) # Add a row to the table, then set each of its columns to the # email's sender and subject values. self.table.setText(i + 1, 0, item.sender) self.table.setText(i + 1, 1, item.email) self.table.setText(i + 1, 2, item.subject) i = i + 1 # Clear any remaining slots. while (i < MailList.VISIBLE_EMAIL_COUNT): self.table.setHTML(i + 1, 0, " ") self.table.setHTML(i + 1, 1, " ") self.table.setHTML(i + 1, 2, " ") i = i + 1 # Select the first row if none is selected. if (self.selectedRow == -1): self.selectRow(0)