List of usage examples for com.vaadin.ui TextField getValue
@Override
public String getValue()
From source file:fi.vtt.RVaadin.RContainer.java
License:Apache License
/** * For general description, see//from ww w .j a v a2 s . com * {@link RContainer#getParameterLayout(String, String)}. * * @param caption * Parameter name * @param parName * The numeric vector name (of 1..N elements) in R * @param enabled * Is the field enabled by default? * @return orizontalLayout element with implicit ValueChangeListeners to * update R */ public HorizontalLayout getParameterLayout(String caption, final String parName, final boolean[] enabled) { /* The horizontal layout to place the parameters [p1, p2, p3,..., pN] */ final HorizontalLayout hl = new HorizontalLayout(); hl.setCaption(caption); hl.setSpacing(true); /* TextFields serve as the input field for the parameters */ final TextField[] pFields; /* Get the default values for the parameter vector */ double[] p = getDoubles(parName); /* * Show the parameter names in the TextField caption, in case that they * were defined in R */ boolean namedPars = false; String[] names = null; if (isTRUE("!is.null(names(" + parName + "))")) { namedPars = true; names = getStrings("names(" + parName + ")"); } if (p != null) { /* * Construct TextField(s) for the parameter vector and set the * initial values */ pFields = new TextField[p.length]; for (int i = 0; i < pFields.length; i++) { pFields[i] = new TextField(); pFields[i].setValue(Double.toString(p[i])); if (enabled != null) { pFields[i].setEnabled(enabled[i]); } /* * Nice default width for a numeric parameter field. This could * actually be a parameter for this call. */ pFields[i].setWidth("10ex"); pFields[i].setImmediate(true); /* * In case that the parameters are named, show the name before * the text field */ if (namedPars) { pFields[i].setCaption(names[i]); } hl.addComponent(pFields[i]); } /* * Set up a listener which can be attached to all the parameter * fields */ ValueChangeListener parChanged = new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { /* Get the Property which fired the listener */ TextField tf = ((TextField) event.getProperty()); /* Find the corresponding parameter index */ int idx; for (idx = 0; idx < pFields.length; idx++) { if (tf == pFields[idx]) { break; } } /* * Try to update the new value. If it is illegal (cannot be * cast to Double), then stick with the old value and * display it to the user to indicate erroneous input. */ double newValue; try { newValue = Double.valueOf(tf.getValue().toString()); /* * Submit the new value to R, remembering that the * indexing is off by one between Java and R */ eval(parName + "[" + (idx + 1) + "] <- " + newValue); } catch (Exception e) { /* * The parameter was illegal. Do nothing for R, and * display the old value to indicate that the new value * was not eligible. */ Double oldPar = getDouble(parName + "[" + (idx + 1) + "]"); tf.setValue(Double.toString(oldPar)); } } }; /* Attach this listener to all TextField items */ for (int i = 0; i < pFields.length; i++) { pFields[i].addValueChangeListener(parChanged); } } else { /* The original parameters were not readable as double[] */ hl.addComponent(new Label("Error reading the parameters")); hl.setEnabled(false); } return hl; }
From source file:fr.amapj.view.views.gestioncontratsignes.ReceptionChequeEditorPart.java
License:Open Source License
public boolean performSauvegarder() { for (int i = 0; i < paiements.size(); i++) { DatePaiementDTO paiement = paiements.get(i); Item item = t.getItem(i);/* w ww .j a v a 2 s . c o m*/ // case cocher CheckBox cb = (CheckBox) item.getItemProperty("box").getValue(); if (cb.getValue().booleanValue() == true) { paiement.etatPaiement = EtatPaiement.AMAP; } else { paiement.etatPaiement = EtatPaiement.A_FOURNIR; } // Commentaire 1 if (peConf.saisieCommentaire1 == ChoixOuiNon.OUI) { TextField tf = (TextField) item.getItemProperty("c1").getValue(); paiement.commentaire1 = tf.getValue(); } // Commentaire 2 if (peConf.saisieCommentaire2 == ChoixOuiNon.OUI) { TextField tf = (TextField) item.getItemProperty("c2").getValue(); paiement.commentaire2 = tf.getValue(); } } new MesPaiementsService().receptionCheque(paiements); return true; }
From source file:gov.va.ds4p.ds4pmobileportal.ui.LoginView.java
License:Open Source License
private Panel getLoginPanel() { Panel p = new Panel(); VerticalLayout v = (VerticalLayout) p.getContent(); v.setSpacing(true);//from w w w . ja v a 2 s . co m v.setHeight("300px"); Label sandi = new Label(""); sandi.setIcon(new ThemeResource("onc_s_and_i_logo.png")); v.addComponent(sandi); final TextField username = new TextField("User Name:"); final PasswordField userpass = new PasswordField("Password:"); username.setWidth("500px"); userpass.setWidth("500px"); v.addComponent(username); v.addComponent(userpass); HorizontalLayout h = new HorizontalLayout(); h.setSpacing(true); h.setWidth("500px"); Button okBTN = new Button("Ok"); Label l = new Label(""); l.setIcon(new ThemeResource("header-logo.png")); h.addComponent(okBTN); h.addComponent(l); v.addComponent(h); okBTN.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { userN = (String) username.getValue(); userP = (String) userpass.getValue(); authenticate(); if (userProfile == null) { getWindow().showNotification("Login Error", "Incorrect username or password combination.", Window.Notification.TYPE_WARNING_MESSAGE); } else { AdminContext.getSessionAttributes().setUserProfile(userProfile); ((MyVaadinApplication) getApplication()).loginComplete(); } } }); okBTN.setImmediate(true); return p; }
From source file:gov.va.ehtac.appsonfhir.ui.PatientSearch.java
public PatientSearch() { session = ((HealthElementsTouchKitUI) UI.getCurrent()).getSessionAttributes(); setCaption("Patient Search"); patientDisplayName = new Label(session.getPatientNameAgeGenderDisplay()); patientDisplayName.setImmediate(true); setRightComponent(patientDisplayName); final VerticalComponentGroup content = new VerticalComponentGroup(); final TextField nameField = new TextField("Enter all or part of Last Name"); nameField.setImmediate(true);/*from w w w .j a v a 2 s.c o m*/ content.addComponent(nameField); final Button submitButton = new Button("Search"); submitButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { lastName = nameField.getValue(); Popover popover = getPopoverResults(); popover.showRelativeTo(getNavigationBar()); } }); submitButton.setImmediate(true); setContent(new CssLayout(content, submitButton)); }
From source file:gui.views.LoginView.java
public void setUp() { // Ein Neuer Kommentar fr Git. this.setSizeFull(); final TextField userlogin = new TextField(); userlogin.setCaption("Username"); final PasswordField password = new PasswordField(); password.setCaption("Passwort"); VerticalLayout layout = new VerticalLayout(); layout.addComponent(userlogin);//from w w w. jav a2 s .com layout.addComponent(password); Panel panel = new Panel("BitteLogin-Daten eingeben"); this.addComponent(panel); this.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); panel.setContent(layout); Button buttonLogin = new Button("Login", FontAwesome.SEARCH); layout.addComponent(buttonLogin); layout.setComponentAlignment(buttonLogin, Alignment.MIDDLE_CENTER); panel.setSizeUndefined(); buttonLogin.addClickListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { String user = userlogin.getValue(); String pw = password.getValue(); LoginControl.controllogin(user, pw); } }); }
From source file:gui.views.MainView.java
public void setup() { final HorizontalLayout hlayout = new HorizontalLayout(); Button button = new Button("Suche"); Button bookingbutton = new Button("Buchen"); final TextField textfield = new TextField(); User user = (User) UI.getCurrent().getSession().getAttribute("Lars"); Button logout = new Button("Logout: " + user.getname()); Label label = new Label(user.getname() + "Bitte Ort eingeben"); hlayout.addComponent(label);/* w w w. j av a2s . c o m*/ hlayout.addComponent(textfield); hlayout.addComponent(button); hlayout.addComponent(bookingbutton); hlayout.addComponent(logout); this.addComponent(hlayout); this.setComponentAlignment(hlayout, Alignment.MIDDLE_CENTER); final BeanContainer<Integer, Hotel> data = new BeanContainer<Integer, Hotel>(Hotel.class); data.setBeanIdProperty("id"); final Table table = new Table("Treffer", data); table.setSizeFull(); table.setSelectable(true); bookingbutton.addClickListener(new ClickListener() { // Interface wird instanziiert durch AnonymeKlasse @Override public void buttonClick(ClickEvent event) { if (hotelselektiert == null) { Notification.show("Kein Hotel ausgew\u00e4hlt ", Notification.Type.WARNING_MESSAGE); } else { Notification.show("Hotel " + hotelselektiert.getname() + " wurde zur Buchung ausgew\u00e4hlt"); } } }); table.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { BeanItem<Hotel> result = data.getItem(event.getItemId()); hotelselektiert = result.getBean(); } }); button.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { String ort = textfield.getValue(); table.removeAllItems(); anzahlsuche++; table.setCaption("Treffer f\u00fcr " + ort + " (Anzahl der Suche " + anzahlsuche + ")"); if (ort.equals("")) { Notification.show("Sie haben keinen Ort angegeben", Notification.Type.WARNING_MESSAGE); } else { addComponent(table); List<Hotel> liste = HotelSearch.getinstance().getHotelsbyort(ort); data.addAll(liste); } } }); logout.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { LoginControl.logoutuser(); } }); }
From source file:info.magnolia.configuration.app.problem.toolbar.ProblemToolbarViewImpl.java
License:Open Source License
private TextField buildSearchField() { final TextField field = new TextField(); ShortcutProtector.extend(field, Arrays.asList(ShortcutAction.KeyCode.ENTER)); final String inputPrompt = i18n.translate("toolbar.search.prompt"); field.setInputPrompt(inputPrompt);// ww w . ja v a2 s . co m field.setSizeUndefined(); field.addStyleName("searchfield"); // TextField has to be immediate to fire value changes when pressing Enter, avoiding ShortcutListener overkill. field.setImmediate(true); field.addValueChangeListener(searchFieldListener); field.addFocusListener(new FieldEvents.FocusListener() { @Override public void focus(FieldEvents.FocusEvent event) { // put the cursor at the end of the field TextField tf = (TextField) event.getSource(); tf.setCursorPosition(tf.getValue().length()); } }); // No blur handler. return field; }
From source file:info.magnolia.security.app.dialog.field.WorkspaceAccessFieldFactory.java
License:Open Source License
protected void openChooseDialog(final TextField textField) { final ConfiguredChooseDialogDefinition def = new ConfiguredChooseDialogDefinition(); final ConfiguredJcrContentConnectorDefinition contentConnectorDefinition = new ConfiguredJcrContentConnectorDefinition(); contentConnectorDefinition.setWorkspace(getFieldDefinition().getWorkspace()); contentConnectorDefinition.setRootPath("/"); contentConnectorDefinition.setDefaultOrder(ModelConstants.JCR_NAME); // node types contentConnectorDefinition.setNodeTypes(resolveNodeTypes()); def.setContentConnector(contentConnectorDefinition); final WorkbenchDefinition wbDef = resolveWorkbenchDefinition(); final WorkbenchFieldDefinition fieldDef = new WorkbenchFieldDefinition(); fieldDef.setWorkbench(wbDef);/*w w w .j a v a2s . c o m*/ def.setField(fieldDef); // create chooseDialogComponentProvider and get new instance of presenter from there ComponentProvider chooseDialogComponentProvider = ChooseDialogComponentProviderUtil .createChooseDialogComponentProvider(def, componentProvider); workbenchChooseDialogPresenter = chooseDialogComponentProvider.newInstance(def.getPresenterClass(), chooseDialogComponentProvider); // Define selected ItemId ChooseDialogView chooseDialogView = workbenchChooseDialogPresenter.start(new ChooseDialogCallback() { @Override public void onItemChosen(String actionName, Object value) { try { if (value instanceof JcrItemId) { JcrItemId jcrItemId = (JcrItemId) value; textField.setValue(JcrItemUtil.getJcrItem(jcrItemId).getPath()); } else { textField.setValue("/"); } } catch (RepositoryException e) { log.error("Failed to read chosen node", e); } } @Override public void onCancel() { } }, def, uiContext, textField.getValue()); chooseDialogView.setCaption(StringUtils.capitalize(getFieldDefinition().getWorkspace())); }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * are el dilogo para autenticarse/*from w w w.j a va2 s . c o m*/ */ private void openLoginDialog(boolean gohome) { // Create a sub-window and set the content Window subWindow = new Window("Login"); subWindow.setWidth("375px"); FormLayout f = new FormLayout(); f.setMargin(true); TextField l; f.addComponent(l = new TextField("Username")); PasswordField p; f.addComponent(p = new PasswordField("Password")); Label e; f.addComponent(e = new Label()); VerticalLayout v = new VerticalLayout(); v.addComponent(f); HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); Label footerText = new Label(""); footerText.setSizeUndefined(); Button forgot = new Button("Forgot password", new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { e.setValue("Asking for email..."); io.mateu.ui.core.client.app.MateuUI.getBaseService().forgotPassword(l.getValue(), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage()); } @Override public void onSuccess(Void result) { e.setValue("Email sent. Please check your inbox"); } }); } }); //forgot.addStyleName(ValoTheme.BUTTON_); Button ok = new Button("Login", new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { e.setValue("Authenticating..."); io.mateu.ui.core.client.app.MateuUI.getBaseService().authenticate(l.getValue(), p.getValue(), new AsyncCallback<UserData>() { @Override public void onFailure(Throwable caught) { e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage()); } @Override public void onSuccess(UserData result) { e.setValue("OK!"); getApp().setUserData(result); VaadinSession.getCurrent().setAttribute("usuario", "admin"); subWindow.close(); if (MateuUI.getApp().isFavouritesAvailable()) linkFavoritos.setVisible(true); if (MateuUI.getApp().isLastEditedAvailable()) linkUltimosRegistros.setVisible(true); if (MateuUI.getApp().isFavouritesAvailable()) linkNuevoFavorito.setVisible(true); refreshSettings(); refreshMenu(null, null); System.out.println("STATE:" + navigator.getState()); System.out.println("URIFRAGMENT:" + Page.getCurrent().getUriFragment()); navigator.navigateTo((gohome) ? "" : navigator.getState()); } }); } }); ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER); Button cancel = new Button("Cancel"); footer.addComponents(footerText, forgot, ok); //, cancel); footer.setExpandRatio(footerText, 1); v.addComponent(footer); subWindow.setContent(v); // Center it in the browser window subWindow.center(); subWindow.setModal(true); // Open it in the UI UI.getCurrent().addWindow(subWindow); l.focus(); }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * abre el dilogo para editar el perfil/*from w w w .j ava 2s.co m*/ * */ private void editProfile() { // Create a sub-window and set the content Window subWindow = new Window("My profile"); subWindow.setWidth("375px"); FormLayout f = new FormLayout(); f.setMargin(true); TextField l; f.addComponent(l = new TextField("Name")); l.setValue(getApp().getUserData().getName()); TextField p; f.addComponent(p = new TextField("Email")); p.setValue(getApp().getUserData().getEmail()); Label e; f.addComponent(e = new Label()); VerticalLayout v = new VerticalLayout(); v.addComponent(f); HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); Label footerText = new Label(""); footerText.setSizeUndefined(); Button ok = new Button("Update it!", new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { e.setValue("Authenticating..."); io.mateu.ui.core.client.app.MateuUI.getBaseService().updateProfile( getApp().getUserData().getLogin(), l.getValue(), p.getValue(), null, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage()); } @Override public void onSuccess(Void result) { e.setValue("OK!"); getApp().getUserData().setName(l.getValue()); getApp().getUserData().setEmail(p.getValue()); subWindow.close(); refreshSettings(); } }); } }); ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER); Button cancel = new Button("Cancel"); footer.addComponents(footerText, ok); //, cancel); footer.setExpandRatio(footerText, 1); v.addComponent(footer); subWindow.setContent(v); // Center it in the browser window subWindow.center(); subWindow.setModal(true); // Open it in the UI UI.getCurrent().addWindow(subWindow); l.focus(); }