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)
class DateLocaleExample(VerticalLayout, IValueChangeListener): 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 valueChange(self, event): selected = self._localeSelection.getItem( event.getProperty().getValue()) self._datetime.setLocale( selected.getItemProperty( ExampleUtil.locale_PROPERTY_LOCALE).getValue()) self._datetime.requestRepaint()
def __init__(self): super(ComboBoxPlainExample, self).__init__() self.setSpacing(True) l = ComboBox('Please select a city') for c in self._cities: l.addItem(c) l.setFilteringMode(IFiltering.FILTERINGMODE_OFF) l.setImmediate(True) l.addListener(self, IValueChangeListener) self.addComponent(l)
def __init__(self): super(ComboBoxInputPromptExample, self).__init__() self.setMargin(True, False, False, False) # for looks: more 'air' # Create & set input prompt l = ComboBox() l.setInputPrompt('Please select a city') # configure & load content l.setImmediate(True) l.addListener(self, IValueChangeListener) for c in self._cities: l.addItem(c) # add to the layout self.addComponent(l)
class ComboBoxNewItemsExample(VerticalLayout, IValueChangeListener, abstract_select.INewItemHandler): _cities = ['Berlin', 'Brussels', 'Helsinki', 'Madrid', 'Oslo', 'Paris', 'Stockholm'] def __init__(self): super(ComboBoxNewItemsExample, self).__init__() self._lastAdded = False self.setSpacing(True) self._l = ComboBox('Please select a city') for c in self._cities: self._l.addItem(c) self._l.setNewItemsAllowed(True) self._l.setNewItemHandler(self) self._l.setImmediate(True) self._l.addListener(self, IValueChangeListener) self.addComponent(self._l) # Shows a notification when a selection is made. def valueChange(self, event): if not self._lastAdded: self.getWindow().showNotification('Selected city: ' + str(event.getProperty())) self._lastAdded = False def addNewItem(self, newItemCaption): if not self._l.containsId(newItemCaption): self.getWindow().showNotification('Added city: ' + newItemCaption) self._lastAdded = True self._l.addItem(newItemCaption) self._l.setValue(newItemCaption)
class SamplerWindow(Window): """The main window for Sampler, contains the full application UI.""" _TITLE = 'Muntjac Sampler' def __init__(self, app): super(SamplerWindow, self).__init__() self._app = app self._currentList = FeatureGrid(self._app) self._featureView = FeatureView() self._currentFeature = ObjectProperty(None, Feature) self._mainSplit = None self._navigationTree = None # self._webAnalytics = GoogleAnalytics('UA-658457-6', 'none') # "backbutton" self._uriFragmentUtility = UriFragmentUtility() # breadcrumbs self._breadcrumbs = BreadCrumbs(self) self._previousSample = None self._nextSample = None self._search = None self.theme = None # Main top/expanded-bottom layout mainExpand = VerticalLayout() self.setContent(mainExpand) self.setSizeFull() mainExpand.setSizeFull() self.setCaption(self._TITLE) self.setTheme(self._app._currentApplicationTheme) # topbar (navigation) nav = HorizontalLayout() mainExpand.addComponent(nav) nav.setHeight('44px') nav.setWidth('100%') nav.setStyleName('topbar') nav.setSpacing(True) nav.setMargin(False, True, False, False) # Upper left logo logo = self.createLogo() nav.addComponent(logo) nav.setComponentAlignment(logo, Alignment.MIDDLE_LEFT) # Breadcrumbs nav.addComponent(self._breadcrumbs) nav.setExpandRatio(self._breadcrumbs, 1) nav.setComponentAlignment(self._breadcrumbs, Alignment.MIDDLE_LEFT) # invisible analytics -component # nav.addComponent(self._webAnalytics) # "backbutton" nav.addComponent(self._uriFragmentUtility) self._uriFragmentUtility.addListener(UriListener(self), IFragmentChangedListener) # Main left/right split; hidden menu tree self._mainSplit = HorizontalSplitPanel() self._mainSplit.setSizeFull() self._mainSplit.setStyleName('main-split') mainExpand.addComponent(self._mainSplit) mainExpand.setExpandRatio(self._mainSplit, 1) # Select theme themeSelect = self.createThemeSelect() nav.addComponent(themeSelect) nav.setComponentAlignment(themeSelect, Alignment.MIDDLE_LEFT) # Layouts for top area buttons quicknav = HorizontalLayout() arrows = HorizontalLayout() nav.addComponent(quicknav) nav.addComponent(arrows) nav.setComponentAlignment(quicknav, Alignment.MIDDLE_LEFT) nav.setComponentAlignment(arrows, Alignment.MIDDLE_LEFT) quicknav.setStyleName('segment') arrows.setStyleName('segment') # Previous sample self._previousSample = self.createPrevButton() arrows.addComponent(self._previousSample) # Next sample self._nextSample = self.createNextButton() arrows.addComponent(self._nextSample) # "Search" combobox searchComponent = self.createSearch() quicknav.addComponent(searchComponent) # Menu tree, initially shown menuLayout = CssLayout() allSamples = ActiveLink('All Samples', ExternalResource('#')) menuLayout.addComponent(allSamples) self._navigationTree = self.createMenuTree() menuLayout.addComponent(self._navigationTree) self._mainSplit.setFirstComponent(menuLayout) # Show / hide tree treeSwitch = self.createTreeSwitch() quicknav.addComponent(treeSwitch) self.addListener(WindowCloseListener(self, self._app), window.ICloseListener) self.updateFeatureList(self._currentList) def detach(self): super(SamplerWindow, self).detach() self._search.setContainerDataSource(None) self._navigationTree.setContainerDataSource(None) def removeSubwindows(self): wins = self.getChildWindows() if None is not wins: for w in wins: self.removeWindow(w) def setFeature(self, arg): """Displays a Feature(Set) or displays a Feature(Set) matching the given path, or the main view if no matching Feature(Set) is found. @param arg: Either the Feature(Set) to show or the path of the Feature(Set) to show """ if isinstance(arg, basestring): path = arg f = FeatureSet.FEATURES.getFeature(path) self.setFeature(f) else: f = arg if f == FeatureSet.FEATURES: # "All" is no longer in the tree, use null instead f = None self._currentFeature.setValue(f) fragment = f.getFragmentName() if f is not None else '' # self._webAnalytics.trackPageview(fragment) self._uriFragmentUtility.setFragment(fragment, False) self._breadcrumbs.setPath( self._app.getFullPathFor(f) ) self._previousSample.setEnabled(f is not None) self._nextSample.setEnabled(not self._app._allFeatures.isLastId(f)) self.updateFeatureList(self._currentList) self.setCaption((f.getName() + ': ' if f is not None else '') + self._TITLE) # SamplerWindow helpers def createSearch(self): self._search = ComboBox() self._search.setWidth('160px') self._search.setNewItemsAllowed(False) self._search.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS) self._search.setNullSelectionAllowed(True) self._search.setImmediate(True) self._search.setInputPrompt('Search samples...') self._search.setContainerDataSource( self._app._allFeatures ) for idd in self._app._allFeatures.getItemIds(): if isinstance(idd, FeatureSet): pass # FIXME: 'SamplerApplication' has no attribute 'getResourceAsStream' # self._search.setItemIcon(idd, # ClassResource('folder.gif', self._app)) self._search.addListener(SearchListener(self), prop.IValueChangeListener) # TODO add icons for section/sample # PopupView pv = new PopupView("", search) { public void # changeVariables(Object source, Map variables) { # super.changeVariables(source, variables); if (isPopupVisible()) { # search.focus(); } } }; pv = PopupView('<span></span>', self._search) pv.addListener(PopupListener(self), IPopupVisibilityListener) pv.setStyleName('quickjump') pv.setDescription('Quick jump') return pv def createThemeSelect(self): self.theme = ComboBox() self.theme.setWidth('32px') self.theme.setNewItemsAllowed(False) self.theme.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS) self.theme.setImmediate(True) self.theme.setNullSelectionAllowed(False) for themeName in self._app._THEMES: idd = self._app._SAMPLER_THEME_NAME + '-' + themeName self.theme.addItem(idd) self.theme.setItemCaption(idd, themeName[:1].upper() + (themeName[1:]) + ' theme') self.theme.setItemIcon(idd, _EMPTY_THEME_ICON) currentWindowTheme = self.getTheme() self.theme.setValue(currentWindowTheme) self.theme.setItemIcon(currentWindowTheme, _SELECTED_THEME_ICON) self.theme.addListener(ThemeChangeListener(self, self._app), prop.IValueChangeListener) self.theme.setStyleName('theme-select') self.theme.setDescription('Select Theme') return self.theme def createLogo(self): logo = NativeButton('', LogoClickListener(self)) logo.setDescription('Home') logo.setStyleName(BaseTheme.BUTTON_LINK) logo.addStyleName('logo') return logo def createNextButton(self): b = NativeButton('', NextClickListener(self, self._app)) b.setStyleName('next') b.setDescription('Jump to the next sample') return b def createPrevButton(self): b = NativeButton('', PrevClickListener(self, self._app)) b.setEnabled(False) b.setStyleName('previous') b.setDescription('Jump to the previous sample') return b def createTreeSwitch(self): b = NativeButton() b.setStyleName('tree-switch') b.addStyleName('down') b.setDescription('Toggle sample tree visibility') b.addListener(TreeClickListener(self), button.IClickListener) self._mainSplit.setSplitPosition(250, ISizeable.UNITS_PIXELS) return b def createMenuTree(self): tree = Tree() tree.setImmediate(True) tree.setStyleName('menu') tree.setContainerDataSource(self._app._allFeatures) self._currentFeature.addListener(FeatureChangeListener(self, tree), prop.IValueChangeListener) for f in FeatureSet.FEATURES.getFeatures(): tree.expandItemsRecursively(f) tree.expandItemsRecursively(FeatureSet.FEATURES) tree.addListener(TreeChangeListener(self), prop.IValueChangeListener) tree.setItemStyleGenerator(TreeStyleGenerator()) return tree def updateFeatureList(self, lst): self._currentList = lst val = self._currentFeature.getValue() if val is None: self._currentList.setFeatureContainer(self._app._allFeatures) self._mainSplit.setSecondComponent(self._currentList) elif isinstance(val, FeatureSet): self._currentList.setFeatureContainer(val.getContainer(True)) self._mainSplit.setSecondComponent(self._currentList) else: self._mainSplit.setSecondComponent(self._featureView) self._featureView.setFeature(val)
class SimpleEditor ( EditorWithList, IValueChangeListener ): """ Simple style of editor for checklists, which displays a combo box. """ #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- # Checklist item names names = List( Unicode ) # Checklist item values values = List #--------------------------------------------------------------------------- # Finishes initializing the editor by creating the underlying toolkit # widget: #--------------------------------------------------------------------------- def init ( self, parent ): """ Finishes initializing the editor by creating the underlying toolkit widget. """ self.create_control( parent ) super( SimpleEditor, self ).init( parent ) self.set_tooltip() #--------------------------------------------------------------------------- # Creates the initial editor control: #--------------------------------------------------------------------------- def create_control ( self, parent ): """ Creates the initial editor control. """ self.control = ComboBox() self.control.setMultiSelect(False) self.control.setNullSelectionAllowed(True) self.control.setImmediate(True) self.control.addListener(self, IValueChangeListener) #--------------------------------------------------------------------------- # Handles the list of legal check list values being updated: #--------------------------------------------------------------------------- def list_updated ( self, values ): """ Handles updates to the list of legal checklist values. """ sv = self.string_value if (len( values ) > 0) and isinstance( values[0], basestring ): values = [ ( x, sv( x, capitalize ) ) for x in values ] self.values = valid_values = [ x[0] for x in values ] self.names = [ x[1] for x in values ] # Make sure the current value is still legal: modified = False cur_value = parse_value( self.value ) for i in range( len( cur_value ) - 1, -1, -1 ): if cur_value[i] not in valid_values: try: del cur_value[i] modified = True except TypeError: logger.warn('Unable to remove non-current value [%s] from ' 'values %s', cur_value[i], values) if modified: if isinstance( self.value, basestring ): cur_value = ','.join( cur_value ) self.value = cur_value self.rebuild_editor() #--------------------------------------------------------------------------- # Rebuilds the editor after its definition is modified: #--------------------------------------------------------------------------- def rebuild_editor ( self ): """ Rebuilds the editor after its definition is modified. """ control = self.control c = IndexedContainer() for name in self.names: c.addItem(name) control.setContainerDataSource(c) self.update_editor() #--------------------------------------------------------------------------- # Handles the user selecting a new value from the combo box: #--------------------------------------------------------------------------- def valueChange(self, event): v = str(event.getProperty()) self.update_object(v) def update_object ( self, text ): """ Handles the user selecting a new value from the combo box. """ if unicode(text) in self.names: value = self.values[self.names.index(unicode(text))] if not isinstance(self.value, basestring): value = [value] elif not isinstance(self.value, basestring): value = [] else: value = '' self.value = value #--------------------------------------------------------------------------- # Updates the editor when the object trait changes external to the editor: #--------------------------------------------------------------------------- def update_editor ( self ): """ Updates the editor when the object trait changes externally to the editor. """ try: self.control.select( parse_value(self.value)[0] ) except: pass
class DateResolutionExample(VerticalLayout, IValueChangeListener): resolution_PROPERTY_NAME = 'name' # Resolution fields from DateField _resolutions = [ InlineDateField.RESOLUTION_YEAR, InlineDateField.RESOLUTION_MONTH, InlineDateField.RESOLUTION_DAY, InlineDateField.RESOLUTION_HOUR, InlineDateField.RESOLUTION_MIN, InlineDateField.RESOLUTION_SEC, InlineDateField.RESOLUTION_MSEC ] _resolutionNames = [ 'Year', 'Month', 'Day', 'Hour', 'Minute', 'Second', 'Millisecond' ] def __init__(self): super(DateResolutionExample, 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_DAY) self._datetime.setImmediate(True) # Create selection self._localeSelection = ComboBox('Select resolution:') self._localeSelection.setNullSelectionAllowed(False) self._localeSelection.addListener(self, IValueChangeListener) self._localeSelection.setImmediate(True) # Fill the selection with choices, set captions correctly self._localeSelection.setContainerDataSource( self.getResolutionContainer()) self._localeSelection.setItemCaptionPropertyId( self.resolution_PROPERTY_NAME) self._localeSelection.setItemCaptionMode( ComboBox.ITEM_CAPTION_MODE_PROPERTY) self.addComponent(self._datetime) self.addComponent(self._localeSelection) def valueChange(self, event): self._datetime.setResolution(event.getProperty().getValue()) self._datetime.requestRepaint() def getResolutionContainer(self): resolutionContainer = IndexedContainer() resolutionContainer.addContainerProperty(self.resolution_PROPERTY_NAME, str, None) for i, res in enumerate(self._resolutions): added = resolutionContainer.addItem(res) added.getItemProperty(self.resolution_PROPERTY_NAME).setValue( self._resolutionNames[i]) return resolutionContainer
class DateResolutionExample(VerticalLayout, IValueChangeListener): resolution_PROPERTY_NAME = 'name' # Resolution fields from DateField _resolutions = [ InlineDateField.RESOLUTION_YEAR, InlineDateField.RESOLUTION_MONTH, InlineDateField.RESOLUTION_DAY, InlineDateField.RESOLUTION_HOUR, InlineDateField.RESOLUTION_MIN, InlineDateField.RESOLUTION_SEC, InlineDateField.RESOLUTION_MSEC ] _resolutionNames = [ 'Year', 'Month', 'Day', 'Hour', 'Minute', 'Second', 'Millisecond' ] def __init__(self): super(DateResolutionExample, 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_DAY) self._datetime.setImmediate(True) # Create selection self._localeSelection = ComboBox('Select resolution:') self._localeSelection.setNullSelectionAllowed(False) self._localeSelection.addListener(self, IValueChangeListener) self._localeSelection.setImmediate(True) # Fill the selection with choices, set captions correctly self._localeSelection.setContainerDataSource( self.getResolutionContainer()) self._localeSelection.setItemCaptionPropertyId( self.resolution_PROPERTY_NAME) self._localeSelection.setItemCaptionMode( ComboBox.ITEM_CAPTION_MODE_PROPERTY) self.addComponent(self._datetime) self.addComponent(self._localeSelection) def valueChange(self, event): self._datetime.setResolution(event.getProperty().getValue()) self._datetime.requestRepaint() def getResolutionContainer(self): resolutionContainer = IndexedContainer() resolutionContainer.addContainerProperty( self.resolution_PROPERTY_NAME, str, None) for i, res in enumerate(self._resolutions): added = resolutionContainer.addItem(res) added.getItemProperty( self.resolution_PROPERTY_NAME).setValue( self._resolutionNames[i]) return resolutionContainer
class SamplerWindow(Window): """The main window for Sampler, contains the full application UI.""" _TITLE = 'Muntjac Sampler' def __init__(self, app): super(SamplerWindow, self).__init__() self._app = app self._currentList = FeatureGrid(self._app) self._featureView = FeatureView() self._currentFeature = ObjectProperty(None, Feature) self._mainSplit = None self._navigationTree = None # self._webAnalytics = GoogleAnalytics('UA-658457-6', 'none') # "backbutton" self._uriFragmentUtility = UriFragmentUtility() # breadcrumbs self._breadcrumbs = BreadCrumbs(self) self._previousSample = None self._nextSample = None self._search = None self.theme = None # Main top/expanded-bottom layout mainExpand = VerticalLayout() self.setContent(mainExpand) self.setSizeFull() mainExpand.setSizeFull() self.setCaption(self._TITLE) self.setTheme(self._app._currentApplicationTheme) # topbar (navigation) nav = HorizontalLayout() mainExpand.addComponent(nav) nav.setHeight('44px') nav.setWidth('100%') nav.setStyleName('topbar') nav.setSpacing(True) nav.setMargin(False, True, False, False) # Upper left logo logo = self.createLogo() nav.addComponent(logo) nav.setComponentAlignment(logo, Alignment.MIDDLE_LEFT) # Breadcrumbs nav.addComponent(self._breadcrumbs) nav.setExpandRatio(self._breadcrumbs, 1) nav.setComponentAlignment(self._breadcrumbs, Alignment.MIDDLE_LEFT) # invisible analytics -component # nav.addComponent(self._webAnalytics) # "backbutton" nav.addComponent(self._uriFragmentUtility) self._uriFragmentUtility.addListener(UriListener(self), IFragmentChangedListener) # Main left/right split; hidden menu tree self._mainSplit = HorizontalSplitPanel() self._mainSplit.setSizeFull() self._mainSplit.setStyleName('main-split') mainExpand.addComponent(self._mainSplit) mainExpand.setExpandRatio(self._mainSplit, 1) # Select theme themeSelect = self.createThemeSelect() nav.addComponent(themeSelect) nav.setComponentAlignment(themeSelect, Alignment.MIDDLE_LEFT) # Layouts for top area buttons quicknav = HorizontalLayout() arrows = HorizontalLayout() nav.addComponent(quicknav) nav.addComponent(arrows) nav.setComponentAlignment(quicknav, Alignment.MIDDLE_LEFT) nav.setComponentAlignment(arrows, Alignment.MIDDLE_LEFT) quicknav.setStyleName('segment') arrows.setStyleName('segment') # Previous sample self._previousSample = self.createPrevButton() arrows.addComponent(self._previousSample) # Next sample self._nextSample = self.createNextButton() arrows.addComponent(self._nextSample) # "Search" combobox searchComponent = self.createSearch() quicknav.addComponent(searchComponent) # Menu tree, initially shown menuLayout = CssLayout() allSamples = ActiveLink('All Samples', ExternalResource('#')) menuLayout.addComponent(allSamples) self._navigationTree = self.createMenuTree() menuLayout.addComponent(self._navigationTree) self._mainSplit.setFirstComponent(menuLayout) # Show / hide tree treeSwitch = self.createTreeSwitch() quicknav.addComponent(treeSwitch) self.addListener(WindowCloseListener(self, self._app), window.ICloseListener) self.updateFeatureList(self._currentList) def detach(self): super(SamplerWindow, self).detach() self._search.setContainerDataSource(None) self._navigationTree.setContainerDataSource(None) def removeSubwindows(self): wins = self.getChildWindows() if None is not wins: for w in wins: self.removeWindow(w) def setFeature(self, arg): """Displays a Feature(Set) or displays a Feature(Set) matching the given path, or the main view if no matching Feature(Set) is found. @param arg: Either the Feature(Set) to show or the path of the Feature(Set) to show """ if isinstance(arg, basestring): path = arg f = FeatureSet.FEATURES.getFeature(path) self.setFeature(f) else: f = arg if f == FeatureSet.FEATURES: # "All" is no longer in the tree, use null instead f = None self._currentFeature.setValue(f) fragment = f.getFragmentName() if f is not None else '' # self._webAnalytics.trackPageview(fragment) self._uriFragmentUtility.setFragment(fragment, False) self._breadcrumbs.setPath(self._app.getFullPathFor(f)) self._previousSample.setEnabled(f is not None) self._nextSample.setEnabled(not self._app._allFeatures.isLastId(f)) self.updateFeatureList(self._currentList) self.setCaption((f.getName() + ': ' if f is not None else '') + self._TITLE) # SamplerWindow helpers def createSearch(self): self._search = ComboBox() self._search.setWidth('160px') self._search.setNewItemsAllowed(False) self._search.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS) self._search.setNullSelectionAllowed(True) self._search.setImmediate(True) self._search.setInputPrompt('Search samples...') self._search.setContainerDataSource(self._app._allFeatures) for idd in self._app._allFeatures.getItemIds(): if isinstance(idd, FeatureSet): pass # FIXME: 'SamplerApplication' has no attribute 'getResourceAsStream' # self._search.setItemIcon(idd, # ClassResource('folder.gif', self._app)) self._search.addListener(SearchListener(self), prop.IValueChangeListener) # TODO add icons for section/sample # PopupView pv = new PopupView("", search) { public void # changeVariables(Object source, Map variables) { # super.changeVariables(source, variables); if (isPopupVisible()) { # search.focus(); } } }; pv = PopupView('<span></span>', self._search) pv.addListener(PopupListener(self), IPopupVisibilityListener) pv.setStyleName('quickjump') pv.setDescription('Quick jump') return pv def createThemeSelect(self): self.theme = ComboBox() self.theme.setWidth('32px') self.theme.setNewItemsAllowed(False) self.theme.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS) self.theme.setImmediate(True) self.theme.setNullSelectionAllowed(False) for themeName in self._app._THEMES: idd = self._app._SAMPLER_THEME_NAME + '-' + themeName self.theme.addItem(idd) self.theme.setItemCaption( idd, themeName[:1].upper() + (themeName[1:]) + ' theme') self.theme.setItemIcon(idd, _EMPTY_THEME_ICON) currentWindowTheme = self.getTheme() self.theme.setValue(currentWindowTheme) self.theme.setItemIcon(currentWindowTheme, _SELECTED_THEME_ICON) self.theme.addListener(ThemeChangeListener(self, self._app), prop.IValueChangeListener) self.theme.setStyleName('theme-select') self.theme.setDescription('Select Theme') return self.theme def createLogo(self): logo = NativeButton('', LogoClickListener(self)) logo.setDescription('Home') logo.setStyleName(BaseTheme.BUTTON_LINK) logo.addStyleName('logo') return logo def createNextButton(self): b = NativeButton('', NextClickListener(self, self._app)) b.setStyleName('next') b.setDescription('Jump to the next sample') return b def createPrevButton(self): b = NativeButton('', PrevClickListener(self, self._app)) b.setEnabled(False) b.setStyleName('previous') b.setDescription('Jump to the previous sample') return b def createTreeSwitch(self): b = NativeButton() b.setStyleName('tree-switch') b.addStyleName('down') b.setDescription('Toggle sample tree visibility') b.addListener(TreeClickListener(self), button.IClickListener) self._mainSplit.setSplitPosition(250, ISizeable.UNITS_PIXELS) return b def createMenuTree(self): tree = Tree() tree.setImmediate(True) tree.setStyleName('menu') tree.setContainerDataSource(self._app._allFeatures) self._currentFeature.addListener(FeatureChangeListener(self, tree), prop.IValueChangeListener) for f in FeatureSet.FEATURES.getFeatures(): tree.expandItemsRecursively(f) tree.expandItemsRecursively(FeatureSet.FEATURES) tree.addListener(TreeChangeListener(self), prop.IValueChangeListener) tree.setItemStyleGenerator(TreeStyleGenerator()) return tree def updateFeatureList(self, lst): self._currentList = lst val = self._currentFeature.getValue() if val is None: self._currentList.setFeatureContainer(self._app._allFeatures) self._mainSplit.setSecondComponent(self._currentList) elif isinstance(val, FeatureSet): self._currentList.setFeatureContainer(val.getContainer(True)) self._mainSplit.setSecondComponent(self._currentList) else: self._mainSplit.setSecondComponent(self._featureView) self._featureView.setFeature(val)