Ejemplo n.º 1
0
    def __init__(self):
        super(SubwindowExample, self).__init__()

        # Create the window
        self._subwindow = Window('A subwindow')

        # Configure the windows layout; by default a VerticalLayout
        layout = self._subwindow.getContent()
        layout.setMargin(True)
        layout.setSpacing(True)

        # Add some content; a label and a close-button
        message = Label('This is a subwindow')
        self._subwindow.addComponent(message)

        close = Button('Close', CloseListener(self))

        # The components added to the window are actually added to the window's
        # layout; you can use either. Alignments are set using the layout
        layout.addComponent(close)
        layout.setComponentAlignment(close, Alignment.TOP_RIGHT)

        # Add a button for opening the subwindow
        opn = Button('Open subwindow', OpenListener(self))
        self.addComponent(opn)
Ejemplo n.º 2
0
    def __init__(self):
        super(SubwindowAutoSizedExample, self).__init__()

        # Create the window
        self._subwindow = Window('Automatically sized subwindow')

        # Configure the windws layout; by default a VerticalLayout
        layout = self._subwindow.getContent()
        layout.setMargin(True)
        layout.setSpacing(True)

        # make it undefined for auto-sizing window
        layout.setSizeUndefined()

        # Add some content;
        for _ in range(7):
            tf = TextField()
            tf.setWidth('400px')
            self._subwindow.addComponent(tf)

        close = Button('Close', CloseListener(self))

        # The components added to the window are actually added to the window's
        # layout; you can use either. Alignments are set using the layout
        layout.addComponent(close)
        layout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT)

        # Add a button for opening the subwindow
        opn = Button('Open sized window', OpenListener(self))
        self.addComponent(opn)
Ejemplo n.º 3
0
    def __init__(self):
        super(ButtonLinkExample, self).__init__()

        self.setSpacing(True)

        # Button w/ text and tooltip
        b = Button(self._CAPTION)
        b.setStyleName(BaseTheme.BUTTON_LINK)
        b.setDescription(self._TOOLTIP)
        b.addListener(self, button.IClickListener)  # react to clicks
        self.addComponent(b)

        # Button w/ text, icon and tooltip
        b = Button(self._CAPTION)
        b.setStyleName(BaseTheme.BUTTON_LINK)
        b.setDescription(self._TOOLTIP)
        b.setIcon(self._ICON)
        b.addListener(self, button.IClickListener)  # react to clicks
        self.addComponent(b)

        # Button w/ icon and tooltip
        b = Button()
        b.setStyleName(BaseTheme.BUTTON_LINK)
        b.setDescription(self._TOOLTIP)
        b.setIcon(self._ICON)
        b.addListener(self, button.IClickListener)  # react to clicks
        self.addComponent(b)
Ejemplo n.º 4
0
    def __init__(self):
        super(FormAdvancedLayoutExample, self).__init__()

        # the 'POJO' we're editing.
        # The Person class is imported from the basic form example.
        self._person = Person()  # a person POJO
        personItem = BeanItem(self._person)  # item from POJO

        # Create the Form
        personForm = FormWithComplexLayout(personItem, self)

        # Add form to layout
        self.addComponent(personForm)

        # The cancel / apply buttons
        buttons = HorizontalLayout()
        buttons.setSpacing(True)

        discardChanges = Button('Discard changes', DiscardListener(personForm))
        discardChanges.setStyleName(BaseTheme.BUTTON_LINK)
        buttons.addComponent(discardChanges)
        buttons.setComponentAlignment(discardChanges, Alignment.MIDDLE_LEFT)

        aply = Button('Apply', ApplyListener(personForm))
        buttons.addComponent(aply)
        personForm.getFooter().setMargin(True)
        personForm.getFooter().addComponent(buttons)

        # button for showing the internal state of the POJO
        l = InternalStateListener(self)
        showPojoState = Button('Show POJO internal state', l)
        self.addComponent(showPojoState)
