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() 

Source Link

Document

Constructs an empty TextField with no caption.

Usage

From source file:com.fatminds.vaadin_cmis_integration.demo.DemoTemplateForm.java

License:Apache License

@AutoGenerated
private GridLayout buildGridLayout_1() {
    // common part: create layout
    gridLayout_1 = new GridLayout();
    gridLayout_1.setImmediate(false);// w w  w  .  ja va  2 s .  c o m
    gridLayout_1.setWidth("350px");
    gridLayout_1.setHeight("110px");
    gridLayout_1.setMargin(true);
    gridLayout_1.setSpacing(true);
    gridLayout_1.setRows(2);

    // label_1
    label_1 = new Label();
    label_1.setImmediate(false);
    label_1.setWidth("-1px");
    label_1.setHeight("-1px");
    label_1.setValue("Edit cmiscustom:docprop_string");
    gridLayout_1.addComponent(label_1, 0, 0);

    // txtDataItemToAddEdit
    txtDataItemToAddEdit = new TextField();
    txtDataItemToAddEdit.setImmediate(false);
    txtDataItemToAddEdit.setWidth("300px");
    txtDataItemToAddEdit.setHeight("24px");
    txtDataItemToAddEdit.setInputPrompt("Enter string value");
    txtDataItemToAddEdit.setSecret(false);
    gridLayout_1.addComponent(txtDataItemToAddEdit, 0, 1);

    return gridLayout_1;
}

From source file:com.foc.vaadin.gui.components.FVEmailField.java

License:Apache License

public TextField getEmailText() {
    if (emailText == null) {
        emailText = new TextField();
    }
    return emailText;
}

From source file:com.foc.vaadin.gui.windows.AddTabWindow.java

License:Apache License

public AddTabWindow(final TabSheet tabSheet, final VerticalLayout addTabLayout) {
    super("Add New Tab");
    setModal(true);//from w  w w  .  j a  va2 s .co  m
    setWidth("264px");
    setHeight("272px");

    layout = new VerticalLayout();
    buttonsLayout = new HorizontalLayout();
    optionsLayout = new VerticalLayout();
    seperateLayout = new VerticalLayout();

    tabName = new TextField();
    tabNameWrapper = new FVWrapperLayout(tabName, "Tab Name:", width);
    layoutHeight = new TextField();
    heightWrapper = new FVWrapperLayout(layoutHeight, "Height:", width);
    layoutWidth = new TextField();
    widthWrapper = new FVWrapperLayout(layoutWidth, "Width:", width);
    innerLayout = new ComboBox();
    innerLayoutWrapper = new FVWrapperLayout(innerLayout, "Layout Type:", width);

    for (int i = 0; i < layoutTypes.length; i++) {
        innerLayout.addItem(layoutTypes[i]);
    }

    innerLayout.setImmediate(true);
    innerLayout.setNullSelectionAllowed(false);
    innerLayout.setValue(layoutTypes[0]);

    innerLayout.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            String layoutType = event.getProperty().toString();

            if (layoutType.equals(FXML.TAG_GRID_LAYOUT)) {
                layoutCols = new TextField();
                colsWrapper = new FVWrapperLayout(layoutCols, "Columns:", width);
                layoutRows = new TextField();
                rowsWrapper = new FVWrapperLayout(layoutRows, "Rows:", width);

                optionsLayout.addComponent(colsWrapper);
                optionsLayout.addComponent(rowsWrapper);

                setHeight("350px");

            } else {

                if (layoutCols != null) {
                    optionsLayout.removeComponent(colsWrapper);
                    layoutCols = null;
                    colsWrapper = null;
                }

                if (layoutRows != null) {
                    optionsLayout.removeComponent(rowsWrapper);
                    layoutRows = null;
                    rowsWrapper = null;
                }

                setHeight("272px");
            }
        }
    });

    create = new Button("Create");
    cancel = new Button("Cancel");

    cancel.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });

    create.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            String layoutType = innerLayout.getValue().toString();

            AttributesImpl attributes = new AttributesImpl();

            attributes.addAttribute("", "name", "name", "CDATA", "null");
            attributes.addAttribute("", "height", "height", "CDATA",
                    layoutHeight.getValue().toString().isEmpty() ? "-1px"
                            : layoutHeight.getValue().toString() + "px");
            attributes.addAttribute("", "width", "width", "CDATA",
                    layoutWidth.getValue().toString().isEmpty() ? "-1px"
                            : layoutWidth.getValue().toString() + "px");

            if (layoutType.equals(FXML.TAG_ABSOLUTE_LAYOUT)) {
                selectedLayout = new FVAbsoluteLayout(attributes);
            } else if (layoutType.equals(FXML.TAG_VERTICAL_LAYOUT)) {
                selectedLayout = new FVVerticalLayout(attributes);
            } else if (layoutType.equals(FXML.TAG_HORIZONTAL_LAYOUT)) {
                selectedLayout = new FVHorizontalLayout(attributes);
            } else {

                attributes.addAttribute("", "rows", "rows", "CDATA", layoutRows.getValue().toString());
                attributes.addAttribute("", "cols", "cols", "CDATA", layoutCols.getValue().toString());

                selectedLayout = new FVGridLayout(attributes);
            }

            tabSheet.removeTab(tabSheet.getTab(addTabLayout));
            tabSheet.addTab((Component) selectedLayout, tabName.getValue().toString());
            tabSheet.addTab(addTabLayout, "+");
            close();
        }
    });

    optionsLayout.setSpacing(true);
    optionsLayout.addComponent(widthWrapper);
    optionsLayout.addComponent(heightWrapper);

    seperateLayout.setHeight("25px");

    buttonsLayout.setSpacing(true);
    buttonsLayout.addComponent(create);
    buttonsLayout.addComponent(cancel);

    layout.setSpacing(true);
    layout.addComponent(tabNameWrapper);
    layout.addComponent(innerLayoutWrapper);
    layout.addComponent(optionsLayout);
    layout.addComponent(seperateLayout);
    layout.addComponent(buttonsLayout);

    layout.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_CENTER);

    setContent(layout);
}

