Esempio n. 1
0
    def __init__(self):
        super(TextFieldInputPromptExample, self).__init__()

        # add some 'air' to the layout
        self.setSpacing(True)

        self.setMargin(True, False, False, False)

        # Username field + input prompt
        username = TextField()
        username.setInputPrompt('Username')

        # configure & add to layout
        username.setImmediate(True)
        username.addListener(self, IValueChangeListener)
        self.addComponent(username)

        # Password field + input prompt
        password = PasswordField()
        password.setInputPrompt('Password')

        # configure & add to layout
        password.setImmediate(True)
        password.addListener(self, IValueChangeListener)
        self.addComponent(password)

        # Comment field + input prompt
        comment = TextArea()
        comment.setInputPrompt('Comment')

        # configure & add to layout
        comment.setRows(3)
        comment.setImmediate(True)
        comment.addListener(self, IValueChangeListener)
        self.addComponent(comment)
Esempio n. 2
0
class TextAreaExample(HorizontalLayout, IValueChangeListener):

    _initialText = 'The quick brown fox jumps over the lazy dog.'

    def __init__(self):
        super(TextAreaExample, self).__init__()

        self.setSpacing(True)

        self.setWidth('100%')

        self._editor = TextArea(None, self._initialText)
        self._editor.setRows(20)
        self._editor.setColumns(20)
        self._editor.addListener(self, IValueChangeListener)
        self._editor.setImmediate(True)
        self.addComponent(self._editor)

        # the TextArea is immediate, and it's valueCahnge updates the Label,
        # so this button actually does nothing
        self.addComponent(Button('>'))
        self._plainText = Label(self._initialText)
        self._plainText.setContentMode(Label.CONTENT_XHTML)
        self.addComponent(self._plainText)
        self.setExpandRatio(self._plainText, 1)

    # Catch the valuechange event of the textfield and update the value of the
    # label component
    def valueChange(self, event):
        text = self._editor.getValue()
        if text is not None:
            # replace newline with BR, because we're using Label.CONTENT_XHTML
            text = text.replace('\n', '<br/>')
        self._plainText.setValue(text)
    def __init__(self):
        super(TextFieldInputPromptExample, self).__init__()

        # add some 'air' to the layout
        self.setSpacing(True)

        self.setMargin(True, False, False, False)

        # Username field + input prompt
        username = TextField()
        username.setInputPrompt('Username')

        # configure & add to layout
        username.setImmediate(True)
        username.addListener(self, IValueChangeListener)
        self.addComponent(username)

        # Password field + input prompt
        password = PasswordField()
        password.setInputPrompt('Password')

        # configure & add to layout
        password.setImmediate(True)
        password.addListener(self, IValueChangeListener)
        self.addComponent(password)

        # Comment field + input prompt
        comment = TextArea()
        comment.setInputPrompt('Comment')

        # configure & add to layout
        comment.setRows(3)
        comment.setImmediate(True)
        comment.addListener(self, IValueChangeListener)
        self.addComponent(comment)
Esempio n. 4
0
    def __init__(self):
        super(JSApiExample, self).__init__()

        self._toBeUpdatedFromThread = None
        self._startThread = None
        self._running = Label('')

        self.setSpacing(True)

        javascript = Label("<h3>Run Native JavaScript</h3>",
                Label.CONTENT_XHTML)
        self.addComponent(javascript)

        script = TextArea()
        script.setWidth('100%')
        script.setRows(3)
        script.setValue('alert(\"Hello Muntjac\");')
        self.addComponent(script)

        self.addComponent(Button('Run script', RunListener(self, script)))
        sync = Label("<h3>Force Server Syncronization</h3>",
                Label.CONTENT_XHTML)
        self.addComponent(sync)

        self.addComponent(Label('For advanced client side programmers '
                'Muntjac offers a simple method which can be used to force '
                'the client to synchronize with the server. This may be '
                'needed for example if another part of a mashup changes '
                'things on server.'))

        self._toBeUpdatedFromThread = Label("This Label component will be "
                "updated by a background thread. Click \"Start "
                "background thread\" button and start clicking "
                "on the link below to force "
                "synchronization.", Label.CONTENT_XHTML)
        self.addComponent(self._toBeUpdatedFromThread)

        # This label will be show for 10 seconds while the background process
        # is working
        self._running.setCaption('Background process is running for 10 '
                'seconds, click the link below')
        self._running.setIcon(
                ThemeResource('../base/common/img/ajax-loader-medium.gif'))

        # Clicking on this button will start a repeating thread that updates
        # the label value
        self._startThread = Button('Start background thread',
                StartListener(self))
        self.addComponent(self._startThread)

        # This link will make an Ajax request to the server that will respond
        # with UI changes that have happened since last request
        self.addComponent(Label("<a href=\"javascript:vaadin.forceSync();\">"
                "javascript: vaadin.forceSync();</a>", Label.CONTENT_XHTML))
Esempio n. 5
0
    def __init__(self):
        super(JSApiExample, self).__init__()

        self._toBeUpdatedFromThread = None
        self._startThread = None
        self._running = Label('')

        self.setSpacing(True)

        javascript = Label("<h3>Run Native JavaScript</h3>",
                           Label.CONTENT_XHTML)
        self.addComponent(javascript)

        script = TextArea()
        script.setWidth('100%')
        script.setRows(3)
        script.setValue('alert(\"Hello Muntjac\");')
        self.addComponent(script)

        self.addComponent(Button('Run script', RunListener(self, script)))
Esempio n. 6
0
    def __init__(self):
        super(TextAreaExample, self).__init__()

        self.setSpacing(True)

        self.setWidth('100%')

        self._editor = TextArea(None, self._initialText)
        self._editor.setRows(20)
        self._editor.setColumns(20)
        self._editor.addListener(self, IValueChangeListener)
        self._editor.setImmediate(True)
        self.addComponent(self._editor)

        # the TextArea is immediate, and it's valueCahnge updates the Label,
        # so this button actually does nothing
        self.addComponent(Button('>'))
        self._plainText = Label(self._initialText)
        self._plainText.setContentMode(Label.CONTENT_XHTML)
        self.addComponent(self._plainText)
        self.setExpandRatio(self._plainText, 1)
Esempio n. 7
0
    def __init__(self):
        super(JSApiExample, self).__init__()

        self._toBeUpdatedFromThread = None
        self._startThread = None
        self._running = Label('')

        self.setSpacing(True)

        javascript = Label("<h3>Run Native JavaScript</h3>",
                Label.CONTENT_XHTML)
        self.addComponent(javascript)

        script = TextArea()
        script.setWidth('100%')
        script.setRows(3)
        script.setValue('alert(\"Hello Muntjac\");')
        self.addComponent(script)

        self.addComponent(Button('Run script', RunListener(self, script)))