List of usage examples for com.vaadin.ui TextField getValue
@Override
public String getValue()
From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.TemplateComponent.java
License:Apache License
private void init() { tree = new Tree(); tree.addItem(getTemplate());//from w w w .j av a2s . c o m tree.setItemIcon(getTemplate(), VaadinIcons.FILE_TREE); tree.setItemCaption(getTemplate(), getTemplate().getTemplateName()); if (getTemplate().getTemplateNodeList() != null) { getTemplate().getTemplateNodeList().forEach(node -> { if (node.getTemplateNode() == null) { //Only root folders addTemplateNode(node); } }); } //Select item on right click as well tree.addItemClickListener((ItemClickEvent event) -> { if (event.getSource() == tree && event.getButton() == MouseEventDetails.MouseButton.RIGHT) { if (event.getItem() != null) { Item clicked = event.getItem(); tree.select(event.getItemId()); } } }); //Add context menu ContextMenu menu = new ContextMenu(tree, true); if (edit) { tree.addItemClickListener((ItemClickEvent event) -> { if (event.getButton() == MouseEventDetails.MouseButton.RIGHT) { menu.removeItems(); if (tree.getValue() != null) { if (tree.getValue() instanceof Template) { Template t = (Template) tree.getValue(); if (t.getId() < 1_000) { return; } } MenuItem create = menu.addItem(TRANSLATOR.translate("general.add.child"), PROJECT_ICON, (MenuItem selectedItem) -> { displayChildCreationWizard(); }); MenuItem delete = menu.addItem(TRANSLATOR.translate("general.delete"), PROJECT_ICON, (MenuItem selectedItem) -> { displayChildDeletionWizard(); }); //Don't allow to delete the root node. delete.setEnabled(!tree.isRoot(tree.getValue())); } } }); } TextField nameField = new TextField(TRANSLATOR.translate("general.name")); VerticalLayout vl = new VerticalLayout(); BeanFieldGroup binder = new BeanFieldGroup(getTemplate().getClass()); binder.setItemDataSource(getTemplate()); binder.bind(nameField, "templateName"); nameField.addValueChangeListener(listener -> { getTemplate().setTemplateName(nameField.getValue()); }); nameField.setNullRepresentation(""); ComboBox type = new ComboBox(TRANSLATOR.translate("general.type")); BeanItemContainer<ProjectType> container = new BeanItemContainer<>(ProjectType.class, new ProjectTypeJpaController(DataBaseManager.getEntityManagerFactory()).findProjectTypeEntities()); type.setContainerDataSource(container); for (Object o : type.getItemIds()) { ProjectType id = ((ProjectType) o); type.setItemCaption(id, TRANSLATOR.translate(id.getTypeName())); } type.addValueChangeListener(listener -> { if (type.getValue() != null) { getTemplate().setProjectTypeId((ProjectType) type.getValue()); } }); binder.bind(type, "projectTypeId"); vl.addComponent(nameField); vl.addComponent(type); if (template.getId() != null) { vl.addComponent(tree); } binder.setReadOnly(!edit); setContent(vl); }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.workflow.WorkflowViewer.java
License:Apache License
private Component getControls() { VerticalLayout controls = new VerticalLayout(); Button addStep = new Button(TRANSLATOR.translate("general.add.step")); VerticalLayout vl = new VerticalLayout(); TextField name = new TextField(TRANSLATOR.translate("general.name")); vl.addComponent(name);/*from w w w .j a va 2s . c om*/ addStep.addClickListener(listener -> { MessageBox prompt = MessageBox.createQuestion().withCaption(TRANSLATOR.translate("general.add.step")) .withMessage(vl).withYesButton(() -> { if (name.getValue() != null && !name.getValue().isEmpty()) { Graph.Node node = new Graph.Node(TRANSLATOR.translate(name.getValue())); nodes.put(--count, node); node.setParam(KEY, "" + count); node.setParam(ITEM_NAME, TRANSLATOR.translate(name.getValue())); added.add(node); refreshWorkflow(); } }, ButtonOption.focus(), ButtonOption.icon(VaadinIcons.CHECK)) .withNoButton(ButtonOption.icon(VaadinIcons.CLOSE)); prompt.getWindow().setIcon(ValidationManagerUI.SMALL_APP_ICON); prompt.open(); }); addStep.setWidth(100, Unit.PERCENTAGE); addStep.setEnabled(workflows.getValue() != null); controls.addComponent(addStep); Button addTransition = new Button(TRANSLATOR.translate("general.add.transition")); VerticalLayout vl2 = new VerticalLayout(); TextField transitionName = new TextField(TRANSLATOR.translate("general.name")); ListSelect nodeList = new ListSelect(TRANSLATOR.translate("general.step")); BeanItemContainer<Graph.Node> container = new BeanItemContainer<>(Graph.Node.class, nodes.values()); nodeList.setContainerDataSource(container); nodeList.getItemIds().forEach(id -> { Graph.Node temp = ((Graph.Node) id); nodeList.setItemCaption(id, temp.getId()); }); nodeList.setNullSelectionAllowed(false); vl2.addComponent(transitionName); vl2.addComponent(nodeList); addTransition.addClickListener(listener -> { MessageBox prompt = MessageBox.createQuestion() .withCaption(TRANSLATOR.translate("general.add.transition")).withMessage(vl2) .withYesButton(() -> { if (transitionName.getValue() != null && !transitionName.getValue().isEmpty() && selected instanceof Subgraph.Node) { Subgraph.Edge edge = new Subgraph.Edge(); edge.setDest((Subgraph.Node) nodeList.getValue()); edges.put(transitionName.getValue(), new AbstractMap.SimpleEntry<>((Subgraph.Node) selected, edge)); edge.setParam(KEY, "" + --count); added.add(edge); refreshWorkflow(); } }, ButtonOption.focus(), ButtonOption.icon(VaadinIcons.CHECK)) .withNoButton(ButtonOption.icon(VaadinIcons.CLOSE)); prompt.getWindow().setIcon(ValidationManagerUI.SMALL_APP_ICON); prompt.open(); }); addTransition.setWidth(100, Unit.PERCENTAGE); addTransition.setEnabled(selected instanceof Subgraph.Node); controls.addComponent(addTransition); Button delete = new Button(TRANSLATOR.translate("general.delete")); delete.setEnabled(selected != null); delete.setWidth(100, Unit.PERCENTAGE); delete.addClickListener(listener -> { MessageBox prompt = MessageBox.createQuestion().withCaption(TRANSLATOR.translate("general.delete")) .withMessage(TRANSLATOR.translate("general.delete.confirmation")).withYesButton(() -> { if (selected instanceof Subgraph.Edge) { Subgraph.Edge edge = (Subgraph.Edge) selected; edges.remove(edge.getParam("label")); addToDelete(edge); } else { Graph.Node node = (Graph.Node) selected; addToDelete(node); } refreshWorkflow(); }, ButtonOption.focus(), ButtonOption.icon(VaadinIcons.CHECK)) .withNoButton(ButtonOption.icon(VaadinIcons.CLOSE)); prompt.getWindow().setIcon(ValidationManagerUI.SMALL_APP_ICON); prompt.open(); }); controls.addComponent(delete); Button rename = new Button(TRANSLATOR.translate("general.rename")); rename.setWidth(100, Unit.PERCENTAGE); rename.setEnabled(selected != null); rename.addClickListener(listener -> { Window w = new VMWindow(TRANSLATOR.translate("general.rename")); w.setWidth(25, Unit.PERCENTAGE); w.setHeight(25, Unit.PERCENTAGE); UI.getCurrent().addWindow(w); }); controls.addComponent(rename); Button save = new Button(TRANSLATOR.translate("general.save")); save.setWidth(100, Unit.PERCENTAGE); save.setEnabled(!added.isEmpty() || !deleted.isEmpty()); save.addClickListener(listener -> { List<Graph.Node> nodesToAdd = new ArrayList<>(); List<Subgraph.Edge> edgesToAdd = new ArrayList<>(); WorkflowServer ws = new WorkflowServer(((Workflow) workflows.getValue()).getId()); added.forEach(a -> { if (a instanceof Graph.Node) { nodesToAdd.add((Graph.Node) a); } else if (a instanceof Subgraph.Edge) { edgesToAdd.add((Subgraph.Edge) a); } }); deleted.forEach(a -> { LOG.log(Level.INFO, "Deleted: {0}", a); }); nodesToAdd.forEach(node -> { try { ws.addStep(node.getParam(ITEM_NAME)); } catch (VMException ex) { LOG.log(Level.SEVERE, ex.getLocalizedMessage(), ex); } }); displayWorkflow(ws.getEntity()); }); controls.addComponent(save); Button cancel = new Button(TRANSLATOR.translate("general.cancel")); cancel.setWidth(100, Unit.PERCENTAGE); cancel.setEnabled(selected != null); cancel.addClickListener(listener -> { Workflow w = (Workflow) workflows.getValue(); if (w != null) { displayWorkflow(w); } deleted.clear(); added.clear(); }); controls.addComponent(cancel); return controls; }
From source file:nl.amc.biolab.nsg.display.component.LoginUI.java
License:Open Source License
public LoginUI(final MainControl mainControl) { setWidth("100%"); setHeight("300px"); layout.setWidth("100%"); layout.setHeight("300px"); layout.addComponent(form);//from w ww .j av a 2 s. c o m setCompositionRoot(layout); final TextField name = new TextField("Please enter your XNAT username"); final PasswordField xnatPassword = new PasswordField("Please enter your XNAT password"); xnatPassword.setRequired(true); form.addField("xnatUsername", name); form.addField("xnatPassword", xnatPassword); final Button okButton = new Button("ok"); okButton.setClickShortcut(KeyCode.ENTER); okButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = -6535226372165482804L; public void buttonClick(ClickEvent event) { User user = null; user = login((String) name.getValue(), (String) xnatPassword.getValue()); xnatPassword.setValue(""); if (user == null) { return; } okButton.setData(user); mainControl.init(user); app.getMainWindow().executeJavaScript("window.location.reload();"); } }); form.getFooter().addComponent(okButton); }
From source file:nl.amc.biolab.nsg.display.component.ProcessingStatusForm.java
License:Open Source License
private void createSubmissionButtons(final VaadinTestApplication app, final SubmissionIO submissionIO, final nl.amc.biolab.datamodel.objects.Error error) { final Link statusLink = new Link("download", new StreamResource(new StreamSource() { private static final long serialVersionUID = 2010850543250392280L; public InputStream getStream() { String status;/*from w ww . j ava2 s .c o m*/ if (error != null) { status = error.getCode() + "\n" + error.getMessage() + "\n" + error.getDescription(); } else { status = "No message"; } return new ByteArrayInputStream(status.getBytes()); } }, "status", getApplication()), "", 400, 300, 2); viewStatusButton = new NativeButton("Details"); viewStatusButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = -8337533736203519683L; @Override public void buttonClick(ClickEvent event) { app.getMainWindow().addWindow(new Window() { private static final long serialVersionUID = 1520192489661790818L; { center(); setWidth("700px"); setHeight("500px"); VerticalLayout vl = new VerticalLayout(); vl.addComponent(statusLink); String status; if (error != null) { status = error.getCode() + "\n" + error.getMessage() + "\n" + error.getDescription(); } else { status = "No message"; } //status += "<img src=\"images/prov.png\""; vl.addComponent(new Label(status, Label.CONTENT_PREFORMATTED)); addComponent(vl); } }); } }); resubmitButton = new NativeButton("Resume"); resubmitButton.setData(processingStatusForm); resubmitButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = -6410875548044234734L; @Override public void buttonClick(ClickEvent event) { long dbId = processingStatus.getProcessing().getDbId(); long liferayID = app.getLiferayId(processingStatus.getProcessing().getUser().getLiferayID()); processingService.resubmit(dbId, submissionIO.getSubmission().getDbId(), userDataService.getUserId(), liferayID); processingStatusForm.attach(); } }); markFailButton = new NativeButton("Abort"); markFailButton.setData(processingStatusForm); markFailButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = -5019762936706219454L; @Override public void buttonClick(ClickEvent event) { app.getMainWindow().addWindow(new Window() { private static final long serialVersionUID = 3852384470521127702L; { final Window window = this; center(); setWidth("500px"); setHeight("300px"); VerticalLayout vl = new VerticalLayout(); final TextField text = new TextField("Remarks to the user"); text.setWidth("97%"); text.setHeight("150px"); vl.addComponent(text); final Button okButton = new NativeButton(); okButton.setCaption("Save"); okButton.setImmediate(true); okButton.setWidth("-1px"); okButton.setHeight("-1px"); okButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = 1754437322024958253L; public void buttonClick(ClickEvent event) { long dbId = processingStatus.getProcessing().getDbId(); long userID = processingStatus.getProcessing().getUser().getDbId(); long liferayID = app .getLiferayId(processingStatus.getProcessing().getUser().getLiferayID()); processingService.markFailed(submissionIO.getSubmission().getDbId(), (String) text.getValue()); processingStatus = processingService.getProcessingStatus( userDataService.getProcessing(dbId), userID, liferayID, false); refreshButton.setData(processingStatus); processingStatusForm.fireValueChange(false);//fireEvent(new Event(refreshButton)); window.getParent().removeWindow(window); } }); vl.addComponent(okButton); addComponent(vl); } }); } }); // } remarksButton = new NativeButton("Why?"); remarksButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = -267778012100029422L; @Override public void buttonClick(ClickEvent event) { app.getMainWindow().addWindow(new Window() { private static final long serialVersionUID = -5026454769214596711L; { List<nl.amc.biolab.datamodel.objects.Error> temp = submissionIO.getSubmission().getErrors(); center(); setWidth("700px"); setHeight("500px"); VerticalLayout vl = new VerticalLayout(); vl.addComponent( new Label(temp.get(temp.size() - 1).getMessage(), Label.CONTENT_PREFORMATTED)); addComponent(vl); } }); } }); }
From source file:nl.kpmg.lcm.ui.view.administration.components.AuthorizedLcmCreateWindow.java
License:Apache License
private void validateText(TextField field, nl.kpmg.lcm.common.validation.Notification notification) { if (field.getValue().isEmpty()) { notification.addError(field.getCaption() + " can not be empty"); }/*from w ww .j av a 2 s . c o m*/ if (field.getValue().indexOf(' ') != -1) { notification.addError(field.getCaption() + " can not contain spaces!"); } if (field.getValue().length() > MAX_LENGTH) { notification.addError(field.getCaption() + " is too long! Max length : " + MAX_LENGTH); } }
From source file:nl.kpmg.lcm.ui.view.administration.components.RemoteLcmCreateWindow.java
License:Apache License
private void validateField(TextField field, nl.kpmg.lcm.common.validation.Notification notification) { if (field.getValue().isEmpty()) { notification.addError(field.getCaption() + " can not be empty"); }//w w w. ja v a2 s.co m if (field.getValue().indexOf(' ') != -1) { notification.addError(field.getCaption() + " can not contain spaces!"); } if (field.getValue().length() > MAX_LENGTH) { notification.addError(field.getCaption() + " is too long! Max length : " + MAX_LENGTH); } }
From source file:no.uib.probe.csf.pr.touch.view.core.SearchingField.java
/** * Default constructor to initialize the main attributes. *//* www .ja va 2 s . c o m*/ public SearchingField() { this.setSpacing(true); this.setHeightUndefined(); HorizontalLayout searchFieldContainerLayout = new HorizontalLayout(); searchFieldContainerLayout.setWidthUndefined(); searchFieldContainerLayout.setHeight(100, Unit.PERCENTAGE); searchFieldContainerLayout.setSpacing(true); TextField searchField = new TextField(); searchField.setDescription("Search proteins by name or accession"); searchField.setImmediate(true); searchField.setWidth(100, Unit.PIXELS); searchField.setHeight(18, Unit.PIXELS); searchField.setInputPrompt("Search..."); searchFieldContainerLayout.addComponent(searchField); searchField.setTextChangeTimeout(1500); searchField.setStyleName(ValoTheme.TEXTFIELD_SMALL); searchField.addStyleName(ValoTheme.TEXTFIELD_TINY); final Button b = new Button(); searchField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.LAZY); searchField.addShortcutListener(new Button.ClickShortcut(b, ShortcutListener.KeyCode.ENTER)); VerticalLayout searchingBtn = new VerticalLayout(); searchingBtn.setWidth(22, Unit.PIXELS); searchingBtn.setHeight(18, Unit.PIXELS); searchingBtn.setStyleName("tablesearchingbtn"); searchFieldContainerLayout.addComponent(searchingBtn); searchFieldContainerLayout.setComponentAlignment(searchingBtn, Alignment.TOP_CENTER); this.addComponent(searchFieldContainerLayout); this.setComponentAlignment(searchFieldContainerLayout, Alignment.TOP_CENTER); searchingCommentLabel = new Label(); searchingCommentLabel.setWidth(100, Unit.PERCENTAGE); searchingCommentLabel.setHeight(23, Unit.PIXELS); searchingCommentLabel.addStyleName(ValoTheme.LABEL_BOLD); searchingCommentLabel.addStyleName(ValoTheme.LABEL_SMALL); searchingCommentLabel.addStyleName(ValoTheme.LABEL_TINY); this.addComponent(searchingCommentLabel); this.setComponentAlignment(searchingCommentLabel, Alignment.TOP_CENTER); searchingBtn.addLayoutClickListener((LayoutEvents.LayoutClickEvent event) -> { b.click(); }); searchField.addTextChangeListener((FieldEvents.TextChangeEvent event) -> { SearchingField.this.textChanged(event.getText()); }); b.addClickListener((Button.ClickEvent event) -> { SearchingField.this.textChanged(searchField.getValue()); }); }
From source file:nz.co.senanque.vaadinsupport.viewmanager.TouchLoginForm.java
License:Apache License
public void afterPropertiesSet() throws Exception { MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(m_messageSource); usernameCaption = messageSourceAccessor.getMessage("username"); passwordCaption = messageSourceAccessor.getMessage("password"); submitCaption = messageSourceAccessor.getMessage("login.button"); welcomeCaption = messageSourceAccessor.getMessage("welcome"); final TextField userName = new TextField(usernameCaption); userName.setImmediate(true);//from w w w . jav a 2 s . c om addField("userName", userName); final PasswordField password = new PasswordField(passwordCaption); password.setImmediate(true); addField("password", password); Button submit = new Button(submitCaption); addField("submit", submit); submit.addListener(new ClickListener() { private static final long serialVersionUID = 5201900702970450254L; public void buttonClick(ClickEvent event) { Map<String, String> map = new HashMap<String, String>(); map.put("user", String.valueOf(userName.getValue())); map.put("password", String.valueOf(password.getValue())); if (getLoginListener() != null) { try { getLoginListener().onLogin(map); } catch (Exception e) { Throwable cause = e.getCause(); if (cause == null || !(cause instanceof LoginException)) { logger.error(e.getMessage(), e); } MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(m_messageSource); String message = messageSourceAccessor.getMessage("Bad.Login", "Bad Login"); TouchKitApplication.get().getMainWindow().showNotification(message, Notification.TYPE_ERROR_MESSAGE); return; } } TouchKitApplication.get().setUser(userName.getValue()); } }); }
From source file:org.activiti.explorer.ui.profile.AccountSelectionPopup.java
License:Apache License
protected void initImapComponent() { imapForm = new Form(); imapForm.setDescription(i18nManager.getMessage(Messages.IMAP_DESCRIPTION)); final TextField imapServer = new TextField(i18nManager.getMessage(Messages.IMAP_SERVER)); imapForm.getLayout().addComponent(imapServer); final TextField imapPort = new TextField(i18nManager.getMessage(Messages.IMAP_PORT)); imapPort.setWidth(30, UNITS_PIXELS); imapPort.setValue(143); // Default imap port (non-ssl) imapForm.getLayout().addComponent(imapPort); final CheckBox useSSL = new CheckBox(i18nManager.getMessage(Messages.IMAP_SSL)); useSSL.setValue(false);/* w w w. jav a 2 s .c o m*/ useSSL.setImmediate(true); imapForm.getLayout().addComponent(useSSL); useSSL.addListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { imapPort.setValue(((Boolean) useSSL.getValue()) ? 993 : 143); } }); final TextField imapUserName = new TextField(i18nManager.getMessage(Messages.IMAP_USERNAME)); imapForm.getLayout().addComponent(imapUserName); final PasswordField imapPassword = new PasswordField(i18nManager.getMessage(Messages.IMAP_PASSWORD)); imapForm.getLayout().addComponent(imapPassword); // Matching listener imapClickListener = new ClickListener() { public void buttonClick(ClickEvent event) { Map<String, Object> accountDetails = createAccountDetails("imap", imapUserName.getValue().toString(), imapPassword.getValue().toString(), "server", imapServer.getValue().toString(), "port", imapPort.getValue().toString(), "ssl", imapPort.getValue().toString()); fireEvent(new SubmitEvent(AccountSelectionPopup.this, SubmitEvent.SUBMITTED, accountDetails)); } }; }
From source file:org.activiti.explorer.ui.profile.AccountSelectionPopup.java
License:Apache License
protected void initAlfrescoComponent() { alfrescoForm = new Form(); alfrescoForm.setDescription(i18nManager.getMessage(Messages.ALFRESCO_DESCRIPTION)); final TextField alfrescoServer = new TextField(i18nManager.getMessage(Messages.ALFRESCO_SERVER)); alfrescoForm.getLayout().addComponent(alfrescoServer); final TextField alfrescoUserName = new TextField(i18nManager.getMessage(Messages.ALFRESCO_USERNAME)); alfrescoForm.getLayout().addComponent(alfrescoUserName); final PasswordField alfrescoPassword = new PasswordField( i18nManager.getMessage(Messages.ALFRESCO_PASSWORD)); alfrescoForm.getLayout().addComponent(alfrescoPassword); // Matching listener alfrescoClickListener = new ClickListener() { public void buttonClick(ClickEvent event) { Map<String, Object> accountDetails = createAccountDetails("alfresco", alfrescoUserName.getValue().toString(), alfrescoPassword.getValue().toString(), "server", alfrescoServer.getValue().toString()); fireEvent(new SubmitEvent(AccountSelectionPopup.this, SubmitEvent.SUBMITTED, accountDetails)); }//from w ww .j av a 2 s . c o m }; }