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.logviewer.ui.dialog.FilterLog.java

License:Open Source License

private com.vaadin.ui.Component buildContetDialog() {
    final TextField txtFilter = new TextField() {
        {/* w  w  w.j  av a 2  s.co m*/
            setWidth(100, Unit.PERCENTAGE);
        }
    };

    table = new Table("");

    table.addStyleName("small compact");
    table.setSizeFull();
    table.setImmediate(true);
    table.setSelectable(true);
    table.setEditable(false);
    table.addContainerProperty("Filter", String.class, null);
    loadTable();

    VerticalLayout panelContent = new VerticalLayout();
    panelContent.setSpacing(true);
    panelContent.setMargin(true);
    panelContent.setSizeFull();
    panelContent.setId("panel-content");
    panelContent.addComponent(new HorizontalLayout() {
        {
            addComponent(txtFilter);
            addComponent(new Button("Add", new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent clickEvent) {
                    filters.add(txtFilter.getValue());
                    loadTable();
                }
            }));
            setExpandRatio(txtFilter, 1f);
            setWidth(100, Unit.PERCENTAGE);
        }
    });
    panelContent.addComponent(table);
    panelContent.setExpandRatio(table, 1.0f);

    return panelContent;
}

From source file:com.m1kah.ui.TodoComponent.java

License:Open Source License

private void initInputRow() {
    toggleAllButton = new CheckBox();
    toggleAllButton.setId("toggle-all");

    inputField = new TextField();
    inputField.setInputPrompt("What needs to be done?");

    Panel panel = new Panel(inputField);
    panel.addShortcutListener(new ShortcutListener("", ShortcutAction.KeyCode.ENTER, null) {
        @Override//  w  ww  .j a v a 2  s .  c  om
        public void handleAction(Object o, Object o1) {
            addNewTodo();
        }
    });

    HorizontalLayout inputFieldLayout = new HorizontalLayout(toggleAllButton, panel);
    inputFieldLayout.setComponentAlignment(toggleAllButton, Alignment.MIDDLE_LEFT);
    inputFieldLayout.setId("new-todo");
    addComponent(inputFieldLayout);
}

From source file:com.m1kah.ui.TodoRow.java

License:Open Source License

private void initTodoField() {
    todoField = new TextField();
    todoField.setValue(todo.getText());// w w w.j av a 2 s. com
    todoField.setReadOnly(true);
    if (todo.isCompleted()) {
        todoField.addStyleName("completed");
    }
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.crud.SampleCrudView.java

License:Apache License

public HorizontalLayout createTopBar() {
    TextField filter = new TextField();
    filter.setStyleName("filter-textfield");
    filter.setInputPrompt("Filter");
    ResetButtonForTextField.extend(filter);
    filter.setImmediate(true);//from ww  w .j  a  v a  2  s .  c o m
    filter.addTextChangeListener(new FieldEvents.TextChangeListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            table.setFilter(event.getText());
        }
    });

    newProduct = new Button("New product");
    newProduct.addStyleName(ValoTheme.BUTTON_PRIMARY);
    newProduct.setIcon(FontAwesome.PLUS_CIRCLE);
    newProduct.addClickListener(new ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            viewLogic.newProduct();
        }
    });

    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setSpacing(true);
    topLayout.setWidth("100%");
    topLayout.addComponent(filter);
    topLayout.addComponent(newProduct);
    topLayout.setComponentAlignment(filter, Alignment.MIDDLE_LEFT);
    topLayout.setExpandRatio(filter, 1);
    topLayout.setStyleName("top-bar");
    return topLayout;
}

From source file:com.moscaville.ui.CsvVaadinUI.java

