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.rdonasco.security.user.views.UserEditorView.java

License:Apache License

public UserEditorView() {

    this.retypedPasswordField = new PasswordField();
    this.passwordField = new PasswordField();
    this.logonIdField = new TextField();
    this.registrationTokenField = new TextField();
    this.registrationTokenExpirationField = new DateField();

    this.userDetailPanel = new Panel();
    this.otherDetailTab = new TabSheet();
    this.capabilitiesLayout = new HorizontalLayout();
    this.rolesLayout = new HorizontalLayout();
    this.groupsLayout = new HorizontalLayout();
    this.buttonsLayout = new HorizontalLayout();

    this.cancelButton = new Button();
    this.saveButton = new Button();
    this.editButton = new Button();
}

From source file:com.rex.components.valo.Tables.java

License:Apache License

static void configure(Table table, Grid grid, boolean footer, boolean sized, boolean expandRatios,
        boolean stripes, boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers,
        boolean compact, boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon,
        boolean componentsInRows) {

    table.setSelectable(true);/*from   w ww . j av  a  2  s. co  m*/
    table.setMultiSelect(true);
    grid.setSelectionMode(SelectionMode.MULTI);

    table.setSortEnabled(true);
    for (Column c : grid.getColumns()) {
        if (!c.getPropertyId().equals("icon")) {
            c.setSortable(true);
        }
        c.setHidable(true);
    }

    table.setColumnCollapsingAllowed(true);
    table.setColumnReorderingAllowed(true);
    grid.setColumnReorderingAllowed(true);

    table.setPageLength(6);
    grid.setHeightByRows(6);

    table.addActionHandler(ReportEngineUI.getActionHandler());
    table.setDragMode(TableDragMode.MULTIROW);
    table.setDropHandler(new DropHandler() {
        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        @Override
        public void drop(DragAndDropEvent event) {
            Notification.show(event.getTransferable().toString());
        }
    });
    table.setColumnAlignment(ReportEngineUI.DESCRIPTION_PROPERTY, Align.RIGHT);
    table.setColumnAlignment(ReportEngineUI.INDEX_PROPERTY, Align.CENTER);

    table.removeContainerProperty("textfield");
    table.removeGeneratedColumn("textfield");
    table.removeContainerProperty("button");
    table.removeGeneratedColumn("button");
    table.removeContainerProperty("label");
    table.removeGeneratedColumn("label");
    table.removeContainerProperty("checkbox");
    table.removeGeneratedColumn("checkbox");
    table.removeContainerProperty("datefield");
    table.removeGeneratedColumn("datefield");
    table.removeContainerProperty("combobox");
    table.removeGeneratedColumn("combobox");
    table.removeContainerProperty("optiongroup");
    table.removeGeneratedColumn("optiongroup");
    table.removeContainerProperty("slider");
    table.removeGeneratedColumn("slider");
    table.removeContainerProperty("progress");
    table.removeGeneratedColumn("progress");

    if (componentsInRows) {
        table.addContainerProperty("textfield", TextField.class, null);
        table.addGeneratedColumn("textfield", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                TextField tf = new TextField();
                tf.setInputPrompt("Type here");
                // tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("datefield", TextField.class, null);
        table.addGeneratedColumn("datefield", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                DateField tf = new DateField();
                tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("combobox", TextField.class, null);
        table.addGeneratedColumn("combobox", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                ComboBox tf = new ComboBox();
                tf.setInputPrompt("Select");
                tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("button", Button.class, null);
        table.addGeneratedColumn("button", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Button b = new Button("Button");
                b.addStyleName("small");
                return b;
            }
        });

        table.addContainerProperty("label", TextField.class, null);
        table.addGeneratedColumn("label", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Label label = new Label("Label component");
                label.setSizeUndefined();
                label.addStyleName("bold");
                return label;
            }
        });

        table.addContainerProperty("checkbox", TextField.class, null);
        table.addGeneratedColumn("checkbox", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                CheckBox cb = new CheckBox(null, true);
                return cb;
            }
        });

        table.addContainerProperty("optiongroup", TextField.class, null);
        table.addGeneratedColumn("optiongroup", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                OptionGroup op = new OptionGroup();
                op.addItem("Male");
                op.addItem("Female");
                op.addStyleName("horizontal");
                return op;
            }
        });

        table.addContainerProperty("slider", TextField.class, null);
        table.addGeneratedColumn("slider", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Slider s = new Slider();
                s.setValue(30.0);
                return s;
            }
        });

        table.addContainerProperty("progress", TextField.class, null);
        table.addGeneratedColumn("progress", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                ProgressBar bar = new ProgressBar();
                bar.setValue(0.7f);
                return bar;
            }
        });
    }
    table.setFooterVisible(footer);
    if (footer) {
        table.setColumnFooter(ReportEngineUI.CAPTION_PROPERTY, "caption");
        table.setColumnFooter(ReportEngineUI.DESCRIPTION_PROPERTY, "description");
        table.setColumnFooter(ReportEngineUI.ICON_PROPERTY, "icon");
        table.setColumnFooter(ReportEngineUI.INDEX_PROPERTY, "index");
    }

    if (sized) {
        table.setWidth("400px");
        grid.setWidth("400px");
        table.setHeight("300px");
        grid.setHeight("300px");
    } else {
        table.setSizeUndefined();
        grid.setSizeUndefined();
    }

    if (componentsInRows) {
        table.setWidth("100%");
    } else {
        table.setWidth(null);
    }

    if (expandRatios) {
        if (!sized) {
            table.setWidth("100%");
        }
    }
    table.setColumnExpandRatio(ReportEngineUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0);
    table.setColumnExpandRatio(ReportEngineUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0);

    if (!stripes) {
        table.addStyleName("no-stripes");
    } else {
        table.removeStyleName("no-stripes");
    }

    if (!verticalLines) {
        table.addStyleName("no-vertical-lines");
    } else {
        table.removeStyleName("no-vertical-lines");
    }

    if (!horizontalLines) {
        table.addStyleName("no-horizontal-lines");
    } else {
        table.removeStyleName("no-horizontal-lines");
    }

    if (borderless) {
        table.addStyleName("borderless");
    } else {
        table.removeStyleName("borderless");
    }

    if (!headers) {
        table.addStyleName("no-header");
    } else {
        table.removeStyleName("no-header");
    }

    if (compact) {
        table.addStyleName("compact");
    } else {
        table.removeStyleName("compact");
    }

    if (small) {
        table.addStyleName("small");
    } else {
        table.removeStyleName("small");
    }

    if (!rowIndex && !rowCaption && rowIcon) {
        table.setRowHeaderMode(RowHeaderMode.HIDDEN);
    }

    if (rowIndex) {
        table.setRowHeaderMode(RowHeaderMode.INDEX);
    }

    if (rowCaption) {
        table.setRowHeaderMode(RowHeaderMode.PROPERTY);
        table.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    } else {
        table.setItemCaptionPropertyId(null);
    }

    if (rowIcon) {
        table.setRowHeaderMode(RowHeaderMode.ICON_ONLY);
        table.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    } else {
        table.setItemIconPropertyId(null);
    }
}

