public interface IPropertyEditor
Interface to a custom Property Editor. This interface is intended to be implemented by Property Editors.
Implementors of this interface do not operate directly on the node property to get and set values. This is done by the framework to provide and easier interface (pure Java) that will not be affected by specific property model API changes.
The framework "set" method are meant to inform the editor of the property values and related information. These values must be stored by implementor and used to populate the UI.
The framework "get" methods are meant to inform the framework of the desired values.
It is important to note that most methods are called before controls are created. this allows controls to be initialized with the current values stored when the "set" methods were called.
Field | Description |
---|---|
copyright |
Method | Description |
---|---|
void createControls(Composite) | Creates the label and the Composite containing the widgets required to edit the Property. |
String getDisplayName() | Returns the display name of the property as it was set by the setDisplayName method. |
IEditorInput getEditorInput() | Returns the editor input which contains the flow to which the property that this editor is matched with belongs. |
String getGroup() | Returns the name of the group to which this property belongs. |
Object getProperty() | Returns the property associated with this Editor. |
Object getValue() | Gets the desired Property value to be saved from the Editor UI. |
String isValid() | Returns whether the editor's contents are valid. |
void notifyChanged(IPropertyEditor) | Is called by the framework to alert the property editors it is managing that another editor has changed and indicates which one. |
void setCurrentValue(Object) | Sets the Property Editor initial value for the property. |
void setDefaultValue(Object) | Sets the Property Editor default value for the property. |
void setDisplayName(String) | Sets the property name. |
void setEditorInput(IEditorInput) | Sets the editor input which contains the flow to which the property that this editor is matched with belongs. |
void setEnabled(boolean) | Sets whether the Property Editor is enabled or disabled. |
void setEnumChoices(String[]) | Sets the Property Editor user choices for the property. |
void setGroup(String) | Sets the category name of this property. |
void setProperty(Object) | Associates the Property to the Editor. |
void setReadOnly(boolean) | Sets the readOnly state for the Property Editor |
void setRequired(boolean) | Sets the "required" state for the Property Editor |
public static final java.lang.String copyright
public void createControls(Composite parent)Creates the label and the Composite containing the widgets required to edit the Property.
This method is called by the Property Editor Framework. Controls typically include a label and a Text widget or radio buttons, checkbox, etc...
If the default label on the left is not required, the created Composite grid data must be set to span both columns specified in the passed in parent composite.
gridData.horizontalSpan=2
- Parameters
- parent - the parent of the created composite
public String getDisplayName()Returns the display name of the property as it was set by the setDisplayName method.
- Returns
- java.lang.String
public IEditorInput getEditorInput()Returns the editor input which contains the flow to which the property that this editor is matched with belongs.
The subclass must returned the IEditorInput store by the setEditorInput method.
- Returns
- The editor input
public String getGroup()Returns the name of the group to which this property belongs.
This method is called by the Property Editor Framework when ordering the properties.
The subclass must returned unchanged string set by the setCategory method.
- Returns
- The category name
public Object getProperty()Returns the property associated with this Editor.
This method is called by the Property Editor Framework when it needs to locate the property matching this editor
The subclass must return the Object stored in the setProperty method.
- Returns
- the property being edited.
public Object getValue()Gets the desired Property value to be saved from the Editor UI.
This method is called by the Property Editor Framework when the user saves the change. The subclass should obtain this value from the UI.
The concrete parameter class returned will be either a String or a java.lang class that wraps a primitive type such a Boolean or Integer. The valueOf method is used to convert the wrapper class value to a string for persistence if the class is not a String.
- Returns
- the desired value from the UI
public String isValid()Returns whether the editor's contents are valid.
This method is called by the Property Editor Framework when it is notified that an input change has occurred on one of the property editors it is managing.
In order for the Property Editor Framework to call this method at meaningful times, it needs to be notified by the editor when the editor's content has been changed (ex. the user modifies a text field). The editor performs this notification by first calling its setChanged() method to indicate its contents have changed and then calling its notifyObservers() method whenever editor contents change.
- Returns
- null if valid, otherwise an error message is returned and will be displayed by the Property Editor Framework. Also, the property editor framework will enable or disable the 'OK' and 'Apply' buttons appropriately.
Note: when the Property Editor Framework displays the error message returned (if one is returned), it will prefix it with the display name of the property in question as returned by the editor's getDisplayName() method.
public void notifyChanged(IPropertyEditor otherEditor)Is called by the framework to alert the property editors it is managing that another editor has changed and indicates which one.
This provides one Property Editor with the ability to respond to a change that is made in another Property Editor.
In addition to being called every time a Property Editor is changed, this method is also called on each editor once for every other editor being managed by the framework after the framework has finished creating editors. This initialization round of calls performed before an editor's controls are created is performed so that editors whose display depends on some aspect of another editor can be initialized correctly.
Note: This method will always be called just prior to the
isValid
method. It is conceivable that a change made in another editor could invalidate the contents of the current one.
- Parameters
- otherEditor - the
IPropertyEditor
that has changed.
public void setCurrentValue(Object value)Sets the Property Editor initial value for the property.
This method is called by the Property Editor Framework when the editor is created (before controls are created) The subclass should display this value in the UI
The method can also be called after the controls are created if UI function such as "reset" are supported.
The concrete parameter class passed in will be either a String or a java.lang class that wraps a primitive type such a Boolean or Integer.
The valueOf method should be used to convert the wrapper class value to a string for display.This method is not called is the property currently has no value.
The subclass is expected to store this value in a field to be used later when the controls are created.
- Parameters
- value - the initial property value
public void setDefaultValue(Object value)Sets the Property Editor default value for the property.
This method is called by the Property Editor Framework when the editor is created (before controls are created) The subclass may use this value to restore defaults.
The concrete parameter class passed in will be either a String or a java.lang class that wraps a primitive type such a Boolean or Integer.
The valueOf method should be used to convert the wrapper class value to a string for display.This method is not called if the property has no default value.
- Parameters
- value - the default property value
public void setDisplayName(String name)Sets the property name.
This method is called by the Property Editor Framework when the editor is created (before controls are created)
The subclass is expected to provide a field to store it. It would typically use it to set an SWT Label. it should never be changed.
- Parameters
- name - the property name
public void setEditorInput(IEditorInput input)Sets the editor input which contains the flow to which the property that this editor is matched with belongs.
This method is called by the Property Editor Framework when the editor is created (before controls are created)
The subclass is expected to store this information but must not change it.
- Parameters
- The - editor input
public void setEnabled(boolean enabled)Sets whether the Property Editor is enabled or disabled.
This method is called by the Property Editor Framework when the subject property has enabled/disabled status. This method is called before the controls are created
The editor may chose to ignore this information if it is known that it will never happen. Otherwise the editor may disable the control to prevent user from changing the value.
- Parameters
- enabled - true if the property is enabled
public void setEnumChoices(String[] choices)Sets the Property Editor user choices for the property.
This method is called by the Property Editor Framework when the editor is created (before controls are created) The subclass should display user choices in the UI
The concrete parameter class passed in will be either a String or a java.lang class that wraps a primitive type such a Boolean or Integer.
The valueOf method should be used to convert the wrapper class value to a string for display.
- Parameters
- choices - the user choices for the UI
public void setGroup(String name)Sets the category name of this property.
This method is called by the Property Editor Framework when the editor is created (before controls are created)
When properties are grouped by category, this name indicates to which category this property belongs. Categories are used to display properties on different pages. The categories are set by the Node author at design time.
The subclass must store this information as it will be used by the Property Editor Framework when ordering Properties
- Parameters
- name - the property name
public void setProperty(Object property)Associates the Property to the Editor.
This method is called by the Property Editor Framework when the editor is created (before controls are created) The subclass must provide a field to store it.
The concrete parameter class passed in is of a type that is not accessible to the Editor. The Editor Framework provides the function of changing the value of the property.
- Parameters
- property - the property being edited
public void setReadOnly(boolean readOnly)Sets the readOnly state for the Property Editor
This method is called by the Property Editor Framework when the subject property has read only status. This method is called before the controls are created
The editor may chose to ignore this information if it is known that it will never happen. Otherwise the editor may disable the control to prevent user from changing the value.
- Parameters
- readOnly - true if the property is read only
public void setRequired(boolean required)Sets the "required" state for the Property Editor
This method is called by the Property Editor Framework when the subject property must have a value set. This method is called before the controls are created
The editor may chose to ignore this information if it is known that it will never happen. Otherwise the editor may change some aspect of the UI to indicate to the user that a value is required.
The Framework wil disable the OK button until all required properties are set.
- Parameters
- required - true if a property value is required