Example usage for com.vaadin.ui TextField TextField

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

Introduction

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

Prototype

public TextField(String caption, ValueChangeListener<String> valueChangeListener) 

Source Link

Document

Constructs a new TextField with the given caption and a value change listener.

Usage

From source file:cb_server.SettingsWindow.java

License:Open Source License

private Component getStringView(final SettingString sB, int backgroundChanger) {
    com.vaadin.ui.HorizontalLayout box = new HorizontalLayout();
    box.setWidth(100, Unit.PERCENTAGE);//from   w ww.  j  a  va2  s . com
    com.vaadin.ui.TextField input = new TextField(sB.getName(), String.valueOf(sB.getValue()));
    input.setWidth(50, Unit.PERCENTAGE);
    input.addTextChangeListener(new TextChangeListener() {
        private static final long serialVersionUID = -634498493292006581L;

        @Override
        public void textChange(TextChangeEvent event) {
            sB.setValue(event.getText());
        }
    });

    box.addComponent(input);
    return box;
}

From source file:cb_server.SettingsWindow.java

License:Open Source License

private Component getEncryptedStringView(final SettingEncryptedString sB, int backgroundChanger) {
    com.vaadin.ui.HorizontalLayout box = new HorizontalLayout();
    box.setWidth(100, Unit.PERCENTAGE);//from  www  .j  ava2s.c  o  m
    com.vaadin.ui.TextField input = new TextField(sB.getName(), String.valueOf(sB.getEncryptedValue()));
    input.setWidth(50, Unit.PERCENTAGE);
    input.addTextChangeListener(new TextChangeListener() {
        private static final long serialVersionUID = -634498493292006581L;

        @Override
        public void textChange(TextChangeEvent event) {
            sB.setEncryptedValue(event.getText());
        }
    });

    box.addComponent(input);
    return box;
}

From source file:cb_server.SettingsWindow.java

License:Open Source License

private Component getFileView(final SettingFile sB, int backgroundChanger) {
    com.vaadin.ui.HorizontalLayout box = new HorizontalLayout();
    box.setWidth(100, Unit.PERCENTAGE);/* w w  w .  j a va 2  s. c o m*/
    com.vaadin.ui.TextField input = new TextField(sB.getName(), String.valueOf(sB.getValue()));
    input.setWidth(50, Unit.PERCENTAGE);
    input.addTextChangeListener(new TextChangeListener() {
        private static final long serialVersionUID = -634498493292006581L;

        @Override
        public void textChange(TextChangeEvent event) {
            sB.setValue(event.getText());
        }
    });

    box.addComponent(input);

    return box;
}

From source file:cb_server.SettingsWindow.java

License:Open Source License

private Component getFolderView(final SettingFolder sB, int backgroundChanger) {
    com.vaadin.ui.HorizontalLayout box = new HorizontalLayout();
    box.setWidth(100, Unit.PERCENTAGE);//from   ww w. java  2  s.c  om
    com.vaadin.ui.TextField input = new TextField(sB.getName(), String.valueOf(sB.getValue()));
    input.setWidth(50, Unit.PERCENTAGE);
    input.addTextChangeListener(new TextChangeListener() {
        private static final long serialVersionUID = -634498493292006581L;

        @Override
        public void textChange(TextChangeEvent event) {
            sB.setValue(event.getText());
        }
    });

    box.addComponent(input);
    return box;
}

From source file:cb_server.SettingsWindow.java

License:Open Source License

private Component getFloatView(final SettingFloat sB, int backgroundChanger) {
    com.vaadin.ui.HorizontalLayout box = new HorizontalLayout();
    com.vaadin.ui.TextField input = new TextField(sB.getName(), String.valueOf(sB.getValue()));
    input.setWidth(50, Unit.PERCENTAGE);
    input.addTextChangeListener(new TextChangeListener() {
        private static final long serialVersionUID = -634498493292006581L;

        @Override/*  www .  j a  va 2  s.  c  om*/
        public void textChange(TextChangeEvent event) {
            sB.setValue(Float.parseFloat(event.getText()));
        }
    });

    box.addComponent(input);
    return box;
}

From source file:cb_server.SettingsWindow.java

License:Open Source License

private Component getDblView(final SettingDouble sB, int backgroundChanger) {
    com.vaadin.ui.HorizontalLayout box = new HorizontalLayout();
    com.vaadin.ui.TextField input = new TextField(sB.getName(), String.valueOf(sB.getValue()));
    input.setWidth(50, Unit.PERCENTAGE);
    input.addTextChangeListener(new TextChangeListener() {
        private static final long serialVersionUID = -634498493292006581L;

        @Override//  w ww .  j a  v a2 s  .  c  o m
        public void textChange(TextChangeEvent event) {
            sB.setValue(Double.parseDouble(event.getText()));
        }
    });

    box.addComponent(input);
    return box;
}

From source file:cb_server.SettingsWindow.java

License:Open Source License

private Component getIntView(final SettingInt sB, int backgroundChanger) {
    com.vaadin.ui.HorizontalLayout box = new HorizontalLayout();
    com.vaadin.ui.TextField input = new TextField(sB.getName(), String.valueOf(sB.getValue()));
    input.setWidth(50, Unit.PERCENTAGE);
    input.addTextChangeListener(new TextChangeListener() {
        private static final long serialVersionUID = -634498493292006581L;

        @Override// www  . j  a  v a 2s  . c  om
        public void textChange(TextChangeEvent event) {

            int newValue = Integer.parseInt(event.getText());
            sB.setValue(newValue);
        }
    });

    box.addComponent(input);
    return box;
}

