Example usage for com.vaadin.v7.ui TextField TextField

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

Introduction

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

Prototype

public TextField(Property dataSource) 

Source Link

Document

Constructs a new TextField that's bound to the specified Property and has no caption.

Usage

From source file:org.esn.esobase.view.tab.BookTranslateTab.java

public BookTranslateTab(DBService service) {
    this.service = service;
    this.setSizeFull();
    FilterChangeListener filterChangeListener = new FilterChangeListener();
    bookListlayout = new HorizontalLayout();
    bookListlayout.setWidth(100f, Unit.PERCENTAGE);
    bookTable = new ComboBox("");
    bookTable.setPageLength(20);//from  w ww . j  a  v a 2s . c o m
    bookTable.setScrollToSelectedItem(true);
    bookTable.setDataProvider(new ListDataProvider<>(books));
    bookTable.addValueChangeListener(new BookSelectListener());

    bookTable.setWidth(100f, Unit.PERCENTAGE);
    locationTable = new ComboBox("?");
    locationTable.setPageLength(15);
    locationTable.setScrollToSelectedItem(true);

    locationTable.setWidth(100f, Unit.PERCENTAGE);
    locationTable.setDataProvider(new ListDataProvider<>(locations));

    locationTable.addValueChangeListener(filterChangeListener);

    subLocationTable = new ComboBox("?");
    subLocationTable.setPageLength(15);
    subLocationTable.setScrollToSelectedItem(true);
    subLocationTable.addValueChangeListener(filterChangeListener);

    subLocationTable.setWidth(100f, Unit.PERCENTAGE);
    subLocationTable.setDataProvider(new ListDataProvider<>(subLocations));

    FormLayout locationAndBook = new FormLayout(locationTable, subLocationTable, bookTable);
    locationAndBook.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    locationAndBook.setSizeFull();

    bookListlayout.addComponent(locationAndBook);
    translateStatus = new ComboBoxMultiselect("? ",
            Arrays.asList(TRANSLATE_STATUS.values()));
    translateStatus.setClearButtonCaption("?");
    translateStatus.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            LoadFilters();
        }
    });
    noTranslations = new CheckBox("?  ?");
    noTranslations.setValue(Boolean.FALSE);
    noTranslations.addValueChangeListener(filterChangeListener);
    emptyTranslations = new CheckBox("?  ");
    emptyTranslations.setValue(Boolean.FALSE);
    emptyTranslations.addValueChangeListener(filterChangeListener);
    HorizontalLayout checkBoxlayout = new HorizontalLayout(noTranslations, emptyTranslations);
    translatorBox = new ComboBox("");
    translatorBox.setPageLength(15);
    translatorBox.setScrollToSelectedItem(true);
    translatorBox.setDataProvider(new ListDataProvider(service.getSysAccounts()));
    translatorBox.addValueChangeListener(filterChangeListener);
    refreshButton = new Button("");
    refreshButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            LoadFilters();
            LoadBookContent();
        }
    });
    countLabel = new Label();
    searchField = new TextField("?? ?");
    searchField.setSizeFull();
    searchField.setNullRepresentation("");
    searchField.addValueChangeListener(filterChangeListener);

    FormLayout filtersLayout = new FormLayout(translateStatus, translatorBox, checkBoxlayout, searchField);
    filtersLayout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    filtersLayout.setSizeFull();
    bookListlayout.addComponent(filtersLayout);
    bookListlayout.addComponent(refreshButton);
    bookListlayout.addComponent(countLabel);
    bookListlayout.setExpandRatio(locationAndBook, 0.4f);
    bookListlayout.setExpandRatio(filtersLayout, 0.4f);
    bookListlayout.setExpandRatio(refreshButton, 0.1f);
    bookListlayout.setExpandRatio(countLabel, 0.1f);
    bookListlayout.setHeight(105f, Unit.PIXELS);

    bookContentLayout = new TabSheet();
    bookContentLayout.setSizeFull();
    bookNameLayout = new HorizontalLayout();
    bookNameLayout.setSizeFull();
    bookNameOrigLayout = new VerticalLayout();
    bookNameEn = new TextField("?");
    bookNameEn.setWidth(500f, Unit.PIXELS);
    bookNameRu = new TextField(" ?");
    bookNameRu.setWidth(500f, Unit.PIXELS);
    bookNameRu.setNullRepresentation("");
    bookNameOrigLayout.addComponent(bookNameEn);
    bookNameOrigLayout.addComponent(bookNameRu);
    bookNameLayout.addComponent(bookNameOrigLayout);
    bookNameTranslationsLayout = new VerticalLayout();
    bookNameTranslationsLayout.setSizeFull();
    bookNameLayout.addComponent(bookNameTranslationsLayout);
    bookContentLayout.addTab(bookNameLayout, "?");

    bookTextLayout = new HorizontalLayout();
    bookTextLayout.setSizeFull();
    bookTextOrigLayout = new HorizontalLayout();
    bookTextOrigLayout.setSizeFull();
    bookTextEn = new TextArea("?");
    bookTextEn.setRows(20);
    bookTextEn.setSizeFull();
    bookTextRu = new TextArea(" ?");
    bookTextRu.setRows(20);
    bookTextRu.setSizeFull();
    bookTextRu.setNullRepresentation("");
    bookTextOrigLayout.addComponent(bookTextEn);
    bookTextOrigLayout.addComponent(bookTextRu);
    bookTextLayout.addComponent(bookTextOrigLayout);
    bookTextTranslationsLayout = new VerticalLayout();
    bookTextTranslationsLayout.setSizeFull();
    bookTextLayout.addComponent(bookTextTranslationsLayout);
    bookTextLayout.setExpandRatio(bookTextOrigLayout, 2f);
    bookTextLayout.setExpandRatio(bookTextTranslationsLayout, 1f);
    bookContentLayout.addTab(bookTextLayout, "?");
    bookNameEn.setReadOnly(true);
    bookNameRu.setReadOnly(true);
    bookTextEn.setReadOnly(true);
    bookTextRu.setReadOnly(true);
    this.addComponent(bookListlayout);
    this.addComponent(bookContentLayout);
    this.bookListlayout.setHeight(105f, Unit.PIXELS);
    this.setExpandRatio(bookContentLayout, 1f);
    new NoAutcompleteComboBoxExtension(locationTable);
    new NoAutcompleteComboBoxExtension(subLocationTable);
    new NoAutcompleteComboBoxExtension(translatorBox);
    LoadFilters();
}

