propertyManager
Class PropertyManager

java.lang.Object
  extended by propertyManager.PropertyManager
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, org.eclipse.ui.views.properties.IPropertySource, org.eclipse.ui.views.properties.IPropertySourceProvider

public class PropertyManager
extends java.lang.Object
implements java.beans.PropertyChangeListener, org.eclipse.ui.views.properties.IPropertySource, org.eclipse.ui.views.properties.IPropertySourceProvider, java.io.Serializable

This class is designed to make integration with the property view easier. ReadableProperties are added to the property manager, which handles the interaction between the property view and the actual properties.

Author:
Dan Phifer June 8, 2005
See Also:
Serialized Form

Field Summary
private  java.util.Hashtable knownDescriptors
          Contains a list of property descriptors that have been previously created and can be reused.
protected  java.lang.Object owner
          The object to which the properties belong.
protected  java.util.ArrayList properties
          Contains the references to the properties that have been added to this
private  java.util.ArrayList propertyChangeListeners
          A list of property change listeners
private static long serialVersionUID
           
 
Constructor Summary
PropertyManager(java.lang.Object owner)
          Creates a new instance of the PropertyManager class.
 
Method Summary
 void addProperty(ReadableProperty readableProperty)
          Adds a ReadableProperty to the PropertyManager.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a property change listener to be notified when any of the managed ReadableProperties are modifed.
private  ReadableProperty findProperty(java.lang.Object id)
           
 EditableProperty getEditableProperty(java.lang.Object id)
           
 java.lang.Object getEditableValue()
           
protected  java.util.Hashtable getKnownDescriptors()
           
 java.util.ArrayList getProperties()
           
 ReadableProperty getProperty(java.lang.Object id)
           
protected  java.util.ArrayList getPropertyChangeListeners()
           
 org.eclipse.ui.views.properties.IPropertyDescriptor[] getPropertyDescriptors()
          Creates an array of property descriptors which will be used by the properties view.
 double getPropertyDoubleValue(java.lang.Object id)
           
 float getPropertyFloatValue(java.lang.Object id)
           
 int getPropertyIntValue(java.lang.Object id)
           
 long getPropertyLongValue(java.lang.Object id)
           
 java.lang.Number getPropertyNumberValue(java.lang.Object id)
           
 org.eclipse.ui.views.properties.IPropertySource getPropertySource(java.lang.Object object)
           
 java.lang.Object getPropertyValue(java.lang.Object id)
           
 ReadableProperty getReadableProperty(java.lang.Object id)
          This method simply calls getProperty and is provided for consistency
 boolean hasProperty(java.lang.Object id)
           
 boolean isPropertySet(java.lang.Object id)
           
private  void linkPropertyOwner(java.lang.Object owner)
          If the owner of this property is another property, link them together
private  void notifyPropertyChangeListeners(java.beans.PropertyChangeEvent event)
          Notify listeners that a property has changed and pass the event
 void propertyChange(java.beans.PropertyChangeEvent event)
           
 void removeProperty(ReadableProperty readableProperty)
          Removes an ReadableProperties from the PropertyManager
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes the given property change listener.
 void resetPropertyValue(java.lang.Object id)
          Resets the property value to the defaultValue.
 void setPropertyValue(java.lang.Object id, java.lang.Object value)
          Sets the value of the given property
 
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

properties

protected java.util.ArrayList properties
Contains the references to the properties that have been added to this


knownDescriptors

private transient java.util.Hashtable knownDescriptors
Contains a list of property descriptors that have been previously created and can be reused. Dynamic descriptors are not cached.

See Also:
ReadableProperty.hasDynamicPropertyDescriptor()

propertyChangeListeners

private transient java.util.ArrayList propertyChangeListeners
A list of property change listeners


owner

protected java.lang.Object owner
The object to which the properties belong. All events are fired on belhalf of the owner.

See Also:
notifyPropertyChangeListeners(PropertyChangeEvent)
Constructor Detail

PropertyManager

public PropertyManager(java.lang.Object owner)
Creates a new instance of the PropertyManager class.

Parameters:
owner - The object to which the properties belong.
Method Detail

linkPropertyOwner

private void linkPropertyOwner(java.lang.Object owner)
If the owner of this property is another property, link them together

Parameters:
owner -

addProperty

public void addProperty(ReadableProperty readableProperty)
Adds a ReadableProperty to the PropertyManager. If a property with the same ID already exists, this method has no effect.

Parameters:
editableProperty - An EditableProperty

removeProperty

public void removeProperty(ReadableProperty readableProperty)
Removes an ReadableProperties from the PropertyManager

Parameters:
editableProperty - An EditableProperty

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a property change listener to be notified when any of the managed ReadableProperties are modifed.

Parameters:
listener - A PropertyChangeListener

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the given property change listener.

Parameters:
listener - a property listener

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

notifyPropertyChangeListeners

private void notifyPropertyChangeListeners(java.beans.PropertyChangeEvent event)
Notify listeners that a property has changed and pass the event

Parameters:
event - The event describing the property change