From source file:com.save.client.ClientsDataGridProperties.java

public ClientsDataGridProperties(HorizontalSplitPanel hsplit, String clientModuleType) {
    this.hsplit = hsplit;
    this.clientModuleType = clientModuleType;

    setSelectionMode(SelectionMode.SINGLE);
    setSizeFull();//  ww w  .  j a  va  2s  .co m

    setContainerDataSource(container);
    addItemClickListener(this);

    // Create a header row to hold column filters
    HeaderRow filterRow = appendHeaderRow();

    // Set up a filter for all columns
    getContainerDataSource().getContainerPropertyIds().stream().filter((pid) -> (pid.equals("name")))
            .forEach((pid) -> {
                HeaderCell cell = filterRow.getCell(pid);

                // Have an input field to use for filter
                TextField filterField = new TextField();
                filterField.setWidth("100%");
                filterField.addStyleName(ValoTheme.TEXTFIELD_TINY);
                filterField.setInputPrompt("Filter");

                // Update filter When the filter input is changed
                filterField.addTextChangeListener(change -> {
                    // Can't modify filters so need to replace
                    container.removeContainerFilters(pid);

                    // (Re)create the filter if necessary
                    if (!change.getText().isEmpty())
                        container.addContainerFilter(new SimpleStringFilter(pid, change.getText(), true, true));
                    recalculateColumnWidths();
                });
                cell.setComponent(filterField);
            });

    getColumn("name").setWidth(280);
    removeColumn("id");
}

From source file:com.save.employee.EmployeesDataGridProperties.java

public EmployeesDataGridProperties(HorizontalSplitPanel hsplit, String employeeModuleType) {
    this.hsplit = hsplit;
    this.employeeModuleType = employeeModuleType;

    setContainerDataSource(container);//from  w  w  w.j  a v a  2  s .c  o  m
    addItemClickListener(this);

    // Create a header row to hold column filters
    HeaderRow filterRow = appendHeaderRow();

    // Set up a filter for all columns
    //        getContainerDataSource().getContainerPropertyIds().stream().filter((pid) -> (pid.equals("name"))).forEach((pid) -> {
    getContainerDataSource().getContainerPropertyIds().stream().forEach((pid) -> {
        HeaderCell cell = filterRow.getCell(pid);

        // Have an input field to use for filter
        TextField filterField = new TextField();
        filterField.setWidth("100%");
        filterField.addStyleName(ValoTheme.TEXTFIELD_TINY);
        filterField.setInputPrompt("Filter");

        // Update filter When the filter input is changed
        filterField.addTextChangeListener(change -> {
            // Can't modify filters so need to replace
            container.removeContainerFilters(pid);

            // (Re)create the filter if necessary
            if (!change.getText().isEmpty())
                container.addContainerFilter(new SimpleStringFilter(pid, change.getText(), true, true));
            recalculateColumnWidths();
        });
        cell.setComponent(filterField);
    });

    getColumn("name").setWidth(280);
    removeColumn("id");
}

