propertyManager
Class ReadableProperty

java.lang.Object
  extended by propertyManager.ReadableProperty
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
EditableProperty

public class ReadableProperty
extends java.lang.Object
implements java.io.Serializable

Author:
Dan Phifer The ReadableProperty class provides read-only support for Properties. It is used in conjuction with the PropertyManager class which allows easy integration with the built-in Eclipse Properties View.
 + ReadableProperty                             // read-only support
 +--+ EditableProperty                  // Text editable
 +--+--- EditableBooleanProperty
    +--- EditableComboProperty  // Drop down box
    +--- EditableIntegerProperty        (INumericProperty) // Integer Editable
    +--- EditableFloatProperty  (INumericProperty) // Float Editable
 
See Also:
Serialized Form

Nested Class Summary
(package private)  class ReadableProperty.SubPropertyChangeListener
           
 
Field Summary
private  java.lang.String category
          The category of this property.
protected  java.lang.Object defaultValue
          The underlying default value.
private  java.lang.String ID
          A unique ID for this property
private  org.eclipse.jface.viewers.LabelProvider labelProvider
           
private  java.lang.String name
          A human-readable String to be shown to the user
private  java.util.ArrayList propertyChangeListeners
           
private static long serialVersionUID
           
private  PropertyManager subProperites
           
private  java.beans.PropertyChangeListener subPropertyListener
           
protected  java.lang.Object value
          the current underlying value
 
Constructor Summary
ReadableProperty(java.lang.String ID, java.lang.String name)
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 org.eclipse.ui.views.properties.PropertyDescriptor getCustomPropertyDescriptor()
          This method can be overridden by suclasses.
 java.lang.Object getDefaultValue()
           
 java.lang.String getID()
           
 java.lang.String getName()
           
 org.eclipse.ui.views.properties.PropertyDescriptor getPropertyDescriptor()
           
private  org.eclipse.ui.views.properties.PropertyDescriptor getReadOnlyPropertyDescriptor()
           
private  java.beans.PropertyChangeListener getSubPropertyListener()
           
 java.lang.Object getSubPropertyManager()
           
 java.lang.Object getUnderlyingDefaultValue()
           
protected  java.lang.Object getUnderlyingValue()
           
 java.lang.Object getValue()
           
 boolean hasDefaultValue()
           
 boolean hasDynamicPropertyDescriptor()
           
 boolean hasSubProperties()
           
 boolean hasValue()
           
