if ((newValue == null && value != null)
|| (newValue != null && !newValue.equals(value))) {
setInternalValue(newValue);
- fireValueChange();
+ fireValueChange(false);
}
// If the value did not change, but the modification status did
readTroughMode = readTrough;
if (!isModified() && readTroughMode && dataSource != null) {
setInternalValue(dataSource.getValue());
- fireValueChange();
+ fireValueChange(false);
}
}
if ((newValue == null && value != null)
|| (newValue != null && !newValue.equals(value))) {
setInternalValue(newValue);
- fireValueChange();
+ fireValueChange(false);
}
return newValue;
*/
public void setValue(Object newValue) throws Property.ReadOnlyException,
Property.ConversionException {
+ setValue(newValue, false);
+ }
+
+ /**
+ * Sets the value of the field.
+ *
+ * @param newValue
+ * the New value of the field.
+ * @param repaintIsNotNeeded True iff caller is sure that repaint is not needed.
+ * @throws Property.ReadOnlyException
+ * @throws Property.ConversionException
+ */
+ protected void setValue(Object newValue, boolean repaintIsNotNeeded) throws Property.ReadOnlyException,
+ Property.ConversionException {
if ((newValue == null && value != null)
|| (newValue != null && !newValue.equals(value))) {
}
// Fires the value change
- fireValueChange();
+ fireValueChange(repaintIsNotNeeded);
}
}
// Fires value change if the value has changed
if ((value != oldValue)
&& ((value != null && !value.equals(oldValue)) || value == null))
- fireValueChange();
+ fireValueChange(false);
}
/* Validation ****************************************************** */
* Emits the value change event. The value contained in the field is
* validated before the event is created.
*/
- protected void fireValueChange() {
+ protected void fireValueChange(boolean repaintIsNotNeeded) {
fireEvent(new AbstractField.ValueChangeEvent(this));
- requestRepaint();
+ if (!repaintIsNotNeeded)
+ requestRepaint();
}
/* Read-only status change events *************************************** */
*/
public void valueChange(Property.ValueChangeEvent event) {
if (isReadThrough() || !isModified())
- fireValueChange();
+ fireValueChange(false);
}
/**
// Multiselect mode
if (isMultiSelect()) {
+ // TODO Optimize by adding repaintNotNeeded whan applicaple
+
// Converts the key-array to id-set
LinkedList s = new LinkedList();
for (int i = 0; i < ka.length; i++) {
Object current = getValue();
Collection visible = getVisibleItemIds();
if (visible != null && visible.contains(current))
- setValue(null);
+ setValue(null, true);
} else {
Object id = itemIdMapper.get(ka[0]);
if (id != null && id.equals(getNullSelectionItemId()))
- setValue(null);
+ setValue(null, true);
else if (itemIdMapper.isNewIdKey(ka[0]))
setValue(newitem);
else
- setValue(id);
+ setValue(id, true);
}
}
}
*/
public void setValue(Object newValue) throws Property.ReadOnlyException,
Property.ConversionException {
+ setValue(newValue, false);
+ }
+
+ /**
+ * Sets the visible value of the property.
+ *
+ * <p>
+ * The value of the select is the selected item id. If the select is in
+ * multiselect-mode, the value is a set of selected item keys. In
+ * multiselect mode all collections of id:s can be assigned.
+ * </p>
+ *
+ * @param newValue
+ * the New selected item or collection of selected items.
+ * @param repaintIsNotNeeded True iff caller is sure that repaint is not needed.
+ * @see com.itmill.toolkit.ui.AbstractField#setValue(java.lang.Object, java.lang.Boolean)
+ */
+ protected void setValue(Object newValue, boolean repaintIsNotNeeded) throws Property.ReadOnlyException,
+ Property.ConversionException {
if (isMultiSelect()) {
if (newValue == null)
- super.setValue(new HashSet());
+ super.setValue(new HashSet(), repaintIsNotNeeded);
else if (Collection.class.isAssignableFrom(newValue.getClass()))
- super.setValue(new HashSet((Collection) newValue));
+ super.setValue(new HashSet((Collection) newValue), repaintIsNotNeeded);
} else if (newValue == null || items.containsId(newValue))
- super.setValue(newValue);
+ super.setValue(newValue, repaintIsNotNeeded);
}
/* Container methods **************************************************** */
}
// TODO: This should be conditional
- fireValueChange();
+ fireValueChange(false);
}
}
newValue = null;
if (newValue != oldValue
&& (newValue == null || !newValue.equals(oldValue)))
- setValue(newValue);
+ setValue(newValue,true);
}
}
String[] keys = (String[]) variables.get("collapse");
for (int i = 0; i < keys.length; i++) {
Object id = itemIdMapper.get(keys[i]);
- if (id != null)
- collapseItem(id);
+ if (id != null && isExpanded(id)) {
+ expanded.remove(id);
+ fireCollapseEvent(id);
+ }
}
}
boolean success = ((Container.Hierarchical) items).setChildrenAllowed(
itemId, areChildrenAllowed);
if (success)
- fireValueChange();
+ fireValueChange(false);
return success;
}