Ejemplo n.º 5
0
    def __init__(self):
        super(AccordionDisabledExample, self).__init__()

        self.setSpacing(True)

        self._l1 = Label('There are no previously saved actions.')
        self._l2 = Label('There are no saved notes.')
        self._l3 = Label('There are currently no issues.')

        self._a = Accordion()
        self._a.setHeight('300px')
        self._a.setWidth('400px')
        self._t1 = self._a.addTab(self._l1, 'Saved actions', self._icon1)
        self._t2 = self._a.addTab(self._l2, 'Notes', self._icon2)
        self._t3 = self._a.addTab(self._l3, 'Issues', self._icon3)
        self._a.addListener(self, tab_sheet.ISelectedTabChangeListener)

        self._b1 = Button('Disable \'Notes\' tab')
        self._b2 = Button('Hide \'Issues\' tab')
        self._b1.addListener(self, button.IClickListener)
        self._b2.addListener(self, button.IClickListener)

        hl = HorizontalLayout()
        hl.setSpacing(True)
        hl.addComponent(self._b1)
        hl.addComponent(self._b2)

        self.addComponent(self._a)
        self.addComponent(hl)
Ejemplo n.º 6
0
    def __init__(self):
        super(ButtonPushExample, self).__init__()

        # Normal buttons (more themable)
        buttons = VerticalLayout()
        buttons.setSpacing(True)
        buttons.setMargin(False, True, False, False)
        self.addComponent(buttons)
        buttons.addComponent(Label("<h3>Normal buttons</h3>",
                Label.CONTENT_XHTML))

        # Button w/ text and tooltip
        b = Button(self._CAPTION)
        b.setDescription(self._TOOLTIP)
        b.addListener(self, IClickListener)  # react to clicks
        buttons.addComponent(b)

        # Button w/ text, icon and tooltip
        b = Button(self._CAPTION)
        b.setDescription(self._TOOLTIP)
        b.setIcon(self._ICON)
        b.addListener(self, IClickListener)  # react to clicks
        buttons.addComponent(b)

        # Button w/ icon and tooltip
        b = Button()
        b.setDescription(self._TOOLTIP)
        b.setIcon(self._ICON)
        b.addListener(self, IClickListener)  # react to clicks
        buttons.addComponent(b)

        # NativeButtons
        buttons = VerticalLayout()
        buttons.setSpacing(True)
        buttons.setMargin(False, False, False, True)
        self.addComponent(buttons)
        buttons.addComponent(Label("<h3>Native buttons</h3>",
                Label.CONTENT_XHTML));

        # NativeButton w/ text and tooltip
        b = NativeButton(self._CAPTION)
        b.setDescription(self._TOOLTIP)
        b.addListener(self, IClickListener)  # react to clicks
        buttons.addComponent(b)

        # NativeButton w/ text, icon and tooltip
        b = NativeButton(self._CAPTION)
        b.setDescription(self._TOOLTIP)
        b.setIcon(self._ICON)
        b.addListener(self, IClickListener)  # react to clicks
        buttons.addComponent(b)

        # NativeButton w/ icon and tooltip
        b = NativeButton()
        b.setDescription(self._TOOLTIP)
        b.setIcon(self._ICON)
        b.addListener(self, IClickListener)  # react to clicks
        buttons.addComponent(b)
    def __init__(self):
        super(MenuBarHiddenItemsExample, self).__init__()

        self._menubar = MenuBar()

        menuCommand = MenuCommand(self)

        # Save reference to individual items so we can add sub-menu
        # items to them
        f = self._menubar.addItem('File', None)
        newItem = f.addItem('New', None)
        f.addItem('Open f...', menuCommand)
        f.addSeparator()
        newItem.addItem('File', menuCommand)
        newItem.addItem('Folder', menuCommand)
        newItem.addItem('Project...', menuCommand)
        f.addItem('Close', menuCommand)
        f.addItem('Close All', menuCommand)
        f.addSeparator()
        f.addItem('Save', menuCommand)
        f.addItem('Save As...', menuCommand)
        f.addItem('Save All', menuCommand)

        edit = self._menubar.addItem('Edit', None)
        edit.addItem('Undo', menuCommand)

        redo = edit.addItem('Redo', menuCommand)
        redo.setEnabled(False)

        edit.addSeparator()
        edit.addItem('Cut', menuCommand)
        edit.addItem('Copy', menuCommand)
        edit.addItem('Paste', menuCommand)
        edit.addSeparator()

        find = edit.addItem('Find/Replace', menuCommand)

        # Actions can be added inline as well, of course
        find.addItem('Google Search', SearchCommand(self))
        find.addSeparator()
        find.addItem('Find/Replace...', menuCommand)
        find.addItem('Find Next', menuCommand)
        find.addItem('Find Previous', menuCommand)

        view = self._menubar.addItem('View', None)
        view.addItem('Show/Hide Status Bar', menuCommand)
        view.addItem('Customize Toolbar...', menuCommand)
        view.addSeparator()
        view.addItem('Actual Size', menuCommand)
        view.addItem('Zoom In', menuCommand)
        view.addItem('Zoom Out', menuCommand)

        self.addComponent(self._menubar)
        self.addComponent( Button('Hide File menu', HideListener(f)) )

        l = RedoListener(redo)
        self.addComponent( Button('Enable Edit -> Redo action', l) )
        self.setSpacing(True)
