1 package eu
.etaxonomy
.taxeditor
.propertysheet
;
3 import java
.util
.Collection
;
4 import java
.util
.Vector
;
6 import org
.apache
.log4j
.Logger
;
7 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
8 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
9 import org
.eclipse
.ui
.views
.properties
.PropertyDescriptor
;
16 abstract public class CollectionPropertySource
implements IPropertySource
{
17 private static final Logger logger
= Logger
18 .getLogger(CollectionPropertySource
.class);
20 protected Vector
<PropertyDescriptor
> descriptors
= new Vector
<PropertyDescriptor
>();
21 protected Collection collection
;
22 private Object collectionOwner
;
24 public CollectionPropertySource(Collection collection
) {
25 this.collection
= collection
;
26 for (Object item
: collection
) {
31 public CollectionPropertySource(Collection collection
, Object collectionOwner
) {
32 this.collection
= collection
;
33 this.collectionOwner
= collectionOwner
;
34 for (Object item
: collection
) {
39 protected Object
getCollectionOwner() {
40 return collectionOwner
;
43 protected void addDescriptor(Object item
) {
44 String itemDisplayName
= getItemDisplayName(item
);
45 descriptors
.addElement(
46 new PropertyDescriptor(item
, itemDisplayName
));
50 * Returns the label for the name of the property sheet entry.
51 * Return "" if the entry should have no label.
56 abstract protected String
getItemDisplayName(Object item
);
58 public Object
getEditableValue() {
62 public IPropertyDescriptor
[] getPropertyDescriptors() {
63 return (IPropertyDescriptor
[]) descriptors
.toArray(
64 new IPropertyDescriptor
[descriptors
.size()]);
67 abstract public Object
getPropertyValue(Object id
);
69 public boolean isPropertySet(Object id
) {
73 public void resetPropertyValue(Object id
) {}
76 * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
78 abstract public void setPropertyValue(Object id
, Object value
);
81 * Returns the string that should appear in the parent
82 * entry's value field, which is usually "".
85 * @see java.lang.Object#toString()
88 abstract public String
toString();