List of usage examples for com.vaadin.ui TextField setValue
@Override public void setValue(String value)
From source file:com.esofthead.mycollab.module.project.view.bug.components.ToggleBugSummaryField.java
License:Open Source License
public ToggleBugSummaryField(final BugWithBLOBs bug, int trimCharacters) { this.bug = bug; this.maxLength = trimCharacters; titleLinkLbl = new Label(buildBugLink(), ContentMode.HTML); titleLinkLbl.addStyleName(UIConstants.LABEL_WORD_WRAP); titleLinkLbl.setWidthUndefined();/*from w ww .j ava 2 s . c o m*/ this.addComponent(titleLinkLbl); buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)) { this.addStyleName("editable-field"); Button instantEditBtn = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (isRead) { ToggleBugSummaryField.this.removeComponent(titleLinkLbl); ToggleBugSummaryField.this.removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(bug.getSummary()); editField.setWidth("100%"); editField.focus(); ToggleBugSummaryField.this.addComponent(editField); ToggleBugSummaryField.this.removeStyleName("editable-field"); editField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { updateFieldValue(editField); } }); editField.addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent event) { updateFieldValue(editField); } }); isRead = !isRead; } } }); instantEditBtn.setDescription("Edit task name"); instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ONLY); instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); instantEditBtn.setIcon(FontAwesome.EDIT); buttonControls.with(instantEditBtn); this.addComponent(buttonControls); } }
From source file:com.esofthead.mycollab.module.project.view.milestone.ToggleGenericTaskSummaryField.java
License:Open Source License
ToggleGenericTaskSummaryField(final ProjectGenericTask genericTask) { this.genericTask = genericTask; this.setWidth("100%"); titleLinkLbl = new ELabel(buildGenericTaskLink(), ContentMode.HTML).withWidthUndefined(); titleLinkLbl.addStyleName(ValoTheme.LABEL_NO_MARGIN); titleLinkLbl.addStyleName(UIConstants.LABEL_WORD_WRAP); this.addComponent(titleLinkLbl); if ((genericTask.isTask() && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) || (genericTask.isBug() && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)) || (genericTask.isRisk()/*from w w w . ja va 2 s. c o m*/ && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.RISKS))) { this.addStyleName("editable-field"); buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false); Button instantEditBtn = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (isRead) { removeComponent(titleLinkLbl); removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(genericTask.getName()); editField.setWidth("100%"); editField.focus(); addComponent(editField); removeStyleName("editable-field"); editField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { updateFieldValue(editField); } }); editField.addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent event) { updateFieldValue(editField); } }); isRead = !isRead; } } }); instantEditBtn.setDescription("Edit task name"); instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ONLY); instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); instantEditBtn.setIcon(FontAwesome.EDIT); buttonControls.with(instantEditBtn); this.addComponent(buttonControls); } }
From source file:com.esofthead.mycollab.module.project.view.milestone.ToggleMilestoneSummaryField.java
License:Open Source License
ToggleMilestoneSummaryField(final SimpleMilestone milestone, int maxLength) { this.milestone = milestone; this.maxLength = maxLength; this.setWidth("100%"); titleLinkLbl = new ELabel(buildMilestoneLink(), ContentMode.HTML).withStyleName(ValoTheme.LABEL_H3) .withWidthUndefined();//from w w w. j a va2 s .c o m titleLinkLbl.addStyleName(ValoTheme.LABEL_NO_MARGIN); titleLinkLbl.addStyleName(UIConstants.LABEL_WORD_WRAP); this.addComponent(titleLinkLbl); buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) { this.addStyleName("editable-field"); Button instantEditBtn = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (isRead) { ToggleMilestoneSummaryField.this.removeComponent(titleLinkLbl); ToggleMilestoneSummaryField.this.removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(milestone.getName()); editField.setWidth("100%"); editField.focus(); ToggleMilestoneSummaryField.this.addComponent(editField); ToggleMilestoneSummaryField.this.removeStyleName("editable-field"); editField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { updateFieldValue(editField); } }); editField.addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent event) { updateFieldValue(editField); } }); isRead = !isRead; } } }); instantEditBtn.setDescription("Edit task name"); instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ONLY); instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); instantEditBtn.setIcon(FontAwesome.EDIT); buttonControls.with(instantEditBtn); this.addComponent(buttonControls); } }
From source file:com.esofthead.mycollab.module.project.view.task.components.ToggleTaskSummaryField.java
License:Open Source License
public ToggleTaskSummaryField(final SimpleTask task, int maxLength) { this.setWidth("100%"); this.maxLength = maxLength; this.task = task; titleLinkLbl = new Label(buildTaskLink(), ContentMode.HTML); titleLinkLbl.setWidthUndefined();/* w w w . j ava2s . com*/ titleLinkLbl.addStyleName(UIConstants.LABEL_WORD_WRAP); this.addComponent(titleLinkLbl); buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { this.addStyleName("editable-field"); Button instantEditBtn = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (isRead) { ToggleTaskSummaryField.this.removeComponent(titleLinkLbl); ToggleTaskSummaryField.this.removeComponent(buttonControls); final TextField editField = new TextField(); editField.setValue(task.getTaskname()); editField.setWidth("100%"); editField.focus(); ToggleTaskSummaryField.this.addComponent(editField); ToggleTaskSummaryField.this.removeStyleName("editable-field"); editField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { updateFieldValue(editField); } }); editField.addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent event) { updateFieldValue(editField); } }); isRead = !isRead; } } }); instantEditBtn.setDescription("Edit task name"); instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ONLY); instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); instantEditBtn.setIcon(FontAwesome.EDIT); buttonControls.with(instantEditBtn); this.addComponent(buttonControls); } }
From source file:com.esofthead.mycollab.module.project.view.task.TaskEditFormFieldFactory.java
License:Open Source License
private void calculateDurationBaseOnStartAndEndDates() { DateTimeOptionField startDateField = (DateTimeOptionField) fieldGroup.getField(Task.Field.startdate.name()); DateTimeOptionField endDateField = (DateTimeOptionField) fieldGroup.getField(Task.Field.enddate.name()); TextField durationField = (TextField) fieldGroup.getField(Task.Field.duration.name()); Date startDate = null;/*www . j a v a 2 s .com*/ Date endDate = null; if (startDateField != null) { startDate = startDateField.getValue(); } if (endDateField != null) { endDate = endDateField.getValue(); } if (startDate != null && endDate != null && startDate.before(endDate) && durationField != null) { LocalDate startDateJoda = new LocalDate(startDate); LocalDate endDateJoda = new LocalDate(endDate); int durationInDays = BusinessDayTimeUtils.duration(startDateJoda, endDateJoda); durationField.setValue(durationInDays + " d"); } }
From source file:com.esspl.datagen.ui.TableDataView.java
License:Open Source License
@SuppressWarnings("rawtypes") protected void populateGenerator(JdbcTable table) { log.debug("TableDataView - populateGenerator() called"); if (rows.getValue() != null) { dataGenApplication.resultNum.setValue(rows.getValue().toString()); }/*from w ww . j a va 2 s.c o m*/ dataGenApplication.tblName.setValue(table.getName().toUpperCase()); dataGenApplication.createQuery.setValue(false); dataGenApplication.tabSheet.setSelectedTab(dataGenApplication.generator); int generatorLength = dataGenApplication.listing.getItemIds().size(); //If there are more column than the present generated row, we need to add new rows first if (columns.size() > generatorLength) { dataGenApplication.addRow(columns.size() - generatorLength); } Iterator iter = dataGenApplication.listing.getItemIds().iterator(); while (iter.hasNext()) { int row = (Integer) iter.next(); Item item = dataGenApplication.listing.getItem(row); TextField txtField = (TextField) (item.getItemProperty("Column Name").getValue()); if (columns.size() > 0) { txtField.setValue(columns.get(0)); columns.remove(0); } } }
From source file:com.etest.valo.Forms.java
License:Apache License
public Forms() { setSpacing(true);//from w w w .j av a2s .co m setMargin(true); Label title = new Label("Forms"); title.addStyleName("h1"); addComponent(title); final FormLayout form = new FormLayout(); form.setMargin(false); form.setWidth("800px"); form.addStyleName("light"); addComponent(form); Label section = new Label("Personal Info"); section.addStyleName("h2"); section.addStyleName("colored"); form.addComponent(section); StringGenerator sg = new StringGenerator(); TextField name = new TextField("Name"); name.setValue(sg.nextString(true) + " " + sg.nextString(true)); name.setWidth("50%"); form.addComponent(name); DateField birthday = new DateField("Birthday"); birthday.setValue(new Date(80, 0, 31)); form.addComponent(birthday); TextField username = new TextField("Username"); username.setValue(sg.nextString(false) + sg.nextString(false)); username.setRequired(true); form.addComponent(username); OptionGroup sex = new OptionGroup("Sex"); sex.addItem("Female"); sex.addItem("Male"); sex.select("Male"); sex.addStyleName("horizontal"); form.addComponent(sex); section = new Label("Contact Info"); section.addStyleName("h3"); section.addStyleName("colored"); form.addComponent(section); TextField email = new TextField("Email"); email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com"); email.setWidth("50%"); email.setRequired(true); form.addComponent(email); TextField location = new TextField("Location"); location.setValue(sg.nextString(true) + ", " + sg.nextString(true)); location.setWidth("50%"); location.setComponentError(new UserError("This address doesn't exist")); form.addComponent(location); TextField phone = new TextField("Phone"); phone.setWidth("50%"); form.addComponent(phone); HorizontalLayout wrap = new HorizontalLayout(); wrap.setSpacing(true); wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); wrap.setCaption("Newsletter"); CheckBox newsletter = new CheckBox("Subscribe to newsletter", true); wrap.addComponent(newsletter); ComboBox period = new ComboBox(); period.setTextInputAllowed(false); period.addItem("Daily"); period.addItem("Weekly"); period.addItem("Monthly"); period.setNullSelectionAllowed(false); period.select("Weekly"); period.addStyleName("small"); period.setWidth("10em"); wrap.addComponent(period); form.addComponent(wrap); section = new Label("Additional Info"); section.addStyleName("h4"); section.addStyleName("colored"); form.addComponent(section); TextField website = new TextField("Website"); website.setInputPrompt("http://"); website.setWidth("100%"); form.addComponent(website); TextArea shortbio = new TextArea("Short Bio"); shortbio.setValue( "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum."); shortbio.setWidth("100%"); shortbio.setRows(2); form.addComponent(shortbio); final RichTextArea bio = new RichTextArea("Bio"); bio.setWidth("100%"); bio.setValue( "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>"); form.addComponent(bio); form.setReadOnly(true); bio.setReadOnly(true); Button edit = new Button("Edit", new ClickListener() { @Override public void buttonClick(ClickEvent event) { boolean readOnly = form.isReadOnly(); if (readOnly) { bio.setReadOnly(false); form.setReadOnly(false); form.removeStyleName("light"); event.getButton().setCaption("Save"); event.getButton().addStyleName("primary"); } else { bio.setReadOnly(true); form.setReadOnly(true); form.addStyleName("light"); event.getButton().setCaption("Edit"); event.getButton().removeStyleName("primary"); } } }); HorizontalLayout footer = new HorizontalLayout(); footer.setMargin(new MarginInfo(true, false, true, false)); footer.setSpacing(true); footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); form.addComponent(footer); footer.addComponent(edit); Label lastModified = new Label("Last modified by you a minute ago"); lastModified.addStyleName("light"); footer.addComponent(lastModified); }
From source file:com.github.mjvesa.herd.wordset.VaadinWordSet.java
License:Apache License
@Override public Word[] getWords() { return new Word[] { new BaseWord("new-button", "", Word.POSTPONED) { private static final long serialVersionUID = -2492817908731559368L; @Override/*from ww w . j a va 2 s .com*/ public void execute(final Interpreter interpreter) { Button b = new Button("", new Button.ClickListener() { private static final long serialVersionUID = -4622489800920283752L; @Override public void buttonClick(ClickEvent event) { Button b = event.getButton(); Word command = (Word) b.getData(); if (command != null) { interpreter.execute(command); } } }); interpreter.pushData(b); } }, new BaseWord("set-click-listener", "", Word.POSTPONED) { private static final long serialVersionUID = 5749856686458297558L; @Override public void execute(Interpreter interpreter) { Object o = interpreter.popData(); Button b = (Button) interpreter.popData(); b.setData(o); interpreter.pushData(b); } }, new BaseWord("new-hl", "", Word.POSTPONED) { private static final long serialVersionUID = 8813556668649386248L; @Override public void execute(Interpreter interpreter) { HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); interpreter.pushData(hl); } }, new BaseWord("new-vl", "", Word.POSTPONED) { private static final long serialVersionUID = -1848213448504804229L; @Override public void execute(Interpreter interpreter) { VerticalLayout vl = new VerticalLayout(); vl.setSpacing(true); interpreter.pushData(vl); } }, new BaseWord("new-gl", "( x y - gl )", Word.POSTPONED) { private static final long serialVersionUID = 4079634885691605257L; @Override public void execute(Interpreter interpreter) { Integer height = (Integer) interpreter.popData(); Integer width = (Integer) interpreter.popData(); interpreter.pushData(new GridLayout(width, height)); } }, new BaseWord("gl-new-line", "", Word.POSTPONED) { private static final long serialVersionUID = 975877390052961807L; @Override public void execute(Interpreter interpreter) { ((GridLayout) interpreter.peekData()).newLine(); } }, new BaseWord("new-window", "", Word.POSTPONED) { private static final long serialVersionUID = -6887364362728545090L; @Override public void execute(Interpreter interpreter) { Window w = new Window(); VerticalLayout vl = new VerticalLayout(); vl.setSpacing(true); w.setContent(vl); interpreter.pushData(w); interpreter.pushData(vl); } }, new BaseWord("main-panel", "", Word.POSTPONED) { private static final long serialVersionUID = -8622281600566696475L; @Override public void execute(Interpreter interpreter) { interpreter.pushData(interpreter.getMainPanel()); } }, new BaseWord("add-window", "", Word.POSTPONED) { private static final long serialVersionUID = 7106029415576813922L; @Override public void execute(Interpreter interpreter) { Window w = (Window) interpreter.popData(); interpreter.getView().getUI().addWindow(w); } }, new BaseWord("add-component", "", Word.POSTPONED) { private static final long serialVersionUID = 5640824046985354091L; @Override public void execute(Interpreter interpreter) { Component comp = (Component) interpreter.popData(); ComponentContainer cc = (ComponentContainer) interpreter.popData(); cc.addComponent(comp); interpreter.pushData(cc); } }, new BaseWord("set-caption", "", Word.POSTPONED) { private static final long serialVersionUID = 5497598050469462487L; @Override public void execute(Interpreter interpreter) { String s = (String) interpreter.popData(); Component c = (Component) interpreter.popData(); c.setCaption(s); interpreter.pushData(c); } }, new BaseWord("set-value", "", Word.POSTPONED) { private static final long serialVersionUID = -1769743552659215058L; @Override public void execute(Interpreter interpreter) { Object o = interpreter.popData(); Property p = (Property) interpreter.popData(); p.setValue(o); interpreter.pushData(p); } }, new BaseWord("get-value", "", Word.POSTPONED) { private static final long serialVersionUID = 8445550546521886374L; @Override public void execute(Interpreter interpreter) { Field f = (Field) interpreter.popData(); interpreter.pushData(f); interpreter.pushData(f.getValue()); } }, new BaseWord("set-size-full", "", Word.POSTPONED) { private static final long serialVersionUID = -1206491811133054467L; @Override public void execute(Interpreter interpreter) { Component comp = (Component) interpreter.popData(); comp.setSizeFull(); interpreter.pushData(comp); } }, new BaseWord("set-size-undefined", "", Word.POSTPONED) { private static final long serialVersionUID = -3450618729379622987L; @Override public void execute(Interpreter interpreter) { Component comp = (Component) interpreter.popData(); comp.setSizeUndefined(); interpreter.pushData(comp); } }, new BaseWord("set-height", "", Word.POSTPONED) { private static final long serialVersionUID = -8426734568403715950L; @Override public void execute(Interpreter interpreter) { String str = (String) interpreter.popData(); Component comp = (Component) interpreter.popData(); comp.setHeight(str); interpreter.pushData(comp); } }, new BaseWord("set-width", "", Word.POSTPONED) { private static final long serialVersionUID = -4558264143049463814L; @Override public void execute(Interpreter interpreter) { String str = (String) interpreter.popData(); Component comp = (Component) interpreter.popData(); comp.setWidth(str); interpreter.pushData(comp); } }, new BaseWord("clear-container", "", Word.POSTPONED) { private static final long serialVersionUID = 1070175466682034329L; @Override public void execute(Interpreter interpreter) { ComponentContainer cc = (ComponentContainer) interpreter.popData(); cc.removeAllComponents(); } }, new BaseWord("new-check-box", "", Word.POSTPONED) { private static final long serialVersionUID = 4018632924389912599L; @Override public void execute(Interpreter interpreter) { interpreter.pushData(new CheckBox()); } }, new BaseWord("new-date-field", "", Word.POSTPONED) { private static final long serialVersionUID = 6313296566085274642L; @Override public void execute(final Interpreter interpreter) { interpreter.pushData(new DateField()); final String dfCommand = (String) interpreter.popData(); DateField df = new DateField(); df.setImmediate(true); df.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = 1472139878970514093L; public void valueChange(ValueChangeEvent event) { interpreter.pushData(event.getProperty().getValue()); interpreter.interpret(dfCommand); } }); interpreter.pushData(df); } }, new BaseWord("new-label", "", Word.POSTPONED) { private static final long serialVersionUID = -2825285195439247251L; @Override public void execute(Interpreter interpreter) { interpreter.pushData(new Label()); } }, new BaseWord("new-text-field", "", Word.POSTPONED) { private static final long serialVersionUID = -1064489458253275380L; @Override public void execute(final Interpreter interpreter) { final String tfCommand = interpreter.getNextNonNopWord(); TextField tf = new TextField(); tf.setCaption((String) interpreter.popData()); tf.setValue(""); tf.setImmediate(true); tf.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 4325104922208051065L; public void valueChange(ValueChangeEvent event) { interpreter.pushData(event.getProperty().getValue()); interpreter.interpret(tfCommand); } }); interpreter.pushData(tf); } }, new BaseWord("new-table", "", Word.POSTPONED) { private static final long serialVersionUID = -5052653341575232035L; @Override public void execute(final Interpreter interpreter) { final String tableCommand = interpreter.getParser().getNextWord(); Table table = new Table(); table.setCaption((String) interpreter.popData()); table.setImmediate(true); table.setSelectable(true); table.addItemClickListener(new ItemClickListener() { /** * */ private static final long serialVersionUID = 3585546076571010729L; public void itemClick(ItemClickEvent event) { interpreter.pushData(event.getItem()); interpreter.execute(interpreter.getDictionary().get(tableCommand)); } }); interpreter.pushData(table); } }, new BaseWord("new-combo-box", "", Word.POSTPONED) { private static final long serialVersionUID = 3881577354424928897L; @Override public void execute(final Interpreter interpreter) { final String newItemCommand = interpreter.getParser().getNextWord(); final String itemSelectedCommand = interpreter.getParser().getNextWord(); final ComboBox cb = new ComboBox(); String str = (String) interpreter.popData(); cb.setNullSelectionAllowed(false); cb.setCaption(str); cb.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM); cb.setNewItemsAllowed(true); cb.setNewItemHandler(new NewItemHandler() { /** * */ private static final long serialVersionUID = 3340658590351611289L; public void addNewItem(String newItemCaption) { cb.setImmediate(false); interpreter.pushData(newItemCaption); interpreter.interpret(newItemCommand); cb.setImmediate(true); } }); cb.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = 2706579869793251379L; public void valueChange(ValueChangeEvent event) { interpreter.pushData( cb.getContainerDataSource().getItem(event.getProperty().getValue())); interpreter.interpret(itemSelectedCommand); } }); cb.setImmediate(true); interpreter.pushData(cb); } }, new BaseWord("new-select", "", Word.POSTPONED) { private static final long serialVersionUID = -6142351970812196488L; @Override public void execute(final Interpreter interpreter) { final String selCommand = interpreter.getParser().getNextWord(); final ComboBox sel = new ComboBox(); sel.setCaption((String) interpreter.popData()); sel.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM); sel.setNullSelectionAllowed(false); sel.setImmediate(true); sel.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = -7705548618092166199L; public void valueChange(ValueChangeEvent event) { Item item = sel.getContainerDataSource().getItem(event.getProperty().getValue()); interpreter.pushData(item); interpreter.interpret(selCommand); } }); interpreter.pushData(sel); } }, new BaseWord("new-list-select", "", Word.POSTPONED) { private static final long serialVersionUID = 8686093227035249035L; @Override public void execute(final Interpreter interpreter) { final String lselCommand = interpreter.getParser().getNextWord(); final ListSelect lsel = new ListSelect(); lsel.setCaption((String) interpreter.popData()); lsel.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM); lsel.setNullSelectionAllowed(false); lsel.setImmediate(true); lsel.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = -5523488417834167806L; public void valueChange(ValueChangeEvent event) { Item item = lsel.getContainerDataSource().getItem(event.getProperty().getValue()); interpreter.pushData(item); interpreter.interpret(lselCommand); } }); interpreter.pushData(lsel); } }, new BaseWord("set-container-data-source", "", Word.POSTPONED) { private static final long serialVersionUID = 8644721936358613031L; @Override public void execute(Interpreter interpreter) { Container cont = (Container) interpreter.popData(); AbstractSelect as = (AbstractSelect) interpreter.popData(); as.setContainerDataSource(cont); interpreter.pushData(as); } }, new BaseWord("set-column-headers", "", Word.POSTPONED) { private static final long serialVersionUID = -7296881714369214846L; @Override public void execute(Interpreter interpreter) { Table table = (Table) interpreter.popData(); table.setColumnHeaders((String[]) getArrayFromList(interpreter, new String[0])); } }, new BaseWord("set-visible-columns", "", Word.POSTPONED) { private static final long serialVersionUID = 5674765074478598320L; @Override public void execute(Interpreter interpreter) { Table table = (Table) interpreter.popData(); table.setVisibleColumns((String[]) getArrayFromList(interpreter, new String[0])); } } }; }
From source file:com.github.wolfie.sessionguard.SessionguardApplication.java
License:Apache License
@Override public void init() { final VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setSpacing(true);//from www.j a va 2s.c o m final Window mainWindow = new Window("Sessionguard Application", mainLayout); final int sessionTimeout = ((WebApplicationContext) getContext()).getHttpSession().getMaxInactiveInterval() / 60; final Label label = new Label( "This application has a " + sessionTimeout + "-minute session, with a timeout warning of " + WARNING_PERIOD_MINS + " minutes session time left."); mainWindow.addComponent(label); setMainWindow(mainWindow); final SessionGuard sessionGuard = new SessionGuard(); sessionGuard.setTimeoutWarningPeriod(WARNING_PERIOD_MINS); mainWindow.addComponent(sessionGuard); mainWindow.addComponent(new Button("Switch to keepalive", new Button.ClickListener() { private static final long serialVersionUID = -4423285632350279761L; private boolean keepalive = false; public void buttonClick(final ClickEvent event) { keepalive = !keepalive; sessionGuard.setKeepalive(keepalive); event.getButton().setCaption(keepalive ? "Switch to timeout message" : "Switch to keepalive"); } })); final TextField warningXhtmlField = new TextField("Change warning XHTML"); warningXhtmlField.setWidth("100%"); warningXhtmlField.setValue(sessionGuard.getTimeoutWarningXHTML()); warningXhtmlField.setImmediate(true); warningXhtmlField.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -5236596836421389890L; public void valueChange(final ValueChangeEvent event) { sessionGuard.setTimeoutWarningXHTML((String) warningXhtmlField.getValue()); getMainWindow().showNotification("Warning string changed"); } }); mainWindow.addComponent(warningXhtmlField); }
From source file:com.jiangyifen.ec2.ui.mgr.outlinemanage.AddOutline.java
@Override public void valueChange(ValueChangeEvent event) { Property source = event.getProperty(); if (source == sipType) { TextField hostField = (TextField) form.getField("host"); if (hostField != null) { if (SipConfigType.gateway_outline.equals(sipType.getValue())) { hostField.setValue("dynamic"); } else { hostField.setValue(""); }/*www . jav a2 s . co m*/ } } else { this.center(); String typeValue = (String) settingType.getValue(); if ("advanced".equals(typeValue)) { this.setHeight("700px"); this.setWidth("395px"); // advanced? createAdvancedSipConfig(); } else { this.setWidth("360px"); this.setHeight("335px"); // ?? createTypicalSipConfig(); } } }