From 462ff9bc39b25577c2092416c417bf7071d426f1 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Tue, 2 Sep 2008 05:57:33 +0000 Subject: [PATCH] fixed item set change listening. Broken since [5281] svn changeset:5320/svn branch:trunk --- src/com/itmill/toolkit/ui/AbstractSelect.java | 130 +++++++++--------- 1 file changed, 64 insertions(+), 66 deletions(-) diff --git a/src/com/itmill/toolkit/ui/AbstractSelect.java b/src/com/itmill/toolkit/ui/AbstractSelect.java index 9f9fbc7b0a..c1f192586e 100644 --- a/src/com/itmill/toolkit/ui/AbstractSelect.java +++ b/src/com/itmill/toolkit/ui/AbstractSelect.java @@ -47,8 +47,8 @@ public abstract class AbstractSelect extends AbstractField implements Container.ItemSetChangeListener { /** - * Item caption mode: Item's ID's String representation is used - * as caption. + * Item caption mode: Item's ID's String representation is + * used as caption. */ public static final int ITEM_CAPTION_MODE_ID = 0; /** @@ -87,8 +87,8 @@ public abstract class AbstractSelect extends AbstractField implements * entered value. The value is matched to the item caption. * FILTERINGMODE_OFF (0) turns the filtering off. * FILTERINGMODE_STARTSWITH (1) matches from the start of the - * caption. FILTERINGMODE_CONTAINS (1) matches anywhere in the - * caption. + * caption. FILTERINGMODE_CONTAINS (1) matches anywhere in + * the caption. */ public interface Filtering { public static final int FILTERINGMODE_OFF = 0; @@ -99,7 +99,7 @@ public abstract class AbstractSelect extends AbstractField implements * Sets the option filtering mode. * * @param filteringMode - * the filtering mode to use + * the filtering mode to use */ public void setFilteringMode(int filteringMode); @@ -206,9 +206,10 @@ public abstract class AbstractSelect extends AbstractField implements * Creates a new select that is connected to a data-source. * * @param caption - * the Caption of the component. + * the Caption of the component. * @param dataSource - * the Container datasource to be selected from by this select. + * the Container datasource to be selected from by this + * select. */ public AbstractSelect(String caption, Container dataSource) { setCaption(caption); @@ -219,9 +220,9 @@ public abstract class AbstractSelect extends AbstractField implements * Creates a new select that is filled from a collection of option values. * * @param caption - * the Caption of this field. + * the Caption of this field. * @param options - * the Collection containing the options. + * the Collection containing the options. */ public AbstractSelect(String caption, Collection options) { @@ -243,9 +244,9 @@ public abstract class AbstractSelect extends AbstractField implements * Paints the content of this component. * * @param target - * the Paint Event. + * the Paint Event. * @throws PaintException - * if the paint operation failed. + * if the paint operation failed. */ public void paintContent(PaintTarget target) throws PaintException { @@ -530,9 +531,9 @@ public abstract class AbstractSelect extends AbstractField implements /** * Returns the type of the property. getValue and - * setValue methods must be compatible with this type: one can - * safely cast getValue to given type and pass any variable - * assignable to this type as a parameter to setValue. + * setValue methods must be compatible with this type: one + * can safely cast getValue to given type and pass any + * variable assignable to this type as a parameter to setValue. * * @return the Type of the property. */ @@ -585,7 +586,7 @@ public abstract class AbstractSelect extends AbstractField implements *

* * @param newValue - * the New selected item or collection of selected items. + * the New selected item or collection of selected items. * @see com.itmill.toolkit.ui.AbstractField#setValue(java.lang.Object) */ public void setValue(Object newValue) throws Property.ReadOnlyException, @@ -607,9 +608,9 @@ public abstract class AbstractSelect extends AbstractField implements *

* * @param newValue - * the New selected item or collection of selected items. + * the New selected item or collection of selected items. * @param repaintIsNotNeeded - * True if caller is sure that repaint is not needed. + * True if caller is sure that repaint is not needed. * @see com.itmill.toolkit.ui.AbstractField#setValue(java.lang.Object, * java.lang.Boolean) */ @@ -635,7 +636,7 @@ public abstract class AbstractSelect extends AbstractField implements * contain the requested item, null is returned. * * @param itemId - * the item id. + * the item id. * @return the item from the container. */ public Item getItem(Object itemId) { @@ -664,7 +665,7 @@ public abstract class AbstractSelect extends AbstractField implements * Gets the property type. * * @param propertyId - * the Id identifying the property. + * the Id identifying the property. * @see com.itmill.toolkit.data.Container#getType(java.lang.Object) */ public Class getType(Object propertyId) { @@ -686,7 +687,7 @@ public abstract class AbstractSelect extends AbstractField implements * Tests, if the collection contains an item with given id. * * @param itemId - * the Id the of item to be tested. + * the Id the of item to be tested. */ public boolean containsId(Object itemId) { if (itemId != null) { @@ -779,7 +780,7 @@ public abstract class AbstractSelect extends AbstractField implements * returns null. * * @param itemId - * the Identification of the item to be created. + * the Identification of the item to be created. * @return the Created item with the given id, or null in case of failure. * @see com.itmill.toolkit.data.Container#addItem(java.lang.Object) */ @@ -839,7 +840,7 @@ public abstract class AbstractSelect extends AbstractField implements * Sets the container as data-source for viewing. * * @param newDataSource - * the new data source. + * the new data source. */ public void setContainerDataSource(Container newDataSource) { if (newDataSource == null) { @@ -852,7 +853,7 @@ public abstract class AbstractSelect extends AbstractField implements // Removes listeners from the old datasource if (items != null) { - if (items instanceof Container.ItemSetChangeListener) { + if (items instanceof Container.ItemSetChangeNotifier) { ((Container.ItemSetChangeNotifier) items) .removeListener(this); } @@ -870,7 +871,7 @@ public abstract class AbstractSelect extends AbstractField implements // Adds listeners if (items != null) { - if (items instanceof Container.ItemSetChangeListener) { + if (items instanceof Container.ItemSetChangeNotifier) { ((Container.ItemSetChangeNotifier) items).addListener(this); } if (items instanceof Container.PropertySetChangeNotifier) { @@ -910,7 +911,7 @@ public abstract class AbstractSelect extends AbstractField implements * selected items, only one of the selected items is kept as selected. * * @param multiSelect - * the New value of property multiSelect. + * the New value of property multiSelect. */ public void setMultiSelect(boolean multiSelect) { if (multiSelect && getNullSelectionItemId() != null) { @@ -962,7 +963,7 @@ public abstract class AbstractSelect extends AbstractField implements * Enables or disables possibility to add new options by the user. * * @param allowNewOptions - * the New value of property allowNewOptions. + * the New value of property allowNewOptions. */ public void setNewItemsAllowed(boolean allowNewOptions) { @@ -980,9 +981,9 @@ public abstract class AbstractSelect extends AbstractField implements * item and index captions. * * @param itemId - * the id of the item to be recaptioned. + * the id of the item to be recaptioned. * @param caption - * the New caption. + * the New caption. */ public void setItemCaption(Object itemId, String caption) { if (itemId != null) { @@ -997,7 +998,7 @@ public abstract class AbstractSelect extends AbstractField implements * details. * * @param itemId - * the id of the item to be queried. + * the id of the item to be queried. * @return the caption for specified item. */ public String getItemCaption(Object itemId) { @@ -1059,9 +1060,9 @@ public abstract class AbstractSelect extends AbstractField implements * Sets the icon for an item. * * @param itemId - * the id of the item to be assigned an icon. + * the id of the item to be assigned an icon. * @param icon - * the New icon. + * the New icon. */ public void setItemIcon(Object itemId, Resource icon) { if (itemId != null) { @@ -1078,7 +1079,7 @@ public abstract class AbstractSelect extends AbstractField implements * Gets the item icon. * * @param itemId - * the id of the item to be assigned an icon. + * the id of the item to be assigned an icon. * @return the Icon for the item or null, if not specified. */ public Resource getItemIcon(Object itemId) { @@ -1117,13 +1118,13 @@ public abstract class AbstractSelect extends AbstractField implements * toString is used as item caption. *
  • ITEM_CAPTION_MODE_ITEM : Item-objects * toString is used as item caption.
  • - *
  • ITEM_CAPTION_MODE_INDEX : The index of the item is used - * as item caption. The index mode can only be used with the containers + *
  • ITEM_CAPTION_MODE_INDEX : The index of the item is + * used as item caption. The index mode can only be used with the containers * implementing Container.Indexed interface.
  • - *
  • ITEM_CAPTION_MODE_EXPLICIT : The item captions must be - * explicitly specified.
  • - *
  • ITEM_CAPTION_MODE_PROPERTY : The item captions are read - * from property, that must be specified with + *
  • ITEM_CAPTION_MODE_EXPLICIT : The item captions must + * be explicitly specified.
  • + *
  • ITEM_CAPTION_MODE_PROPERTY : The item captions are + * read from property, that must be specified with * setItemCaptionPropertyId.
  • * * The ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID is the default @@ -1131,7 +1132,7 @@ public abstract class AbstractSelect extends AbstractField implements *

    * * @param mode - * the One of the modes listed above. + * the One of the modes listed above. */ public void setItemCaptionMode(int mode) { if (ITEM_CAPTION_MODE_ID <= mode && mode <= ITEM_CAPTION_MODE_PROPERTY) { @@ -1153,13 +1154,13 @@ public abstract class AbstractSelect extends AbstractField implements * toString is used as item caption. *
  • ITEM_CAPTION_MODE_ITEM : Item-objects * toString is used as item caption.
  • - *
  • ITEM_CAPTION_MODE_INDEX : The index of the item is used - * as item caption. The index mode can only be used with the containers + *
  • ITEM_CAPTION_MODE_INDEX : The index of the item is + * used as item caption. The index mode can only be used with the containers * implementing Container.Indexed interface.
  • - *
  • ITEM_CAPTION_MODE_EXPLICIT : The item captions must be - * explicitly specified.
  • - *
  • ITEM_CAPTION_MODE_PROPERTY : The item captions are read - * from property, that must be specified with + *
  • ITEM_CAPTION_MODE_EXPLICIT : The item captions must + * be explicitly specified.
  • + *
  • ITEM_CAPTION_MODE_PROPERTY : The item captions are + * read from property, that must be specified with * setItemCaptionPropertyId.
  • * * The ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID is the default @@ -1178,19 +1179,18 @@ public abstract class AbstractSelect extends AbstractField implements *

    * Setting the id to a existing property implicitly sets the item caption * mode to ITEM_CAPTION_MODE_PROPERTY. If the object is in - * ITEM_CAPTION_MODE_PROPERTY mode, setting caption property id - * null resets the item caption mode to + * ITEM_CAPTION_MODE_PROPERTY mode, setting caption property + * id null resets the item caption mode to * ITEM_CAPTION_EXPLICIT_DEFAULTS_ID. *

    * *

    * Setting the property id to null disables this feature. The id is null by * default - *

    - * . + *

    . * * @param propertyId - * the id of the property. + * the id of the property. * */ public void setItemCaptionPropertyId(Object propertyId) { @@ -1226,18 +1226,17 @@ public abstract class AbstractSelect extends AbstractField implements *

    * *

    - * Note : The icons set with setItemIcon function override the - * icons from the property. + * Note : The icons set with setItemIcon function override + * the icons from the property. *

    * *

    * Setting the property id to null disables this feature. The id is null by * default - *

    - * . + *

    . * * @param propertyId - * the Id of the property that specifies icons for items. + * the Id of the property that specifies icons for items. */ public void setItemIconPropertyId(Object propertyId) { if ((propertyId != null) @@ -1259,15 +1258,14 @@ public abstract class AbstractSelect extends AbstractField implements *

    * *

    - * Note : The icons set with setItemIcon function override the - * icons from the property. + * Note : The icons set with setItemIcon function override + * the icons from the property. *

    * *

    * Setting the property id to null disables this feature. The id is null by * default - *

    - * . + *

    . * * @return the Id of the property containing the item icons. */ @@ -1285,7 +1283,7 @@ public abstract class AbstractSelect extends AbstractField implements *

    * * @param itemId - * the Id the of the item to be tested. + * the Id the of the item to be tested. * @see #getNullSelectionItemId() * @see #setNullSelectionItemId(Object) * @@ -1312,7 +1310,7 @@ public abstract class AbstractSelect extends AbstractField implements *

    * * @param itemId - * the tem to be selected. + * the tem to be selected. * @see #getNullSelectionItemId() * @see #setNullSelectionItemId(Object) * @@ -1332,7 +1330,7 @@ public abstract class AbstractSelect extends AbstractField implements * Unselects an item. * * @param itemId - * the Item to be unselected. + * the Item to be unselected. * @see #getNullSelectionItemId() * @see #setNullSelectionItemId(Object) * @@ -1491,11 +1489,11 @@ public abstract class AbstractSelect extends AbstractField implements /** * Allow of disallow empty selection. If the select is in single-select * mode, you can make an item represent the empty selection by calling - * setNullSelectionItemId(). This way you can for instance set - * an icon and caption for the null selection item. + * setNullSelectionItemId(). This way you can for instance + * set an icon and caption for the null selection item. * * @param nullSelectionAllowed - * whether or not to allow empty selection + * whether or not to allow empty selection * @see #setNullSelectionItemId(Object) * @see #isNullSelectionAllowed() */ @@ -1542,7 +1540,7 @@ public abstract class AbstractSelect extends AbstractField implements *

    * * @param nullSelectionItemId - * the nullSelectionItemId to set. + * the nullSelectionItemId to set. * @see #getNullSelectionItemId() * @see #isSelected(Object) * @see #select(Object) -- 2.39.5