@Override public Dateitem getSelectedItem() { return (Dateitem) super.getSelectedItem(); }
@Override protected void setValue(Object value) { Comboitem item = (Comboitem) editor.findChildByData(value); editor.setSelectedItem(item); if (item == null) { editor.setValue(value == null ? null : value.toString()); } updateValue(); }
@EventHandler(value = "dblclick", target = "editor") private void onDblclick() { int i = editor.getSelectedIndex() + 1; editor.setSelectedIndex(i >= editor.getChildCount() ? 0 : i); onChange(null); //TODO: editor.close(); } }
/** * Sets the item at the specified index as selected. * * @param index Index of the item to select, or -1 to clear the selection. */ public void setSelectedIndex(int index) { setSelectedItem((Comboitem) getChildAt(index)); }
public void setSelectorVisible(boolean visible) { selectorVisible = visible; cboLibrary.setVisible(visible && cboLibrary.getChildCount() > 1); }
/** * Set read only mode. * * @param readonly If true, the component is read only and the delete key (or ctrl-x) will * remove the selection. If false, the combo box content can be modified and the * delete key functions normally. */ private void setReadonly(boolean readonly) { editor.setReadonly(readonly); editor.setKeycapture(readonly ? "DELETE" : null); if (readonly) { editor.addEventListener(KeycaptureEvent.TYPE, deleteListener); } else { editor.removeEventListener(KeycaptureEvent.TYPE, deleteListener); } }
/** * Initializes Controller. */ @Override protected void initializeController() { super.initializeController(); if (dateRangePicker != null) { String deflt = getPropertyValue(Constants.PROPERTY_ID_DATE_RANGE, String.class, "Last Two Years"); dateRangePicker.setSelectedItem(dateRangePicker.findMatchingItem(deflt)); initDateFilter().setDateRange(dateRangePicker.getSelectedRange()); } if (dateTypePicker != null) { for (DateType dt : DateType.values()) { String lbl = getLabel(Constants.LABEL_ID_SORT_MODE.replace("$", dt.name().toLowerCase())); Comboitem item = new Comboitem(lbl); item.setData(dt); dateTypePicker.addChild(item); } DateType sortModePref = getPropertyValue(Constants.PROPERTY_ID_SORT_MODE, DateType.class, DateType.MEASURED); Comboitem item = (Comboitem) dateTypePicker.findChildByData(sortModePref); dateTypePicker.setSelectedItem(item == null ? (Comboitem) dateTypePicker.getFirstChild() : item); dateTypePicker.setReadonly(true); initDateFilter().setDateType(sortModePref); } if (dateFilter != null) { registerQueryFilter(dateFilter); } }
@Override protected Object getValue() { Comboitem item = editor.getSelectedItem(); Object value = item != null ? item.getData() : editor.isReadonly() ? null : editor.getValue(); return value; }
public void setIconLibrary(IIconLibrary iconLibrary) { this.iconLibrary = iconLibrary; Comboitem item = (Comboitem) cboLibrary.findChildByData(iconLibrary); if (item != null) { cboLibrary.setSelectedItem(item); libraryChanged(); } }
private void refreshScenarios() { cboScenarios.setSelectedItem(null); model.clear(); model.addAll(scenarioRegistry.getAll()); cboScenarios.setPlaceholder( StrUtil.getLabel(model.isEmpty() ? "cwf.scenario.cbox.placeholder.none" : "cwf.scenario.cbox.placeholder")); Collections.sort(model, scenarioComparator); CWFUtil.disableChildren(scenarioButtons, true); }
/** * Need to update visual appearance of selection when it is changed. * * @see org.fujion.component.Combobox#setSelectedItem(Comboitem) */ @Override public void setSelectedItem(Comboitem item) { super.setSelectedItem(item); updateSelection(); }
/** * Append a new combo item using the specified label and internal value. * * @param label The item label. * @param value The internal value. * @return The newly created combo item. */ protected Comboitem appendItem(String label, Object value) { Comboitem item = new Comboitem(label); editor.addChild(item); item.setData(value); return item; }
/** * Update the selected item to the specified value. * * @param item Item to be selected. */ protected void _updateSelected(Comboitem item) { if (selected != null) { selected._setSelected(false, true, false); } selected = item; setValue(selected == null ? null : selected.getLabel()); }
public IconPicker() { addStyle("overflow", "visible"); addStyle("display", "inline-block"); PageUtil.createPage(Constants.RESOURCE_PREFIX + "cwf/iconPicker.fsp", this); wireController(this); for (IIconLibrary lib : iconRegistry) { Comboitem item = new Comboitem(lib.getId()); item.setData(lib); cboLibrary.addChild(item); } setSelectorVisible(true); }
/** * Returns the index of the currently selected item. * * @return The index of the currently selected item, or -1 if no item is selected. */ public int getSelectedIndex() { Comboitem item = getSelectedItem(); return item == null ? -1 : item.getIndex(); }
/** * Returns the currently selected scenario, or null if none. * * @return The currently selected scenario. */ private Scenario getSelectedScenario() { Comboitem item = cboScenarios.getSelectedItem(); return item == null ? null : (Scenario) item.getData(); }
/** * Returns date type from picker. * * @return The date type. */ protected DateType getDateType() { Comboitem item = dateTypePicker == null ? null : dateTypePicker.getSelectedItem(); return item == null ? dateFilter.getDateType() : (DateType) item.getData(); }
@EventHandler(value = "change", target = "@cboLibrary", onFailure = OnFailure.IGNORE) private void onChange$cboLibrary() { iconLibrary = (IIconLibrary) cboLibrary.getSelectedItem().getData(); libraryChanged(); } }
@EventHandler(value = "click", target = "btnSendMessage") private void onClick$btnSendMessage() { Comboitem item = cboxChannels.getSelectedItem(); if (item != null) { String type = item.getLabel(); String channel = chkAsEvent.isChecked() ? EventUtil.getChannelName(type) : type; Message message = chkAsEvent.isChecked() ? new EventMessage(type, memoMessage.getValue()) : new Message(channel, memoMessage.getValue()); producerService.publish(channel, message); } }