From source file:com.garyclayburg.vconsole.VConsole.java

License:Open Source License

protected void init(VaadinRequest vaadinRequest) {
    final Refresher refresher = new Refresher();
    refresher.addListener(new Refresher.RefreshListener() {
        @Override/*  w w  w . j av  a  2 s  . com*/
        public void refresh(Refresher refresher) {
            //                log.debug("refreshing UI...");
        }
    });
    addExtension(refresher);

    addStyleName("dashboard-view");
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    setContent(layout);

    searchStatus = new Label("0 users matching: ");
    TextField searchField = new TextField();
    searchField.setInputPrompt("first or last name");
    searchField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.LAZY);
    searchField.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            String searchText = event.getText();
            log.debug("search: {}", searchText);
            QUser qUser = new QUser("user");
            long startSearch = System.nanoTime();
            if (searchText.length() > 2) {
                Iterable<User> searchedUsers = autoUserRepo.findAll(qUser.firstname
                        .containsIgnoreCase(searchText).or(qUser.lastname.containsIgnoreCase(searchText)));
                long endSearch = System.nanoTime();
                log.info("Finshed searching for \"{}\" in {} secs", searchText,
                        ((endSearch - startSearch) / 1000000000.0));
                searchStatus.setValue("? users matching: " + searchText);
                updateUserList(searchedUsers, searchText);
            } else if (searchText.equals("*")) {
                Iterable<User> searchedUsers = autoUserRepo.findAll();
                long endSearch = System.nanoTime();
                log.info("Searched for \"{}\" in {} secs", searchText,
                        ((endSearch - startSearch) / 1000000000.0));
                searchStatus.setValue("? users matching: " + searchText);
                updateUserList(searchedUsers, searchText);

            } else {
                log.debug("not enough chars");
                searchStatus.setValue("* for all users...");
            }
        }
    });

    createExceptionWindow("no errors yet...");

    final User finalFirstUser = firstUser;
    policyChangeController.addChangeListener(new PolicyChangeListener() {
        @Override
        public void policyChanged() {
            log.info("policy is changing");
            BeanContainer beanContainer = (BeanContainer) userTable.getContainerDataSource();
            List itemIds = beanContainer.getItemIds();
            boolean refreshedSelected = false;
            for (Object itemId : itemIds) {
                String id = (String) itemId;
                BeanItem item = beanContainer.getItem(itemId);
                log.debug("refreshing user id: " + id);
                User user = (User) item.getBean();
                log.debug("refreshing user: " + user.getFirstname());
                if (userTable.isSelected(itemId)) {
                    refreshUserValues(user);
                    refreshedSelected = true;
                }
            }
            log.debug("forcing table update");
            updateRightClickItems();
            log.debug("forcing table update complete");
            if (!refreshedSelected && finalFirstUser != null) {
                refreshUserValues(finalFirstUser);
            }
            int numErrors = populatePolicyExceptionList(); // this will catch runtime errors not caught during groovy compile
            if (numErrors == 0) {
                showPolicyUpdated();
            }
        }

        @Override
        public void policyException(Throwable e) {
            populatePolicyExceptionList(); //cannot compile operator supplied groovy?
        }
    });
    attributeTable = new Table();
    attributeTable.setSizeFull();
    attributeTable.setSelectable(true);
    attributeTable.setMultiSelect(false);
    attributeTable.setImmediate(true);

    attributesBeanContainer = new BeanContainer<>(GeneratedAttributesBean.class);
    attributesBeanContainer.setBeanIdProperty("attributeName");

    attributeTable.setContainerDataSource(attributesBeanContainer);

    BeanContainer<String, User> userBeanContainer = new BeanContainer<>(User.class);
    userBeanContainer.setBeanIdProperty("id");
    userTable = createUserTable(userBeanContainer);
    userTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            User selectedUser = (User) ((BeanItem) event.getItem()).getBean();
            refreshUserValues(selectedUser);
            populatePolicyExceptionList(); // maybe this user clicked on causes runtime exception in groovy?
        }
    });
    HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
    splitPanel.setSizeFull();
    splitPanel.setSplitPosition(150, Unit.PIXELS);
    splitPanel.setFirstComponent(userTable);
    splitPanel.setSecondComponent(attributeTable);

    //        MenuBar menuBar = createMenu();

    //        layout.addComponent(menuBar);

    HorizontalLayout top = createTop();
    populatePolicyExceptionList(); //initial check for groovy errors
    layout.addComponent(top);

    layout.addComponent(searchField);
    layout.addComponent(searchStatus);
    layout.addComponent(splitPanel);
    populateItems(firstUser, attributesBeanContainer);

}