From source file:org.esn.esobase.view.tab.QuestsTab.java

public QuestsTab(DBService service) {
    this.service = service;
    actions = new HorizontalLayout();
    refreshButton = new Button("");
    refreshButton.addClickListener(new Button.ClickListener() {

        @Override/* ww  w. j a  v a2 s. c  o  m*/
        public void buttonClick(Button.ClickEvent event) {
            LoadTable();
            CloseForm();
        }
    });
    actions.addComponent(refreshButton);
    addButton = new Button("");
    addButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            AddItem();
        }
    });
    actions.addComponent(addButton);
    this.addComponent(actions);
    tableAndForm = new HorizontalLayout();
    tableAndForm.setSizeFull();
    table = new Table();
    table.setSizeFull();
    container = new BeanItemContainer<>(Quest.class);
    table.setContainerDataSource(container);

    table.setVisibleColumns(new Object[] { "name", "nameRu", "progress" });
    table.setColumnHeaders(new String[] { "?", " ?",
            "? " });
    table.setConverter("progress", new Converter<String, BigDecimal>() {

        @Override
        public BigDecimal convertToModel(String value, Class<? extends BigDecimal> targetType, Locale locale)
                throws Converter.ConversionException {
            return null;
        }

        @Override
        public String convertToPresentation(BigDecimal value, Class<? extends String> targetType, Locale locale)
                throws Converter.ConversionException {
            String r = "";
            if (value != null) {
                r = value.multiply(BigDecimal.valueOf(100L).setScale(2, RoundingMode.HALF_DOWN))
                        .setScale(0, RoundingMode.HALF_UP).toString() + "%";
            }
            return r;
        }

        @Override
        public Class<BigDecimal> getModelType() {
            return BigDecimal.class;
        }

        @Override
        public Class<String> getPresentationType() {
            return String.class;
        }

    });
    table.addItemClickListener(new TableClickListener());
    LoadTable();
    table.sort(new Object[] { "name" }, new boolean[] { true });
    tableAndForm.addComponent(table);
    tableAndForm.setExpandRatio(table, 0.2f);
    form = new FormLayout();
    form.setSizeFull();
    name = new TextField("?");
    name.setNullRepresentation("");
    name.setRequired(true);
    form.addComponent(name);
    nameRu = new TextField(" ?");
    nameRu.setNullRepresentation("");
    nameRu.setRequired(false);
    form.addComponent(nameRu);

    npcs = new TwinColSelect("NPC");
    npcsContainer = new BeanItemContainer<>(Npc.class);
    npcsContainer = service.loadBeanItems(npcsContainer);
    npcsContainer.sort(new Object[] { "name" }, new boolean[] { true });
    npcsContainer.addNestedContainerProperty("location.name");
    npcsContainer.addNestedContainerProperty("location.nameRu");
    npcs.setContainerDataSource(npcsContainer);
    npcs.setWidth(900f, Unit.PIXELS);
    Page.Styles styles = Page.getCurrent().getStyles();
    styles.add(".v-font-size {\n" + "    font-size: 11px;\n" + "}");
    npcs.addStyleName("v-font-size");
    npcFilter = new TextField(" ?? NPC");
    npcFilter.setNullRepresentation("");
    npcFilter.setImmediate(true);
    npcFilter.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.TIMEOUT);
    npcFilter.setTextChangeTimeout(500);
    npcFilter.addTextChangeListener(new FieldEvents.TextChangeListener() {

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            npcsContainer.removeAllContainerFilters();
            if (event.getText() != null && !event.getText().isEmpty()) {
                try {
                    npcsContainer
                            .addContainerFilter(new Or(new Like("name", "%" + event.getText() + "%", false),
                                    new Like("nameRu", "%" + event.getText() + "%", false),
                                    new Like("location.name", "%" + event.getText() + "%", false),
                                    new Like("location.nameRu", "%" + event.getText() + "%", false)));
                } catch (UnsupportedFilterException | PatternSyntaxException ex) {

                }
            }
        }
    });
    form.addComponent(npcFilter);
    form.addComponent(npcs);
    saveButton = new Button("");
    saveButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            SaveForm();
        }
    });
    cancelButton = new Button("");
    cancelButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            CloseForm();
            LoadTable();
        }
    });
    HorizontalLayout actions = new HorizontalLayout(cancelButton, saveButton);
    form.addComponent(actions);
    form.setVisible(false);
    tableAndForm.addComponent(form);
    tableAndForm.setExpandRatio(form, 0.75f);
    this.addComponent(tableAndForm);
}