Ejemplo n.º 8
0
    def initContactAddRemoveButtons(self):
        # New item button
        newItem = Button('+')
        newItem.addCallback(onNew, ClickEvent, self)
        self._bottomLeftCorner.addComponent(newItem)

        # Remove item button
        self._contactRemovalButton = Button('-')
        self._contactRemovalButton.addCallback(onRemove, ClickEvent, self)
        self._contactRemovalButton.setVisible(False)
        self._bottomLeftCorner.addComponent(self._contactRemovalButton)
Ejemplo n.º 9
0
    def init(self):
        main = Window('CSS Tools Add-on Test')
        self.setMainWindow(main)

        testWindow = Window('Normal Window')
        testWindow.addComponent(
            Label("<p>This window is used as the component to measure.</p>",
                  Label.CONTENT_XHTML))
        main.addWindow(testWindow)
        testWindow.center()

        title = Label('CSS Properties to Retrieve')
        title.addStyleName(Reindeer.LABEL_H2)
        main.addComponent(title)

        target = NativeSelect('Target Component')
        main.addComponent(target)

        get = Button('Refresh Properties', GetClickListener(self, target))
        main.addComponent(get)

        main.addComponent(self.buildLabels())

        target.addItem(main.getContent())
        target.setItemCaption(main.getContent(), 'Root layout')
        target.addItem(testWindow)
        target.setItemCaption(testWindow, 'Sub window')
        target.addItem(get)
        target.setItemCaption(get, 'The \'' + get.getCaption() + '\' Button')
        target.setNullSelectionAllowed(False)
        target.select(testWindow)
Ejemplo n.º 10
0
    def __init__(self):
        super(ShortcutBasicsExample, self).__init__()

        self.setSpacing(True)

        # Firstname input with an input prompt for demo clarity
        firstname = TextField('Firstname')
        firstname.setInputPrompt('ALT-SHIFT-F to focus')
        self.addComponent(firstname)

        # Add global shortcut that focuses the field
        firstname.addShortcutListener(
            FocusShortcut(firstname, KeyCode.F, ModifierKey.ALT,
                          ModifierKey.SHIFT))

        # Lastname input with an input prompt for demo clarity
        lastname = TextField('Lastname')
        lastname.setInputPrompt('ALT-SHIFT-L to focus')
        self.addComponent(lastname)

        # Add global shortcut that focuses the field
        lastname.addShortcutListener(
            FocusShortcut(lastname, KeyCode.L, ModifierKey.ALT,
                          ModifierKey.SHIFT))

        # Button with a simple click-listener
        enter = Button('Enter', EnterListener(self))
        self.addComponent(enter)
        enter.setStyleName('primary')  # make it look like it's default

        # Add global shortcut using the built-in helper
        enter.setClickShortcut(KeyCode.ENTER)
    def createComponents(self):
        components = list()

        label = Label('This is a long text block that will wrap.')
        label.setWidth('120px')
        components.append(label)

        image = Embedded('', ThemeResource('../runo/icons/64/document.png'))
        components.append(image)

        documentLayout = CssLayout()
        documentLayout.setWidth('19px')
        for _ in range(5):
            e = Embedded(None, ThemeResource('../runo/icons/16/document.png'))
            e.setHeight('16px')
            e.setWidth('16px')
            documentLayout.addComponent(e)
        components.append(documentLayout)

        buttonLayout = VerticalLayout()
        button = Button('Button')

        button.addListener(ButtonClickListener(self), IClickListener)
        buttonLayout.addComponent(button)
        buttonLayout.setComponentAlignment(button, Alignment.MIDDLE_CENTER)
        components.append(buttonLayout)

        return components
