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:org.escidoc.browser.ui.useraccount.OnAddPreference.java

License:Open Source License

@Override
public void buttonClick(@SuppressWarnings("unused") final com.vaadin.ui.Button.ClickEvent event) {
    addPreference.setEnabled(false);//  ww  w. j a va2 s  .  c om
    final HorizontalLayout hl = new HorizontalLayout();
    final TextField key = new TextField();
    key.setCaption("Name");
    key.setImmediate(false);
    key.setWidth("-1px");
    key.setHeight("-1px");
    key.setInvalidAllowed(false);
    key.setRequired(true);

    final TextField value = new TextField();
    value.setCaption("Value");
    value.setImmediate(false);
    value.setWidth("-1px");
    value.setHeight("-1px");
    value.setInvalidAllowed(false);
    value.setRequired(true);

    final Button addButton = new Button();
    addButton.setIcon(new ThemeResource("images/assets/plus.png"));
    addButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(@SuppressWarnings("unused") final com.vaadin.ui.Button.ClickEvent event) {
            if (UserAccountView.isNotValid(key, value)) {
                OnAddPreference.this.userAccountView.showMessage();
            } else {
                try {
                    OnAddPreference.this.userAccountView.ur.createPreference(
                            OnAddPreference.this.userAccountView.userProxy,
                            new Preference(key.getValue().toString(), value.getValue().toString()));
                    OnAddPreference.this.userAccountView.router.getMainWindow().showNotification(
                            "Preference added successfully ", Window.Notification.TYPE_TRAY_NOTIFICATION);
                    hl.removeAllComponents();
                    addPreference.setEnabled(true);
                    userPrefTable.createItem(userPrefTable.getTableContainer(), key.getValue().toString(),
                            key.getValue().toString(), value.getValue().toString());
                } catch (final EscidocClientException e) {
                    OnAddPreference.this.userAccountView.router.getMainWindow().showNotification(
                            ViewConstants.ERROR_CREATING_USER_PREFERENCE + e.getLocalizedMessage(),
                            Window.Notification.TYPE_ERROR_MESSAGE);
                }
            }
        }

    });
    hl.addComponent(key);
    hl.addComponent(value);
    hl.addComponent(addButton);
    hl.setComponentAlignment(addButton, Alignment.BOTTOM_RIGHT);
    preferencePanel.addComponent(hl);
}

From source file:org.escidoc.browser.ui.useraccount.UserAccountView.java

License:Open Source License

static boolean isNotValid(final TextField key, final TextField value) {
    return key.getValue().toString().length() < 1 || lessThanTwoChars(value);
}

From source file:org.escidoc.browser.ui.useraccount.UserAccountView.java

License:Open Source License

private static boolean lessThanTwoChars(final TextField key) {
    return key.getValue().toString().length() < 2;
}

From source file:org.escidoc.browser.ui.view.helpers.ChangeComponentCategoryTypeHelper.java

License:Open Source License

