Changeset 5234
- Timestamp:
- 08/21/08 10:28:00 (3 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/itmill/toolkit/data/util/IndexedContainer.java
r5186 r5234 44 44 Cloneable, Container.Filterable { 45 45 46 /* Internal structure * ************************************************** */46 /* Internal structure */ 47 47 48 48 /** … … 115 115 private HashSet filters; 116 116 117 /* Container constructors * ********************************************** */117 /* Container constructors */ 118 118 119 119 public IndexedContainer() { … … 128 128 } 129 129 130 /* Container methods * *************************************************** */130 /* Container methods */ 131 131 132 132 /** … … 136 136 * 137 137 * @param itemId 138 * the ID of the Item to retrieve.138 * the ID of the Item to retrieve. 139 139 * @return the Item with the given ID or <code>null</code> if the Item is 140 140 * not found in the list … … 181 181 * 182 182 * @param id 183 * the ID of the Property.183 * the ID of the Property. 184 184 * @return Type of the requested Property 185 185 */ … … 190 190 /** 191 191 * Gets the Property identified by the given Item ID and Property ID from 192 * the lsit. If the list does not contain the Property, <code>null</code> 193 * isreturned.192 * the lsit. If the list does not contain the Property, <code>null</code> is 193 * returned. 194 194 * 195 195 * @param itemId 196 * the ID of the Item which contains the requested Property.196 * the ID of the Item which contains the requested Property. 197 197 * @param propertyId 198 * the ID of the Property to retrieve.198 * the ID of the Property to retrieve. 199 199 * @return Property with the given ID or <code>null</code> 200 200 * … … 230 230 * 231 231 * @param itemId 232 * the ID the of Item to be tested for.233 * @return <code>true</code> if the operation succeeded, 234 * <code>false</code>if not232 * the ID the of Item to be tested for. 233 * @return <code>true</code> if the operation succeeded, <code>false</code> 234 * if not 235 235 */ 236 236 public boolean containsId(Object itemId) { … … 246 246 * 247 247 * @param propertyId 248 * the ID of the new Property.248 * the ID of the new Property. 249 249 * @param type 250 * the Data type of the new Property.250 * the Data type of the new Property. 251 251 * @param defaultValue 252 * the value all created Properties are initialized to.253 * @return <code>true</code> if the operation succeeded, 254 * <code>false</code>if not252 * the value all created Properties are initialized to. 253 * @return <code>true</code> if the operation succeeded, <code>false</code> 254 * if not 255 255 */ 256 256 public boolean addContainerProperty(Object propertyId, Class type, … … 291 291 * </p> 292 292 * 293 * @return <code>true</code> if the operation succeeded, 294 * <code>false</code>if not293 * @return <code>true</code> if the operation succeeded, <code>false</code> 294 * if not 295 295 */ 296 296 public boolean removeAllItems() { … … 312 312 * Creates a new Item into the list, and assign it an automatic ID. The new 313 313 * ID is returned, or <code>null</code> if the operation fails. After a 314 * successful call you can use the 315 * {@link #getItem(Object ItemId) <code>getItem</code>}method to fetch the 316 * Item. 314 * successful call you can use the {@link #getItem(Object ItemId) 315 * <code>getItem</code>}method to fetch the Item. 317 316 * 318 317 * @return ID of the newly created Item, or <code>null</code> in case of a … … 337 336 * 338 337 * @param itemId 339 * the ID of the Item to be created.338 * the ID of the Item to be created. 340 339 * @return Created new Item, or <code>null</code> in case of a failure 341 340 */ … … 355 354 itemIds.add(itemId); 356 355 items.put(itemId, new Hashtable()); 357 final Item item = getItem(itemId);356 final Item item = new IndexedContainerItem(itemId); 358 357 if (filteredItemIds != null) { 359 358 if (passesFilters(item)) { … … 372 371 * 373 372 * @param itemId 374 * the ID of the Item to remove.375 * @return <code>true</code> if the operation succeeded, 376 * <code>false</code>if not373 * the ID of the Item to remove. 374 * @return <code>true</code> if the operation succeeded, <code>false</code> 375 * if not 377 376 */ 378 377 public boolean removeItem(Object itemId) { … … 396 395 * 397 396 * @param propertyId 398 * the ID of the Property to remove.399 * @return <code>true</code> if the operation succeeded, 400 * <code>false</code>if not397 * the ID of the Property to remove. 398 * @return <code>true</code> if the operation succeeded, <code>false</code> 399 * if not 401 400 */ 402 401 public boolean removeContainerProperty(Object propertyId) { … … 422 421 } 423 422 424 /* Container.Ordered methods * ******************************************* */423 /* Container.Ordered methods */ 425 424 426 425 /** … … 468 467 * 469 468 * @param itemId 470 * the ID of an Item in the list.469 * the ID of an Item in the list. 471 470 * @return ID of the next Item or <code>null</code> 472 471 */ … … 501 500 * 502 501 * @param itemId 503 * the ID of an Item in the list.502 * the ID of an Item in the list. 504 503 * @return ID of the previous Item or <code>null</code> 505 504 */ … … 532 531 * 533 532 * @param itemId 534 * the ID of an Item in the list.533 * the ID of an Item in the list. 535 534 * @return <code>true</code> if the Item is first in the list, 536 535 * <code>false</code> if not … … 553 552 * 554 553 * @param itemId 555 * the ID of an Item in the list.554 * the ID of an Item in the list. 556 555 * @return <code>true</code> if the Item is last in the list, 557 556 * <code>false</code> if not … … 614 613 * @return ID in the given index. 615 614 * @param index 616 * Index of the requested ID in the container.615 * Index of the requested ID in the container. 617 616 */ 618 617 public Object getIdByIndex(int index) { … … 637 636 638 637 /** 639 * Gets the index of an id. The following is true for the index: 0 <= index <640 * size().638 * Gets the index of an id. The following is true for the index: 0 <= index 639 * < size(). 641 640 * 642 641 * @return Index of the Item or -1 if the Item is not in the container. 643 642 * @param itemId 644 * ID of an Item in the collection643 * ID of an Item in the collection 645 644 */ 646 645 public int indexOfId(Object itemId) { … … 700 699 } 701 700 702 /* Event notifiers * ***************************************************** */701 /* Event notifiers */ 703 702 704 703 /** … … 749 748 */ 750 749 private static final long serialVersionUID = 3832616279386372147L; 751 private int addedItemIndex;750 private final int addedItemIndex; 752 751 753 752 private ItemSetChangeEvent(IndexedContainer source, int addedItemIndex) { … … 778 777 779 778 /** 780 * An <code>event</code> object specifying the Propery in a list whose 781 * valuehas changed.779 * An <code>event</code> object specifying the Propery in a list whose value 780 * has changed. 782 781 * 783 782 * @author IT Mill Ltd. … … 813 812 * 814 813 * @param listener 815 * the new Listener to be registered.814 * the new Listener to be registered. 816 815 */ 817 816 public void addListener(Container.PropertySetChangeListener listener) { … … 826 825 * 827 826 * @param listener 828 * the listener to be removed.827 * the listener to be removed. 829 828 */ 830 829 public void removeListener(Container.PropertySetChangeListener listener) { … … 838 837 * 839 838 * @param listener 840 * the listener to be added.839 * the listener to be added. 841 840 */ 842 841 public void addListener(Container.ItemSetChangeListener listener) { … … 851 850 * 852 851 * @param listener 853 * the listener to be removed.852 * the listener to be removed. 854 853 */ 855 854 public void removeListener(Container.ItemSetChangeListener listener) { … … 863 862 * 864 863 * @param listener 865 * the new Listener to be registered864 * the new Listener to be registered 866 865 */ 867 866 public void addListener(Property.ValueChangeListener listener) { … … 876 875 * 877 876 * @param listener 878 * the listener to be removed.877 * the listener to be removed. 879 878 */ 880 879 public void removeListener(Property.ValueChangeListener listener) { … … 888 887 * 889 888 * @param source 890 * the IndexedContainerProperty object.889 * the IndexedContainerProperty object. 891 890 */ 892 891 private void firePropertyValueChange(IndexedContainerProperty source) { … … 942 941 * 943 942 * @param addedItemIndex 944 * index of new item if change event was an item addition943 * index of new item if change event was an item addition 945 944 */ 946 945 private void fireContentsChange(int addedItemIndex) { … … 960 959 * 961 960 * @param propertyId 962 * the ID of the Property to add.961 * the ID of the Property to add. 963 962 * @param itemId 964 * the ID of the Item .963 * the ID of the Item . 965 964 * @param listener 966 * the listener to be added.965 * the listener to be added. 967 966 */ 968 967 private void addSinglePropertyChangeListener(Object propertyId, … … 993 992 * 994 993 * @param propertyId 995 * the ID of the Property to remove.994 * the ID of the Property to remove. 996 995 * @param itemId 997 * the ID of the Item.996 * the ID of the Item. 998 997 * @param listener 999 * the listener to be removed.998 * the listener to be removed. 1000 999 */ 1001 1000 private void removeSinglePropertyChangeListener(Object propertyId, … … 1023 1022 } 1024 1023 1025 /* Internal Item and Property implementations * ************************** */1024 /* Internal Item and Property implementations */ 1026 1025 1027 1026 /* … … 1030 1029 * 1031 1030 * @version @VERSION@ 1031 * 1032 1032 * @since 3.0 1033 1033 */ … … 1044 1044 * 1045 1045 * @param itemId 1046 * the Item ID of the new Item.1046 * the Item ID of the new Item. 1047 1047 */ 1048 1048 private IndexedContainerItem(Object itemId) { … … 1061 1061 * 1062 1062 * @param id 1063 * the identifier of the Property to get.1063 * the identifier of the Property to get. 1064 1064 * @return the Property with the given ID or <code>null</code> 1065 1065 */ … … 1118 1118 * 1119 1119 * @param obj 1120 * an object to compare with this object1120 * an object to compare with this object 1121 1121 * @return <code>true</code> if the given object is the same as this 1122 1122 * object, <code>false</code> if not … … 1191 1191 * 1192 1192 * @param itemId 1193 * the ID of the Item to connect the new Property to.1193 * the ID of the Item to connect the new Property to. 1194 1194 * @param propertyId 1195 * the Property ID of the new Property.1195 * the Property ID of the new Property. 1196 1196 * @param host 1197 * the list that contains the Item to contain the new1198 * Property.1197 * the list that contains the Item to contain the new 1198 * Property. 1199 1199 */ 1200 1200 private IndexedContainerProperty(Object itemId, Object propertyId) { … … 1210 1210 /** 1211 1211 * Returns the type of the Property. The methods <code>getValue</code> 1212 * and <code>setValue</code> must be compatible with this type: one 1213 * must be able to safely cast the value returned from1214 * <code>getValue</code> to the given type and pass any variable1215 * assignable to this type as aparameter to <code>setValue</code.1212 * and <code>setValue</code> must be compatible with this type: one must 1213 * be able to safely cast the value returned from <code>getValue</code> 1214 * to the given type and pass any variable assignable to this type as a 1215 * parameter to <code>setValue</code. 1216 1216 * 1217 1217 * @return the type of the Property. … … 1231 1231 1232 1232 /** 1233 * <p> 1234 * Tests if the Property is in read-only mode. In read-only mode calls 1235 * to the method <code>setValue</code> will throw 1236 * <code>ReadOnlyException</code> s and will not modify the value of 1237 * the Property. 1238 * </p> 1233 * <p> Tests if the Property is in read-only mode. In read-only mode 1234 * calls to the method <code>setValue</code> will throw 1235 * <code>ReadOnlyException</code> s and will not modify the value of the 1236 * Property. </p> 1239 1237 * 1240 1238 * @return <code>true</code> if the Property is in read-only mode, … … 1249 1247 * 1250 1248 * @param newStatus 1251 * the new read-only status of the Property.1249 * the new read-only status of the Property. 1252 1250 */ 1253 1251 public void setReadOnly(boolean newStatus) { … … 1262 1260 * Sets the value of the Property. By default this method will try to 1263 1261 * assign the value directly, but if it is unassignable, it will try to 1264 * use the <code>String</code> constructor of the internal data type 1265 * toassign the value,1262 * use the <code>String</code> constructor of the internal data type to 1263 * assign the value, 1266 1264 * 1267 1265 * @param newValue 1268 * the New value of the Property. This should be1269 * assignableto the Property's internal type or support1270 * <code>toString</code>.1266 * the New value of the Property. This should be assignable 1267 * to the Property's internal type or support 1268 * <code>toString</code>. 1271 1269 * 1272 1270 * @throws Property.ReadOnlyException 1273 * if the object is in read-only mode1271 * if the object is in read-only mode 1274 1272 * @throws Property.ConversionException 1275 * if <code>newValue</code> can't be converted into1276 * theProperty's native type directly or through1277 * <code>String</code>1273 * if <code>newValue</code> can't be converted into the 1274 * Property's native type directly or through 1275 * <code>String</code> 1278 1276 */ 1279 1277 public void setValue(Object newValue) … … 1315 1313 * method if the Property is not in read-only mode. 1316 1314 * 1317 * @return <code>String</code> representation of the value stored in 1318 * theProperty1315 * @return <code>String</code> representation of the value stored in the 1316 * Property 1319 1317 */ 1320 1318 public String toString() { … … 1344 1342 * 1345 1343 * @param obj 1346 * an object to compare with this object1344 * an object to compare with this object 1347 1345 * @return <code>true</code> if the given object is the same as this 1348 1346 * object, <code>false</code> if not … … 1363 1361 * 1364 1362 * @param listener 1365 * the new Listener to be registered.1363 * the new Listener to be registered. 1366 1364 * @see com.itmill.toolkit.data.Property.ValueChangeNotifier#addListener(ValueChangeListener) 1367 1365 */ … … 1374 1372 * 1375 1373 * @param listener 1376 * listener to be removed1374 * listener to be removed 1377 1375 * @see com.itmill.toolkit.data.Property.ValueChangeNotifier#removeListener(ValueChangeListener) 1378 1376 */ … … 1431 1429 * (non-Javadoc) 1432 1430 * 1433 * @see com.itmill.toolkit.data.Container.Sortable#getSortableContainerPropertyIds() 1431 * @see 1432 * com.itmill.toolkit.data.Container.Sortable#getSortableContainerPropertyIds 1433 * () 1434 1434 */ 1435 1435 public Collection getSortableContainerPropertyIds() { … … 1500 1500 * 1501 1501 * @throws CloneNotSupportedException 1502 * if an object cannot be cloned. .1502 * if an object cannot be cloned. . 1503 1503 */ 1504 1504 public Object clone() throws CloneNotSupportedException {
