Example usage for com.vaadin.ui TextField setValue

List of usage examples for com.vaadin.ui TextField setValue

Introduction

In this page you can find the example usage for com.vaadin.ui TextField setValue.

Prototype

@Override
public void setValue(String value) 

Source Link

Document

Sets the value of this text field.

Usage

From source file:ru.codeinside.gses.activiti.ftarchive.LongFFT.java

License:Mozilla Public License

@Override
public Field createField(final String taskId, final String fieldId, String name, Long value, PropertyNode node,
        boolean archive) {
    final TextField textField = new LongField();
    textField.setNullRepresentation("");
    textField.addValidator(new LongValidator("  ?"));
    textField.setImmediate(true);/*from  ww  w.j  a va 2s .  c om*/
    textField.setValue(value);
    if (node.isFieldWritable() && !archive && taskId != null) {
        textField.addListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                Object newValue = event.getProperty().getValue();
                if (!(newValue instanceof Long)) {
                    newValue = null;
                }
                Flash.flash().getExecutorService().saveBuffer(taskId, fieldId, (Long) newValue);
            }
        });
    }
    FieldHelper.setCommonFieldProperty(textField, node.isFieldWritable() && !archive, name,
            node.isFieldRequired());
    return textField;
}

From source file:steps.ConditionInstanceStep.java

License:Open Source License

public void buildTable(List<String> permutations, String startAmount) {
    preview.removeAllItems();/*from   w  ww.  j a v  a  2 s . c  o  m*/
    int i = 0;
    for (String s : permutations) {
        s = s.replace("###", " ; ");
        i++;
        Integer itemId = new Integer(i);
        TextField tf = new StandardTextField();
        tf.setValue(startAmount);
        preview.addItem(new Object[] { s, tf }, itemId);
    }
    preview.setPageLength(preview.size());
    previewFrame.setVisible(true);
}

From source file:tad.grupo7.ccamistadeslargas.AmigosLayout.java

/**
 * Muestra una amistad en concreto./*w ww  .  j  a  v  a 2 s . c om*/
 * @param p Participante
 */
private void mostrarParticipante(Participante p) {
    //FORMULARIO POR SI SE QUIERE EDITAR EL PARTICIPANTE
    TextField nombre = new TextField("Nombre");
    nombre.setValue(p.getNombre());
    final Button eliminar = new Button("Eliminar Participante");
    final Button actualizar = new Button("Actualizar Participante");

    //BOTN PARA ACTUALIZAR EL PARTICIPANTE
    actualizar.addClickListener(clickEvent -> {
        if (ParticipanteDAO.read(nombre.getValue(), usuario.getId()) == null) {
            ParticipanteDAO.update(p.getId(), nombre.getValue());
            UsuarioDAO.updateAmigo(nombre.getValue(), p.getId(), usuario.getId());
            Notification n = new Notification("Amigo actualizado", Notification.Type.ASSISTIVE_NOTIFICATION);
            n.setPosition(Position.TOP_CENTER);
            n.show(Page.getCurrent());
            removeAllComponents();
            mostrarAmistades();
        } else {
            Notification n = new Notification("Ya existe un amigo con el mismo nombre",
                    Notification.Type.WARNING_MESSAGE);
            n.setPosition(Position.TOP_CENTER);
            n.show(Page.getCurrent());
        }

    });
    //BOTN PARA ELIMINAR EL PARTICIPANTE
    eliminar.addClickListener(clickEvent -> {
        ParticipanteDAO.delete(p.getId());
        UsuarioDAO.removeAmigo(nombre.getValue(), usuario.getId());
        removeAllComponents();
        mostrarAmistades();
    });

    //AADIMOS LOS COMPONENTES
    FormLayout form = new FormLayout(nombre, actualizar, eliminar);
    VerticalLayout l = new VerticalLayout(form);
    l.setMargin(true);
    setSecondComponent(l);
}

From source file:tad.grupo7.ccamistadeslargas.EventosLayout.java

/**
 * Se muestra el evento en el vertical layout derecho del splitpanel.
 *
 * @param e Recoge el evento que se quiere mostrar.
 *//* w w  w. j  a va2 s. c o m*/