Ejemplo n.º 12
0
    def __init__(self):
        super(SubwindowCloseExample, self).__init__()

        self._closableWindow = CheckBox('Allow user to close the window', True)
        self._closableWindow.setImmediate(True)

        self._closableWindow.addListener(ClosableChangeListener(self),
                IValueChangeListener)

        # Create the window
        self._subwindow = Window('A subwindow w/ close-listener')

        self._subwindow.addListener(CloseListener(self), ICloseListener)

        # Configure the windws layout; by default a VerticalLayout
        layout = self._subwindow.getContent()
        layout.setMargin(True)
        layout.setSpacing(True)

        # Add some content; a label and a close-button
        message = Label('This is a subwindow with a close-listener.')
        self._subwindow.addComponent(message)

        # Add a button for opening the subwindow
        self._openCloseButton = Button("Open window", ClickListener(self))

        self.setSpacing(True)
        self.addComponent(self._closableWindow)
        self.addComponent(self._openCloseButton)
Ejemplo n.º 13
0
    def __init__(self):
        super(PanelLightExample, self).__init__()

        self.setSpacing(True)
        self.setSpacing(True)

        # Panel 1 - with caption
        self._panel = Panel('This is a light Panel')
        self._panel.setStyleName(Reindeer.PANEL_LIGHT)
        self._panel.setHeight('200px')  # we want scrollbars
        # let's adjust the panels default layout (a VerticalLayout)
        layout = self._panel.getContent()
        layout.setMargin(True)  # we want a margin
        layout.setSpacing(True)
        # and spacing between components
        self.addComponent(self._panel)

        # Let's add a few rows to provoke scrollbars:
        for _ in range(20):
            l = Label('The quick brown fox jumps over the lazy dog.')
            self._panel.addComponent(l)

        # Caption toggle:
        b = Button('Toggle caption')
        b.addListener(self, IClickListener)
        self.addComponent(b)
Ejemplo n.º 14
0
    def __init__(self):
        super(LayoutSpacingExample, self).__init__()

        # Create a grid layout.
        self.grid = GridLayout(3, 3)

        # Enable sp for the example layout (this is the one we'll toggle
        # with the checkbox)
        self.grid.setSpacing(False)

        # CheckBox for toggling sp on and off
        self.sp = CheckBox("Spacing enabled")
        #        self.sp.setValue(True)  # FIXME:
        self.sp.setImmediate(True)

        self.sp.addListener(self, IClickListener)
        self.addComponent(self.sp)

        # Add the layout to the containing layout.
        self.addComponent(self.grid)

        # Populate the layout with components.
        for i in range(9):
            self.grid.addComponent(Button('Component %d' % (i + 1)))

        self.setSpacing(True)  # enable sp for the example itself
Ejemplo n.º 15
0
    def create(self, parent):
        """ Creates the underlying Button control.

        """
        self.widget = Button()
        self.widget.setImmediate(True)
        parent.addComponent(self.widget)
Ejemplo n.º 16
0
    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)
Ejemplo n.º 17
0
    def init(self):
        # Application.init is called once for each application. Here it
        # creates the UI and connects it to the business logic.

        # Create the main layout for our application (4 columns, 5 rows)
        layout = GridLayout(4, 5)

        # Create the main window for the application using the main layout.
        # The main window is shown when the application is starts.
        self.setMainWindow(Window('Calculator Application', layout))

        # Create a result label that over all 4 columns in the first row
        layout.addComponent(self._display, 0, 0, 3, 0)

        # The operations for the calculator in the order they appear on the
        # screen (left to right, top to bottom)
        operations = ['7', '8', '9', '/', '4', '5', '6',
                '*', '1', '2', '3', '-', '0', '=', 'C', '+']

        for caption in operations:
            # Create a button and use this application for event handling
            button = Button(caption)
            button.addListener(self)

            # Add the button to our main layout
            layout.addComponent(button)