getEditableProperty

public EditableProperty getEditableProperty(java.lang.Object id)
Parameters:
id -
Returns:
The EditableProperty that corresponds to the given ID

getProperty

public ReadableProperty getProperty(java.lang.Object id)
Parameters:
id - The ID of the property to be returned
Returns:
The EditableProperty that corresponds the the given ID
Throws:
java.lang.IllegalArgumentException - if a property with the given ID has not been added to the PropertyManager

hasProperty

public boolean hasProperty(java.lang.Object id)
Parameters:
id - The ID of a property
Returns:
true if the property exists in the PropertyManager class

getReadableProperty

public ReadableProperty getReadableProperty(java.lang.Object id)
This method simply calls getProperty and is provided for consistency

Parameters:
id - The ID of a property
Returns:
The corresponding property

findProperty

private ReadableProperty findProperty(java.lang.Object id)

getPropertyDescriptors

public org.eclipse.ui.views.properties.IPropertyDescriptor[] getPropertyDescriptors()
Creates an array of property descriptors which will be used by the properties view. One property descriptor is created for each EditableProperty managed by the PropertyManager

Specified by:
getPropertyDescriptors in interface org.eclipse.ui.views.properties.IPropertySource
Returns:
an array of property descriptors for use with the property view.

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.Object id)
Specified by:
getPropertyValue in interface org.eclipse.ui.views.properties.IPropertySource
Parameters:
id - The id of the EditableProperty
Returns:
the value for the given property. This value should be valid for the properties view. Subclasses of EditableProperty should provide other methods for returning the value in a different form. For instance, EditableComboProperty will return an Integer which represents the index of the selected item in the combo box. However, the correspoding value (which is ultimately what is wanted by the class that is using the EditableComboProperty) is returned by getComboValue().

getPropertyNumberValue

public java.lang.Number getPropertyNumberValue(java.lang.Object id)
Parameters:
id - The id of the property
Returns:
A Number if the given property implements INumericProperty
Throws:
java.lang.IllegalArgumentException - if the property does not exist or does not implement INumericProperty

getPropertyIntValue

public int getPropertyIntValue(java.lang.Object id)
                        throws java.lang.IllegalArgumentException
Parameters:
id - The id of the property
Returns:
An int if the given property implements INumericProperty
Throws:
java.lang.IllegalArgumentException - if the property does not exist or does not implement INumericProperty

getPropertyFloatValue

public float getPropertyFloatValue(java.lang.Object id)
                            throws java.lang.IllegalArgumentException
Parameters:
id - The id of the property
Returns:
A float if the given property implements INumericProperty
Throws:
java.lang.IllegalArgumentException - if the property does not exist or does not implement INumericProperty

getPropertyDoubleValue

public double getPropertyDoubleValue(java.lang.Object id)
                              throws java.lang.IllegalArgumentException
Parameters:
id - The id of the property
Returns:
A double if the given property implements INumericProperty
Throws:
java.lang.IllegalArgumentException - if the property does not exist or does not implement INumericProperty

getPropertyLongValue

public long getPropertyLongValue(java.lang.Object id)
                          throws java.lang.IllegalArgumentException
Parameters:
id - The id of the property
Returns:
A long if the given property implements INumericProperty
Throws:
java.lang.IllegalArgumentException - if the property does not exist or does not implement INumericProperty

isPropertySet

public boolean isPropertySet(java.lang.Object id)
Specified by:
isPropertySet in interface org.eclipse.ui.views.properties.IPropertySource
Parameters:
id - The id of the EditableProperty
Returns:
true if the property is anything other than the defaultValue

resetPropertyValue

public void resetPropertyValue(java.lang.Object id)
Resets the property value to the defaultValue. If not default value was specified, this method has not effect.

Specified by:
resetPropertyValue in interface org.eclipse.ui.views.properties.IPropertySource
Parameters:
id - The id of the EditableProperty

setPropertyValue

public void setPropertyValue(java.lang.Object id,
                             java.lang.Object value)
Sets the value of the given property

Specified by:
setPropertyValue in interface org.eclipse.ui.views.properties.IPropertySource
Parameters:
id - The id of the ReadableProperty
value - The new value

getEditableValue

public java.lang.Object getEditableValue()
Specified by:
getEditableValue in interface org.eclipse.ui.views.properties.IPropertySource

getPropertySource

public org.eclipse.ui.views.properties.IPropertySource getPropertySource(java.lang.Object object)
Specified by:
getPropertySource in interface org.eclipse.ui.views.properties.IPropertySourceProvider

getProperties

public java.util.ArrayList getProperties()
Returns:
A List with a reference to all properties managed by the property manager

getPropertyChangeListeners

protected java.util.ArrayList getPropertyChangeListeners()
Returns:
Returns the propertyChangeListeners. If the object has not been initialized, it is initialized and returned

getKnownDescriptors

protected java.util.Hashtable getKnownDescriptors()
Returns:
Returns the knownDescriptors. If the object has not been initialized, it is initialized and returned