Example usage for com.vaadin.ui TextField getValue

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

Introduction

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

Prototype

@Override
    public String getValue() 

Source Link

Usage

From source file:ac.uk.icl.dell.vaadin.glycanbuilder.VaadinGlycanCanvas.java

License:Open Source License

@Override
public void recieveSelectionUpdate(double x, double y, double width, double height, boolean mouseMoved) {
    final Residue selectedResidue = theCanvas.getCurrentResidue();

    theCanvas.selectIntersectingRectangles(x, y, width, height, mouseMoved);

    if (theCanvas.getCurrentResidue() != null && selectedResidue == theCanvas.getCurrentResidue()
            && selectedResidue.isRepetition()) {
        final Window window = new Window("Repeatition options");

        WeeLayout layout = new WeeLayout(org.vaadin.weelayout.WeeLayout.Direction.VERTICAL);

        final TextField minRep = new TextField("Minimum");
        final TextField maxRep = new TextField("Maximum");
        NativeButton okBut = new NativeButton("Ok");
        NativeButton cancelBut = new NativeButton("Cancel");

        minRep.setImmediate(true);/*w  w w .j  a v  a2  s .c  om*/
        maxRep.setImmediate(true);

        minRep.setValue(String.valueOf(selectedResidue.getMinRepetitions()));
        maxRep.setValue(String.valueOf(selectedResidue.getMaxRepetitions()));

        okBut.addListener(new ClickListener() {
            private static final long serialVersionUID = -408364885359729326L;

            @Override
            public void buttonClick(ClickEvent event) {
                String minRepNum = (String) minRep.getValue();
                String maxRepNum = (String) maxRep.getValue();

                boolean valid = true;

                try {
                    Integer.parseInt(minRepNum);
                    Integer.parseInt(maxRepNum);
                } catch (NumberFormatException ex) {
                    valid = false;
                }

                if (valid) {
                    selectedResidue.setMinRepetitions((String) minRep.getValue());
                    selectedResidue.setMaxRepetitions((String) maxRep.getValue());

                    theCanvas.documentUpdated();
                }

                getWindow().removeWindow(window);
            }
        });

        cancelBut.addListener(new ClickListener() {
            private static final long serialVersionUID = -657746118918366530L;

            @Override
            public void buttonClick(ClickEvent event) {
                getWindow().removeWindow(window);
            }
        });

        layout.addComponent(minRep, Alignment.TOP_CENTER);
        layout.addComponent(maxRep, Alignment.MIDDLE_CENTER);

        WeeLayout buttonLayout = new WeeLayout(Direction.HORIZONTAL);
        buttonLayout.addComponent(okBut, Alignment.TOP_CENTER);
        buttonLayout.addComponent(cancelBut, Alignment.TOP_CENTER);

        layout.addComponent(buttonLayout, Alignment.BOTTOM_CENTER);

        window.center();
        window.getContent().addComponent(layout);

        window.getContent().setSizeUndefined();
        window.setSizeUndefined();

        getWindow().addWindow(window);
    }
}

From source file:at.jku.ce.adaptivetesting.vaadin.ui.topic.accounting.AccountingQuestionManager.java

License:LGPL