public void showWindow() {

    subwindow = new Window("Change Category Type");
    subwindow.setModal(true);/*w  w  w .  ja  va  2 s  . c om*/

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);

    final TextField txtField = new TextField("Change Category Type");
    txtField.setValue(categoryType);
    subwindow.addComponent(txtField);

    Button close = new Button("Close", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    Button save = new Button("Save", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String newCatType = txtField.getValue().toString();
            controller.updateComponentCategory(componentId, newCatType, itemId);
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(save);
    hl.addComponent(close);

    layout.addComponent(hl);
    subwindow.setWidth("350px");
    subwindow.addComponent(layout);
    router.getMainWindow().addWindow(subwindow);

}

From source file:org.hbrs.nosql.mongoweb.gui.views.UseCase1.java

@Override
protected void setUp() {
    //MongoDB Connector
    MongoDBConnector mongo = new MongoDBConnector();

    VerticalLayout uc1 = new VerticalLayout();

    TextField uc1input = new TextField();

    uc1input.setCaption("Geben Sie ein Thema ein, welches Sie interessiert!");

    Button button = new Button("Suche");

    button.addClickListener(e -> {//from w  w w.j ava 2  s . c  om
        uc1.removeAllComponents();

        LocalTime t1 = LocalTime.now();

        // load list with values
        List uc1answer = mongo.getQuery1(uc1input.getValue());

        LocalTime t2 = LocalTime.now();
        Duration elapsed = Duration.between(t1, t2);

        // query over list
        for (int i = 0; i < uc1answer.size(); i++) {
            //create and post labels for list elements
            uc1.addComponent(new Label((String) uc1answer.get(i)));
        }

        uc1.addComponent(new Label("Time: " + elapsed));

        addComponent(uc1);
        /*
        layout.addComponent(new Label("I got " + mongo.getDocsinCollection()
            + " Docs in Store. here They are:"));
        */
    });

    addComponents(uc1input, button);
    setMargin(true);
    setSpacing(true);
}

From source file:org.hbrs.nosql.mongoweb.gui.views.UseCase3.java

@Override
protected void setUp() {
    //Add your Vaadin Coding here ;)
    //MongoDB Connector
    MongoDBConnector mongo = new MongoDBConnector();

    VerticalLayout uc3 = new VerticalLayout();

    TextField uc3input = new TextField();

    uc3input.setCaption("Geben Sie einen Professor ein und sehen Sie welche Themen dieser untersttzt hat!");

    Button button = new Button("Suche");

    button.addClickListener(e -> {/*w  ww . ja  va2  s.c o m*/
        uc3.removeAllComponents();

        LocalTime t1 = LocalTime.now();

        // load list with values
        List uc3answer = mongo.getQuery3(uc3input.getValue());

        LocalTime t2 = LocalTime.now();
        Duration elapsed = Duration.between(t1, t2);

        // query over list
        for (int i = 0; i < uc3answer.size(); i++) {
            //create and post labels for list elements
            uc3.addComponent(new Label((String) uc3answer.get(i)));
        }

        uc3.addComponent(new Label("Time: " + elapsed));

        addComponent(uc3);
    });
    addComponents(uc3input, button);
    setMargin(true);
    setSpacing(true);
}

From source file:org.hbrs.nosql.mongoweb.gui.views.UseCase4.java

@Override
protected void setUp() {
    //Add your Vaadin Coding here ;)
    //MongoDB Connector
    MongoDBConnector mongo = new MongoDBConnector();

    VerticalLayout uc4 = new VerticalLayout();

    TextField uc4input = new TextField();

    uc4input.setCaption("Geben Sie das Semester ein fr das Sie die Anzahl der Abschlsse wollen!");

    Button button = new Button("Suche");

    button.addClickListener(e -> {//from   w  w  w. j  a v  a  2  s . c o  m
        uc4.removeAllComponents();

        LocalTime t1 = LocalTime.now();

        // load list with values
        int uc4Answer = mongo.getQuery4(uc4input.getValue());

        LocalTime t2 = LocalTime.now();
        Duration elapsed = Duration.between(t1, t2);

        String uc4Answ = uc4Answer + "";
        uc4.addComponent(new Label(uc4Answ));

        uc4.addComponent(new Label("Time: " + elapsed));

        addComponent(uc4);
    });
    addComponents(uc4input, button);
    setMargin(true);
    setSpacing(true);
}

From source file:org.hbrs.nosql.mongoweb.gui.views.UseCase7.java

@Override
protected void setUp() {
    //Add your Vaadin Coding here ;)
    //Add your Vaadin Coding here ;)
    //MongoDB Connector
    MongoDBConnector mongo = new MongoDBConnector();

    VerticalLayout uc7 = new VerticalLayout();

    TextField uc7input = new TextField();

    uc7input.setCaption("Thema prfen!");

    Button button = new Button("Suche");

    button.addClickListener(e -> {//from ww w .jav  a 2 s.c om
        uc7.removeAllComponents();

        LocalTime t1 = LocalTime.now();

        // load list with values
        List uc7answer = mongo.getQuery7(uc7input.getValue());

        LocalTime t2 = LocalTime.now();
        Duration elapsed = Duration.between(t1, t2);

        // query over list
        for (int i = 0; i < uc7answer.size(); i++) {
            //create and post labels for list elements
            uc7.addComponent(new Label((String) uc7answer.get(i)));
        }

        uc7.addComponent(new Label("Time: " + elapsed));

        addComponent(uc7);
    });
    addComponents(uc7input, button);
    setMargin(true);
    setSpacing(true);
}

From source file:org.hbrs.nosql.mongoweb.gui.views.UseCase8.java

@Override
protected void setUp() {
    //Add your Vaadin Coding here ;)
    //MongoDB Connector
    MongoDBConnector mongo = new MongoDBConnector();

    VerticalLayout uc8 = new VerticalLayout();

    Label uc8label = new Label("Welche Professoren haben wieviele Arbeiten zu einem Thema betreut?");

    TextField uc8input = new TextField();
    uc8input.setCaption("Thema:");

    Button button = new Button("Suche");

    button.addClickListener(e -> {/* w w w  . java 2 s. c  o m*/
        uc8.removeAllComponents();

        LocalTime t1 = LocalTime.now();

        // load list with values
        AggregationOutput uc8answer = mongo.getQuery8(uc8input.getValue());

        LocalTime t2 = LocalTime.now();
        Duration elapsed = Duration.between(t1, t2);

        // query over list
        for (DBObject place : uc8answer.results()) {
            if (!place.get("_id").equals("")) {
                uc8.addComponent(new Label(place.get("_id") + ": " + place.get("Anzahl")));
            }
        }

        uc8.addComponent(new Label("Time: " + elapsed));

        addComponent(uc8);
    });

    addComponents(uc8label, uc8input, button);
    setMargin(true);
    setSpacing(true);
}

From source file:org.hbrs.nosql.mongoweb.gui.views.UseCaseC.java

@Override
protected void setUp() {
    MongoDBConnector mongo = new MongoDBConnector();

    VerticalLayout vl = new VerticalLayout();

    //CRUD Operations
    Label lbCreate = new Label("Create:");
    addComponent(lbCreate);//from w  w  w. j  a v a 2s.c om

    HorizontalLayout hlCreate = new HorizontalLayout();
    TextField tfCreate = new TextField("Neues Dokument:");
    hlCreate.addComponent(tfCreate);
    Button btSaveCreate = new Button("Speichern");
    btSaveCreate.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            if (!tfCreate.getValue().equals("")) {
                String doc = tfCreate.getValue();
                mongo.insertNewDocumnet(doc);
            }
        }
    });

    hlCreate.addComponent(btSaveCreate);

    addComponent(hlCreate);

    //Read: All

    //Update:
    // https://www.mkyong.com/mongodb/java-mongodb-update-document/
    // http://mongodb.github.io/mongo-java-driver/3.4/driver/getting-started/quick-start/

    //Delete: Attributes or Documents

    setMargin(true);
    setSpacing(true);
}