com.vaadin.ui.NativeSelect Java Examples
The following examples show how to use
com.vaadin.ui.NativeSelect.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DemoUI.java From gantt with Apache License 2.0 | 6 votes |
private void fillParentStepCanditatesToSelect(AbstractStep step, final NativeSelect<Step> parentStepSelect) { if (!gantt.getSteps().contains(step)) { // new step parentStepSelect.setEnabled(true); List<Step> items = new ArrayList<>(); for (Step parentStepCanditate : gantt.getSteps()) { items.add(parentStepCanditate); if (step instanceof SubStep) { if (parentStepCanditate.getSubSteps().contains(step)) { parentStepSelect.setValue(parentStepCanditate); parentStepSelect.setEnabled(false); break; } } } parentStepSelect.setItems(items); } }
Example #2
Source File: DemoUI.java From gantt with Apache License 2.0 | 6 votes |
private void commit(final Window win, final Binder<? extends AbstractStep> binder, final NativeSelect<Step> parentStepSelect) { AbstractStep step = binder.getBean(); gantt.markStepDirty(step); if (parentStepSelect.isEnabled() && parentStepSelect.getValue() != null) { SubStep subStep = addSubStep(parentStepSelect, step); step = subStep; } if (step instanceof Step && !gantt.getSteps().contains(step)) { gantt.addStep((Step) step); } if (ganttListener != null && step instanceof Step) { ganttListener.stepModified((Step) step); } win.close(); }
Example #3
Source File: Util.java From gantt with Apache License 2.0 | 6 votes |
public static NativeSelect createNativeSelectEditor(String caption, Object value, Collection<Object> items, final SelectValueChange valueChange) { NativeSelect<Object> s = new NativeSelect<>(caption); s.setItemCaptionGenerator(item -> String.valueOf(item)); s.setItems(items); s.setEmptySelectionAllowed(false); s.setValue(value); s.addValueChangeListener(new ValueChangeListener<Object>() { @Override public void valueChange(ValueChangeEvent<Object> event) { valueChange.onValueChange(event.getValue()); } }); return s; }
Example #4
Source File: DemoUI.java From gantt with Apache License 2.0 | 5 votes |
private void fillPredecessorCanditatesToSelect(AbstractStep step, final NativeSelect<AbstractStep> predecessorSelect) { List<AbstractStep> items = new ArrayList<>(); for (Step stepCanditate : gantt.getSteps()) { if (!stepCanditate.equals(step) && stepCanditate instanceof Step) { items.add(stepCanditate); } } predecessorSelect.setItems(items); }
Example #5
Source File: DemoUI.java From gantt with Apache License 2.0 | 5 votes |
private SubStep addSubStep(final NativeSelect parentStepSelect, AbstractStep dataSource) { SubStep subStep = new SubStep(); subStep.setCaption(dataSource.getCaption()); subStep.setCaptionMode(dataSource.getCaptionMode()); subStep.setStartDate(dataSource.getStartDate()); subStep.setEndDate(dataSource.getEndDate()); subStep.setBackgroundColor(dataSource.getBackgroundColor()); subStep.setDescription(dataSource.getDescription()); subStep.setProgress(dataSource.getProgress()); subStep.setShowProgress(dataSource.isShowProgress()); subStep.setStyleName(dataSource.getStyleName()); ((Step) parentStepSelect.getValue()).addSubStep(subStep); return subStep; }
Example #6
Source File: Util.java From gantt with Apache License 2.0 | 5 votes |
public static NativeSelect createHeightUnitEditor(final Component component) { return createNativeSelectEditor("Height Unit", component.getHeightUnits(), Arrays.asList(Unit.PERCENTAGE, Unit.PIXELS), new SelectValueChange() { @Override public void onValueChange(Object unit) { component.setHeight(component.getHeight(), (Unit) unit); } }); }
Example #7
Source File: Util.java From gantt with Apache License 2.0 | 5 votes |
public static NativeSelect createWidthUnitEditor(final Component component) { return createNativeSelectEditor("Width Unit", component.getWidthUnits(), Arrays.asList(Unit.PERCENTAGE, Unit.PIXELS), new SelectValueChange() { @Override public void onValueChange(Object unit) { component.setWidth(component.getWidth(), (Unit) unit); } }); }
Example #8
Source File: DemoUI.java From gantt with Apache License 2.0 | 4 votes |
private Panel createControls() { Panel panel = new Panel(); panel.setWidth(100, Unit.PERCENTAGE); controls = new HorizontalLayout(); controls.setSpacing(true); controls.setMargin(true); panel.setContent(controls); subControls = new HorizontalLayout(); subControls.setSpacing(true); subControls.setVisible(false); start = createStartDateField(); end = createEndDateField(); Button createStep = new Button("Create New Step...", createStepClickListener); HorizontalLayout heightAndUnit = new HorizontalLayout(Util.createHeightEditor(gantt), Util.createHeightUnitEditor(gantt)); HorizontalLayout widthAndUnit = new HorizontalLayout(Util.createWidthEditor(gantt), Util.createWidthUnitEditor(gantt)); reso = new NativeSelect<Resolution>("Resolution"); reso.setEmptySelectionAllowed(false); reso.setItems(org.tltv.gantt.client.shared.Resolution.Hour, org.tltv.gantt.client.shared.Resolution.Day, org.tltv.gantt.client.shared.Resolution.Week); reso.setValue(gantt.getResolution()); resolutionValueChangeRegistration = Optional.of(reso.addValueChangeListener(resolutionValueChangeListener)); localeSelect = new NativeSelect<Locale>("Locale") { @Override public void attach() { super.attach(); if (getValue() == null) { // use default locale setValue(gantt.getLocale()); addValueChangeListener(localeValueChangeListener); } } }; localeSelect.setEmptySelectionAllowed(false); localeSelect.setItems(Locale.getAvailableLocales()); localeSelect.setItemCaptionGenerator((l) -> l.getDisplayName(getLocale())); ComboBox<String> timezoneSelect = new ComboBox<String>("Timezone"); timezoneSelect.setWidth(300, Unit.PIXELS); timezoneSelect.setEmptySelectionAllowed(false); timezoneSelect.setItemCaptionGenerator(new ItemCaptionGenerator<String>() { @Override public String apply(String item) { if ("Default".equals(item)) { return "Default (" + getDefaultTimeZone().getDisplayName() + ")"; } TimeZone tz = TimeZone.getTimeZone(item); return tz.getID() + " (raw offset " + (tz.getRawOffset() / 60000) + "m)"; } }); List<String> items = new ArrayList<>(); items.add("Default"); items.addAll(Gantt.getSupportedTimeZoneIDs()); timezoneSelect.setItems((caption, fltr) -> caption.contains(fltr), items); timezoneSelect.setValue("Default"); timezoneSelect.addValueChangeListener(timezoneValueChangeListener); final Button toggleSubControlsBtn = new Button("Show More Settings..."); toggleSubControlsBtn.addStyleName("link"); toggleSubControlsBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { subControls.setVisible(!subControls.isVisible()); toggleSubControlsBtn.setCaption(subControls.isVisible() ? "Less Settings..." : "More Settings..."); } }); controls.addComponent(start); controls.addComponent(end); controls.addComponent(reso); controls.addComponent(subControls); controls.addComponent(toggleSubControlsBtn); controls.setComponentAlignment(toggleSubControlsBtn, Alignment.BOTTOM_CENTER); subControls.addComponent(localeSelect); subControls.addComponent(timezoneSelect); subControls.addComponent(heightAndUnit); subControls.addComponent(widthAndUnit); subControls.addComponent(createStep); subControls.setComponentAlignment(createStep, Alignment.MIDDLE_LEFT); return panel; }
Example #9
Source File: JobLogFilter.java From chipster with MIT License | 4 votes |
public JobLogFilter(final JobLogView view, String column, String search) { this.view = view; searchStringField = new TextField(); if (search != null) { searchStringField.setValue(search); } searchStringField.setDescription("Search for values starting with this string. Question mark (?) is a wildcard for a single character and asterisk (*) for any number of characters."); searchStringField.addShortcutListener(new ShortcutListener("Search", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { view.update(); } }); columnToSearch = new NativeSelect(); Button clearButton = new Button(); clearButton.setIcon(new ThemeResource("crystal/button_cancel-bw.png")); clearButton.setDescription("Remove filter"); clearButton.addStyleName("search-button"); for (int i = 0; i < JobLogContainer.NATURAL_COL_ORDER.length; i++) { //Do not search from generated columns if (SEARCH_COLUMNS.contains(JobLogContainer.NATURAL_COL_ORDER[i])) { columnToSearch.addItem(JobLogContainer.NATURAL_COL_ORDER[i]); columnToSearch.setItemCaption(JobLogContainer.NATURAL_COL_ORDER[i], JobLogContainer.COL_HEADERS_ENGLISH[i]); } } if (column != null) { columnToSearch.setValue(column); } else { columnToSearch.setValue(JobLogContainer.USERNAME); } columnToSearch.setNullSelectionAllowed(false); clearButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { getView().clearFilter(JobLogFilter.this); } }); addComponent(columnToSearch); addComponent(searchStringField); addComponent(clearButton); addStyleName("search-filter-bg"); addStyleName("search-filter"); }