From source file:com.github.cjm.TmdbUI.java

private void addTvShowGrid() {

    tvShowGridLayout.setSpacing(true);/*ww  w . j  a va2s. c o  m*/
    tvShowGridLayout.setWidth("100%");
    tvShowGrid = new Grid();
    tvShowGrid.setSizeFull();
    tvShows = new BeanItemContainer<>(TvShow.class);
    tvShowGrid.setColumns("name", "popularity", "voteAverage", "firstAirDate");
    tvShowGrid.setHeaderVisible(true);
    tvShowGrid.setContainerDataSource(tvShows);
    HeaderRow filterRow = tvShowGrid.appendHeaderRow();
    // Not really loading "all"; multiple pages up to some reasonable/polite limit 
    // (API is throttled and this is a demo afterall).
    tvShows.addAll(
            tvShowService.loadAll(TvShowService.RESOURCE_TV_POPULAR, TvShowCollection.class).getResults());
    tvShowGridLayout.addComponent(tvShowGrid);
    mainLayout.addComponent(tvShowGridLayout);

    tvShowGrid.getContainerDataSource().getContainerPropertyIds().stream().forEach((pid) -> {
        if (tvShowGrid.getColumn(pid) != null) {
            Grid.HeaderCell cell = filterRow.getCell(pid);

            TextField filterField = new TextField();
            filterField.setColumns(8);
            // Update filter When the filter input is changed
            filterField.addTextChangeListener(change -> {
                // Can't modify filters so need to replace
                tvShows.removeContainerFilters(pid);
                // (Re)create the filter if necessary
                if (!change.getText().isEmpty()) {
                    tvShows.addContainerFilter(new SimpleStringFilter(pid, change.getText(), true, false));
                }
            });
            filterField.setImmediate(true);
            cell.setComponent(filterField);

        }
    });

    SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
    DateRenderer dateRenderer = new DateRenderer(dateFormat);
    tvShowGrid.getColumn("firstAirDate").setRenderer(dateRenderer);

    tvShowGrid.addItemClickListener((ItemClickEvent event) -> {
        if (event.isDoubleClick()) {
            User u = (User) username.getValue();
            if (u != null) {
                users.removeItem(u);
                TvShow tvShow = getSelectedTvShow();
                if (tvShow != null) {
                    favorites.addBean(tvShow);
                    List<Integer> i = new ArrayList<>();
                    favorites.getItemIds().stream().forEach((t) -> {
                        i.add(t.getId());
                    });
                    u.setFavoriteTvShows(new Integer[i.size()]);
                    u.setFavoriteTvShows(i.toArray(u.getFavoriteTvShows()));
                    userDao.save(u);
                    users.addBean(u);
                }
            }
        }
    });

}