From source file:co.edu.icesi.academ.client.perfiles.propietario.DialogoEditarRubrica.java

License:Open Source License

/**
 * The constructor should first build the main layout, set the
 * composition root and then do any custom initialization.
 *
 * The constructor will not be automatically regenerated by the
 * visual editor.//from  w  w  w.  j a  v a2s.com
 */
public DialogoEditarRubrica() {
    buildMainLayout();
    setCompositionRoot(mainLayout);

    tblCriterios.addContainerProperty("Posicion", TextField.class, null);
    tblCriterios.addContainerProperty("Descripcion", TextField.class, null);

    tblNiveles.addContainerProperty("Puntos", TextField.class, null);
    tblNiveles.addContainerProperty("Descripcion", TextField.class, null);

    btnCrearCriterio.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            CriterioBO criterio = new CriterioBO();
            criterio.setId(0);
            criterio.setDescripcion("");

            TextField txtId = new TextField("", criterio.getId() + "");

            TextField txtDescripcion = new TextField("", criterio.getDescripcion());

            tblCriterios.addItem(new Object[] { txtId, txtDescripcion }, criterio);
        }
    });

    btnCrearNivel.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            NivelCriterioBO nivel = new NivelCriterioBO();
            nivel.setId(0);
            nivel.setNivel(0);
            nivel.setDescripcion("");

            TextField txtNivel = new TextField("", nivel.getNivel() + "");

            TextField txtDescripcion = new TextField("", nivel.getDescripcion());

            tblNiveles.addItem(new Object[] { txtNivel, txtDescripcion }, nivel);
        }
    });

    btnGuardar.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {

            rubrica.getCriterios().clear();

            while (tblCriterios.size() != 0) {
                for (Object o : tblCriterios.getItemIds().toArray()) {
                    CriterioBO criterio = (CriterioBO) o;

                    criterio.setId(Integer.parseInt(
                            tblCriterios.getItem(criterio).getItemProperty("Posicion").getValue().toString()));
                    criterio.setDescripcion(tblCriterios.getItem(criterio).getItemProperty("Descripcion")
                            .getValue().toString());

                    tblCriterios.removeItem(criterio);

                    if (!rubrica.getCriterios().contains(criterio))
                        rubrica.getCriterios().add(criterio);
                }
            }

            LinkedList<NivelCriterioBO> niveles = new LinkedList<NivelCriterioBO>();

            while (tblNiveles.size() != 0) {
                for (Object o : tblNiveles.getItemIds().toArray()) {
                    NivelCriterioBO nivel = (NivelCriterioBO) o;

                    nivel.setId(Integer.parseInt(
                            tblNiveles.getItem(nivel).getItemProperty("Puntos").getValue().toString()));
                    nivel.setNivel(nivel.getId());
                    nivel.setDescripcion(
                            tblNiveles.getItem(nivel).getItemProperty("Descripcion").getValue().toString());

                    tblNiveles.removeItem(nivel);

                    if (!niveles.contains(nivel))
                        niveles.add(nivel);
                }
            }

            for (CriterioBO criterio : rubrica.getCriterios())
                criterio.setNiveles(niveles);

            ControladorPropietario.getInstance().guardarRubrica(rubrica);

            actualizar(rubrica);
        }
    });
}

From source file:co.edu.icesi.academ.client.perfiles.propietario.DialogoEditarRubrica.java

License:Open Source License

public void actualizar(RubricaBO rubricaBO) {
    rubrica = rubricaBO;/* w  ww . j a va  2s.com*/

    tblCriterios.removeAllItems();

    for (CriterioBO criterio : rubrica.getCriterios()) {
        TextField txtId = new TextField("", criterio.getId() + "");
        txtId.setId("id");

        TextField txtDescripcion = new TextField("", criterio.getDescripcion());
        txtDescripcion.setId("descripcion");

        tblCriterios.addItem(new Object[] { txtId, txtDescripcion }, criterio);
    }

    tblNiveles.removeAllItems();

    if (!rubrica.getCriterios().isEmpty()) {
        for (NivelCriterioBO nivel : rubrica.getCriterios().get(0).getNiveles()) {
            TextField txtNivel = new TextField("", nivel.getNivel() + "");
            txtNivel.setId("nivel");

            TextField txtDescripcion = new TextField("", nivel.getDescripcion());
            txtDescripcion.setId("descripcion");

            tblNiveles.addItem(new Object[] { txtNivel, txtDescripcion }, nivel);
        }
    }
}

From source file:com.esofthead.mycollab.vaadin.web.ui.field.DateFormatField.java

License:Open Source License

public DateFormatField(final String initialFormat) {
    this.dateFormat = initialFormat;
    dateInput = new TextField(null, initialFormat);
    dateInput.setImmediate(true);//  w w  w .j  av  a  2s.  co m
    dateInput.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER);
    now = new DateTime();
    dateExample = new Label();
    dateFormatInstance = DateTimeFormat.forPattern(dateFormat);
    dateExample.setValue("(" + dateFormatInstance.print(now) + ")");
    dateExample.setWidthUndefined();
    dateInput.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            try {
                String newFormat = event.getText();
                dateFormatInstance = DateTimeFormat.forPattern(newFormat);
                dateExample.setValue("(" + dateFormatInstance.print(now) + ")");
            } catch (Exception e) {
                NotificationUtil.showErrorNotification("Invalid format");
                dateInput.setValue(initialFormat);
                dateFormatInstance = DateTimeFormat.forPattern(initialFormat);
                dateExample.setValue("(" + dateFormatInstance.print(now) + ")");
            }
        }
    });
}