private void buildTemplateGridHeader() {
    HorizontalLayout templateGridHeaderLayout = new HorizontalLayout();
    templateGridHeaderLayout.setSpacing(true);
    templateGridHeaderLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    Button btnNew = new Button("New", FontAwesome.FILE);
    btnNew.setDescription("New template file");
    btnNew.addClickListener((Button.ClickEvent event) -> {
        templateManager.newTemplate();//from  w w w. java2  s . co  m
    });
    templateGridHeaderLayout.addComponent(btnNew);

    Button btnOpen = new Button("Open", FontAwesome.FILE_O);
    btnOpen.setDescription("Open template file");
    btnOpen.addClickListener((Button.ClickEvent event) -> {
        fileChooser.setFileExtension(FileChooser.FILE_EXTENSION_TEMPLATE);
        addWindow(fileChooser);
    });
    templateGridHeaderLayout.addComponent(btnOpen);

    Button btnSave = new Button("Save", FontAwesome.SAVE);
    tfTemplateFileName = new TextField();
    tfTemplateFileName.setDescription("template file name");
    tfTemplateFileName.setInputPrompt("template file name");
    tfTemplateFileName.setImmediate(true);
    tfTemplateFileName.addValueChangeListener((Property.ValueChangeEvent event) -> {
        btnSave.setEnabled(tfTemplateFileName.getValue() != null && tfTemplateFileName.getValue().length() > 0);
    });
    templateGridHeaderLayout.addComponent(tfTemplateFileName);

    FieldGroup binder = new FieldGroup(templateManager.getTemplateBeanItem());
    binder.setBuffered(false);
    binder.bind(tfTemplateFileName, "templateFileName");

    btnSave.setDescription("Save template file");
    btnSave.setImmediate(true);
    btnSave.setEnabled(false);
    btnSave.addClickListener((Button.ClickEvent event) -> {
        templateManager.saveTemplate();
    });
    templateGridHeaderLayout.addComponent(btnSave);

    Button btnData = new Button("Data", FontAwesome.DATABASE);
    btnData.setDescription("Load data");
    btnData.addClickListener((Button.ClickEvent event) -> {
        fileChooser.setFileExtension(FileChooser.FILE_EXTENSION_CSV);
        addWindow(fileChooser);
    });
    templateGridHeaderLayout.addComponent(btnData);

    Button btnImport = new Button("Import", FontAwesome.DOWNLOAD);

    templateGridHeaderLayout.addComponent(btnImport);
    mainLayout.addComponent(templateGridHeaderLayout);
}

From source file:com.mycollab.mobile.module.crm.view.activity.AssignmentEditFormFieldFactory.java

License:Open Source License

@Override
protected Field<?> onCreateField(Object propertyId) {
    if (propertyId.equals("startdate")) {
        return new DatePicker();
    } else if (propertyId.equals("duedate")) {
        return new DatePicker();
    } else if (propertyId.equals("status")) {
        return new TaskStatusListSelect();
    } else if (propertyId.equals("priority")) {
        return new TaskPriorityListSelect();
    } else if (propertyId.equals("description")) {
        TextArea descArea = new TextArea();
        descArea.setNullRepresentation("");
        return descArea;
    } else if (propertyId.equals("contactid")) {
        return new ContactSelectionField();
    } else if (propertyId.equals("subject")) {
        TextField tf = new TextField();

        if (isValidateForm) {
            tf.setRequired(true);//w  w  w.  ja  va2  s .  c  o m
            tf.setRequiredError("Subject must not be null");
            tf.setNullRepresentation("");
        }

        return tf;
    } else if (propertyId.equals("typeid")) {
        return new RelatedItemSelectionField(attachForm.getBean());
    } else if (propertyId.equals("type")) {
        return new DummyCustomField<String>();
    } else if (propertyId.equals("assignuser")) {
        ActiveUserComboBox userBox = new ActiveUserComboBox();
        userBox.select(attachForm.getBean().getAssignuser());
        return userBox;
    }
    return null;
}

From source file:com.mycollab.mobile.module.crm.view.activity.MeetingEditFormFieldFactory.java

License:Open Source License

@Override
protected Field<?> onCreateField(Object propertyId) {
    if (propertyId.equals("subject")) {
        TextField tf = new TextField();
        if (isValidateForm) {
            tf.setNullRepresentation("");
            tf.setRequired(true);//w ww .j  a  va  2 s  .  c  o m
            tf.setRequiredError("Subject must not be null");
        }

        return tf;
    } else if (propertyId.equals("status")) {
        return new MeetingStatusListSelect();
    } else if (propertyId.equals("startdate")) {
        return new DatePicker();
    } else if (propertyId.equals("enddate")) {
        return new DatePicker();
    } else if (propertyId.equals("description")) {
        TextArea descArea = new TextArea();
        descArea.setNullRepresentation("");
        return descArea;
    } else if (propertyId.equals("typeid")) {
        return new RelatedItemSelectionField(attachForm.getBean());
    } else if (propertyId.equals("type")) {
        return new DummyCustomField<String>();
    } else if (propertyId.equals("isrecurrence")) {
        return null;
    }
    return null;
}

