Search in sources :

Example 16 with TextField

use of com.vaadin.ui.TextField in project v-leaflet by mstahv.

the class PopupTest method setup.

@Override
protected void setup() {
    super.setup();
    final TextField lat = new TextField("Lat");
    lat.setValue("" + 60.4525);
    content.addComponentAsFirst(lat);
    final TextField lon = new TextField("Lon");
    lon.setValue("" + 22.301);
    content.addComponentAsFirst(lon);
    final TextField html = new TextField("html");
    content.addComponentAsFirst(html);
    final CheckBox closeButton = new CheckBox("Close button");
    content.addComponentAsFirst(closeButton);
    final CheckBox closeonclick = new CheckBox("Close on click");
    content.addComponentAsFirst(closeonclick);
    content.addComponentAsFirst(new Button("Open popup", new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Double lonValue = Double.valueOf(lon.getValue());
            Double latValue = Double.valueOf(lat.getValue());
            LPopup lPopup = new LPopup(latValue, lonValue).setContent(html.getValue());
            lPopup.setCloseButton(closeButton.getValue());
            lPopup.setCloseOnClick(closeonclick.getValue());
            leafletMap.addComponent(lPopup);
            leafletMap.zoomToContent();
            popups.add(lPopup);
            lPopup.addDetachListener(PopupTest.this);
        }
    }));
    content.addComponentAsFirst(new Button("Remove first", new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            popups.remove(0).close();
        }
    }));
}
Also used : Button(com.vaadin.ui.Button) CheckBox(com.vaadin.ui.CheckBox) LeafletClickEvent(org.vaadin.addon.leaflet.LeafletClickEvent) TextField(com.vaadin.ui.TextField) LPopup(org.vaadin.addon.leaflet.LPopup) ClickListener(com.vaadin.ui.Button.ClickListener) LeafletClickListener(org.vaadin.addon.leaflet.LeafletClickListener)

Example 17 with TextField

use of com.vaadin.ui.TextField in project VaadinUtils by rlsutton1.

the class FormHelper method bindTextField.

public <M> TextField bindTextField(String fieldLabel, SingularAttribute<E, M> member) {
    TextField field = bindTextField(form, group, fieldLabel, member.getName());
    this.fieldList.add(field);
    return field;
}
Also used : TextField(com.vaadin.ui.TextField) SplitTextField(au.com.vaadinutils.crud.splitFields.SplitTextField)

Example 18 with TextField

use of com.vaadin.ui.TextField in project VaadinUtils by rlsutton1.

the class ReportParameterTable method init.