From source file:com.shopwiki.vaadin.InlineTextForm.java

License:Apache License

public InlineTextForm(String submitCaption, Handler handler) {
    super(new TextField(), submitCaption, handler);

    this.textField = (TextField) super.getField();

    textField.addListener(new FieldEvents.FocusListener() {
        @Override// w ww. j a  v  a 2 s. c om
        public void focus(FocusEvent event) {
            textField.selectAll();
        }
    });

    //textField.setNullRepresentation("");
    //textField.setNullSettingAllowed(true);
}

From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java

private HorizontalLayout getPC() {

    VerticalLayout cAgentInfo = new VerticalLayout();
    final HorizontalLayout cPlaceholder = new HorizontalLayout();
    cAgentInfo.setMargin(new MarginInfo(true, true, true, true));
    cAgentInfo.setStyleName("c_details_test");

    final VerticalLayout cLBody = new VerticalLayout();

    cLBody.setStyleName("c_body_visible");
    tb = new Table("Linked child accounts");
    // addLinksTable();

    final VerticalLayout cAllProf = new VerticalLayout();

    HorizontalLayout cProfActions = new HorizontalLayout();
    final FormLayout cProfName = new FormLayout();

    cProfName.setStyleName("frm_profile_name");
    cProfName.setSizeUndefined();//from   w  w w . j  a  va2  s. co  m

    final Label lbProf = new Label();
    final TextField tFProf = new TextField();

    lbProf.setCaption("Profile Name: ");
    lbProf.setValue("Certified Authorized User.");

    tFProf.setCaption(lbProf.getCaption());
    cProfName.addComponent(lbProf);

    final Button btnEdit = new Button();
    btnEdit.setIcon(FontAwesome.EDIT);
    btnEdit.setStyleName("btn_link");
    btnEdit.setDescription("Edit profile name");

    final Button btnCancel = new Button();
    btnCancel.setIcon(FontAwesome.UNDO);
    btnCancel.setStyleName("btn_link");
    btnCancel.setDescription("Cancel Profile name editting.");

    Button btnAdd = new Button("+");
    // btnAdd.setIcon(FontAwesome.EDIT);
    btnAdd.setStyleName("btn_link");
    btnAdd.setDescription("Set new profile");

    Button btnRemove = new Button("-");
    // btnRemove.setIcon(FontAwesome.EDIT);
    btnRemove.setStyleName("btn_link");
    btnRemove.setDescription("Remove current profile");

    // cProf.addComponent(cProfName);
    cProfActions.addComponent(btnEdit);
    cProfActions.addComponent(btnCancel);
    cProfActions.addComponent(btnAdd);
    cProfActions.addComponent(btnRemove);

    btnCancel.setVisible(false);

    cAllProf.addComponent(cProfName);
    cAllProf.addComponent(cProfActions);
    cAllProf.setComponentAlignment(cProfActions, Alignment.TOP_CENTER);

    cLBody.addComponent(cAllProf);

    // cLBody.addComponent(tb);

    tb.setSelectable(true);

    cAgentInfo.addComponent(cLBody);

    btnLink = new Button("Add New Link");
    btnLink.setIcon(FontAwesome.LINK);
    btnLink.setDescription("Link new account.");

    // cLBody.addComponent(btnLink);
    // cLBody.setComponentAlignment(btnLink, Alignment.TOP_LEFT);
    btnLink.addClickListener(new LinkClickHandler());

    cPlaceholder.setVisible(false);
    addLinkUserContainer();
    cPlaceholder.setWidth("100%");

    cLBody.addComponent(cPlaceholder);
    cLBody.setComponentAlignment(cPlaceholder, Alignment.TOP_CENTER);
    HorizontalLayout c = new HorizontalLayout();
    c.addComponent(cAgentInfo);

    btnEdit.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -8427226211153164650L;

        @Override
        public void buttonClick(ClickEvent event) {

            if (btnEdit.getIcon().equals(FontAwesome.EDIT)) {

                tFProf.setValue(lbProf.getValue());
                tFProf.selectAll();
                cProfName.replaceComponent(lbProf, tFProf);
                btnEdit.setIcon(FontAwesome.SAVE);
                btnCancel.setVisible(true);
                return;

            } else if (btnEdit.getIcon().equals(FontAwesome.SAVE)) {

                lbProf.setValue(tFProf.getValue());
                cProfName.replaceComponent(tFProf, lbProf);
                btnEdit.setIcon(FontAwesome.EDIT);
                btnCancel.setVisible(false);

                return;
            }
            lbProf.setValue(tFProf.getValue());
            cProfName.replaceComponent(tFProf, lbProf);
            btnEdit.setIcon(FontAwesome.EDIT);
            btnCancel.setVisible(false);

        }
    });

    btnCancel.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = -2870045546205986347L;

        @Override
        public void buttonClick(ClickEvent event) {
            cProfName.replaceComponent(tFProf, lbProf);
            btnEdit.setIcon(FontAwesome.EDIT);
            btnCancel.setVisible(false);

        }
    });

    btnAdd.addClickListener(new AddProfileHandler(cAllProf, cPlaceholder));

    btnRemove.addClickListener(new RemoveProfileHandler(pop));

    return c;

}