From source file:com.mycollab.mobile.module.crm.view.campaign.CampaignEditFormFieldFactory.java

License:Open Source License

@Override
protected Field<?> onCreateField(Object propertyId) {

    if ("type".equals(propertyId)) {
        CampaignTypeListSelect typeCombo = new CampaignTypeListSelect();
        typeCombo.setWidth("100%");
        return typeCombo;
    } else if ("status".equals(propertyId)) {
        CampaignStatusListSelect statusCombo = new CampaignStatusListSelect();
        statusCombo.setWidth("100%");
        return statusCombo;
    } else if ("campaignname".equals(propertyId)) {
        TextField tf = new TextField();
        if (isValidateForm) {
            tf.setNullRepresentation("");
            tf.setRequired(true);/*from  w  ww  . j  av a  2s. c  o m*/
            tf.setRequiredError("Name must not be null");
        }
        return tf;
    } else if ("description".equals(propertyId)) {
        TextArea descArea = new TextArea();
        descArea.setNullRepresentation("");
        return descArea;
    } else if ("assignuser".equals(propertyId)) {
        ActiveUserComboBox userBox = new ActiveUserComboBox();
        userBox.select(attachForm.getBean().getAssignuser());
        return userBox;
    } else if (propertyId.equals("currencyid")) {
        return new CurrencyComboBoxField();
    }
    return null;
}

From source file:com.mycollab.mobile.module.crm.view.cases.CaseEditFormFieldFactory.java

License:Open Source License

@Override
protected Field<?> onCreateField(Object propertyId) {
    if (propertyId.equals("priority")) {
        return new CasePriorityListSelect();
    } else if (propertyId.equals("status")) {
        return new CaseStatusListSelect();
    } else if (propertyId.equals("reason")) {
        return new CaseReasonListSelect();
    } else if (propertyId.equals("origin")) {
        return new CasesOriginListSelect();
    } else if (propertyId.equals("type")) {
        return new CaseTypeListSelect();
    } else if (propertyId.equals("description")) {
        TextArea descArea = new TextArea("", "");
        descArea.setNullRepresentation("");
        return descArea;
    } else if (propertyId.equals("resolution")) {
        TextArea reArea = new TextArea("", "");
        reArea.setNullRepresentation("");
        return reArea;
    } else if (propertyId.equals("accountid")) {
        AccountSelectionField accountField = new AccountSelectionField();
        accountField.setRequired(true);/*from w w w.j a  v  a 2  s  .  com*/
        return accountField;
    } else if (propertyId.equals("subject")) {
        TextField tf = new TextField();
        if (isValidateForm) {
            tf.setNullRepresentation("");
            tf.setRequired(true);
            tf.setRequiredError("Subject must not be null");
        }

        return tf;
    } else if (propertyId.equals("assignuser")) {
        ActiveUserComboBox userBox = new ActiveUserComboBox();
        userBox.select(attachForm.getBean().getAssignuser());
        return userBox;
    }

    return null;
}

From source file:com.mycollab.mobile.module.crm.view.contact.ContactEditFormFieldFactory.java

License:Open Source License

@Override
protected Field<?> onCreateField(Object propertyId) {
    if (propertyId.equals("firstname") || propertyId.equals("prefix")) {
        return firstNamePrefixField;
    } else if (propertyId.equals("leadsource")) {
        return new LeadSourceListSelect();
    } else if (propertyId.equals("accountid")) {
        return new AccountSelectionField();
    } else if (propertyId.equals("lastname")) {
        TextField tf = new TextField();
        if (isValidateForm) {
            tf.setNullRepresentation("");
            tf.setRequired(true);/*w w  w. j a v  a  2  s .  com*/
            tf.setRequiredError("Last name must not be null");
        }
        return tf;
    } else if (propertyId.equals("description")) {
        TextArea descArea = new TextArea();
        descArea.setNullRepresentation("");
        return descArea;
    } else if (propertyId.equals("assignuser")) {
        ActiveUserComboBox userBox = new ActiveUserComboBox();
        userBox.select(attachForm.getBean().getAssignuser());
        return userBox;
    } else if (propertyId.equals("primcountry") || propertyId.equals("othercountry")) {
        return new CountryListSelect();
    } else if (propertyId.equals("birthday")) {
        return new BirthdayPickerField();
    }
    return null;
}