com.metamatrix.toolbox.ui.widget.property
Interface PropertyComponent

All Known Implementing Classes:
DirectoryEntryPropertyComponent

public interface PropertyComponent

Defines interface that custom JComponents can implement to be used in the PropertyTable. Custom components that implement or provide adapters to this interface can be used generically in the table.


Field Summary
static java.lang.String EMPTY_STRING
          An empty String constant.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
           
 void addFocusListener(java.awt.event.FocusListener listener)
           
 void editingStarted()
          Notify this component that it has been activated and should enable any controls necessary for editing property values.
 void editingStopped()
          Notification to this component that keyboard/mouse focus has moved away from the component and it should deselect any items and deactivate any editing controls.
 java.lang.Object getNullValue()
          Get the Object that this PropertyComponent will use to indicate null.
 javax.swing.JComponent getSingleRowComponent()
          create a single-row JComponent from this component when needed.
 java.lang.String getSingleRowString()
          create a String from this component when needed.
 java.lang.Object getValue()
          Get the value being displayed by this component.
 boolean isCurrentValueEqualTo(java.lang.Object value)
          Return whether or not the specified value Object is equal to this component's currently displayed value.
 void removePropertyValidationListener(PropertyValidationListener listener)
          Remove the PropertyValidationListener for this component.
 void setEnabled(boolean flag)
          Set whether or not this component should be enabled to allow user editing of the value(s).
 void setPropertyValidationListener(PropertyValidationListener listener)
          Set a listener on this component that will receive request to validate property values as they are entered.
 void setValidity(boolean flag)
          Set a visual indication that this component's displayed value is or is not valid in the current context.
 

Field Detail

EMPTY_STRING

static final java.lang.String EMPTY_STRING
An empty String constant. This constant may be used by PropertyComponent implementations for the getNullValue( ) return Object.

See Also:
Constant Field Values
Method Detail

addActionListener

void addActionListener(java.awt.event.ActionListener listener)

addFocusListener

void addFocusListener(java.awt.event.FocusListener listener)

getNullValue

java.lang.Object getNullValue()
Get the Object that this PropertyComponent will use to indicate null. This Object will be used by the PropertyChangeAdapter to detect that a PropertiedObject's value for a particular PropertyDefintion is null, or, has no value. If the PropertyComponent returns an Object (not null), PropertyChangeAdapter will compare all Objects returned by the getValue() method to detect null. An example of the usage of this Object would be a text field which return an empty String to indicates that the specified property has no value.

Returns:
the Object that should be compared to the getValue() result to detect null. Implementations of this method may return null.

getValue

java.lang.Object getValue()
Get the value being displayed by this component. This value will be obtained from the PropertyChangeAdapter immediately prior to and after editing. After the user has stopped editing the value, the isEqualTo() method will be called allowing this component to determine if the user has changed the value.

Returns:
the property's value. May be a single object or an Object[] array.

setEnabled

void setEnabled(boolean flag)
Set whether or not this component should be enabled to allow user editing of the value(s).

Parameters:
flag - true if the component should enable editing.

setPropertyValidationListener

void setPropertyValidationListener(PropertyValidationListener listener)

Set a listener on this component that will receive request to validate property values as they are entered. An example would be a custom component that allows a user to type in an entry that should be validated keystroke-by-keystroke. Such a component would route KeyListener.keyReleased() events to the PropertyValidationListener.checkValue(Object) method. The result of the checkValue call will be communicated to this component via the setValidity(boolean) method.

Not all components require validation; therefore it is permissable for such components to no-op this method.

Parameters:
listener - the PropertyValidationListener that this object should call if validation is required.

removePropertyValidationListener

void removePropertyValidationListener(PropertyValidationListener listener)

Remove the PropertyValidationListener for this component. This method will be called immediately after editing has stopped on this component. Implementations that no-op the setPropertyValidationListener method may no-op this method as well.

Parameters:
listener - the PropertyValidationListener to be removed from this object.

setValidity

void setValidity(boolean flag)
Set a visual indication that this component's displayed value is or is not valid in the current context. PropertyValidationListener calls this method after a request to checkValidity of a specified value. The method may also be called if an invalid entry exists after editing has completed. An example would be a collection of values that are required to be unique, but contain a repeated value.

Parameters:
flag - true if the value is valid, false if it is invalid.

isCurrentValueEqualTo

boolean isCurrentValueEqualTo(java.lang.Object value)
Return whether or not the specified value Object is equal to this component's currently displayed value. This method is called by PropertyChangeAdapter and allows the value comparison logic to reside within the custom component, rather than requiring custom components to hardcode comparison logic in the adapter.

Parameters:
value - an Object that was previously obtained from this component's getValue method.
Returns:
true if the specified Object is the same as the value currently being displayed in this component, false if it is not. Returning true will cause the new value to be "set" on the target propertied object.

editingStarted

void editingStarted()
Notify this component that it has been activated and should enable any controls necessary for editing property values.


editingStopped

void editingStopped()
Notification to this component that keyboard/mouse focus has moved away from the component and it should deselect any items and deactivate any editing controls.


getSingleRowComponent

javax.swing.JComponent getSingleRowComponent()
create a single-row JComponent from this component when needed.


getSingleRowString

java.lang.String getSingleRowString()
create a String from this component when needed.



Copyright © 2009. All Rights Reserved.