Public Member Functions | |
void | addPropertyChangeListener (PropertyChangeListener listener) |
void | addPropertyChangeListener (String propertyName, PropertyChangeListener listener) |
void | removePropertyChangeListener (PropertyChangeListener listener) |
void | removePropertyChangeListener (String propertyName, PropertyChangeListener listener) |
String | getDisplayName () |
String | getName () |
String[] | getNodeActions () |
String | getNodeDefaultAction () |
Image | getNodeIcon () |
Boolean | getNodePropertiesCacheable () |
String | getShortDescription () |
PropertyInfo[] | getPropertyInfo () |
Protected Member Functions | |
BeanSupport () | |
void | firePropertyChange (String propertyName, Object oldValue, Object newValue) |
void | fireNamePropertyChange (String newName) |
void | fireDisplayNamePropertyChange (String newDisplayName) |
void | fireShortDescriptionPropertyChange (String newShortDescription) |
void | fireNodeIconPropertyChange (java.awt.Image newIcon) |
void | fireNodeDefaultActionPropertyChange (String newDefaultAction) |
java.awt.Image | getNodeIconFromPathname (String newIconPathname) |
synchronized void | checkPropertyChangeSupport () |
Static Protected Member Functions | |
static String[] | mergeNodeActions (String[] actions1, String[] actions2) |
static PropertyInfo[] | mergePropertyInfo (PropertyInfo[] info1, PropertyInfo[] info2) |
This support class should be subclassed by bean classes. It facilitates the writing of JavaBean classes that are friendly with a node representing them by providing the extra information needed. The information provided by the bean can be static or dynamic using PropertyChangeEvents.
This support class provides the necessary methods to register a listener and provides methods to send PropertyChangeEvents. The bean can use the protected methods to fire events each time a property changes.
In order to be represented by a node, the bean can provide extra information that is not directly related to the business of the bean but that is nevertheless interesting to control the node. The bean can provide that information through its BeanInfo
or through specific getters (defined in the interface GPNode
). The information provided can be static or dynamic. It is static if the value is just given once when the node is created, it is dynamic if the bean allow the node to register itself as PropertyChangeListener
and fire events when those properties changes.
The list of properties recognized by the node and associated getters is given by the GPBean
interface. This support class implements all the getter methods in GPNode
by returning a null value. You should override each method you want to provide information for. For each property that can be dynamically updated there is a protected method in this class you can use to fire an event to update the value. Here is the list :
property name | method name | method to fire related event |
name | getName() | fireNamePropertyChange() |
displayName | getDisplayName() | fireDisplayNamePropertyChange() |
shortDescription | getShortDescription() | fireShortDescriptionPropertyChange() |
nodeDefaultAction | getNodeDefaultAction() | fireNodeDefaultActionPropertyChange() |
nodeIcon | getNodeIcon | fireNodeIconPropertyChange() |
If the bean fire a given event, it should provide the getter matching the PropertyChangeEvent
that it fires. For instance if the bean call the protected method fireNamePropertyChange
when a name change occurs, it should have the matching getter getName()
implemented and returning a non null value.
When a given getter is not available in this bean, the corresponding information will be looked-up in the BeanInfo
. It will only be static, because the BeanInfo provides static information common to all beans. There is only one BeanInfo for a given class of beans and therefore the information founds inside the BeanInfo is shared by all beans of that class. If the BeanInfo
does not contain the information, a standard default value will be applied when possible.
cern.gp.beans.BeanSupport.BeanSupport | ( | ) | [protected] |
void cern.gp.beans.BeanSupport.addPropertyChangeListener | ( | PropertyChangeListener | listener | ) |
Add a PropertyChangeListener to the listener list. The listener is registered for all properties.
listener | The PropertyChangeListener to be added |
References cern.gp.beans.BeanSupport.checkPropertyChangeSupport().
Referenced by cern.gp.explorer.properties.PropertyField.BeanPropertyChangeListener.registerListener().
void cern.gp.beans.BeanSupport.addPropertyChangeListener | ( | String | propertyName, | |
PropertyChangeListener | listener | |||
) |
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.
listener | The PropertyChangeListener to be removed |
References cern.gp.beans.BeanSupport.checkPropertyChangeSupport().
synchronized void cern.gp.beans.BeanSupport.checkPropertyChangeSupport | ( | ) | [protected] |
Lazily creates the PropertyChangeSupport
Referenced by cern.gp.beans.BeanSupport.addPropertyChangeListener().
void cern.gp.beans.BeanSupport.fireDisplayNamePropertyChange | ( | String | newDisplayName | ) | [protected] |
Reports a DisplayName property update to any registered listeners.
newDisplayName | The new value of the DisplayName. |
References cern.gp.beans.GPBean.DISPLAYNAME_PROPERTY_NAME, and cern.gp.beans.BeanSupport.firePropertyChange().
void cern.gp.beans.BeanSupport.fireNamePropertyChange | ( | String | newName | ) | [protected] |
Reports a Name property update to any registered listeners.
newName | The new value of the name. |
References cern.gp.beans.BeanSupport.firePropertyChange(), and cern.gp.beans.GPBean.NAME_PROPERTY_NAME.
void cern.gp.beans.BeanSupport.fireNodeDefaultActionPropertyChange | ( | String | newDefaultAction | ) | [protected] |
Reports a default action property update to any registered listeners.
newDefaultAction | The new value of the default action. |
References cern.gp.beans.BeanSupport.firePropertyChange(), and cern.gp.beans.GPBean.NODE_DEFAULT_ACTION_PROPERTY_NAME.
void cern.gp.beans.BeanSupport.fireNodeIconPropertyChange | ( | java.awt.Image | newIcon | ) | [protected] |
Reports a icon property update to any registered listeners.
newIcon | The new value of the icon. |
References cern.gp.beans.BeanSupport.firePropertyChange(), and cern.gp.beans.GPBean.NODE_ICON_PROPERTY_NAME.
void cern.gp.beans.BeanSupport.firePropertyChange | ( | String | propertyName, | |
Object | oldValue, | |||
Object | newValue | |||
) | [protected] |
Reports a bound property update to any registered listeners. No event is fired if old and new are equal and non-null.
You pass null for all 3 parameters, to tell the listeners to read all properties again, using the accessor methods. This is useful if you want to force all properties of this bean to be refreshed in the GUI (e.g. refresh the whole property sheet or a row in a ListTable at once).
propertyName | The programmatic name of the property that was changed. | |
oldValue | The old value of the property. | |
newValue | The new value of the property. |
Referenced by cern.gp.beans.BeanSupport.fireDisplayNamePropertyChange(), cern.gp.beans.BeanSupport.fireNamePropertyChange(), cern.gp.beans.BeanSupport.fireNodeDefaultActionPropertyChange(), cern.gp.beans.BeanSupport.fireNodeIconPropertyChange(), and cern.gp.beans.BeanSupport.fireShortDescriptionPropertyChange().
void cern.gp.beans.BeanSupport.fireShortDescriptionPropertyChange | ( | String | newShortDescription | ) | [protected] |
Reports a ShortDescription property update to any registered listeners.
newShortDescription | The new value of the ShortDescription. |
References cern.gp.beans.BeanSupport.firePropertyChange(), and cern.gp.beans.GPBean.SHORTDESCRIPTION_PROPERTY_NAME.
String cern.gp.beans.BeanSupport.getDisplayName | ( | ) |
Returns the internal display name of the associated bean. If null is returned a default name will be used.
displayName
normal (visible in a property sheet)
if getName() is available it is used instead of getDisplayName(), else beanInfo.getBeanDescriptor().getDisplayName() is used
Implements cern.gp.beans.GPBean.
Reimplemented in cern.gp.explorer.NamedBean.
String cern.gp.beans.BeanSupport.getName | ( | ) |
Returns the internal name of the associated bean. If null is returned a default name will be used.
name
normal (visible in a property sheet)
a unique name generated using BeanUtils. generateUniqueBeanName()
Implements cern.gp.beans.GPBean.
Reimplemented in cern.gp.explorer.NamedBean.
String [] cern.gp.beans.BeanSupport.getNodeActions | ( | ) |
Returns an array of qualified name of actions for the node representing the associated bean. Null can be used in the array to represent a separator.
nodeActions
hidden (not visible in a property sheet)
use the possible tagging of the BeanDescriptor of the BeanInfo : BeanTagger.getActions(beanInfo.getBeanDescriptor())
Implements cern.gp.beans.GPBean.
String cern.gp.beans.BeanSupport.getNodeDefaultAction | ( | ) |
Returns the qualified name of the default action for the node representing the associated bean. The default action is the one triggered when the user double-clic on the node. If null is returned a default default action will be used.
nodeDefaultAction
hidden
use the possible tagging of the BeanDescriptor of the BeanInfo : BeanTagger.getDefaultAction(beanInfo.getBeanDescriptor())
Implements cern.gp.beans.GPBean.
Image cern.gp.beans.BeanSupport.getNodeIcon | ( | ) |
Returns the icon in 16x16 size used to display the node representing the associated bean. If null is returned a default icon will be used.
nodeIcon
hidden (not visible in a property sheet)
beanInfo.getIcon()
Implements cern.gp.beans.GPBean.
java.awt.Image cern.gp.beans.BeanSupport.getNodeIconFromPathname | ( | String | newIconPathname | ) | [protected] |
Returns the icon image from the pathname of the icon.
The pathname should be relative to the package of this bean and be contained in the classpath. For instance if this bean is in cern.gp.beans
and the icon is stored in cern/gp/beans/images/MyIcon.gif
the pathname to give would be images/MyIcon.gif
.
newIconPathname | The new value of the Icon pathname. |
Boolean cern.gp.beans.BeanSupport.getNodePropertiesCacheable | ( | ) |
Returns true if the value of the properties can be cached in the node, false if they cannot or null if no behavior is specified. The default behavior is not to cache the value of the properties.
If the value of a property is not cached, the getter method will be invoked whenever the node need to get the value of the property.
If the value of the property is cached, the getter method for the property will only be invoked once to read the value. Then, whenever the node need the value of the property it will used the cached one until a PropertyChangeEvent
for the property (or for all properties) is fired.
Caching values can improve performance greatly but it adds one more responsibility on the developer who has to fire PropertyChangeEvent
whenever the property values change.
This property gives the caching strategy for all properties. It is possible to override the bean level caching strategy at the property level by using the property information getPropertyInformation()
.
nodePropertiesCacheable
hidden (not visible in a property sheet)
use the possible tagging of the BeanDescriptor of the BeanInfo : BeanTagger.isCacheable(beanInfo.getBeanDescriptor())
Implements cern.gp.beans.GPBean.
PropertyInfo [] cern.gp.beans.BeanSupport.getPropertyInfo | ( | ) |
Returns an array of PropertyInfo
specifying information on some properties.
Each PropertyInfo
of this array defines information for one property of this bean. Defining a PropertyInfo
for a given property is usefull when there is no explicit BeanInfo
for the bean and when the property have non default characteristics such as, for instance, a specific PropertyEditor
.
propertyInfo
hidden (not visible in a property sheet)
use PropertyDescriptors from BeanInfo
Implements cern.gp.beans.GPBean.
String cern.gp.beans.BeanSupport.getShortDescription | ( | ) |
Returns a short description of the associated bean (used in tooltip for instance). If null is returned a default description will be used.
shortDescription
normal (visible in a property sheet)
beanInfo.getBeanDescriptor(). getShortDescription()
Implements cern.gp.beans.GPBean.
static String [] cern.gp.beans.BeanSupport.mergeNodeActions | ( | String[] | actions1, | |
String[] | actions2 | |||
) | [static, protected] |
Merges the two String
arrays into one. This method is useful when a class inherits from another that already has a method getNodeActions
that returned an array of String
. If the subclass wants to return a String
array while taking into account the one from the parent class it can use this method. For instance :
String[] parentArray= super.getNodeActions(); String[] myArray = new String [] { .... }; return mergePropertyInfo(parentPI, myPI);
actions1 | the first array of String to merge | |
actions2 | the second array of String to merge |
static PropertyInfo [] cern.gp.beans.BeanSupport.mergePropertyInfo | ( | PropertyInfo[] | info1, | |
PropertyInfo[] | info2 | |||
) | [static, protected] |
Merges the two PropertyInfo
arrays into one. This method is useful when a class inherits from another that already has a method getPropertyInfo
that returned an array of PropertyInfo
. If the subclass wants to return PropertyInfo
while taking into account the one from the parent class it can use this method. For instance :
PropertyInfo[] parentPI = super.getPropertyInfo(); PropertyInfo[] myPI = new PropertyInfo[] { .... }; return mergePropertyInfo(parentPI, myPI);
info1 | the first array of PropertyInfo to merge | |
info2 | the second array of PropertyInfo to merge |
void cern.gp.beans.BeanSupport.removePropertyChangeListener | ( | String | propertyName, | |
PropertyChangeListener | listener | |||
) |
Remove a PropertyChangeListener for a specific property.
propertyName | The name of the property that was listened on. | |
listener | The PropertyChangeListener to be removed |
void cern.gp.beans.BeanSupport.removePropertyChangeListener | ( | PropertyChangeListener | listener | ) |
Add a PropertyChangeListener for a specific property. The listener will be invoked only when a call on firePropertyChange names that specific property.
propertyName | The name of the property to listen on. | |
listener | The PropertyChangeListener to be added |