You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Item.java 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.data;
  5. import java.io.Serializable;
  6. import java.util.Collection;
  7. /**
  8. * <p>
  9. * Provides a mechanism for handling a set of Properties, each associated to a
  10. * locally unique non-null identifier. The interface is split into subinterfaces
  11. * to enable a class to implement only the functionalities it needs.
  12. * </p>
  13. *
  14. * @author Vaadin Ltd
  15. * @version
  16. * @VERSION@
  17. * @since 3.0
  18. */
  19. public interface Item extends Serializable {
  20. /**
  21. * Gets the Property corresponding to the given Property ID stored in the
  22. * Item. If the Item does not contain the Property, <code>null</code> is
  23. * returned.
  24. *
  25. * @param id
  26. * identifier of the Property to get
  27. * @return the Property with the given ID or <code>null</code>
  28. */
  29. public Property getItemProperty(Object id);
  30. /**
  31. * Gets the collection of IDs of all Properties stored in the Item.
  32. *
  33. * @return unmodifiable collection containing IDs of the Properties stored
  34. * the Item
  35. */
  36. public Collection<?> getItemPropertyIds();
  37. /**
  38. * Tries to add a new Property into the Item.
  39. *
  40. * <p>
  41. * This functionality is optional.
  42. * </p>
  43. *
  44. * @param id
  45. * ID of the new Property
  46. * @param property
  47. * the Property to be added and associated with the id
  48. * @return <code>true</code> if the operation succeeded, <code>false</code>
  49. * if not
  50. * @throws UnsupportedOperationException
  51. * if the operation is not supported.
  52. */
  53. public boolean addItemProperty(Object id, Property property)
  54. throws UnsupportedOperationException;
  55. /**
  56. * Removes the Property identified by ID from the Item.
  57. *
  58. * <p>
  59. * This functionality is optional.
  60. * </p>
  61. *
  62. * @param id
  63. * ID of the Property to be removed
  64. * @return <code>true</code> if the operation succeeded
  65. * @throws UnsupportedOperationException
  66. * if the operation is not supported. <code>false</code> if not
  67. */
  68. public boolean removeItemProperty(Object id)
  69. throws UnsupportedOperationException;
  70. /**
  71. * Interface implemented by viewer classes capable of using an Item as a
  72. * data source.
  73. */
  74. public interface Viewer extends Serializable {
  75. /**
  76. * Sets the Item that serves as the data source of the viewer.
  77. *
  78. * @param newDataSource
  79. * The new data source Item
  80. */
  81. public void setItemDataSource(Item newDataSource);
  82. /**
  83. * Gets the Item serving as the data source of the viewer.
  84. *
  85. * @return data source Item
  86. */
  87. public Item getItemDataSource();
  88. }
  89. /**
  90. * Interface implemented by the <code>Editor</code> classes capable of
  91. * editing the Item. Implementing this interface means that the Item serving
  92. * as the data source of the editor can be modified through it.
  93. * <p>
  94. * Note : Not implementing the <code>Item.Editor</code> interface does not
  95. * restrict the class from editing the contents of an internally.
  96. * </p>
  97. */
  98. public interface Editor extends Item.Viewer, Serializable {
  99. }
  100. /* Property set change event */
  101. /**
  102. * An <code>Event</code> object specifying the Item whose contents has been
  103. * changed through the <code>Property</code> interface.
  104. * <p>
  105. * Note: The values stored in the Properties may change without triggering
  106. * this event.
  107. * </p>
  108. */
  109. public interface PropertySetChangeEvent extends Serializable {
  110. /**
  111. * Retrieves the Item whose contents has been modified.
  112. *
  113. * @return source Item of the event
  114. */
  115. public Item getItem();
  116. }
  117. /**
  118. * The listener interface for receiving <code>PropertySetChangeEvent</code>
  119. * objects.
  120. */
  121. public interface PropertySetChangeListener extends Serializable {
  122. /**
  123. * Notifies this listener that the Item's property set has changed.
  124. *
  125. * @param event
  126. * Property set change event object
  127. */
  128. public void itemPropertySetChange(Item.PropertySetChangeEvent event);
  129. }
  130. /**
  131. * The interface for adding and removing <code>PropertySetChangeEvent</code>
  132. * listeners. By implementing this interface a class explicitly announces
  133. * that it will generate a <code>PropertySetChangeEvent</code> when its
  134. * Property set is modified.
  135. * <p>
  136. * Note : The general Java convention is not to explicitly declare that a
  137. * class generates events, but to directly define the
  138. * <code>addListener</code> and <code>removeListener</code> methods. That
  139. * way the caller of these methods has no real way of finding out if the
  140. * class really will send the events, or if it just defines the methods to
  141. * be able to implement an interface.
  142. * </p>
  143. */
  144. public interface PropertySetChangeNotifier extends Serializable {
  145. /**
  146. * Registers a new property set change listener for this Item.
  147. *
  148. * @param listener
  149. * The new Listener to be registered.
  150. */
  151. public void addListener(Item.PropertySetChangeListener listener);
  152. /**
  153. * Removes a previously registered property set change listener.
  154. *
  155. * @param listener
  156. * Listener to be removed.
  157. */
  158. public void removeListener(Item.PropertySetChangeListener listener);
  159. }
  160. }