protected void init(final String caption, final Class<T> tableClass, final SingularAttribute<T, String> displayField) {
    JpaBaseDao.getGenericDao(tableClass).flushCache();
    container = createContainer(tableClass, displayField);
    UI ui = UI.getCurrent();
    if (ui != null) {
        Runnable runner = new Runnable() {

            @Override
            public void run() {
                try (AutoCloseable closer = EntityManagerProvider.setThreadLocalEntityManagerTryWithResources()) {
                    ReportParameterTable.this.displayField = displayField;
                    layout.setSizeFull();
                    ReportParameterTable.this.caption = caption;
                    TextField searchText = new TextField();
                    searchText.setInputPrompt("Search");
                    searchText.setWidth("100%");
                    searchText.setImmediate(true);
                    searchText.setHeight("20");
                    searchText.addTextChangeListener(new TextChangeListener() {

                        private static final long serialVersionUID = 1315710313315289836L;

                        @Override
                        public void textChange(TextChangeEvent event) {
                            String value = event.getText();
                            removeAllContainerFilters();
                            if (value.length() > 0) {
                                container.addContainerFilter(new SimpleStringFilter(displayField.getName(), value, true, false));
                            }
                        }
                    });
                    grid = new Grid();
                    grid.setImmediate(true);
                    grid.setSizeFull();
                    // table.setHeight("150");
                    grid.setContainerDataSource(container);
                    new GridHeadingPropertySet.Builder<T>().createColumn(caption, displayField.getName()).setLockedState(true).build().applyToGrid(grid);
                    List<SortOrder> orders = new LinkedList<>();
                    orders.add(new SortOrder(displayField.getName(), SortDirection.ASCENDING));
                    grid.setSortOrder(orders);
                    final Label selectionCount = new Label("0 selected");
                    // removed for concertina
                    // layout.addComponent(new Label(caption));
                    layout.addComponent(searchText);
                    layout.addComponent(grid);
                    HorizontalLayout selectionLayout = new HorizontalLayout();
                    selectionLayout.setHeight("30");
                    selectionLayout.setWidth("100%");
                    selectionLayout.addComponent(selectionCount);
                    selectionLayout.setComponentAlignment(selectionCount, Alignment.MIDDLE_RIGHT);
                    layout.addComponent(selectionLayout);
                    grid.addSelectionListener(new SelectionListener() {

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

                        @Override
                        public void select(SelectionEvent event) {
                            validate();
                            selectionCount.setValue("" + event.getSelected().size() + " selected");
                        }
                    });
                    layout.setExpandRatio(grid, 1);
                // layout.setComponentAlignment(selectAll,
                // Alignment.BOTTOM_RIGHT);
                } catch (Exception e) {
                    ErrorWindow.showErrorWindow(e);
                }
            }
        };
        UI.getCurrent().accessSynchronously(runner);
    } else {
        logger.warn("No vaadin session available, not setting up UI");
    }
}
Also used : Grid(com.vaadin.ui.Grid) Label(com.vaadin.ui.Label) SortOrder(com.vaadin.data.sort.SortOrder) LinkedList(java.util.LinkedList) HorizontalLayout(com.vaadin.ui.HorizontalLayout) UI(com.vaadin.ui.UI) TextChangeEvent(com.vaadin.event.FieldEvents.TextChangeEvent) SelectionEvent(com.vaadin.event.SelectionEvent) TextField(com.vaadin.ui.TextField) TextChangeListener(com.vaadin.event.FieldEvents.TextChangeListener) SimpleStringFilter(com.vaadin.data.util.filter.SimpleStringFilter) SelectionListener(com.vaadin.event.SelectionEvent.SelectionListener)

Example 19 with TextField

use of com.vaadin.ui.TextField in project VaadinUtils by rlsutton1.

the class DateTimePickerInline method buildUI.

@Override
protected void buildUI(String title) {
    datePicker = new InlineDateField(title + " Date");
    datePicker.setDateFormat("yyyy/MM/dd");
    datePicker.setValue(new Date());
    displayDate = createTextDateField();
    datePicker.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            final Date date = (Date) event.getProperty().getValue();
            displayDate.setValue(dateFormatter.format(date));
        }
    });
    final Label midnightLabel = new Label();
    midnightLabel.setContentMode(ContentMode.HTML);
    field = new TextField();
    field.setWidth("125");
    field.setImmediate(true);
    displayTime = field;
    displayTime.addValidator(timeValidator);
    field.addValidator(timeValidator);
    field.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            DateTimePickerInline.this.valueChange(event);
            @SuppressWarnings("deprecation") int hour = getValue().getHours();
            if (hour == 0) {
                midnightLabel.setValue("<font color='red'><b>Midnight</b></font>");
            } else {
                midnightLabel.setValue("");
            }
            try {
                final Date parsedDate = parseDate((String) event.getProperty().getValue());
                if (parsedDate != null) {
                    Calendar parsed = Calendar.getInstance();
                    parsed.setTime(parsedDate);
                    dateTime.set(Calendar.HOUR_OF_DAY, parsed.get(Calendar.HOUR_OF_DAY));
                    dateTime.set(Calendar.MINUTE, parsed.get(Calendar.MINUTE));
                    isSet = true;
                    setNewValue();
                }
            } catch (InvalidValueException e) {
                logger.info(e);
            // the validator will handle this
            }
        }
    });
    field.setCaption(null);
    datePicker.setCaption(null);
    VerticalLayout vl = new VerticalLayout();
    HorizontalLayout dateLayout = new HorizontalLayout();
    dateLayout.setWidth("210");
    Button changeYearButton = new Button("Year");
    changeYearButton.setDescription("Change the year");
    changeYearButton.setStyleName(ValoTheme.BUTTON_TINY);
    changeYearButton.addClickListener(getChangeYearClickListener());
    dateLayout.addComponent(displayDate);
    dateLayout.addComponent(changeYearButton);
    dateLayout.setComponentAlignment(changeYearButton, Alignment.MIDDLE_RIGHT);
    vl.addComponent(datePicker);
    HorizontalLayout timeFieldLayout = new HorizontalLayout();
    timeFieldLayout.setSpacing(true);
    timeFieldLayout.addComponent(field);
    timeFieldLayout.addComponent(midnightLabel);
    timeFieldLayout.setComponentAlignment(midnightLabel, Alignment.MIDDLE_LEFT);
    vl.addComponent(buildInline());
    addComponent(vl);
    vl.addComponent(timeFieldLayout);
    vl.addComponent(dateLayout);
    vl.setSpacing(true);
}
Also used : InlineDateField(com.vaadin.ui.InlineDateField) Calendar(java.util.Calendar) Label(com.vaadin.ui.Label) Date(java.util.Date) HorizontalLayout(com.vaadin.ui.HorizontalLayout) InvalidValueException(com.vaadin.data.Validator.InvalidValueException) Button(com.vaadin.ui.Button) TextField(com.vaadin.ui.TextField) VerticalLayout(com.vaadin.ui.VerticalLayout) Property(com.vaadin.data.Property)