private void mostrarEvento(Evento e) {
    removeAllComponents();
    //T?TULO
    CssLayout labels = new CssLayout();
    labels.addStyleName("labels");
    Label l = new Label("Evento " + e.getNombre());
    l.setSizeUndefined();
    l.addStyleName(ValoTheme.LABEL_H2);
    l.addStyleName(ValoTheme.LABEL_COLORED);
    //FORMULARIO POR SI SE QUIERE EDITAR EL EVENTO
    TextField nombre = new TextField("Nombre");
    nombre.setValue(e.getNombre());
    nombre.setRequired(true);
    ComboBox divisa = new ComboBox("Divisa");
    divisa.setNullSelectionAllowed(false);
    divisa.setRequired(true);
    divisa.addItem("");
    divisa.addItem("$");

    HorizontalLayout layouth = new HorizontalLayout();
    HorizontalLayout layouth2 = new HorizontalLayout();
    layouth.setSpacing(true);
    layouth2.setSpacing(true);

    final Button actualizar = new Button("Actualizar Evento");
    final Button eliminar = new Button("Eliminar Evento");
    final Button addPago = new Button("Aadir Pago");
    final Button addParticipante = new Button("Aadir Participante");
    layouth.addComponents(actualizar, eliminar);
    layouth2.addComponents(addPago, addParticipante);
    final Button hacerCuentas = new Button("Hacer las cuentas");
    //BOTN PARA ACTUALIZAR EL EVENTO
    actualizar.addClickListener(clickEvent -> {
        try {
            nombre.validate();
            divisa.validate();
            if (EventoDAO.readDBObject(nombre.getValue(), usuario.getId()) == null) {
                EventoDAO.update(e.getId(), nombre.getValue(), divisa.getValue().toString());
                Notification n = new Notification("Evento actualizado",
                        Notification.Type.ASSISTIVE_NOTIFICATION);
                n.setPosition(Position.TOP_CENTER);
                n.show(Page.getCurrent());
                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());
        }

    });
    //BOTN PARA QUE SALGA UNA VENTANA EMERGENTE PARA AADIR UN GASTO AL EVENTO
    addPago.addClickListener(clickEvent -> {
        mostrarFormularioAddGasto(e);
    });
    //BOTN PARA ELIMINAR EL EVENTO
    eliminar.addClickListener(clickEvent -> {
        EventoDAO.delete(e.getId());
        removeAllComponents();
        mostrarEventos();
    });
    //BOTN PARA AADIR PARTICIPANTES
    addParticipante.addClickListener(clickEvent -> {
        mostrarFormularioAddParticipante(e);
    });
    //BOTN PARA HACER LAS CUENTAS
    hacerCuentas.addClickListener(clickEvent -> {
        removeAllComponents();
        VerticalLayout vl = new VerticalLayout();
        Table tablaResumenPlusvalia = getTablaResumenPlusvalia(e);
        HorizontalLayout hl1 = new HorizontalLayout(tablaResumenPlusvalia);
        hl1.setMargin(true);
        hl1.setSpacing(true);
        vl.addComponent(hl1);
        for (Participante p : ParticipanteDAO.readAllFromEvento(e.getId())) {
            HorizontalLayout hl = new HorizontalLayout(getTablaResumenGastosPorPersona(e, p));
            hl.setMargin(true);
            hl.setSpacing(true);
            vl.addComponent(hl);
        }
        setSplitPosition(100, Sizeable.UNITS_PERCENTAGE);
        setFirstComponent(vl);
    });
    //TABLA CON TODOS LOS GASTOS DEL EVENTO
    Table tablaGastos = getTablaGastos(e);
    //TABLA CON TODOS LOS PARTICIPANTES DEL EVENTO
    Table tablaParticipantes = getTablaParticipantes(e);
    //AADIMOS LOS COMPONENTES
    FormLayout form = new FormLayout(nombre, divisa, layouth, layouth2, hacerCuentas);
    VerticalLayout vl = new VerticalLayout(l, form, tablaGastos, tablaParticipantes);
    vl.setMargin(true);
    setFirstComponent(vl);
}

From source file:tad.grupo7.ccamistadeslargas.EventosLayout.java

/**
 * Se muestra un gasto para poder actualizarlo o eliminarlo.
 *
 * @param e Recoge el evento al que pertenece el gasto.
 *//*w ww.  jav a  2 s  .com*/
private void mostrarGasto(Gasto g, Evento e) {
    //T?TULO
    CssLayout labels = new CssLayout();
    labels.addStyleName("labels");
    Label l = new Label("Gasto " + g.getNombre());
    l.setSizeUndefined();
    l.addStyleName(ValoTheme.LABEL_H2);
    l.addStyleName(ValoTheme.LABEL_COLORED);
    //FORMULARIO POR SI SE QUIERE EDITAR EL GASTO
    TextField nombre = new TextField("Titulo");
    nombre.setValue(g.getNombre());
    nombre.setRequired(true);
    TextField precio = new TextField("Precio");
    precio.setValue(g.getPrecio().toString());
    precio.setRequired(true);
    final Button actualizar = new Button("Actualizar Gasto");
    final Button eliminar = new Button("Eliminar Gasto");
    //BOTN PARA ACTUALIZAR EL GASTO
    actualizar.addClickListener(clickEvent -> {
        try {
            nombre.validate();
            precio.validate();
            GastoDAO.update(g.getId(), nombre.getValue(), Double.valueOf(precio.getValue()), g.getIdEvento(),
                    g.getIdPagador(), g.getDeudores());
            Notification n = new Notification("Gasto actualizado", Notification.Type.ASSISTIVE_NOTIFICATION);
            n.setPosition(Position.TOP_CENTER);
            n.show(Page.getCurrent());
            setSecondComponent(null);
            mostrarEvento(e);
        } 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());
        }
    });
    //BOTN PARA ELIMINAR EL GASTO
    eliminar.addClickListener(clickEvent -> {
        GastoDAO.delete(g.getId());
        removeAllComponents();
        mostrarEvento(e);
    });
    //AADIMOS LOS COMPONENTES
    FormLayout form = new FormLayout(nombre, precio, actualizar, eliminar);
    VerticalLayout vl = new VerticalLayout(l, form);
    vl.setMargin(true);
    setSecondComponent(vl);
}