Ejemplo n.º 18
0
    def __init__(self):
        super(TabSheetDisabledExample, self).__init__()

        self.setSpacing(True)

        # Tab 1 content
        self._l1 = VerticalLayout()
        self._l1.setMargin(True)
        self._l1.addComponent(Label('There are no previously saved actions.'))

        # Tab 2 content
        self._l2 = VerticalLayout()
        self._l2.setMargin(True)
        self._l2.addComponent(Label('There are no saved notes.'))

        # Tab 3 content
        self._l3 = VerticalLayout()
        self._l3.setMargin(True)
        self._l3.addComponent(Label('There are currently no issues.'))

        self._t = TabSheet()
        self._t.setHeight('200px')
        self._t.setWidth('400px')

        self._t1 = self._t.addTab(self._l1, 'Saved actions', self._icon1)
        self._t2 = self._t.addTab(self._l2, 'Notes', self._icon2)
        self._t3 = self._t.addTab(self._l3, 'Issues', self._icon3)

        self._t.addListener(self, tab_sheet.ISelectedTabChangeListener)

        self._toggleEnabled = Button('Disable \'Notes\' tab')
        self._toggleEnabled.addListener(self, button.IClickListener)

        self._toggleVisible = Button('Hide \'Issues\' tab')
        self._toggleVisible.addListener(self, button.IClickListener)

        hl = HorizontalLayout()
        hl.setSpacing(True)
        hl.addComponent(self._toggleEnabled)
        hl.addComponent(self._toggleVisible)

        self.addComponent(self._t)
        self.addComponent(hl)
Ejemplo n.º 19
0
    def __init__(self):
        super(FormPojoExample, self).__init__()

        self._person = Person()  # a person POJO
        personItem = BeanItem(self._person)  # item from POJO

        # Create the Form
        personForm = Form()
        personForm.setCaption('Personal details')
        personForm.setWriteThrough(False)  # we want explicit 'apply'
        personForm.setInvalidCommitted(False)  # no invalid values in datamodel

        # FieldFactory for customizing the fields and adding validators
        personForm.setFormFieldFactory(PersonFieldFactory(self))
        personForm.setItemDataSource(personItem)  # bind to POJO via BeanItem

        # Determines which properties are shown, and in which order:
        personForm.setVisibleItemProperties(['firstName', 'lastName',
                'countryCode', 'password', 'birthdate', 'shoesize', 'uuid'])

        # Add form to layout
        self.addComponent(personForm)

        # The cancel / apply buttons
        buttons = HorizontalLayout()
        buttons.setSpacing(True)

        discardChanges = Button('Discard changes', DiscardListener(personForm))
        discardChanges.setStyleName(BaseTheme.BUTTON_LINK)
        buttons.addComponent(discardChanges)
        buttons.setComponentAlignment(discardChanges, Alignment.MIDDLE_LEFT)

        aply = Button('Apply', ApplyListener(personForm))
        buttons.addComponent(aply)
        personForm.getFooter().addComponent(buttons)
        personForm.getFooter().setMargin(False, False, True, True)

        # button for showing the internal state of the POJO
        l = InternalStateListener(self)
        showPojoState = Button('Show POJO internal state', l)
        self.addComponent(showPojoState)
    def __init__(self):
        super(AbsoluteLayoutBasicExample, self).__init__()

        self.setMargin(True)

        # Add a border to the layout with CSS to indicate its boundaries
        self.addStyleName('border')

        # allow border to show (100% would clip the right side border)
        self.setWidth('99%')
        self.setHeight('300px')
        self.addComponent(Button('Top: 10px, left: 10px'),
                          'top:10px; left:10px')
        self.addComponent(Button('Top: 10px, right: 40px'),
                          'top:10px; right:40px')
        self.addComponent(Button('Bottom: 0, left: 50%'), 'bottom:0; left:50%')
        self.addComponent(Button('Top: 50%, right: 50%'), 'top:50%; right:50%')

        # Components can overflow out of the container, but they will be
        # clipped. Negative values do not work currently (see issue #4479)
        self.addComponent(Button('Top: 50%, right: 50%'), 'top:50%; right:50%')
    def __init__(self):
        super(SubwindowPositionedExample, self).__init__()

        self.setSpacing(True)
        # Create the window
        self._subwindow = Window('A positioned subwindow')

        # let's give it a size (optional)
        self._subwindow.setWidth('300px')
        self._subwindow.setHeight('200px')

        # Configure the windows layout; by default a VerticalLayout
        layout = self._subwindow.getContent()
        layout.setMargin(True)
        layout.setSpacing(True)

        # make it fill the whole window
        layout.setSizeFull()

        # Add some content; a label and a close-button
        message = Label('This is a positioned window')
        self._subwindow.addComponent(message)

        close = Button('Close', CloseListener(self))

        # The components added to the window are actually added to the window's
        # layout; you can use either. Alignments are set using the layout
        layout.addComponent(close)
        layout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT)

        # Add buttons for opening the subwindow
        fifty = Button('Open window at position 50x50', OpenListener50(self))
        self.addComponent(fifty)

        onefifty = Button('Open window at position 150x200',
                          OpenListener150(self))
        self.addComponent(onefifty)

        center = Button('Open centered window', CenterListener(self))
        self.addComponent(center)
