def __init__(self): super(WebLayoutWindow, self).__init__() # Our main layout is a horizontal layout main = HorizontalLayout() main.setMargin(True) main.setSpacing(True) self.setContent(main) # Tree to the left tree = Tree() tree.setContainerDataSource( ExampleUtil.getHardwareContainer() ) tree.setItemCaptionPropertyId( ExampleUtil.hw_PROPERTY_NAME ) for idd in tree.rootItemIds(): tree.expandItemsRecursively(idd) self.addComponent(tree) # vertically divide the right area left = VerticalLayout() left.setSpacing(True) self.addComponent(left) # table on top tbl = Table() tbl.setWidth('500px') tbl.setContainerDataSource( ExampleUtil.getISO3166Container() ) tbl.setSortDisabled(True) tbl.setPageLength(7) left.addComponent(tbl) # Label on bottom text = Label(ExampleUtil.lorem, Label.CONTENT_XHTML) text.setWidth('500px') # some limit is good for text left.addComponent(text)
def __init__(self): super(WebLayoutWindow, self).__init__() # Our main layout is a horizontal layout main = HorizontalLayout() main.setMargin(True) main.setSpacing(True) self.setContent(main) # Tree to the left tree = Tree() tree.setContainerDataSource(ExampleUtil.getHardwareContainer()) tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME) for idd in tree.rootItemIds(): tree.expandItemsRecursively(idd) self.addComponent(tree) # vertically divide the right area left = VerticalLayout() left.setSpacing(True) self.addComponent(left) # table on top tbl = Table() tbl.setWidth('500px') tbl.setContainerDataSource(ExampleUtil.getISO3166Container()) tbl.setSortDisabled(True) tbl.setPageLength(7) left.addComponent(tbl) # Label on bottom text = Label(ExampleUtil.lorem, Label.CONTENT_XHTML) text.setWidth('500px') # some limit is good for text left.addComponent(text)
def __init__(self): super(TreeMouseEventsExample, self).__init__() self.setSpacing(True) # Create new Tree object using a hierarchical container from # ExampleUtil class self._t = Tree('Hardware Inventory', ExampleUtil.getHardwareContainer()) # Add ItemClickListener to the tree self._t.addListener(self, IItemClickListener) self._t.setImmediate(True) # Set tree to show the 'name' property as caption for items self._t.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME) self._t.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY) # Starting itemId # for new items self._itemId = len(self._t.getContainerDataSource()) # Expand whole tree for i in range(self._itemId): self._t.expandItemsRecursively(i) # Disallow selecting items from the tree self._t.setSelectable(False) self.addComponent(self._t)
def __init__(self): super(DragDropTreeSortingExample, self).__init__() self.setSpacing(True) tree = Tree('Tree sortable using drag\'n\'drop') # Populate the tree container = ExampleUtil.getHardwareContainer() tree.setContainerDataSource(container) tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME) tree.setItemIconPropertyId(ExampleUtil.hw_PROPERTY_ICON) # Allow all nodes to have children for itemId in tree.getItemIds(): tree.setChildrenAllowed(itemId, True) # Expand all nodes for idd in tree.rootItemIds(): tree.expandItemsRecursively(idd) tree.setDragMode(TreeDragMode.NODE) tree.setDropHandler(TreeSortDropHandler(tree, container)) self.addComponent(tree)
def __init__(self): super(DateLocaleExample, self).__init__() self.setSpacing(True) self._datetime = InlineDateField('Please select the starting time:') # Set the value of the PopupDateField to current date self._datetime.setValue(datetime.today()) # Set the correct resolution self._datetime.setResolution(InlineDateField.RESOLUTION_MIN) self._datetime.setImmediate(True) self._datetime.setShowISOWeekNumbers(True) # Create selection and fill it with locales self._localeSelection = ComboBox('Select date format:') self._localeSelection.addListener(self, IValueChangeListener) self._localeSelection.setImmediate(True) self._localeSelection.setContainerDataSource( ExampleUtil.getLocaleContainer()) self._localeSelection.setNullSelectionAllowed(False) self.addComponent(self._datetime) self.addComponent(self._localeSelection)
def __init__(self): super(TreeMultiSelectExample, self).__init__() self.setSpacing(True) # Create new Tree object using a hierarchical container from # ExampleUtil class self._tree = Tree('Hardware Inventory', ExampleUtil.getHardwareContainer()) # Set multiselect mode self._tree.setMultiSelect(True) self._tree.setImmediate(True) self._tree.addListener(TreeListener(self), IValueChangeListener) # Add Actionhandler self._tree.addActionHandler(self) # Set tree to show the 'name' property as caption for items self._tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME) self._tree.setItemCaptionMode( AbstractSelect.ITEM_CAPTION_MODE_PROPERTY) # Expand whole tree for idd in self._tree.rootItemIds(): self._tree.expandItemsRecursively(idd) # Create the 'delete button', inline click-listener self._deleteButton = Button('Delete', DeleteListener(self)) self._deleteButton.setEnabled(False) self.addComponent(self._deleteButton) self.addComponent(self._tree)
def __init__(self): super(TreeMultiSelectExample, self).__init__() self.setSpacing(True) # Create new Tree object using a hierarchical container from # ExampleUtil class self._tree = Tree('Hardware Inventory', ExampleUtil.getHardwareContainer()) # Set multiselect mode self._tree.setMultiSelect(True) self._tree.setImmediate(True) self._tree.addListener(TreeListener(self), IValueChangeListener) # Add Actionhandler self._tree.addActionHandler(self) # Set tree to show the 'name' property as caption for items self._tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME) self._tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY) # Expand whole tree for idd in self._tree.rootItemIds(): self._tree.expandItemsRecursively(idd) # Create the 'delete button', inline click-listener self._deleteButton = Button('Delete', DeleteListener(self)) self._deleteButton.setEnabled(False) self.addComponent(self._deleteButton) self.addComponent(self._tree)
def __init__(self): super(ComboBoxStartsWithExample, self).__init__() self.setSpacing(True) # Creates a new combobox using an existing container l = ComboBox('Please select your country', ExampleUtil.getISO3166Container()) # Sets the combobox to show a certain property as the item caption l.setItemCaptionPropertyId(ExampleUtil.iso3166_PROPERTY_NAME) l.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY) # Sets the icon to use with the items l.setItemIconPropertyId(ExampleUtil.iso3166_PROPERTY_FLAG) # Set a reasonable width l.setWidth(350, self.UNITS_PIXELS) # Set the appropriate filtering mode for this example l.setFilteringMode(IFiltering.FILTERINGMODE_STARTSWITH) l.setImmediate(True) l.addListener(self, IValueChangeListener) # Disallow null selections l.setNullSelectionAllowed(False) self.addComponent(l)
def __init__(self): super(ApplicationLayoutWindow, self).__init__() # Our main layout is a horizontal layout main = HorizontalLayout() main.setSizeFull() self.setContent(main) # Tree to the left treePanel = Panel() # for scrollbars treePanel.setStyleName(Reindeer.PANEL_LIGHT) treePanel.setHeight('100%') treePanel.setWidth(None) treePanel.getContent().setSizeUndefined() self.addComponent(treePanel) tree = Tree() tree.setContainerDataSource(ExampleUtil.getHardwareContainer()) tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME) for idd in tree.rootItemIds(): tree.expandItemsRecursively(idd) treePanel.addComponent(tree) # vertically divide the right area left = VerticalLayout() left.setSizeFull() self.addComponent(left) main.setExpandRatio(left, 1.0) # use all available space # table on top tbl = Table() tbl.setWidth('100%') tbl.setContainerDataSource(ExampleUtil.getISO3166Container()) tbl.setSortDisabled(True) tbl.setPageLength(7) left.addComponent(tbl) # Label on bottom textPanel = Panel() # for scrollbars textPanel.setStyleName(Reindeer.PANEL_LIGHT) textPanel.setSizeFull() left.addComponent(textPanel) left.setExpandRatio(textPanel, 1.0) # use all available space text = Label(ExampleUtil.lorem, Label.CONTENT_XHTML) text.setWidth('500px') # some limit is good for text textPanel.addComponent(text)
def initializeTree(self, acceptCriterion): self._tree.setContainerDataSource(ExampleUtil.getHardwareContainer()) self._tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME) # Expand all nodes for idd in self._tree.rootItemIds(): self._tree.expandItemsRecursively(idd) self._tree.setDragMode(TreeDragMode.NODE) self._tree.setDropHandler(TreeDropHandler(self))
def __init__(self, c): self._c = c super(PersonFieldFactory, self).__init__() self.countries = ComboBox("Country") self.countries.setWidth("100%") self.countries.setContainerDataSource(ExampleUtil.getISO3166Container()) self.countries.setItemCaptionPropertyId(ExampleUtil.iso3166_PROPERTY_NAME) self.countries.setItemIconPropertyId(ExampleUtil.iso3166_PROPERTY_FLAG) self.countries.setFilteringMode(ComboBox.FILTERINGMODE_STARTSWITH)
def initializeTree(self, acceptCriterion): self._tree.setContainerDataSource(ExampleUtil.getHardwareContainer()) self._tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME) # Expand all nodes for idd in self._tree.rootItemIds(): self._tree.expandItemsRecursively(idd) self._tree.setDragMode(TreeDragMode.NODE) self._tree.setDropHandler( TreeDropHandler(self) )
def __init__(self): super(TableClickListenersExample, self).__init__() # Create our data source dataSource = ExampleUtil.getOrderContainer() # Calculate total sum totalSum = 0.0 for i in range(len(dataSource)): item = dataSource.getItem(dataSource.getIdByIndex(i)) value = item.getItemProperty( ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID).getValue() #amount = NumberFormat.getCurrencyInstance().parse(str(value)) amount = re.search(u'([\u00A3\u0024\u20AC])(\d+(?:\.\d{2})?)', str(value)).groups()[1] totalSum += float(amount) # Create table table = Table('', ExampleUtil.getOrderContainer()) table.setColumnExpandRatio(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID, 1) table.setSortDisabled(True) table.setWidth('100%') table.setPageLength(6) table.setFooterVisible(True) table.setImmediate(True) # Add some total sum and description to footer table.setColumnFooter(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID, 'Total Price') l = defaultLocale() fc = format_currency(totalSum, currency='USD', locale=l).encode('utf-8') table.setColumnFooter(ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID, fc) # Add a header click handler table.addListener(HeaderListener(self), IHeaderClickListener) # Add a footer click handler table.addListener(FooterListener(self), IFooterClickListener) self.addComponent(table)
def __init__(self): super(TableClickListenersExample, self).__init__() # Create our data source dataSource = ExampleUtil.getOrderContainer() # Calculate total sum totalSum = 0.0 for i in range(len(dataSource)): item = dataSource.getItem(dataSource.getIdByIndex(i)) value = item.getItemProperty( ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID).getValue() match = re.search(self.CURRENCY_PATTERN, str(value)) if match is not None: amount = match.groups()[1] totalSum += float(amount) # Create table table = Table('', ExampleUtil.getOrderContainer()) table.setColumnExpandRatio(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID, 1) table.setSortDisabled(True) table.setWidth('100%') table.setPageLength(6) table.setFooterVisible(True) table.setImmediate(True) # Add some total sum and description to footer table.setColumnFooter(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID, 'Total Price') l = defaultLocale() fc = format_currency(totalSum, currency='USD', locale=l).encode('utf-8') table.setColumnFooter(ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID, fc) # Add a header click handler table.addListener(HeaderListener(self), IHeaderClickListener) # Add a footer click handler table.addListener(FooterListener(self), IFooterClickListener) self.addComponent(table)
def __init__(self, c): self._c = c super(PersonFieldFactory, self).__init__() self.countries = ComboBox('Country') self.countries.setWidth('100%') self.countries.setContainerDataSource( ExampleUtil.getISO3166Container()) self.countries.setItemCaptionPropertyId( ExampleUtil.iso3166_PROPERTY_NAME) self.countries.setItemIconPropertyId(ExampleUtil.iso3166_PROPERTY_FLAG) self.countries.setFilteringMode(ComboBox.FILTERINGMODE_STARTSWITH)
def __init__(self): super(TableStylingExample, self).__init__() self.setSpacing(True) self._table = Table() self._markedRows = dict() self._markedCells = dict() self.addComponent(self._table) # set a style name, so we can style rows and cells self._table.setStyleName('contacts') # size self._table.setWidth('100%') self._table.setPageLength(7) # connect data source self._table.setContainerDataSource(ExampleUtil.getPersonContainer()) # Generate the email-link from firstname & lastname self._table.addGeneratedColumn('Email', TableColumnGenerator(self)) # turn on column reordering and collapsing self._table.setColumnReorderingAllowed(True) self._table.setColumnCollapsingAllowed(True) # Actions (a.k.a context menu) self._table.addActionHandler( TableActionHandler(self) ) # style generator self._table.setCellStyleGenerator( TableStyleGenerator(self) ) # toggle cell 'marked' styling when double-clicked self._table.addListener(TableClickListener(self), IItemClickListener) # Editing # we don't want to update container before pressing 'save': self._table.setWriteThrough(False) # edit button editButton = Button('Edit') self.addComponent(editButton) editButton.addListener(EditListener(self, editButton), button.IClickListener) self.setComponentAlignment(editButton, Alignment.TOP_RIGHT)
def __init__(self): super(TreeSingleSelectExample, self).__init__() self.setSpacing(True) # Create the Tree,a dd to layout self._tree = Tree('Hardware Inventory') self.addComponent(self._tree) # Contents from a (prefilled example) hierarchical container: self._tree.setContainerDataSource(ExampleUtil.getHardwareContainer()) # Add Valuechangelistener and Actionhandler self._tree.addListener(self, IValueChangeListener) # Add actions (context menu) self._tree.addActionHandler(self) # Cause valueChange immediately when the user selects self._tree.setImmediate(True) # Set tree to show the 'name' property as caption for items self._tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME) self._tree.setItemCaptionMode( AbstractSelect.ITEM_CAPTION_MODE_PROPERTY) # Expand whole tree for idd in self._tree.rootItemIds(): self._tree.expandItemsRecursively(idd) # Create the 'editor bar' (textfield and button in a horizontallayout) self._editBar = HorizontalLayout() self._editBar.setMargin(False, False, False, True) self._editBar.setEnabled(False) self.addComponent(self._editBar) # textfield self._editor = TextField('Item name') self._editor.setImmediate(True) self._editBar.addComponent(self._editor) # apply-button self._change = Button('Apply', self) #, 'buttonClick') FIXME: listener self._editBar.addComponent(self._change) self._editBar.setComponentAlignment(self._change, Alignment.BOTTOM_LEFT)
def __init__(self): super(TableFooterExample, self).__init__() # Create our data source dataSource = ExampleUtil.getOrderContainer() # Calculate total sum totalSum = 0.0 for i in range(len(dataSource)): item = dataSource.getItem(dataSource.getIdByIndex(i)) value = item.getItemProperty( ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID).getValue() match = re.search(self.CURRENCY_PATTERN, str(value)) if match is not None: amount = match.groups()[1] totalSum += float(amount) # Create a table to show the data in table = Table('Order table', dataSource) table.setPageLength(6) table.setWidth('100%') # Set alignments table.setColumnAlignments([ Table.ALIGN_LEFT, Table.ALIGN_RIGHT, Table.ALIGN_RIGHT, Table.ALIGN_RIGHT ]) # Set column widths table.setColumnExpandRatio(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID, 1) # Enable footer table.setFooterVisible(True) # Add some total sum and description to footer table.setColumnFooter(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID, 'Total Price') l = defaultLocale() fc = format_currency(totalSum, currency='USD', locale=l).encode('utf-8') table.setColumnFooter(ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID, fc) self.addComponent(table)
def __init__(self): super(DragDropServerValidationExample, self).__init__() self.setSpacing(True) # First create the components to be able to refer to them as allowed # drag sources self._table = Table('Drag persons onto their relatives') self._table.setWidth('100%') self._container = ExampleUtil.getPersonContainer() self._table.setContainerDataSource(self._container) # Drag and drop support self._table.setDragMode(TableDragMode.ROW) self._table.setDropHandler( TableDropHandler(self) ) self.addComponent(self._table)
def __init__(self): super(DragDropServerValidationExample, self).__init__() self.setSpacing(True) # First create the components to be able to refer to them as allowed # drag sources self._table = Table('Drag persons onto their relatives') self._table.setWidth('100%') self._container = ExampleUtil.getPersonContainer() self._table.setContainerDataSource(self._container) # Drag and drop support self._table.setDragMode(TableDragMode.ROW) self._table.setDropHandler(TableDropHandler(self)) self.addComponent(self._table)
def __init__(self): super(TreeSingleSelectExample, self).__init__() self.setSpacing(True) # Create the Tree,a dd to layout self._tree = Tree('Hardware Inventory') self.addComponent(self._tree) # Contents from a (prefilled example) hierarchical container: self._tree.setContainerDataSource(ExampleUtil.getHardwareContainer()) # Add Valuechangelistener and Actionhandler self._tree.addListener(self, IValueChangeListener) # Add actions (context menu) self._tree.addActionHandler(self) # Cause valueChange immediately when the user selects self._tree.setImmediate(True) # Set tree to show the 'name' property as caption for items self._tree.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME) self._tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY) # Expand whole tree for idd in self._tree.rootItemIds(): self._tree.expandItemsRecursively(idd) # Create the 'editor bar' (textfield and button in a horizontallayout) self._editBar = HorizontalLayout() self._editBar.setMargin(False, False, False, True) self._editBar.setEnabled(False) self.addComponent(self._editBar) # textfield self._editor = TextField('Item name') self._editor.setImmediate(True) self._editBar.addComponent(self._editor) # apply-button self._change = Button('Apply', self)#, 'buttonClick') FIXME: listener self._editBar.addComponent(self._change) self._editBar.setComponentAlignment(self._change, Alignment.BOTTOM_LEFT)
def __init__(self): super(TextFieldTextChangeEventExample, self).__init__() nameContainer = ExampleUtil.getNameContainer() filterField = TextField('Filter') filterField.setTextChangeEventMode(TextChangeEventMode.LAZY) filterField.setTextChangeTimeout(200) filterField.addListener(FilterListener(nameContainer), ITextChangeListener) table = Table(None, nameContainer) table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN) self.setSpacing(False) self.addComponent(filterField) self.addComponent(table) filterField.setWidth('150px') table.setWidth('150px')
def __init__(self): super(TableFooterExample, self).__init__() # Create our data source dataSource = ExampleUtil.getOrderContainer() # Calculate total sum totalSum = 0.0 for i in range(len(dataSource)): item = dataSource.getItem(dataSource.getIdByIndex(i)) value = item.getItemProperty( ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID).getValue() match = re.search(self.CURRENCY_PATTERN, str(value)) if match is not None: amount = match.groups()[1] totalSum += float(amount) # Create a table to show the data in table = Table('Order table', dataSource) table.setPageLength(6) table.setWidth('100%') # Set alignments table.setColumnAlignments([Table.ALIGN_LEFT, Table.ALIGN_RIGHT, Table.ALIGN_RIGHT, Table.ALIGN_RIGHT]) # Set column widths table.setColumnExpandRatio(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID, 1) # Enable footer table.setFooterVisible(True) # Add some total sum and description to footer table.setColumnFooter(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID, 'Total Price') l = defaultLocale() fc = format_currency(totalSum, currency='USD', locale=l).encode('utf-8') table.setColumnFooter(ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID, fc) self.addComponent(table)
def __init__(self): super(TableFooterExample, self).__init__() # Create our data source dataSource = ExampleUtil.getOrderContainer() # Calculate total sum totalSum = 0.0 for i in range(len(dataSource)): item = dataSource.getItem(dataSource.getIdByIndex(i)) value = item.getItemProperty( ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID).getValue() amount = re.search(u'([\u00A3\u0024\u20AC])(\d+(?:\.\d{2})?)', str(value)).groups()[1] totalSum += float(amount) # Create a table to show the data in table = Table('Order table', dataSource) table.setPageLength(6) table.setWidth('100%') # Set alignments table.setColumnAlignments([Table.ALIGN_LEFT, Table.ALIGN_RIGHT, Table.ALIGN_RIGHT, Table.ALIGN_RIGHT]) # Set column widths table.setColumnExpandRatio(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID, 1) # Enable footer table.setFooterVisible(True) # Add some total sum and description to footer table.setColumnFooter(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID, 'Total Price') table.setColumnFooter(ExampleUtil.ORDER_ITEMPRICE_PROPERTY_ID, locale.currency(totalSum, grouping=True)) # FIXME: babel self.addComponent(table)
def __init__(self): super(TableMainFeaturesExample, self).__init__() self._markedRows = set() self._table = Table('ISO-3166 Country Codes and flags') self.addComponent(self._table) # Label to indicate current selection selected = Label('No selection') self.addComponent(selected) # set a style name, so we can style rows and cells self._table.setStyleName('iso3166') # size self._table.setWidth('100%') self._table.setHeight('170px') # selectable self._table.setSelectable(True) self._table.setMultiSelect(True) # react at once when something is selected self._table.setImmediate(True) # connect data source self._table.setContainerDataSource(ExampleUtil.getISO3166Container()) # turn on column reordering and collapsing self._table.setColumnReorderingAllowed(True) self._table.setColumnCollapsingAllowed(True) # set column headers self._table.setColumnHeaders(['Country', 'Code', 'Icon file']) # Icons for column headers self._table.setColumnIcon(ExampleUtil.iso3166_PROPERTY_FLAG, ThemeResource('../sampler/icons/action_save.gif')) self._table.setColumnIcon(ExampleUtil.iso3166_PROPERTY_NAME, ThemeResource('../sampler/icons/icon_get_world.gif')) self._table.setColumnIcon(ExampleUtil.iso3166_PROPERTY_SHORT, ThemeResource('../sampler/icons/page_code.gif')) # Column alignment self._table.setColumnAlignment(ExampleUtil.iso3166_PROPERTY_SHORT, Table.ALIGN_CENTER) # Column width self._table.setColumnExpandRatio(ExampleUtil.iso3166_PROPERTY_NAME, 1) self._table.setColumnWidth(ExampleUtil.iso3166_PROPERTY_SHORT, 70) # Collapse one column - the user can make it visible again self._table.setColumnCollapsed(ExampleUtil.iso3166_PROPERTY_FLAG, True) # show row header w/ icon self._table.setRowHeaderMode(Table.ROW_HEADER_MODE_ICON_ONLY) self._table.setItemIconPropertyId(ExampleUtil.iso3166_PROPERTY_FLAG) # Actions (a.k.a context menu) self._table.addActionHandler( TableActionHandler(self) ) # style generator self._table.setCellStyleGenerator( TableStyleGenerator(self) ) # listen for valueChange, a.k.a 'select' and update the label self._table.addListener(TableChangeListener(self, selected), IValueChangeListener)
def __init__(self): super(TableMainFeaturesExample, self).__init__() self._markedRows = set() self._table = Table('ISO-3166 Country Codes and flags') self.addComponent(self._table) # Label to indicate current selection selected = Label('No selection') self.addComponent(selected) # set a style name, so we can style rows and cells self._table.setStyleName('iso3166') # size self._table.setWidth('100%') self._table.setHeight('170px') # selectable self._table.setSelectable(True) self._table.setMultiSelect(True) # react at once when something is selected self._table.setImmediate(True) # connect data source self._table.setContainerDataSource(ExampleUtil.getISO3166Container()) # turn on column reordering and collapsing self._table.setColumnReorderingAllowed(True) self._table.setColumnCollapsingAllowed(True) # set column headers self._table.setColumnHeaders(['Country', 'Code', 'Icon file']) # Icons for column headers self._table.setColumnIcon( ExampleUtil.iso3166_PROPERTY_FLAG, ThemeResource('../sampler/icons/action_save.gif')) self._table.setColumnIcon( ExampleUtil.iso3166_PROPERTY_NAME, ThemeResource('../sampler/icons/icon_get_world.gif')) self._table.setColumnIcon( ExampleUtil.iso3166_PROPERTY_SHORT, ThemeResource('../sampler/icons/page_code.gif')) # Column alignment self._table.setColumnAlignment(ExampleUtil.iso3166_PROPERTY_SHORT, Table.ALIGN_CENTER) # Column width self._table.setColumnExpandRatio(ExampleUtil.iso3166_PROPERTY_NAME, 1) self._table.setColumnWidth(ExampleUtil.iso3166_PROPERTY_SHORT, 70) # Collapse one column - the user can make it visible again self._table.setColumnCollapsed(ExampleUtil.iso3166_PROPERTY_FLAG, True) # show row header w/ icon self._table.setRowHeaderMode(Table.ROW_HEADER_MODE_ICON_ONLY) self._table.setItemIconPropertyId(ExampleUtil.iso3166_PROPERTY_FLAG) # Actions (a.k.a context menu) self._table.addActionHandler(TableActionHandler(self)) # style generator self._table.setCellStyleGenerator(TableStyleGenerator(self)) # listen for valueChange, a.k.a 'select' and update the label self._table.addListener(TableChangeListener(self, selected), IValueChangeListener)
def valueChange(self, event): selected = ExampleUtil.getISO3166Container().getContainerProperty( str(event.getProperty()), 'name') self.getWindow().showNotification('Selected country: ' + str(selected))