class JSApiExample(VerticalLayout): 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))
def buildLabels(self): grid = GridLayout() grid.setSpacing(True) grid.setWidth("100%") grid.setColumns(6) for prop in CssProperty.values(): l = Label("-") l.setSizeUndefined() l.setCaption(str(prop)) self._props[prop] = l grid.addComponent(l) return grid
def buildLabels(self): grid = GridLayout() grid.setSpacing(True) grid.setWidth('100%') grid.setColumns(6) for prop in CssProperty.values(): l = Label('-') l.setSizeUndefined() l.setCaption(str(prop)) self._props[prop] = l grid.addComponent(l) return grid
def __init__(self): super(IconsExample, self).__init__() self.setSpacing(True) # Button w/ icon button = Button('Save') button.setIcon(ThemeResource('../sampler/icons/action_save.gif')) self.addComponent(button) # Label l = Label('Icons are very handy') l.setCaption('Comment') l.setIcon(ThemeResource('../sampler/icons/comment_yellow.gif')) self.addComponent(l) # Panel w/ links p = Panel('Handy links') p.setIcon(ThemeResource('../sampler/icons/icon_info.gif')) self.addComponent(p) lnk = Link('http://vaadin.com', ExternalResource('http://www.vaadin.com')) lnk.setIcon(ThemeResource('../sampler/icons/icon_world.gif')) p.addComponent(lnk) lnk = Link('http://vaadin.com/learn', ExternalResource('http://www.vaadin.com/learn')) lnk.setIcon(ThemeResource('../sampler/icons/icon_world.gif')) p.addComponent(lnk) lnk = Link('http://dev.vaadin.com/', ExternalResource('http://dev.vaadin.com/')) lnk.setIcon(ThemeResource('../sampler/icons/icon_world.gif')) p.addComponent(lnk) lnk = Link('http://vaadin.com/forum', ExternalResource('http://vaadin.com/forum')) lnk.setIcon(ThemeResource('../sampler/icons/icon_world.gif')) p.addComponent(lnk)
class UploadWithProgressMonitoringExample(VerticalLayout): def __init__(self): super(UploadWithProgressMonitoringExample, self).__init__() self.setSpacing(True) self._state = Label() self._result = Label() self._fileName = Label() self._textualProgress = Label() self._pi = ProgressIndicator() self._counter = LineBreakCounter() self._upload = Upload(None, self._counter) self.addComponent(Label('Upload a file and we\'ll count the number ' 'of line break characters (\\n) found in it.')) # make analyzing start immediatedly when file is selected self._upload.setImmediate(True) self._upload.setButtonCaption('Upload File') self.addComponent(self._upload) handBrake = CheckBox('Simulate slow server') handBrake.setValue(True) self._counter.setSlow(True) handBrake.setDescription('Sleep for 100ms after each kilobyte to ' 'simulate slower processing/bandwidth. This is to show ' 'progress indicator even with rather small files.') handBrake.addListener(HandBrakeListener(self), button.IClickListener) cancelProcessing = Button('Cancel') cancelProcessing.addListener(CancelListener(self), button.IClickListener) cancelProcessing.setVisible(False) cancelProcessing.setStyleName('small') handBrake.setImmediate(True) self.addComponent(handBrake) p = Panel('Status') p.setSizeUndefined() l = FormLayout() l.setMargin(True) p.setContent(l) stateLayout = HorizontalLayout() stateLayout.setSpacing(True) stateLayout.addComponent(self._state) stateLayout.addComponent(cancelProcessing) stateLayout.setCaption('Current state') self._state.setValue('Idle') l.addComponent(stateLayout) self._fileName.setCaption('File name') l.addComponent(self._fileName) self._result.setCaption('Line breaks counted') l.addComponent(self._result) self._pi.setCaption('Progress') self._pi.setVisible(False) l.addComponent(self._pi) self._textualProgress.setVisible(False) l.addComponent(self._textualProgress) self.addComponent(p) 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)
class UploadWithProgressMonitoringExample(VerticalLayout): def __init__(self): super(UploadWithProgressMonitoringExample, self).__init__() self.setSpacing(True) self._state = Label() self._result = Label() self._fileName = Label() self._textualProgress = Label() self._pi = ProgressIndicator() self._counter = LineBreakCounter() self._upload = Upload(None, self._counter) self.addComponent( Label('Upload a file and we\'ll count the number ' 'of line break characters (\\n) found in it.')) # make analyzing start immediatedly when file is selected self._upload.setImmediate(True) self._upload.setButtonCaption('Upload File') self.addComponent(self._upload) handBrake = CheckBox('Simulate slow server') handBrake.setValue(True) self._counter.setSlow(True) handBrake.setDescription( 'Sleep for 100ms after each kilobyte to ' 'simulate slower processing/bandwidth. This is to show ' 'progress indicator even with rather small files.') handBrake.addListener(HandBrakeListener(self), button.IClickListener) cancelProcessing = Button('Cancel') cancelProcessing.addListener(CancelListener(self), button.IClickListener) cancelProcessing.setVisible(False) cancelProcessing.setStyleName('small') handBrake.setImmediate(True) self.addComponent(handBrake) p = Panel('Status') p.setSizeUndefined() l = FormLayout() l.setMargin(True) p.setContent(l) stateLayout = HorizontalLayout() stateLayout.setSpacing(True) stateLayout.addComponent(self._state) stateLayout.addComponent(cancelProcessing) stateLayout.setCaption('Current state') self._state.setValue('Idle') l.addComponent(stateLayout) self._fileName.setCaption('File name') l.addComponent(self._fileName) self._result.setCaption('Line breaks counted') l.addComponent(self._result) self._pi.setCaption('Progress') self._pi.setVisible(False) l.addComponent(self._pi) self._textualProgress.setVisible(False) l.addComponent(self._textualProgress) self.addComponent(p) 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)