From source file:org.esn.esobase.view.tab.UsersTab.java

public UsersTab(DBService service) {
    this.service = service;
    actions = new HorizontalLayout();
    refreshButton = new Button("");
    refreshButton.addClickListener(new Button.ClickListener() {

        @Override//from   w w w.j  a  v a 2s.  co m
        public void buttonClick(Button.ClickEvent event) {
            LoadTable();
        }
    });
    actions.addComponent(refreshButton);
    addButton = new Button("");
    addButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            AddUser();
        }
    });
    actions.addComponent(addButton);
    this.addComponent(actions);
    tableAndForm = new HorizontalLayout();
    tableAndForm.setSizeFull();
    table = new Table();
    table.setSizeFull();
    container = new BeanItemContainer<>(SysAccount.class);
    table.setContainerDataSource(container);
    table.setVisibleColumns(new Object[] { "login", "roles" });
    table.addItemClickListener(new TableClickListener());
    LoadTable();
    tableAndForm.addComponent(table);
    tableAndForm.setExpandRatio(table, 0.5f);
    form = new FormLayout();
    form.setSizeFull();
    login = new TextField("");
    login.setNullRepresentation("");
    login.setRequired(true);
    form.addComponent(login);
    password = new PasswordField("");
    form.addComponent(password);
    passwordRepeat = new PasswordField(" ?");
    passwordRepeat.addValidator(new PasswordValidator(password, passwordRepeat));
    form.addComponent(passwordRepeat);
    roles = new TwinColSelect("");
    BeanItemContainer<SysAccountRole> rolesContainer = new BeanItemContainer<>(SysAccountRole.class);
    rolesContainer = service.loadBeanItems(rolesContainer);
    roles.setContainerDataSource(rolesContainer);
    roles.setWidth(900f, Unit.PIXELS);
    Page.Styles styles = Page.getCurrent().getStyles();
    styles.add(".v-font-size {\n" + "    font-size: 11px;\n" + "}");
    roles.addStyleName("v-font-size");
    form.addComponent(roles);
    isBlocked = new CheckBox("");
    form.addComponent(isBlocked);
    saveButton = new Button("");
    saveButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            SaveForm();
        }
    });
    form.addComponent(saveButton);
    form.setVisible(false);
    tableAndForm.addComponent(form);
    tableAndForm.setExpandRatio(form, 0.5f);
    this.addComponent(tableAndForm);
}