Ejemplo n.º 22
0
    def __init__(self):
        super(ProgressIndicatorsExample, self).__init__()

        self.setSpacing(True)

        self.addComponent(
            Label('<strong>Normal mode</strong> '
                  'Runs for 20 seconds', Label.CONTENT_XHTML))
        hl = HorizontalLayout()
        hl.setSpacing(True)
        self.addComponent(hl)

        # Add a normal progress indicator
        self._pi1 = ProgressIndicator()
        self._pi1.setIndeterminate(False)
        self._pi1.setEnabled(False)
        hl.addComponent(self._pi1)
        hl.setComponentAlignment(self._pi1, Alignment.MIDDLE_LEFT)

        self._startButton1 = Button('Start normal', NormalListener(self))
        self._startButton1.setStyleName('small')
        hl.addComponent(self._startButton1)
        self.addComponent(
            Label('<strong>Indeterminate mode</strong> '
                  'Runs for 10 seconds', Label.CONTENT_XHTML))
        hl = HorizontalLayout()
        hl.setSpacing(True)
        self.addComponent(hl)

        # Add an indeterminate progress indicator
        self._pi2 = ProgressIndicator()
        self._pi2.setIndeterminate(True)
        self._pi2.setPollingInterval(5000)
        self._pi2.setEnabled(False)
        hl.addComponent(self._pi2)

        l = IndeterminateListener(self)
        self._startButton2 = Button('Start indeterminate', l)
        self._startButton2.setStyleName('small')
        hl.addComponent(self._startButton2)
Ejemplo n.º 23
0
    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)