From source file:com.tenforce.lodms.extractors.ODSCSVExtractorDialog.java

public ODSCSVExtractorDialog(ODSCSVExtractorConfig config) {
    this.config = config;
    form.setFormFieldFactory(new DefaultFieldFactory() {
        @Override/*www  .  jav  a2  s . com*/
        public Field createField(Item item, Object propertyId, Component uiContext) {
            TextField f = new TextField();
            f.setCaption(createCaptionByPropertyId(propertyId));
            f.setImmediate(true);
            f.setWidth(350, VerticalLayout.UNITS_PIXELS);
            f.addValidator(new AbstractStringValidator(null) {
                @Override
                protected boolean isValidString(String value) {
                    if (value.isEmpty())
                        return true;
                    try {
                        URL u = new URL(value);
                        return true;
                    } catch (Exception ex) {
                        setErrorMessage("Invalid Url: " + ex.getMessage());
                        return false;
                    }
                }
            });
            return f;
        }
    });
    form.setVisibleItemProperties(new String[] { "catalogCsv", "recordCsv", "datasetCsv", "distributionCsv",
            "agentCsv", "licenseCsv" });
    form.setItemDataSource(new BeanItem<ODSCSVExtractorConfig>(this.config));
    addComponent(form);
}

From source file:com.terralcode.frontend.vista.widgets.listados.ListadoAlumnosView.java

private Component addSearch() {
    searchText = new TextField();
    //searchText.setIcon(FontAwesome.EYE);
    searchText.setInputPrompt("Introduzca una cadena de bsqueda");
    searchText.addTextChangeListener(new FieldEvents.TextChangeListener() {

        @Override// ww  w. ja  v a 2  s  . c o m
        public void textChange(FieldEvents.TextChangeEvent event) {
            String search = event.getText();
            buscarAlumnos(search);
        }
    });
    searchText.setWidth("100%");
    return searchText;
}

From source file:com.terralcode.gestion.frontend.view.window.CustomerFinderDialogWindow.java

private void buildLayout() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();/*  w  w w  .  j av  a 2s .  c  o m*/

    searchText = new TextField();
    searchText.setInputPrompt("Introduzca una cadena de bsqueda");
    searchText.addTextChangeListener(new FieldEvents.TextChangeListener() {

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            String search = event.getText();
            if (search.length() > 3) {
                findCustomer(search);
            }
        }
    });
    searchText.setWidth("100%");
    vlayout.addComponent(searchText);

    resultsTable = new Table();
    resultsTable.setContainerDataSource(containerCustomers);
    resultsTable.setVisibleColumns(new Object[] { "code", "name", "customerStatus", "customerType" });
    resultsTable.setSelectable(true);
    resultsTable.setNullSelectionAllowed(false);
    resultsTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {

        @Override
        public void itemClick(ItemClickEvent event) {
            selectedCustomer = (CustomerCRM) event.getItemId();
            okButton.setEnabled(selectedCustomer != null);
        }
    });
    resultsTable.setSizeFull();
    vlayout.addComponent(resultsTable);
    vlayout.setExpandRatio(resultsTable, 1);

    setBody(vlayout);
    setFooterButtons(DialogButton.OK, DialogButton.CANCEL);
}

From source file:com.vaushell.treetasker.application.content.layout.EditTaskLayout.java

License:Open Source License

private VerticalLayout getTitleLayout() {
    if (titleLayout == null) {
        titleLayout = new VerticalLayout();
        titleLayout.setMargin(true);//from w  w  w . j a  va2 s .  com

        refreshStyle();

        vTFtaskTitleValue = new TextField();
        vTFtaskTitleValue.setWidth("100%");
        vTFtaskTitleValue.setValue(taskNode.getTask().getTitle());
        vTFtaskTitleValue.setReadOnly(true);

        titleLayout.addComponent(vTFtaskTitleValue);
    }
    return titleLayout;
}