Example 20 with TextField

use of com.vaadin.ui.TextField in project VaadinUtils by rlsutton1.

the class TimePicker method buildUI.

protected void buildUI(String title) {
    field = new TextField();
    field.setWidth("125");
    field.setImmediate(true);
    displayTime.setImmediate(true);
    displayTime.addValidator(timeValidator);
    field.addValidator(timeValidator);
    field.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("deprecation")
        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            try {
                final Date parsedDate = parseDate((String) event.getProperty().getValue());
                if (parsedDate != null) {
                    dateTime.set(Calendar.HOUR_OF_DAY, parsedDate.getHours());
                    dateTime.set(Calendar.MINUTE, parsedDate.getMinutes());
                    isSet = true;
                    setNewValue();
                }
                TimePicker.this.valueChange(event);
                field.setComponentError(null);
            } catch (final InvalidValueException e) {
                field.setComponentError(new ErrorMessage() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public String getFormattedHtmlMessage() {
                        return e.getMessage();
                    }

                    @Override
                    public ErrorLevel getErrorLevel() {
                        return ErrorLevel.ERROR;
                    }
                });
            }
        }
    });
    this.title = title;
    CssLayout hl = new CssLayout();
    hl.addStyleName("v-component-group");
    hl.setWidth("100%");
    hl.setHeight("35");
    pickerButton = new Button();
    pickerButton.setIcon(FontAwesome.CLOCK_O);
    hl.addComponent(pickerButton);
    hl.addComponent(field);
    pickerButton.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            showPopupTimePicker();
        }
    });
    addComponent(hl);
}
Also used : ClickEvent(com.vaadin.ui.Button.ClickEvent) Date(java.util.Date) InvalidValueException(com.vaadin.data.Validator.InvalidValueException) CssLayout(com.vaadin.ui.CssLayout) NativeButton(com.vaadin.ui.NativeButton) Button(com.vaadin.ui.Button) TextField(com.vaadin.ui.TextField) ErrorMessage(com.vaadin.server.ErrorMessage) Property(com.vaadin.data.Property) ClickListener(com.vaadin.ui.Button.ClickListener)

Aggregations

TextField (com.vaadin.ui.TextField)79 Test (org.junit.Test)22 Button (com.vaadin.ui.Button)15 Label (com.vaadin.ui.Label)15 HorizontalLayout (com.vaadin.ui.HorizontalLayout)12 VerticalLayout (com.vaadin.ui.VerticalLayout)10 ClickListener (com.vaadin.ui.Button.ClickListener)7 ComboBox (com.vaadin.ui.ComboBox)7 GridLayout (com.vaadin.ui.GridLayout)7 SplitTextField (au.com.vaadinutils.crud.splitFields.SplitTextField)6 InvalidValueException (com.vaadin.data.Validator.InvalidValueException)6 ClickEvent (com.vaadin.ui.Button.ClickEvent)6 PasswordField (com.vaadin.ui.PasswordField)6 CheckBox (com.vaadin.ui.CheckBox)4 Form (com.vaadin.ui.Form)4 TextArea (com.vaadin.ui.TextArea)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 Property (com.vaadin.data.Property)3 Validator (com.vaadin.data.Validator)3