Ejemplo n.º 24
0
    def __init__(self):
        super(ExpandingComponentExample, self).__init__()

        self.setSpacing(True)

        # Basic scenario: single expanded component
        layout = HorizontalLayout()
        layout.setWidth('100%')  # make the layout grow with the window size
        self.addComponent(layout)

        naturalButton = Button('Natural')
        naturalButton.setDescription('This button does not have an explicit '
                'size - instead, its size depends on it\'s content - a.k.a '
                '<i>natural size.</i>')
        layout.addComponent(naturalButton)

        expandedButton = Button('Expanded')
        expandedButton.setWidth('100%')
        expandedButton.setDescription('The width of this button is set to '
                '100% and expanded, and will thus occupy the space left over '
                'by the other components.')
        layout.addComponent(expandedButton)
        layout.setExpandRatio(expandedButton, 1.0)

        sizedButton = Button('Explicit')
        sizedButton.setWidth('150px')
        sizedButton.setDescription('This button is explicitly set to be '
                '150 pixels wide.')
        layout.addComponent(sizedButton)


        # Ratio example
        layout = HorizontalLayout()
        layout.setWidth('100%')  # make the layout grow with the window size
        self.addComponent(layout)

        naturalButton = Button('Natural')
        naturalButton.setDescription('This button does not have an explicit '
                'size - instead, its size depends on it\'s content - a.k.a '
                '<i>natural size.</i>')
        layout.addComponent(naturalButton)

        expandedButton1 = Button('Ratio 1.0')
        expandedButton1.setWidth('100%')
        expandedButton1.setDescription('The width of this button is set to '
                '100% and expanded with a ratio of 1.0, and will in this '
                'example occupy 1:3 of the leftover space.')
        layout.addComponent(expandedButton1)
        layout.setExpandRatio(expandedButton1, 1.0)

        expandedButton2 = Button('Ratio 2.0')
        expandedButton2.setWidth('100%')
        expandedButton2.setDescription('The width of this button is set to '
                '100% and expanded with a ratio of 2.0, and will in this '
                'example occupy 2:3 of the leftover space.')
        layout.addComponent(expandedButton2)
        layout.setExpandRatio(expandedButton2, 2.0)
Ejemplo n.º 25
0
    def __init__(self):
        super(ImmediateUploadExample, self).__init__()

        self.setSpacing(True)

        self._status = Label('Please select a file to upload')
        self._pi = ProgressIndicator()
        self._receiver = MyReceiver()
        self._progressLayout = HorizontalLayout()
        self._upload = Upload(None, self._receiver)

        # Slow down the upload
        self._receiver.setSlow(True)
        self.addComponent(self._status)
        self.addComponent(self._upload)
        self.addComponent(self._progressLayout)

        # Make uploading start immediately when file is selected
        self._upload.setImmediate(True)
        self._upload.setButtonCaption('Select file')

        self._progressLayout.setSpacing(True)
        self._progressLayout.setVisible(False)
        self._progressLayout.addComponent(self._pi)
        self._progressLayout.setComponentAlignment(self._pi,
                                                   Alignment.MIDDLE_LEFT)

        cancelProcessing = Button('Cancel')
        cancelProcessing.addListener(CancelListener(self),
                                     button.IClickListener)
        cancelProcessing.setStyleName('small')
        self._progressLayout.addComponent(cancelProcessing)

        # =========== Add needed listener for the upload component: start,
        # progress, finish, success, fail ===========

        self._upload.addListener(StartedListener(self),
                                 upload.IStartedListener)

        self._upload.addListener(ProgressListener(self),
                                 upload.IProgressListener)

        self._upload.addListener(SucceededListener(self),
                                 upload.ISucceededListener)

        self._upload.addListener(FailedListener(self), upload.IFailedListener)

        self._upload.addListener(FinishedListener(self),
                                 upload.IFinishedListener)
Ejemplo n.º 26
0
    def __init__(self):
        super(TooltipsExample, self).__init__()

        self.setSpacing(True)

        # Plain tooltip (description)
        plain = Button('Mouse over for plain tooltip')
        plain.setStyleName(BaseTheme.BUTTON_LINK)
        # add the tooltip:
        plain.setDescription('A simple plaintext tooltip')
        self.addComponent(plain)

        # Richtext tooltip (description)
        rich = Button('Mouse over for richtext tooltip')
        rich.setStyleName(BaseTheme.BUTTON_LINK)
        # add the tooltip:
        rich.setDescription(
            ('<h2><img src=\"../VAADIN/themes/sampler/'
             'icons/comment_yellow.gif\"/>A richtext tooltip</h2>'
             '<ul>'
             '<li>HTML formatting</li><li>Images<br/>'
             '</li><li>etc...</li></ul>'))
        self.addComponent(rich)

        # Edit
        rte = RichTextArea()
        rte.setValue(
            ('Click <b>' + self._editTxt +
             '</b> to edit this tooltip, then <b>' + self._applyTxt + '</b>'))
        rte.setVisible(False)  # hide editor initially
        rte.setWidth('100%')
        self.addComponent(rte)

        aply = Button(self._editTxt, EditListener(self, rte))
        aply.setDescription(rte.getValue())
        self.addComponent(aply)
