List of usage examples for com.vaadin.ui TextField getValue
@Override
public String getValue()
From source file:tad.grupo7.ccamistadeslargas.EventosLayout.java
/** * Se muestra el formulario de aadir un nuevo evento. *//* w ww . j a va 2 s . co m*/ private void mostrarFormularioAddEvento() { //T?TULO CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Aadir Evento"); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO TextField nombre = new TextField("Nombre"); nombre.setRequired(true); ComboBox divisa = new ComboBox("Divisa"); divisa.setRequired(true); divisa.addItem(""); divisa.addItem("$"); final Button add = new Button("Crear evento"); add.addStyleName(ValoTheme.BUTTON_PRIMARY); add.setClickShortcut(ShortcutAction.KeyCode.ENTER); FormLayout form = new FormLayout(nombre, divisa, add); //BOTN PARA AADIR EVENTO add.addClickListener(clickEvent -> { try { nombre.validate(); divisa.validate(); if (EventoDAO.readDBObject(nombre.getValue(), usuario.getId()) == null) { EventoDAO.create(nombre.getValue(), divisa.getValue().toString(), usuario); mostrarEventos(); } else { Notification n = new Notification("Ya existe un evento con ese nombre", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Error con los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } }); //AADIMOS COMPONENTES form.setMargin(true); setSecondComponent(form); }
From source file:tad.grupo7.ccamistadeslargas.EventosLayout.java
/** * Muestra el formulario para aadir un gasto al evento. * * @param e Evento al que aadir el gasto. *//*from w ww . j a v a 2s. c o m*/ private void mostrarFormularioAddGasto(Evento e) { //T?TULO CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Aadir Gasto"); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO TextField titulo = new TextField("Ttulo"); titulo.setRequired(true); TextField precio = new TextField("Precio"); precio.setRequired(true); List<Participante> participantes = ParticipanteDAO.readAllFromEvento(e.getId()); ComboBox pagador = new ComboBox("Pagador"); List<Participante> deudores = new ArrayList<>(); Label d = new Label("Deudores"); FormLayout form = new FormLayout(l, titulo, precio, pagador, d); for (Participante p : participantes) { pagador.addItem(p.getNombre()); CheckBox c = new CheckBox(p.getNombre()); c.addValueChangeListener(evento -> { deudores.add(p); }); form.addComponent(c); } final Button add = new Button("Aadir Gasto"); add.addStyleName(ValoTheme.BUTTON_PRIMARY); add.setClickShortcut(ShortcutAction.KeyCode.ENTER); //SI SE CLICA EN AADIR PAGO SE CREA EL PAGO A LA VEZ QUE SE CIERRA LA VENTANA add.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { titulo.validate(); precio.validate(); pagador.validate(); GastoDAO.create(titulo.getValue(), Double.valueOf(precio.getValue()), e.getId(), ParticipanteDAO.read(pagador.getValue().toString(), usuario.getId()).getId(), deudores); mostrarEvento(e); } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Rellena todos los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } }); //AADIMOS LOS COMPONENTES form.addComponent(add); setSecondComponent(form); }
From source file:tad.grupo7.ccamistadeslargas.LoginView.java
/** * Crea los campos del formulario./* w w w . j a v a2s. c o m*/ * * @return Component Devuelve el layout que contiene todos los campos del * formulario. */ private Component buildFields() { //LAYOUT CON LOS CAMPOS DEL FORMULARIO HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.addStyleName("fields"); final TextField email = new TextField("Email"); email.setRequired(true); email.setIcon(FontAwesome.USER); email.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); email.focus(); final PasswordField password = new PasswordField("Password"); password.setRequired(true); password.setIcon(FontAwesome.LOCK); password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final Button signin = new Button("Sign In"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); signin.setClickShortcut(KeyCode.ENTER); final Button registrar = new Button("Sign Up"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); fields.addComponents(email, password, signin, registrar); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); fields.setComponentAlignment(registrar, Alignment.BOTTOM_LEFT); //LOGARSE signin.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { email.validate(); password.validate(); Usuario u = UsuarioDAO.read(email.getValue(), password.getValue()); if (u != null) { if (u.getEmail().equals("admin") && u.getPassword().equals("admin")) { Session.setAttribute("usuario", u); UI.getCurrent().getNavigator().navigateTo("AdminIndex"); } else { Session.setAttribute("usuario", u); UI.getCurrent().getNavigator().navigateTo("index"); } } else { Notification n = new Notification("Usuario incorrecto", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Rellena todos los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } }); //IR AL FORMULARIO DE REGISTRARSE registrar.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { UI.getCurrent().getNavigator().navigateTo("registrar"); } }); return fields; }
From source file:tad.grupo7.ccamistadeslargas.PerfilLayout.java
private void mostrarPerfil() { //T?TULO// w ww . j a va 2 s. c o m CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Perfil"); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO TextField nombre = new TextField("Nombre"); nombre.setValue(usuario.getNombre()); nombre.setRequired(true); TextField password = new TextField("Password"); password.setValue(usuario.getPassword()); password.setRequired(true); TextField email = new TextField("Email"); email.setValue(usuario.getEmail()); email.setEnabled(false); Button actualizar = new Button("Actualizar"); //BOTN ACTUALIZAR actualizar.addClickListener(clickEvent -> { UsuarioDAO.update(usuario.getId(), nombre.getValue(), password.getValue(), usuario.getEmail()); Notification n = new Notification("Usuario actualizado", Notification.Type.ASSISTIVE_NOTIFICATION); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); usuario.setNombre(nombre.getValue()); usuario.setPassword(password.getValue()); }); //AADIR COMPONENTES FormLayout form = new FormLayout(l, nombre, password, email, actualizar); form.setMargin(true); addComponents(form); }
From source file:tad.grupo7.ccamistadeslargas.RegistrarView.java
public RegistrarView() { setMargin(true);// www.jav a 2 s. c o m setSpacing(true); //T?TULO CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Registro"); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO TextField nombre = new TextField("Nombre"); nombre.setRequired(true); PasswordField password = new PasswordField("Contrasea"); password.setRequired(true); TextField email = new TextField("Email"); email.setRequired(true); final Button registrar = new Button("Sign Up"); registrar.setClickShortcut(ShortcutAction.KeyCode.ENTER); registrar.addStyleName(ValoTheme.BUTTON_PRIMARY); FormLayout form = new FormLayout(nombre, password, email, registrar); //BOTN PARA REGISTRARSE registrar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { try { nombre.validate(); password.validate(); email.validate(); UsuarioDAO.create(nombre.getValue(), password.getValue(), email.getValue()); Usuario u = UsuarioDAO.read(email.getValue(), password.getValue()); Session.setAttribute("usuario", u); UI.getCurrent().getNavigator().navigateTo("index"); } catch (Validator.InvalidValueException ex) { } } }); //AADIR COMPONENTES addComponents(l, form); setComponentAlignment(form, Alignment.MIDDLE_CENTER); }
From source file:uicomponents.LigandExtractPanel.java
License:Open Source License
public Map<String, MHCLigandExtractionProtocol> getAntibodyInfos() { Map<String, MHCLigandExtractionProtocol> res = new HashMap<String, MHCLigandExtractionProtocol>(); for (Iterator i = extractionExperiments.getItemIds().iterator(); i.hasNext();) { // Get the current item identifier, which is an integer. int iid = (Integer) i.next(); // Now get the actual item from the table. Item item = extractionExperiments.getItem(iid); String source = tableIdToBarcode.get(iid);// came from this sample TextField mass = (TextField) item.getItemProperty("Mass [mg]").getValue(); String inputSampleMass = mass.getValue(); DateField d = (DateField) item.getItemProperty("Date").getValue(); Date date = d.getValue(); ComboBox ab1 = (ComboBox) item.getItemProperty("Antibody 1").getValue(); TextField mass1 = (TextField) item.getItemProperty("Mass 1 [mg]").getValue(); ComboBox ab2 = (ComboBox) item.getItemProperty("Antibody 2").getValue(); TextField mass2 = (TextField) item.getItemProperty("Mass 2 [mg]").getValue(); ComboBox ab3 = (ComboBox) item.getItemProperty("Antibody 3").getValue(); TextField mass3 = (TextField) item.getItemProperty("Mass 3 [mg]").getValue(); List<String> antibodies = new ArrayList<String>(); List<String> antibodyMasses = new ArrayList<String>(); if (ab1.getValue() != null) { antibodies.add(ab1.getValue().toString()); antibodyMasses.add(mass1.getValue()); }//from w w w .j av a 2 s . co m if (ab2.getValue() != null) { antibodies.add(ab2.getValue().toString()); antibodyMasses.add(mass2.getValue()); } if (ab3.getValue() != null) { antibodies.add(ab3.getValue().toString()); antibodyMasses.add(mass3.getValue()); } res.put(source, new MHCLigandExtractionProtocol(inputSampleMass, date, antibodies, antibodyMasses)); } return res; }
From source file:uicomponents.LigandExtractPanel.java
License:Open Source License
public boolean isValid() { boolean res = true; String error = ""; for (Iterator i = extractionExperiments.getItemIds().iterator(); i.hasNext();) { // Get the current item identifier, which is an integer. int iid = (Integer) i.next(); // Now get the actual item from the table. Item item = extractionExperiments.getItem(iid); TextField mass = (TextField) item.getItemProperty("Mass [mg]").getValue(); try {//from ww w. j a v a2s . c o m Integer.parseInt(mass.getValue()); } catch (NumberFormatException e) { res = false; error = "Sample mass has to be a number!"; } DateField d = (DateField) item.getItemProperty("Date").getValue(); if (d.getValue() == null) { error = "Please select preparation dates for all samples!"; } ComboBox ab1 = (ComboBox) item.getItemProperty("Antibody 1").getValue(); TextField mass1 = (TextField) item.getItemProperty("Mass 1 [mg]").getValue(); ComboBox ab2 = (ComboBox) item.getItemProperty("Antibody 2").getValue(); TextField mass2 = (TextField) item.getItemProperty("Mass 2 [mg]").getValue(); ComboBox ab3 = (ComboBox) item.getItemProperty("Antibody 3").getValue(); TextField mass3 = (TextField) item.getItemProperty("Mass 3 [mg]").getValue(); String antibodyError = "Please choose at least one antibody and fill in the mass."; if (ab1.getValue() != null && !mass1.getValue().isEmpty()) { try { Integer.parseInt(mass.getValue()); } catch (NumberFormatException e) { res = false; error = "Antibody 1 mass has to be a number!"; } } else { res = false; error = antibodyError; } if (ab2.getValue() != null && !mass2.getValue().isEmpty()) { try { Integer.parseInt(mass.getValue()); } catch (NumberFormatException e) { res = false; error = "Antibody 2 mass has to be a number!"; } } if (ab3.getValue() != null && !mass3.getValue().isEmpty()) { try { Integer.parseInt(mass.getValue()); } catch (NumberFormatException e) { res = false; error = "Antibody 3 mass has to be a number!"; } } } if (!res) { Notification n = new Notification(error); n.setStyleName(ValoTheme.NOTIFICATION_CLOSABLE); n.setDelayMsec(-1); n.show(UI.getCurrent().getPage()); return false; } else return true; }
From source file:uicomponents.SummaryTable.java
License:Open Source License
private void removeColEntries(String colName) { for (Object id : table.getItemIds()) { TextField tf = (TextField) table.getItem(id).getItemProperty(colName).getValue(); if (!tf.getValue().equals("DELETED")) tf.setValue(""); }/*from w w w. j a va 2s .c o m*/ }
From source file:uicomponents.SummaryTable.java
License:Open Source License
public void initTable(List<AOpenbisSample> samples, LabelingMethod labelingMethod) { if (labelingMethod != null) { this.labelingMethod = labelingMethod; isotopes = true;//from w ww .ja v a 2s . co m } table.setStyleName(Styles.tableTheme); // table.addContainerProperty("ID", String.class, null); // table.setColumnWidth("ID", 35); table.addContainerProperty("Secondary Name", TextField.class, null); table.addContainerProperty("External DB ID", TextField.class, null); table.setColumnWidth("External DB ID", 106); table.setImmediate(true); table.setCaption(samples.size() + " " + name); if (isotopes) table.addContainerProperty(labelingMethod.getName(), ComboBox.class, null); List<String> factorLabels = new ArrayList<String>(); int maxCols = 0; AOpenbisSample mostInformative = samples.get(0); for (AOpenbisSample s : samples) { int size = s.getFactors().size(); if (size > maxCols) { maxCols = size; mostInformative = s; } } List<Property> factors = mostInformative.getFactors(); for (int i = 0; i < factors.size(); i++) { String l = factors.get(i).getLabel(); int j = 2; while (factorLabels.contains(l)) { l = factors.get(i).getLabel() + " (" + Integer.toString(j) + ")"; j++; } factorLabels.add(l); table.addContainerProperty(l, String.class, null); } table.addContainerProperty("Customize", Button.class, null); table.setColumnWidth("Customize", 85); List<String> reagents = null; if (isotopes) reagents = labelingMethod.getReagents(); int i = -1; for (AOpenbisSample s : samples) { i++; // AOpenbisSample s = samples.get(i); // Obje id = Integer.toString(i); // map.put(id, s); // The Table item identifier for the row. // Integer itemId = new Integer(i); // Create a button and handle its click. Button delete = new Button(); Styles.iconButton(delete, FontAwesome.TRASH_O); // delete.setWidth("15px"); // delete.setHeight("30px"); delete.setData(s); delete.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = 5414603256990177472L; @Override public void buttonClick(ClickEvent event) { Button b = event.getButton(); Object iid = b.getData(); TextField secNameField = (TextField) table.getItem(iid).getItemProperty("Secondary Name") .getValue(); TextField extIDField = (TextField) table.getItem(iid).getItemProperty("External DB ID") .getValue(); if (secNameField.getValue().equals("DELETED")) { secNameField.setReadOnly(false); extIDField.setReadOnly(false); // String id = (String) table.getItem(iid).getItemProperty("ID").getValue(); secNameField.setValue(s.getQ_SECONDARY_NAME()); extIDField.setValue(s.getQ_EXTERNALDB_ID()); b.setIcon(FontAwesome.TRASH_O); } else { secNameField.setValue("DELETED"); secNameField.setReadOnly(true); extIDField.setValue("DELETED"); extIDField.setReadOnly(true); b.setIcon(FontAwesome.UNDO); } } }); // Create the table row. List<Object> row = new ArrayList<Object>(); TextField secNameField = new StandardTextField(); secNameField.setImmediate(true); String secName = ""; if (s.getQ_SECONDARY_NAME() != null) secName = s.getQ_SECONDARY_NAME(); secNameField.setValue(secName); row.add(secNameField); TextField extIDField = new StandardTextField(); extIDField.setWidth("95px"); extIDField.setImmediate(true); String extID = ""; if (s.getQ_EXTERNALDB_ID() != null) extID = s.getQ_EXTERNALDB_ID(); extIDField.setValue(extID); row.add(extIDField); if (isotopes) { ComboBox cb = new ComboBox(); cb.setImmediate(true); cb.addItems(reagents); cb.select(reagents.get(i % reagents.size())); row.add(cb); } int missing = maxCols - s.getFactors().size(); for (Property f : s.getFactors()) { String v = f.getValue(); if (f.hasUnit()) v += " " + f.getUnit(); row.add(v); } for (int j = 0; j < missing; j++) row.add(""); row.add(delete); table.addItem(row.toArray(new Object[row.size()]), s); } }
From source file:uk.org.brindy.guessit.view.GameView.java
License:Apache License
@SuppressWarnings("serial") public GameView(final GuessItApp app) { System.out.println("GameView.GameView()"); final Session session = (Session) app.getUser(); if (!session.gameInProgress()) { session.startGame();/*from w w w . java 2 s .c om*/ } VerticalLayout vbox = new VerticalLayout(); vbox.addComponent(new Label("Hello " + session.name)); vbox.addComponent(new Label("Guess the number between 1 and 100")); final TextField number = new TextField(); vbox.addComponent(number); Button button = new Button("Guess"); button.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { if (session.guess(Integer.parseInt((String) number.getValue()))) { new WelldoneView(app); } else { new GameView(app); } } catch (NumberFormatException e) { session.guess(-1); new GameView(app); } } }); switch (session.getHint()) { case NOGUESSES: // do nothing break; case HIGHER: vbox.addComponent(new Label("Try higher...")); break; case LOWER: vbox.addComponent(new Label("Not that high!")); break; case WRONG: vbox.addComponent(new Label("I didn't quite get that.")); break; } vbox.addComponent(button); vbox.addComponent(new Label("You have had " + session.getGuessCount() + " guesses")); app.getMainWindow().setContent(vbox); }