protected  void notifyPropertyChangeListeners(java.beans.PropertyChangeEvent event)
          Notify the propertChangeListeners that this property has changed
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void setCategory(java.lang.String category)
          Sets the category of this property.
 void setDefaultValue(java.lang.Object defaultValue)
          Unless overidden by a subclass, this is equivalent to the setUnderlyingDefaultValue.
 void setLabelProvider(org.eclipse.jface.viewers.LabelProvider provider)
          Sets the lable provider for this property.
 void setSubPropertyManager(PropertyManager propertyManager)
           
 void setUnderlyingDefaultValue(java.lang.Object defaultValue)
          Sets the underlying default value.
 void setUnderlyingValue(java.lang.Object newValue)
          Sets the value of the EditableProperty and fires the PropertyChange event
 void setValue(java.lang.Object newValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

ID

private java.lang.String ID
A unique ID for this property


name

private java.lang.String name
A human-readable String to be shown to the user


defaultValue

protected java.lang.Object defaultValue
The underlying default value. The underlying value is passed between the PropertyManager and the Properties View, while the value is passed between the PropertiesManager and the client. This avoids rewriting code that translates the String value needed by the Properties view and the value needed by the client. For instance, if the client wants to expose a Float property, the client class should not have to worry about translating from String to Float and vice versa. Therefore, the EditableFloatProperty handles this translation behind the scenes, and the client can be ignorant of any translation that needs to take place.


value

protected java.lang.Object value
the current underlying value


category

private java.lang.String category
The category of this property. Categories can be used to organize properties in the PropertiesView if sorting them alphabetically is not managable


labelProvider

private org.eclipse.jface.viewers.LabelProvider labelProvider

subProperites

private PropertyManager subProperites

propertyChangeListeners

private java.util.ArrayList propertyChangeListeners

subPropertyListener

private java.beans.PropertyChangeListener subPropertyListener
Constructor Detail

ReadableProperty

public ReadableProperty(java.lang.String ID,
                        java.lang.String name)
Parameters:
ID - The unique ID to be used for this property.
name - The name to be displayed to the user
Method Detail

getDefaultValue

public java.lang.Object getDefaultValue()
Returns:
By default, the default underlying value is returned.

getUnderlyingDefaultValue

public java.lang.Object getUnderlyingDefaultValue()
Returns:
The underlying default value. This is the value that should be ultimately returned to the properties view.

setUnderlyingValue

public void setUnderlyingValue(java.lang.Object newValue)
Sets the value of the EditableProperty and fires the PropertyChange event

Parameters:
newValue - The new PropertyValue

setValue

public void setValue(java.lang.Object newValue)

setDefaultValue

public void setDefaultValue(java.lang.Object defaultValue)
Unless overidden by a subclass, this is equivalent to the setUnderlyingDefaultValue. Subclasses may overide this method if they need to proprocess (or translate) the value before setting the underlying default value, which the Properties view will ultimately work with.

Parameters:
defaultValue - The new default value.

setUnderlyingDefaultValue

public void setUnderlyingDefaultValue(java.lang.Object defaultValue)
Sets the underlying default value. No translation occurs before setting the value

Parameters:
defaultValue - The new underlying default value
See Also:
setDefaultValue(Object defaultValue)

getID

public java.lang.String getID()
Returns:
the unique ID of the object.

getName

public java.lang.String getName()
Returns:
The name of the object. The name is displayed to the user

getValue

public java.lang.Object getValue()
Returns:
By default, the ReadableProperty class returns the underlying value

getUnderlyingValue

protected java.lang.Object getUnderlyingValue()
Returns:
The underlying value. For readable properties, the underlying value is the same as the value. However, when dealing with Custom types, it is more convenient for the getValue function to return an object of the correct type, rather than a string which must be parsed. Or, in the case of a combo property, the value associated with the item selected, instead of the index of the item (which is what the Properties view returns).

setCategory

public void setCategory(java.lang.String category)
Sets the category of this property. In the properties view, the user can choose to see the properties by category, or alphabetically.

Parameters:
category - The category ID (and description)

setLabelProvider

public void setLabelProvider(org.eclipse.jface.viewers.LabelProvider provider)
Sets the lable provider for this property. This allows for a custom text be shown in the properties view

Parameters:
provider -

hasValue

public boolean hasValue()
Returns:
true if the value is anything other than null

hasDefaultValue

public boolean hasDefaultValue()
Returns:
true if the defaultValue is anything other than null

getPropertyDescriptor

public final org.eclipse.ui.views.properties.PropertyDescriptor getPropertyDescriptor()
Returns:
the property descriptor to be used by this property. This method cannot be overidden. Instead, overide the hook method getCustomPropertyDescriptor

getCustomPropertyDescriptor

public org.eclipse.ui.views.properties.PropertyDescriptor getCustomPropertyDescriptor()
This method can be overridden by suclasses. The default implementation returns a read-only PropertyDescriptor.

Returns:
the property descriptor to be used for this property

getReadOnlyPropertyDescriptor

private org.eclipse.ui.views.properties.PropertyDescriptor getReadOnlyPropertyDescriptor()
Returns:
A PropertyDescriptor that allows the user to see the value, but not edit it. Subclasses of PropertyDescriptor allow editing.

hasDynamicPropertyDescriptor

public boolean hasDynamicPropertyDescriptor()
Returns:
true if the property descriptor can change. Mainly, this is for combo property object, so that the items in the list can be dynamic. Other types of descriptors do not contain information that is data dependent

hasSubProperties

public boolean hasSubProperties()

getSubPropertyManager

public java.lang.Object getSubPropertyManager()

setSubPropertyManager

public void setSubPropertyManager(PropertyManager propertyManager)
Parameters:
propertyManager -

getSubPropertyListener

private java.beans.PropertyChangeListener getSubPropertyListener()
Returns:
A property change listener that will simply pass events up to the higher level property manager

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

notifyPropertyChangeListeners

protected void notifyPropertyChangeListeners(java.beans.PropertyChangeEvent event)
Notify the propertChangeListeners that this property has changed

Parameters:
event -