1 package eu
.etaxonomy
.taxeditor
.propertysheet
;
3 import java
.util
.Collection
;
4 import java
.util
.Vector
;
6 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
7 import org
.eclipse
.ui
.views
.properties
.PropertyDescriptor
;
14 abstract public class CollectionPropertySource
implements ICdmBasePropertySource
{
16 protected Vector
<PropertyDescriptor
> descriptors
= new Vector
<PropertyDescriptor
>();
17 protected Collection
<?
> collection
;
18 private Object collectionOwner
;
20 public CollectionPropertySource(Collection
<?
> collection
) {
21 this.collection
= collection
;
22 for (Object item
: collection
) {
27 public CollectionPropertySource(Collection
<?
> collection
, Object collectionOwner
) {
28 this.collection
= collection
;
29 this.collectionOwner
= collectionOwner
;
30 for (Object item
: collection
) {
35 protected Object
getCollectionOwner() {
36 return collectionOwner
;
39 protected void addDescriptor(Object item
) {
40 String itemDisplayName
= getItemDisplayName(item
);
41 descriptors
.addElement(
42 new PropertyDescriptor(item
, itemDisplayName
));
46 * Returns the label for the name of the property sheet entry.
47 * Return "" if the entry should have no label.
52 abstract protected String
getItemDisplayName(Object item
);
54 public Object
getEditableValue() {
58 public IPropertyDescriptor
[] getPropertyDescriptors() {
59 return (IPropertyDescriptor
[]) descriptors
.toArray(
60 new IPropertyDescriptor
[descriptors
.size()]);
63 abstract public Object
getPropertyValue(Object id
);
65 public boolean isPropertySet(Object id
) {
69 public void resetPropertyValue(Object id
) {}
72 * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
74 abstract public void setPropertyValue(Object id
, Object value
);
77 * Returns the string that should appear in the parent
78 * entry's value field, which is usually "".
81 * @see java.lang.Object#toString()
84 abstract public String
toString();