public void onEvent(Event event) { if (Events.ON_SELECT.equalsIgnoreCase(event.getName())) { Object newValue = getValue(); if (isValueChange(newValue)) { ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue); super.fireValueChange(changeEvent); oldValue = newValue; } } else if (Events.ON_BLUR.equalsIgnoreCase(event.getName())) { Comboitem item = getComponent().getSelectedItem(); if (item == null) { setValue(oldValue); } else { // on select not fire for empty label item if (item.getLabel().equals("")) { Object newValue = getValue(); if (isValueChange(newValue)) { ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue); super.fireValueChange(changeEvent); oldValue = newValue; } } } } }
public void setValue(Object value) { if (value != null && (value instanceof Integer || value instanceof String)) { getComponent().setValue(value); if (!getComponent().isSelected(value)) { if (isReadWrite() && lookup != null) lookup.refresh(); Object curValue = oldValue; oldValue = value; refreshList(); // still not in list, reset to zero if (!getComponent().isSelected(value)) { if (value instanceof Integer && (Integer) value == 0) { getComponent().setValue(null); if (curValue == null) curValue = value; ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), curValue, null); super.fireValueChange(changeEvent); oldValue = null; } } } else { oldValue = value; } } else { getComponent().setValue(null); oldValue = value; } }
/** * Constructor for use if a grid field is unavailable * * @param lookup Store of selectable data * @param label column name (not displayed) * @param description description of component * @param mandatory whether a selection must be made * @param readonly whether or not the editor is read only * @param updateable whether the editor contents can be changed */ public WTableDirEditor( Lookup lookup, String label, String description, boolean mandatory, boolean readonly, boolean updateable) { super(new Combobox(), label, description, mandatory, readonly, updateable); if (lookup == null) { throw new IllegalArgumentException("Lookup cannot be null"); } this.lookup = lookup; super.setColumnName(lookup.getColumnName()); init(); }
public void onEvent(Event event) { if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()) || Events.ON_OK.equalsIgnoreCase(event.getName())) { Date date = getComponent().getValue(); Timestamp newValue = null; if (date != null) { newValue = new Timestamp(date.getTime()); } if (oldValue != null && newValue != null && oldValue.equals(newValue)) { return; } if (oldValue == null && newValue == null) { return; } ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue); super.fireValueChange(changeEvent); oldValue = newValue; } }