From source file:com.github.daytron.twaattin.ui.LoginScreen.java

License:Open Source License

public LoginScreen() {

    this.twitterLink = new Link();
    this.pinField = new TextField();

    this.submitButton = new Button("Submit");

    setMargin(true);//w  w  w .j  ava  2 s .c  o  m
    setSpacing(true);
    try {
        twitterLink.setCaption("Get PIN");
        twitterLink.setTargetName("twitterauth");
        twitterLink.setResource(new ExternalResource(TwitterService.get().getAuthenticationUrl()));

        pinField.setInputPrompt("PIN");

        addComponent(twitterLink);
        addComponent(pinField);
        addComponent(submitButton);

        submitButton.addClickListener(new LoginBehaviour(pinField));
    } catch (TwitterException ex) {
        Logger.getLogger(LoginScreen.class.getName()).log(Level.SEVERE, null, ex);
        throw new InstantiationError();

    }
}

From source file:com.github.fbhd.view.TicketView.java

private void createDetail() {
    detailLayout = new HorizontalLayout();
    tfSummary = new TextField();
    tfSummary.setInputPrompt("Summary");
    detailLayout.addComponent(tfSummary);
    mainLayout.addComponent(detailLayout);
}

From source file:com.github.mjvesa.herd.HerdIDE.java

License:Apache License

private TextField createFileName() {
    final TextField tf = new TextField();
    return tf;
}

From source file:com.github.mjvesa.herd.wordset.VaadinWordSet.java

License:Apache License