@Override
public void startQuiz(StudentData student) {
    // Remove everything from the layout, save it for displaying after
    // clicking OK
    final Component[] components = new Component[getComponentCount()];
    for (int i = 0; i < components.length; i++) {
        components[i] = getComponent(i);
    }//from   w w w.ja v  a 2  s .c o  m
    removeAllComponents();
    // Create first page
    VerticalLayout layout = new VerticalLayout();
    addComponent(layout);

    ComboBox gender = new ComboBox("Geschlecht");
    String[] genderItems = { "mnnlich", "weiblich" };
    gender.addItems(genderItems);
    //gender.setSizeFull();
    gender.setEnabled(true);

    Label gradeLastYear = new Label("<p/>Welche Note hattest du im letzten Zeugnis in ...", ContentMode.HTML);
    TextField gradeLastYearRW = new TextField("Rechungswesen");
    TextField gradeLastYearBWL = new TextField("BWL/BVW");
    TextField gradeLastYearD = new TextField("Deutsch");
    TextField gradeLastYearE = new TextField("Englisch");
    TextField gradeLastYearM = new TextField("Mathematik");

    Label gradeLastTest = new Label("<p/>Welche Note hattest du auf die letzte Schularbeit aus ...",
            ContentMode.HTML);
    TextField gradeLastTestRW = new TextField("Rechungswesen");
    TextField gradeLastTestBWL = new TextField("BWL/BVW");
    TextField gradeLastTestD = new TextField("Deutsch");
    TextField gradeLastTestE = new TextField("Englisch");
    TextField gradeLastTestM = new TextField("Mathematik");

    Label classNameLabel = new Label("<p/>Welche Klasse besuchst du?", ContentMode.HTML);
    TextField className = new TextField("(z.B. 4A)");

    Label studentCode = new Label(
            "<p/>Damit deine Antworten mit spteren Fragebogenergebnissen verknpft werden knnen, ist es notwendig, einen anonymen Benutzernamen anzulegen. Erstelle deinen persnlichen Code nach folgendem Muster:",
            ContentMode.HTML);
    TextField studentCodeC1 = new TextField(
            "Tag und Monat der Geburt (DDMM), z.B. \"1008\" fr Geburtstag am 10. August");
    TextField studentCodeC2 = new TextField(
            "Zwei Anfangsbuchstaben des Vornamens, z.B. \"St\" fr \"Stefan\"");
    TextField studentCodeC3 = new TextField(
            "Zwei Anfangsbuchstaben des Vornamens der Mutter,, z.B. \"Jo\" fr \"Johanna\"");

    Label thankYou = new Label("<p/>Danke fr die Angaben.<p/>", ContentMode.HTML);
    Button cont = new Button("Weiter", e -> {
        removeAllComponents();
        studentIDCode = new String(
                studentCodeC1.getValue() + studentCodeC2.getValue() + studentCodeC3.getValue());
        studentGender = (gender.getValue() == null) ? new String("undefined") : gender.getValue().toString();
        studentClass = className.getValue();

        studentGradesLastYear = new HashMap();
        studentGradesLastYear.put("RW", gradeLastYearRW.getValue());
        studentGradesLastYear.put("BWL", gradeLastYearBWL.getValue());
        studentGradesLastYear.put("D", gradeLastYearD.getValue());
        studentGradesLastYear.put("E", gradeLastYearE.getValue());
        studentGradesLastYear.put("M", gradeLastYearM.getValue());

        studentGradesLastTest = new HashMap();
        studentGradesLastTest.put("RW", gradeLastTestRW.getValue());
        studentGradesLastTest.put("BWL", gradeLastTestBWL.getValue());
        studentGradesLastTest.put("D", gradeLastTestD.getValue());
        studentGradesLastTest.put("E", gradeLastTestE.getValue());
        studentGradesLastTest.put("M", gradeLastTestM.getValue());

        this.student = new StudentData(studentIDCode, studentGender, studentClass, studentGradesLastYear,
                studentGradesLastTest);
        LogHelper.logInfo("StudentData: " + this.student.toString());

        displayCompanyInfo(components);
    });

    layout.addComponent(HtmlLabel.getCenteredLabel("h1", "Fragen zu deiner Person"));// Title of the quiz

    layout.addComponent(gender);

    layout.addComponent(gradeLastYear);
    layout.addComponent(gradeLastYearRW);
    layout.addComponent(gradeLastYearBWL);
    layout.addComponent(gradeLastYearD);
    layout.addComponent(gradeLastYearE);
    layout.addComponent(gradeLastYearM);

    layout.addComponent(gradeLastTest);
    layout.addComponent(gradeLastTestRW);
    layout.addComponent(gradeLastTestBWL);
    layout.addComponent(gradeLastTestD);
    layout.addComponent(gradeLastTestE);
    layout.addComponent(gradeLastTestM);

    layout.addComponent(classNameLabel);
    layout.addComponent(className);

    layout.addComponent(studentCode);
    layout.addComponent(studentCodeC1);
    layout.addComponent(studentCodeC2);
    layout.addComponent(studentCodeC3);

    layout.addComponent(thankYou);
    layout.addComponent(cont);
    layout.setComponentAlignment(components[0], Alignment.MIDDLE_CENTER);
}

From source file:au.org.scoutmaster.views.ContactView.java

private void showMailForm(final TextField emailField) {
    final Window mailWindow = new Window("Send Email");
    mailWindow.setWidth("80%");
    mailWindow.setHeight("80%");
    final User sender = (User) getSession().getAttribute("user");
    mailWindow.setContent(new EmailForm(mailWindow, sender, getCurrent(), emailField.getValue()));
    mailWindow.setVisible(true);//from www  .  ja v a  2s .  c o  m
    mailWindow.center();
    UI.getCurrent().addWindow(mailWindow);

}

From source file:br.gov.frameworkdemoiselle.vaadin.util.FieldFactory.java

License:Open Source License

@SuppressWarnings("serial")
public static Field createCPFField(String prompt, String caption) {
    final TextField listenedField = createTextField(prompt, caption);
    listenedField.setImmediate(true);/*w  ww  .ja  v  a 2 s  . c o m*/
    listenedField.addListener(new ValueChangeListener() {

        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            if (listenedField.getValue() != null) {
                try {
                    listenedField.setValue(
                            TextUtil.format(listenedField.getValue().toString(), "999.999.999-99", true));
                } catch (RuntimeException re) {
                    // Notthing to be done!
                }
            }
        }
    });
    return listenedField;
}