Ejemplo n.º 27
0
    def __init__(self):
        super(NotificationCustomExample, self).__init__()

        self.setSpacing(True)

        caption = TextField('Caption', 'Message sent')
        caption.setDescription(('Main info; a short caption-only '
                                'notification is often most effective.'))
        caption.setWidth('200px')
        self.addComponent(caption)

        description = RichTextArea()
        description.setWidth('100%')
        description.setValue('<p>to <i>[email protected]</i></p>')
        description.setCaption('Description')
        description.setDescription(('Additional information; '
                                    'try to keep it short.'))
        self.addComponent(description)

        horiz = HorizontalLayout()
        horiz.setSpacing(True)
        self.addComponent(horiz)

        position = NativeSelect('Position')
        position.setNullSelectionAllowed(False)
        horiz.addComponent(position)
        self.initPositionItems(position)

        style = NativeSelect('Style')
        style.setNullSelectionAllowed(False)
        horiz.addComponent(style)
        self.initTypeItems(style)
        delay = Slider('Delay (msec), -1 means click to hide')
        delay.setDescription(
            ('Delay before fading<br/>Pull all the way to '
             'the left to get -1, which means forever (click to hide).'))
        delay.setWidth('100%')  # 'description' will push width
        delay.setMin(Notification.DELAY_FOREVER)
        delay.setMax(10000)
        self.addComponent(delay)

        # TODO icon select

        l = ShowListener(self, caption, description, style, position, delay)
        show = Button('Show notification', l)
        self.addComponent(show)
        self.setComponentAlignment(show, Alignment.MIDDLE_RIGHT)
Ejemplo n.º 28
0
    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)
Ejemplo n.º 29
0
    def __init__(self):
        super(NotificationHumanizedExample, self).__init__()

        self.setSpacing(True)
        self.setWidth(None)
        # layout will grow with content
        caption = TextField('Caption', 'Document saved')
        caption.setWidth('200px')
        self.addComponent(caption)
        description = TextField('Description', 'Invoices-2008.csv')
        description.setWidth('300px')
        self.addComponent(description)

        l = ShowListener(self, caption, description)
        show = Button('Show notification', l)
        self.addComponent(show)
        self.setComponentAlignment(show, Alignment.MIDDLE_RIGHT)
Ejemplo n.º 30
0
    def createPanel(self, number):
        p = Panel('Panel %d' % number)
        p.getContent().setSpacing(True)

        # Let's create a customized shortcut that jumps to the next field
        p.addAction(NextFieldListener("Next field", KeyCode.ARROW_DOWN, None))

        # Firstname input with an input prompt for demo clarity
        firstname = TextField('Firstname')
        firstname.setInputPrompt('ALT-SHIFT-F to focus')
        p.addComponent(firstname)

        # Using firstname.addShortcutListener() would add globally,
        # but we want the shortcut only in this panel:
        p.addAction(
            FocusShortcut(firstname, KeyCode.F, ModifierKey.ALT,
                          ModifierKey.SHIFT))

        # additinally we'll add a global shortcut for this field using the
        # shorthand notation (^1 == CTRL-1,NextFieldListener etc)
        firstname.addShortcutListener(
            FocusShortcut(firstname, 'Focus panel &_' + str(number)))
        p.setDescription('CTRL-' + str(number) + ' to focus')

        # Lastname input with an input prompt for demo clarity
        lastname = TextField('Lastname')
        lastname.setInputPrompt('ALT-SHIFT-L to focus')
        p.addComponent(lastname)

        # Using firstname.addShortcutListener() would add globally,
        # but we want the shortcut only in this panel:
        p.addAction(
            FocusShortcut(lastname, KeyCode.L, ModifierKey.ALT,
                          ModifierKey.SHIFT))

        # Button with a simple click-listener
        save = Button('Save', SaveListener(self, p))
        p.addComponent(save)

        # setClickShortcut() would add global shortcut, instead we
        # 'scope' the shortcut to the panel:
        p.addAction(
            ClickShortcut(save, KeyCode.S, ModifierKey.ALT, ModifierKey.SHIFT))

        return p