@Override
public Word[] getWords() {
    return new Word[] {

            new BaseWord("new-button", "", Word.POSTPONED) {

                private static final long serialVersionUID = -2492817908731559368L;

                @Override//from w  w  w .  j  a va  2s. com
                public void execute(final Interpreter interpreter) {

                    Button b = new Button("", new Button.ClickListener() {
                        private static final long serialVersionUID = -4622489800920283752L;

                        @Override
                        public void buttonClick(ClickEvent event) {
                            Button b = event.getButton();
                            Word command = (Word) b.getData();
                            if (command != null) {
                                interpreter.execute(command);
                            }
                        }
                    });
                    interpreter.pushData(b);
                }
            },

            new BaseWord("set-click-listener", "", Word.POSTPONED) {

                private static final long serialVersionUID = 5749856686458297558L;

                @Override
                public void execute(Interpreter interpreter) {
                    Object o = interpreter.popData();
                    Button b = (Button) interpreter.popData();
                    b.setData(o);
                    interpreter.pushData(b);
                }
            },

            new BaseWord("new-hl", "", Word.POSTPONED) {

                private static final long serialVersionUID = 8813556668649386248L;

                @Override
                public void execute(Interpreter interpreter) {
                    HorizontalLayout hl = new HorizontalLayout();
                    hl.setSpacing(true);
                    interpreter.pushData(hl);
                }
            },

            new BaseWord("new-vl", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1848213448504804229L;

                @Override
                public void execute(Interpreter interpreter) {
                    VerticalLayout vl = new VerticalLayout();
                    vl.setSpacing(true);
                    interpreter.pushData(vl);
                }
            },

            new BaseWord("new-gl", "( x y - gl )", Word.POSTPONED) {

                private static final long serialVersionUID = 4079634885691605257L;

                @Override
                public void execute(Interpreter interpreter) {
                    Integer height = (Integer) interpreter.popData();
                    Integer width = (Integer) interpreter.popData();
                    interpreter.pushData(new GridLayout(width, height));
                }
            },

            new BaseWord("gl-new-line", "", Word.POSTPONED) {

                private static final long serialVersionUID = 975877390052961807L;

                @Override
                public void execute(Interpreter interpreter) {
                    ((GridLayout) interpreter.peekData()).newLine();
                }
            },

            new BaseWord("new-window", "", Word.POSTPONED) {

                private static final long serialVersionUID = -6887364362728545090L;

                @Override
                public void execute(Interpreter interpreter) {
                    Window w = new Window();
                    VerticalLayout vl = new VerticalLayout();
                    vl.setSpacing(true);
                    w.setContent(vl);
                    interpreter.pushData(w);
                    interpreter.pushData(vl);
                }
            },

            new BaseWord("main-panel", "", Word.POSTPONED) {

                private static final long serialVersionUID = -8622281600566696475L;

                @Override
                public void execute(Interpreter interpreter) {
                    interpreter.pushData(interpreter.getMainPanel());
                }
            },

            new BaseWord("add-window", "", Word.POSTPONED) {

                private static final long serialVersionUID = 7106029415576813922L;

                @Override
                public void execute(Interpreter interpreter) {
                    Window w = (Window) interpreter.popData();
                    interpreter.getView().getUI().addWindow(w);
                }
            },

            new BaseWord("add-component", "", Word.POSTPONED) {

                private static final long serialVersionUID = 5640824046985354091L;

                @Override
                public void execute(Interpreter interpreter) {
                    Component comp = (Component) interpreter.popData();
                    ComponentContainer cc = (ComponentContainer) interpreter.popData();
                    cc.addComponent(comp);
                    interpreter.pushData(cc);
                }
            },

            new BaseWord("set-caption", "", Word.POSTPONED) {

                private static final long serialVersionUID = 5497598050469462487L;

                @Override
                public void execute(Interpreter interpreter) {
                    String s = (String) interpreter.popData();
                    Component c = (Component) interpreter.popData();
                    c.setCaption(s);
                    interpreter.pushData(c);
                }
            },

            new BaseWord("set-value", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1769743552659215058L;

                @Override
                public void execute(Interpreter interpreter) {
                    Object o = interpreter.popData();
                    Property p = (Property) interpreter.popData();
                    p.setValue(o);
                    interpreter.pushData(p);
                }
            },

            new BaseWord("get-value", "", Word.POSTPONED) {

                private static final long serialVersionUID = 8445550546521886374L;

                @Override
                public void execute(Interpreter interpreter) {
                    Field f = (Field) interpreter.popData();
                    interpreter.pushData(f);
                    interpreter.pushData(f.getValue());

                }
            },

            new BaseWord("set-size-full", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1206491811133054467L;

                @Override
                public void execute(Interpreter interpreter) {
                    Component comp = (Component) interpreter.popData();
                    comp.setSizeFull();
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("set-size-undefined", "", Word.POSTPONED) {

                private static final long serialVersionUID = -3450618729379622987L;

                @Override
                public void execute(Interpreter interpreter) {
                    Component comp = (Component) interpreter.popData();
                    comp.setSizeUndefined();
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("set-height", "", Word.POSTPONED) {

                private static final long serialVersionUID = -8426734568403715950L;

                @Override
                public void execute(Interpreter interpreter) {
                    String str = (String) interpreter.popData();
                    Component comp = (Component) interpreter.popData();
                    comp.setHeight(str);
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("set-width", "", Word.POSTPONED) {

                private static final long serialVersionUID = -4558264143049463814L;

                @Override
                public void execute(Interpreter interpreter) {
                    String str = (String) interpreter.popData();
                    Component comp = (Component) interpreter.popData();
                    comp.setWidth(str);
                    interpreter.pushData(comp);
                }
            },

            new BaseWord("clear-container", "", Word.POSTPONED) {

                private static final long serialVersionUID = 1070175466682034329L;

                @Override
                public void execute(Interpreter interpreter) {
                    ComponentContainer cc = (ComponentContainer) interpreter.popData();
                    cc.removeAllComponents();
                }
            },

            new BaseWord("new-check-box", "", Word.POSTPONED) {

                private static final long serialVersionUID = 4018632924389912599L;

                @Override
                public void execute(Interpreter interpreter) {
                    interpreter.pushData(new CheckBox());
                }
            },

            new BaseWord("new-date-field", "", Word.POSTPONED) {

                private static final long serialVersionUID = 6313296566085274642L;

                @Override
                public void execute(final Interpreter interpreter) {
                    interpreter.pushData(new DateField());
                    final String dfCommand = (String) interpreter.popData();
                    DateField df = new DateField();
                    df.setImmediate(true);
                    df.addValueChangeListener(new ValueChangeListener() {
                        /**
                        * 
                        */
                        private static final long serialVersionUID = 1472139878970514093L;

                        public void valueChange(ValueChangeEvent event) {
                            interpreter.pushData(event.getProperty().getValue());
                            interpreter.interpret(dfCommand);
                        }

                    });
                    interpreter.pushData(df);
                }
            },

            new BaseWord("new-label", "", Word.POSTPONED) {

                private static final long serialVersionUID = -2825285195439247251L;

                @Override
                public void execute(Interpreter interpreter) {
                    interpreter.pushData(new Label());
                }
            },

            new BaseWord("new-text-field", "", Word.POSTPONED) {

                private static final long serialVersionUID = -1064489458253275380L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String tfCommand = interpreter.getNextNonNopWord();
                    TextField tf = new TextField();
                    tf.setCaption((String) interpreter.popData());
                    tf.setValue("");
                    tf.setImmediate(true);
                    tf.addValueChangeListener(new ValueChangeListener() {
                        private static final long serialVersionUID = 4325104922208051065L;

                        public void valueChange(ValueChangeEvent event) {
                            interpreter.pushData(event.getProperty().getValue());
                            interpreter.interpret(tfCommand);
                        }
                    });
                    interpreter.pushData(tf);
                }
            },

            new BaseWord("new-table", "", Word.POSTPONED) {

                private static final long serialVersionUID = -5052653341575232035L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String tableCommand = interpreter.getParser().getNextWord();
                    Table table = new Table();
                    table.setCaption((String) interpreter.popData());
                    table.setImmediate(true);
                    table.setSelectable(true);
                    table.addItemClickListener(new ItemClickListener() {

                        /**
                        *
                        */
                        private static final long serialVersionUID = 3585546076571010729L;

                        public void itemClick(ItemClickEvent event) {

                            interpreter.pushData(event.getItem());
                            interpreter.execute(interpreter.getDictionary().get(tableCommand));
                        }
                    });
                    interpreter.pushData(table);
                }
            },

            new BaseWord("new-combo-box", "", Word.POSTPONED) {

                private static final long serialVersionUID = 3881577354424928897L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String newItemCommand = interpreter.getParser().getNextWord();
                    final String itemSelectedCommand = interpreter.getParser().getNextWord();
                    final ComboBox cb = new ComboBox();
                    String str = (String) interpreter.popData();
                    cb.setNullSelectionAllowed(false);
                    cb.setCaption(str);
                    cb.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
                    cb.setNewItemsAllowed(true);
                    cb.setNewItemHandler(new NewItemHandler() {

                        /**
                        *
                        */
                        private static final long serialVersionUID = 3340658590351611289L;

                        public void addNewItem(String newItemCaption) {
                            cb.setImmediate(false);
                            interpreter.pushData(newItemCaption);
                            interpreter.interpret(newItemCommand);
                            cb.setImmediate(true);
                        }
                    });

                    cb.addValueChangeListener(new ValueChangeListener() {

                        /**
                        *
                        */
                        private static final long serialVersionUID = 2706579869793251379L;

                        public void valueChange(ValueChangeEvent event) {
                            interpreter.pushData(
                                    cb.getContainerDataSource().getItem(event.getProperty().getValue()));
                            interpreter.interpret(itemSelectedCommand);
                        }
                    });
                    cb.setImmediate(true);
                    interpreter.pushData(cb);
                }
            },

            new BaseWord("new-select", "", Word.POSTPONED) {

                private static final long serialVersionUID = -6142351970812196488L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String selCommand = interpreter.getParser().getNextWord();
                    final ComboBox sel = new ComboBox();
                    sel.setCaption((String) interpreter.popData());
                    sel.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
                    sel.setNullSelectionAllowed(false);
                    sel.setImmediate(true);
                    sel.addValueChangeListener(new ValueChangeListener() {
                        /**
                        *
                        */
                        private static final long serialVersionUID = -7705548618092166199L;

                        public void valueChange(ValueChangeEvent event) {
                            Item item = sel.getContainerDataSource().getItem(event.getProperty().getValue());
                            interpreter.pushData(item);
                            interpreter.interpret(selCommand);
                        }
                    });
                    interpreter.pushData(sel);
                }
            },

            new BaseWord("new-list-select", "", Word.POSTPONED) {
                private static final long serialVersionUID = 8686093227035249035L;

                @Override
                public void execute(final Interpreter interpreter) {
                    final String lselCommand = interpreter.getParser().getNextWord();
                    final ListSelect lsel = new ListSelect();
                    lsel.setCaption((String) interpreter.popData());
                    lsel.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM);
                    lsel.setNullSelectionAllowed(false);
                    lsel.setImmediate(true);
                    lsel.addValueChangeListener(new ValueChangeListener() {
                        private static final long serialVersionUID = -5523488417834167806L;

                        public void valueChange(ValueChangeEvent event) {
                            Item item = lsel.getContainerDataSource().getItem(event.getProperty().getValue());
                            interpreter.pushData(item);
                            interpreter.interpret(lselCommand);
                        }
                    });
                    interpreter.pushData(lsel);
                }
            },

            new BaseWord("set-container-data-source", "", Word.POSTPONED) {
                private static final long serialVersionUID = 8644721936358613031L;

                @Override
                public void execute(Interpreter interpreter) {
                    Container cont = (Container) interpreter.popData();
                    AbstractSelect as = (AbstractSelect) interpreter.popData();
                    as.setContainerDataSource(cont);
                    interpreter.pushData(as);
                }
            },

            new BaseWord("set-column-headers", "", Word.POSTPONED) {
                private static final long serialVersionUID = -7296881714369214846L;

                @Override
                public void execute(Interpreter interpreter) {
                    Table table = (Table) interpreter.popData();
                    table.setColumnHeaders((String[]) getArrayFromList(interpreter, new String[0]));
                }
            },

            new BaseWord("set-visible-columns", "", Word.POSTPONED) {
                private static final long serialVersionUID = 5674765074478598320L;

                @Override
                public void execute(Interpreter interpreter) {
                    Table table = (Table) interpreter.popData();
                    table.setVisibleColumns((String[]) getArrayFromList(interpreter, new String[0]));
                }
            }

    };
}

From source file:com.github.moscaville.contactsdb.main.DetailView.java

private TextField createTextField(String inputPrompt, HorizontalLayout horizontalLayout) {
    TextField textField = new TextField();
    textField.setInputPrompt(inputPrompt);
    textField.setImmediate(true);//  w ww  .  j a  va  2s  .  c  o  m
    textField.setNullRepresentation("");
    if (horizontalLayout != null) {
        horizontalLayout.addComponent(textField);
    }
    textField.addListener((Event event) -> {
        enableButtons(true);
    });
    return textField;
}