From source file:br.gov.frameworkdemoiselle.vaadin.util.FieldFactory.java

License:Open Source License

public static Field createPhoneField(String prompt, String caption) {
    final TextField listenedField = createTextField(prompt, caption);
    listenedField.setImmediate(true);//from   w  ww .  ja  va 2  s. c o m
    listenedField.addListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            if (listenedField.getValue() != null) {
                try {
                    listenedField
                            .setValue(TextUtil.format(listenedField.getValue().toString(), "9999-9999", true));
                } catch (RuntimeException re) {
                    // Notthing to be done!
                }
            }
        }
    });
    return listenedField;
}

From source file:br.gov.frameworkdemoiselle.vaadin.util.FieldFactory.java

License:Open Source License

@SuppressWarnings("serial")
public static Field createFormattedField(String prompt, String caption, final String formato,
        final boolean direcao) {
    final TextField listenedField = createTextField(prompt, caption);
    listenedField.setImmediate(true);//  w  ww. j  av  a  2s .  co  m
    listenedField.addListener(new ValueChangeListener() {

        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            if (listenedField.getValue() != null) {
                try {
                    listenedField
                            .setValue(TextUtil.format(listenedField.getValue().toString(), formato, direcao));
                } catch (RuntimeException re) {
                    // Notthing to be done!
                }
            }
        }

    });
    return listenedField;
}

From source file:by.bigvova.ui.LoginUI.java

License:Apache License

private Component buildFields() {
    final VerticalLayout layout = new VerticalLayout();
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);/*  w  ww.jav  a 2s.co  m*/
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.setIcon(FontAwesome.USER);
    username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final PasswordField password = new PasswordField("Password");
    password.setIcon(FontAwesome.LOCK);
    password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final Button signin = new Button("Sign In");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signin.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    signin.focus();

    final CheckBox checkBox = new CheckBox("Remember me", true);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            login(username.getValue(), password.getValue(), checkBox.getValue());
        }
    });

    fields.addComponents(username, password, signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    layout.setSpacing(true);
    layout.addComponent(fields);
    layout.addComponent(checkBox);
    return layout;
}

From source file:ch.bfh.ti.soed.hs16.srs.kandr3.view.MyUI.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {
    final VerticalLayout layout = new VerticalLayout();

    final TextField name = new TextField();
    name.setCaption("Type your name here:");

    Button button = new Button("Click Me");
    button.addClickListener(e -> {/* w  ww.  ja  va2 s .c om*/
        layout.addComponent(new Label("Thanks " + name.getValue() + ", it works!"));
    });

    layout.addComponents(name, button);
    layout.setMargin(true);
    layout.setSpacing(true);

    setContent(layout);
}

From source file:ch.bfh.ti.soed.hs16.srs.purple.controller.ValidationController.java

License:Open Source License

/**
 * Function checks in the database if the username is already used.
 *
 * @param username - The "username"-textfield
 * @param dbController - Instance of DBController
 *///www .ja  va 2  s .c  o  m
public static void checkIfUserAlredyExist(TextField username, DBController dbController)
        throws InvalidValueException {
    username.addValidator(new Validator() {

        @Override
        public void validate(Object value) throws InvalidValueException {
            List<User> users = dbController.selectUserBy(Table_User.COLUMN_USERNAME, username.getValue());

            if (users.size() > 0) {
                throw new InvalidValueException("Username ist bereits vergeben!");
            }
        }
    });
}

From source file:com.abien.vaadin.helloapp.HelloApp.java

License:Apache License

@Override
public void init() {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);//from  w ww.  ja  v  a 2s.c o  m
    Label header = new Label("Vaadin on Java EE");
    header.setStyleName("h1");
    layout.addComponent(header);

    final TextField nameField = new TextField("Input something:");
    final Label greetingLbl = new Label();
    layout.addComponent(nameField);

    layout.addComponent(
            new Button("Say slow Hello, clicking this shouldn't stall other users", new Button.ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                    try {
                        Thread.sleep(20 * 1000);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(HelloApp.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    getMainWindow().showNotification("Hello!");
                }
            }));

    layout.addComponent(new Button("Say Hello", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            greetingLbl.setCaption(greetingService.sayHello(nameField.getValue().toString()));
            buttonEvents.fire(event);
        }
    }));
    layout.addComponent(greetingLbl);

    Window mainWindow = new Window("Vaadin 6.8 - Java EE Integration", layout);
    setMainWindow(mainWindow);
}