List of usage examples for com.vaadin.ui ComboBox addValueChangeListener
@Override
public Registration addValueChangeListener(HasValue.ValueChangeListener<T> listener)
From source file:com.haulmont.cuba.web.gui.components.WebLookupPickerField.java
License:Apache License
protected void initValueSync(final ComboBox selectComponent, final WebPickerField.Picker picker) { selectComponent.addValueChangeListener(new Property.ValueChangeListener() { @Override//from www. jav a2s . c o m public void valueChange(Property.ValueChangeEvent event) { if (updateComponentValue) return; updateComponentValue = true; if (!Objects.equals(selectComponent.getValue(), picker.getValue())) { picker.setValueIgnoreReadOnly(selectComponent.getValue()); } updateComponentValue = false; } }); picker.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (updateComponentValue) return; updateComponentValue = true; if (!Objects.equals(selectComponent.getValue(), picker.getValue())) { selectComponent.setValueIgnoreReadOnly(picker.getValue()); } updateComponentValue = false; } }); }
From source file:com.haulmont.cuba.web.gui.components.WebSearchPickerField.java
License:Apache License
protected void initValueSync(final ComboBox selectComponent, final WebPickerField.Picker picker) { selectComponent.addValueChangeListener(new Property.ValueChangeListener() { @Override//from ww w . j av a 2s . co m public void valueChange(Property.ValueChangeEvent event) { if (updateComponentValue) return; updateComponentValue = true; if (!Objects.equals(selectComponent.getValue(), picker.getValue())) { //noinspection unchecked picker.setValueIgnoreReadOnly(selectComponent.getValue()); } updateComponentValue = false; } }); picker.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (updateComponentValue) return; updateComponentValue = true; if (!Objects.equals(selectComponent.getValue(), picker.getValue())) { selectComponent.setValueIgnoreReadOnly(picker.getValue()); } updateComponentValue = false; } }); }
From source file:com.klwork.explorer.project.MyCalendarView.java
License:Apache License
private ComboBox createTimeZoneSelect() { ComboBox s = new ComboBox(""); s.addContainerProperty("caption", String.class, ""); s.setItemCaptionPropertyId("caption"); s.setFilteringMode(FilteringMode.CONTAINS); Item i = s.addItem(DEFAULT_ITEMID);/* ww w. j a v a2 s .co m*/ i.getItemProperty("caption").setValue("Default (" + TimeZone.getDefault().getID() + ")"); for (String id : TimeZone.getAvailableIDs()) { if (!s.containsId(id)) { i = s.addItem(id); i.getItemProperty("caption").setValue(id); } } if (testBench) { s.select("America/New_York"); } else { s.select(DEFAULT_ITEMID); } s.setImmediate(true); s.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { updateCalendarTimeZone(event.getProperty().getValue()); } }); return s; }
From source file:com.klwork.explorer.project.MyCalendarView.java
License:Apache License
private ComboBox createCalendarFormatSelect() { ComboBox s = new ComboBox("?"); s.addContainerProperty("caption", String.class, ""); s.setItemCaptionPropertyId("caption"); Item i = s.addItem(DEFAULT_ITEMID);//from w ww . j a v a2 s. com i.getItemProperty("caption").setValue(""); i = s.addItem(TimeFormat.Format12H); i.getItemProperty("caption").setValue("12H"); i = s.addItem(TimeFormat.Format24H); i.getItemProperty("caption").setValue("24H"); s.select(DEFAULT_ITEMID); s.setImmediate(true); s.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { updateCalendarFormat(event.getProperty().getValue()); } }); return s; }
From source file:com.klwork.explorer.project.MyCalendarView.java
License:Apache License
private ComboBox createLocaleSelect() { ComboBox s = new ComboBox("/"); s.addContainerProperty("caption", String.class, ""); s.setItemCaptionPropertyId("caption"); s.setFilteringMode(FilteringMode.CONTAINS); for (Locale l : Locale.getAvailableLocales()) { if (!s.containsId(l)) { Item i = s.addItem(l);/*from w w w. ja v a 2 s. c o m*/ i.getItemProperty("caption").setValue(getLocaleItemCaption(l)); } } s.select(getLocale()); s.setImmediate(true); s.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { updateCalendarLocale((Locale) event.getProperty().getValue()); } }); return s; }
From source file:com.klwork.explorer.ui.business.project.MyCalendarView.java
License:Apache License
private ComboBox createCalendarFormatSelect() { ComboBox s = new ComboBox("?"); s.addContainerProperty("caption", String.class, ""); s.setItemCaptionPropertyId("caption"); Item i = s.addItem(DEFAULT_ITEMID);/*from ww w. j av a2 s. com*/ i.getItemProperty("caption").setValue(""); i = s.addItem(TimeFormat.Format12H); i.getItemProperty("caption").setValue("12H"); i = s.addItem(TimeFormat.Format24H); i.getItemProperty("caption").setValue("24H"); s.select(DEFAULT_ITEMID); s.setImmediate(true); s.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { updateCalendarFormat(event.getProperty().getValue()); } }); return s; }
From source file:com.mycollab.module.project.view.bug.BugListViewImpl.java
License:Open Source License
public BugListViewImpl() { this.withMargin(new MarginInfo(false, true, true, true)); searchPanel = new BugSearchPanel(); MHorizontalLayout groupWrapLayout = new MHorizontalLayout(); groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); groupWrapLayout.addComponent(new Label("Sort")); final ComboBox sortCombo = new ValueComboBox(false, AppContext.getMessage(GenericI18Enum.OPT_SORT_DESCENDING), AppContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING)); sortCombo.addValueChangeListener(valueChangeEvent -> { String sortValue = (String) sortCombo.getValue(); if (AppContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING).equals(sortValue)) { sortDirection = SearchCriteria.ASC; } else {/*from w w w . j a v a2 s. co m*/ sortDirection = SearchCriteria.DESC; } queryAndDisplayBugs(); }); sortDirection = SearchCriteria.DESC; groupWrapLayout.addComponent(sortCombo); groupWrapLayout.addComponent(new Label("Group by")); final ComboBox groupCombo = new ValueComboBox(false, GROUP_DUE_DATE, GROUP_START_DATE, GROUP_CREATED_DATE, PLAIN_LIST, GROUP_USER); groupCombo.addValueChangeListener(valueChangeEvent -> { groupByState = (String) groupCombo.getValue(); queryAndDisplayBugs(); }); groupByState = GROUP_DUE_DATE; groupWrapLayout.addComponent(groupCombo); searchPanel.addHeaderRight(groupWrapLayout); MButton printBtn = new MButton("", clickEvent -> { UI.getCurrent().addWindow(new BugCustomizeReportOutputWindow(new LazyValueInjector() { @Override protected Object doEval() { return baseCriteria; } })); }).withIcon(FontAwesome.PRINT).withStyleName(UIConstants.BUTTON_OPTION); printBtn.setDescription(AppContext.getMessage(GenericI18Enum.ACTION_EXPORT)); groupWrapLayout.addComponent(printBtn); MButton newBugBtn = new MButton(AppContext.getMessage(BugI18nEnum.NEW), clickEvent -> { SimpleBug bug = new SimpleBug(); bug.setProjectid(CurrentProjectVariables.getProjectId()); bug.setSaccountid(AppContext.getAccountId()); bug.setLogby(AppContext.getUsername()); UI.getCurrent().addWindow(new BugAddWindow(bug)); }).withIcon(FontAwesome.PLUS).withStyleName(UIConstants.BUTTON_ACTION) .withDescription(AppContext.getMessage(BugI18nEnum.NEW)) .withVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)); groupWrapLayout.addComponent(newBugBtn); Button advanceDisplayBtn = new Button("List"); advanceDisplayBtn.setWidth("100px"); advanceDisplayBtn.setIcon(FontAwesome.SITEMAP); advanceDisplayBtn.setDescription("Detail"); MButton kanbanBtn = new MButton("Kanban", clickEvent -> displayKanbanView()).withIcon(FontAwesome.TH) .withWidth("100px"); kanbanBtn.setDescription("Kanban View"); ToggleButtonGroup viewButtons = new ToggleButtonGroup(); viewButtons.addButton(advanceDisplayBtn); viewButtons.addButton(kanbanBtn); viewButtons.withDefaultButton(advanceDisplayBtn); groupWrapLayout.addComponent(viewButtons); MHorizontalLayout mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth(); wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, false)); rightColumn = new MVerticalLayout().withWidth("370px").withMargin(new MarginInfo(true, false, true, false)); mainLayout.with(wrapBody, rightColumn).expand(wrapBody); this.with(searchPanel, mainLayout); }
From source file:com.mycollab.module.project.view.task.TaskDashboardViewImpl.java
License:Open Source License
public TaskDashboardViewImpl() { this.withMargin(new MarginInfo(false, true, true, true)); taskSearchPanel = new TaskSearchPanel(); MHorizontalLayout groupWrapLayout = new MHorizontalLayout(); groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); groupWrapLayout.addComponent(new Label("Sort")); final ComboBox sortCombo = new ValueComboBox(false, AppContext.getMessage(GenericI18Enum.OPT_SORT_DESCENDING), AppContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING)); sortCombo.addValueChangeListener(new Property.ValueChangeListener() { @Override/*from ww w. java2 s . c o m*/ public void valueChange(Property.ValueChangeEvent valueChangeEvent) { String sortValue = (String) sortCombo.getValue(); if (AppContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING).equals(sortValue)) { sortDirection = SearchCriteria.ASC; } else { sortDirection = SearchCriteria.DESC; } queryAndDisplayTasks(); } }); sortDirection = SearchCriteria.DESC; groupWrapLayout.addComponent(sortCombo); groupWrapLayout.addComponent(new Label("Group by")); final ComboBox groupCombo = new ValueComboBox(false, GROUP_DUE_DATE, GROUP_START_DATE, GROUP_CREATED_DATE, PLAIN_LIST, GROUP_USER); groupCombo.addValueChangeListener(valueChangeEvent -> { groupByState = (String) groupCombo.getValue(); queryAndDisplayTasks(); }); groupByState = GROUP_DUE_DATE; groupWrapLayout.addComponent(groupCombo); taskSearchPanel.addHeaderRight(groupWrapLayout); MButton printBtn = new MButton("", clickEvent -> { UI.getCurrent().addWindow(new TaskCustomizeReportOutputWindow(new LazyValueInjector() { @Override protected Object doEval() { return baseCriteria; } })); }).withIcon(FontAwesome.PRINT).withStyleName(UIConstants.BUTTON_OPTION) .withDescription(AppContext.getMessage(GenericI18Enum.ACTION_EXPORT)); groupWrapLayout.addComponent(printBtn); MButton newTaskBtn = new MButton(AppContext.getMessage(TaskI18nEnum.NEW), clickEvent -> { if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { SimpleTask newTask = new SimpleTask(); newTask.setProjectid(CurrentProjectVariables.getProjectId()); newTask.setSaccountid(AppContext.getAccountId()); newTask.setLogby(AppContext.getUsername()); UI.getCurrent().addWindow(new TaskAddWindow(newTask)); } }).withIcon(FontAwesome.PLUS).withStyleName(UIConstants.BUTTON_ACTION); newTaskBtn.setVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); groupWrapLayout.addComponent(newTaskBtn); Button advanceDisplayBtn = new Button("List"); advanceDisplayBtn.setWidth("100px"); advanceDisplayBtn.setIcon(FontAwesome.SITEMAP); advanceDisplayBtn.setDescription("Advance View"); MButton kanbanBtn = new MButton("Kanban", clickEvent -> displayKanbanView()).withWidth("100px") .withIcon(FontAwesome.TH).withDescription("Kanban view"); ToggleButtonGroup viewButtons = new ToggleButtonGroup(); viewButtons.addButton(advanceDisplayBtn); viewButtons.addButton(kanbanBtn); viewButtons.withDefaultButton(advanceDisplayBtn); groupWrapLayout.addComponent(viewButtons); MHorizontalLayout mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth(); wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, false)); rightColumn = new MVerticalLayout().withWidth("370px") .withMargin(new MarginInfo(true, false, false, false)); mainLayout.with(wrapBody, rightColumn).expand(wrapBody); this.with(taskSearchPanel, mainLayout); }
From source file:com.mycollab.module.project.view.ticket.TicketDashboardViewImpl.java
License:Open Source License
public TicketDashboardViewImpl() { this.withMargin(new MarginInfo(false, true, true, true)); ticketSearchPanel = new TicketSearchPanel(); MHorizontalLayout groupWrapLayout = new MHorizontalLayout(); groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); groupWrapLayout.addComponent(new ELabel(UserUIContext.getMessage(GenericI18Enum.ACTION_SORT))); final ComboBox sortCombo = new ValueComboBox(false, UserUIContext.getMessage(GenericI18Enum.OPT_SORT_DESCENDING), UserUIContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING)); sortCombo.addValueChangeListener(valueChangeEvent -> { String sortValue = (String) sortCombo.getValue(); if (UserUIContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING).equals(sortValue)) { sortDirection = SearchCriteria.ASC; } else {//from ww w. j a v a 2s. c om sortDirection = SearchCriteria.DESC; } queryAndDisplayTickets(); }); sortDirection = SearchCriteria.DESC; groupWrapLayout.addComponent(sortCombo); groupWrapLayout.addComponent(new ELabel(UserUIContext.getMessage(GenericI18Enum.OPT_GROUP))); final ComboBox groupCombo = new ValueComboBox(false, UserUIContext.getMessage(GenericI18Enum.FORM_DUE_DATE), UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE), UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME), UserUIContext.getMessage(GenericI18Enum.OPT_PLAIN), UserUIContext.getMessage(GenericI18Enum.OPT_USER), UserUIContext.getMessage(MilestoneI18nEnum.SINGLE)); groupByState = UserUIContext.getMessage(MilestoneI18nEnum.SINGLE); groupCombo.setValue(UserUIContext.getMessage(MilestoneI18nEnum.SINGLE)); groupCombo.addValueChangeListener(valueChangeEvent -> { groupByState = (String) groupCombo.getValue(); queryAndDisplayTickets(); }); groupWrapLayout.addComponent(groupCombo); ticketSearchPanel.addHeaderRight(groupWrapLayout); MButton printBtn = new MButton("", clickEvent -> UI.getCurrent() .addWindow(new TicketCustomizeReportOutputWindow(new LazyValueInjector() { @Override protected Object doEval() { return baseCriteria; } }))).withIcon(FontAwesome.PRINT).withStyleName(WebThemes.BUTTON_OPTION) .withDescription(UserUIContext.getMessage(GenericI18Enum.ACTION_EXPORT)); groupWrapLayout.addComponent(printBtn); MButton newTicketBtn = new MButton(UserUIContext.getMessage(TicketI18nEnum.NEW), clickEvent -> { UI.getCurrent().addWindow(AppContextUtil.getSpringBean(TicketComponentFactory.class) .createNewTicketWindow(null, CurrentProjectVariables.getProjectId(), null, false)); }).withIcon(FontAwesome.PLUS).withStyleName(WebThemes.BUTTON_ACTION) .withVisible(CurrentProjectVariables.canWriteTicket()); groupWrapLayout.addComponent(newTicketBtn); MButton advanceDisplayBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_LIST)) .withIcon(FontAwesome.NAVICON).withWidth("100px"); MButton kanbanBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_KANBAN), clickEvent -> displayKanbanView()).withWidth("100px").withIcon(FontAwesome.TH); ToggleButtonGroup viewButtons = new ToggleButtonGroup(); viewButtons.addButton(advanceDisplayBtn); viewButtons.addButton(kanbanBtn); viewButtons.withDefaultButton(advanceDisplayBtn); groupWrapLayout.addComponent(viewButtons); MHorizontalLayout mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth(); wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, false)); rightColumn = new MVerticalLayout().withWidth("370px") .withMargin(new MarginInfo(true, false, false, false)); mainLayout.with(wrapBody, rightColumn).expand(wrapBody); this.with(ticketSearchPanel, mainLayout); }
From source file:com.skysql.manager.ui.MonitorsLayout.java
License:Open Source License
/** * Adds a new monitor row.//from www .j av a 2s .c o m * * @param monitorID the monitor id * @return the component */ private Component addRow(String monitorID) { HorizontalLayout row = new HorizontalLayout(); ComboBox selectMonitor = new ComboBox(); for (MonitorRecord availMonitor : availableMonitors.values()) { selectMonitor.addItem(availMonitor.getID()); selectMonitor.setItemCaption(availMonitor.getID(), availMonitor.getName()); } row.addComponent(selectMonitor); selectMonitorList.add(selectMonitor); selectMonitor.setValue(monitorID); selectMonitor.setNullSelectionAllowed(false); selectMonitor.setImmediate(true); selectMonitor.addValueChangeListener(monitorSelectListener); if (getComponentCount() > componentIndex) { Button deleteButton = new Button("X"); row.addComponent(deleteButton); deleteButton.setData(selectMonitor); deleteButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { // remove combobox from list Button button = event.getButton(); ComboBox select = (ComboBox) button.getData(); selectMonitorList.remove(select); // remove layout from dialog int layoutIndex = getComponentIndex(button.getParent()); HorizontalLayout layout = (HorizontalLayout) getComponent(layoutIndex); removeComponent(layout); refreshMonitors(); } }); } focus(); return (row); }