From source file:tad.grupo7.ccamistadeslargas.PerfilLayout.java

private void mostrarPerfil() {
    //T?TULO//w w w  .  java2 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:uicomponents.MSSampleMultiplicationTable.java

License:Open Source License

public void setAnalyteSamples(List<AOpenbisSample> proteins, HashMap<Integer, Integer> tableIdToFractions,
        boolean peptides) {
    sampleTable.removeAllItems();//from   w w  w  . ja  v a2  s  .c o m
    tableIdToParent = new HashMap<String, AOpenbisSample>();
    enzymeMap = new HashMap<String, List<String>>();
    int i = 0;
    for (AOpenbisSample s : proteins) {
        i++;
        // multiply by number of fractions
        for (int j = 1; j <= tableIdToFractions.get(i); j++) {
            boolean complexRow = sampleTable.size() == 0; // the first row contains a combobox with
                                                          // added
                                                          // button to copy
                                                          // its selection to the whole column

            String parentID = Integer.toString(i);
            String fractionID = Integer.toString(j);
            String id = parentID + "-" + fractionID;
            tableIdToParent.put(id, s);

            List<Object> row = new ArrayList<Object>();

            Label sample = new Label(s.getQ_SECONDARY_NAME() + "<br>" + s.getQ_EXTERNALDB_ID(),
                    Label.CONTENT_XHTML);
            row.add(sample);

            Label num = new Label(fractionID);
            row.add(num);

            TextField secNameInput = generateTableTextInput("200px");
            secNameInput.setValue(s.getQ_SECONDARY_NAME() + " " + type + " #" + fractionID);
            row.add(secNameInput);
            TextField extIdInput = generateTableTextInput("95px");
            row.add(extIdInput);

            ComboBox processBox = generateTableBox(new ArrayList<String>(Arrays.asList("None", "Measure")),
                    "95px");
            if (!peptides) {
                processBox.addItem("Digest");
                processBox.addItem("Both");
            }
            processBox.setNullSelectionAllowed(false);
            processBox.select("None");
            if (complexRow)
                row.add(createComplexCellComponent(processBox, "Process", id));
            else
                row.add(processBox);

            processBox.addValueChangeListener(new ValueChangeListener() {

                @Override
                public void valueChange(ValueChangeEvent event) {
                    checkFractionMeasured();
                }
            });

            Collections.sort(enzymes);
            ComboBox enzymeBox = generateTableBox(enzymes, "105px");
            enzymeBox.removeAllItems();
            enzymeBox.addItem("[Multiple]");
            enzymeBox.addItems(enzymes);
            enzymeBox.setEnabled(false);
            enzymeBox.setFilteringMode(FilteringMode.CONTAINS);
            if (complexRow)
                row.add(createComplexCellComponent(enzymeBox, "Enzyme", id));
            else
                row.add(enzymeBox);
            final String rowNum = id;
            enzymeBox.addValueChangeListener(new ValueChangeListener() {

                @Override
                public void valueChange(ValueChangeEvent event) {
                    Object newVal = enzymeBox.getValue();
                    if (newVal.equals("[Multiple]"))
                        createEnzymeSelectionWindow(rowNum);
                    else if (!newVal.equals("Custom"))
                        enzymeBox.removeItem("Custom");
                }
            });

            sampleTable.addItem(row.toArray(new Object[row.size()]), id);

            processBox.addValueChangeListener(new ValueChangeListener() {

                @Override
                public void valueChange(ValueChangeEvent event) {
                    String value = (String) processBox.getValue();
                    boolean enableEnzyme = value.equals("Digest") || value.equals("Both");
                    parseBoxRow(id, "Enzyme").setEnabled(enableEnzyme);
                    // boolean enableMS = value.equals("Measure") || value.equals("Both");
                    // parseBoxRow(item, "Chr. Type").setEnabled(enableMS);
                    // parseBoxRow(item, "LCMS Method").setEnabled(enableMS);
                    // parseBoxRow(item, "MS Device").setEnabled(enableMS);
                }
            });
        }
    }
    int pagelength = 0;
    for (int n : tableIdToFractions.values()) {
        pagelength += n;
    }
    sampleTable.setPageLength(pagelength);
    this.setVisible(pagelength > 0);
    checkFractionMeasured();
}

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 ava2  s  . 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  w  w  .  ja v a  2  s .  c om*/
    }
    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);
    }
}