Interface ILcyCustomizerPanel
- All Superinterfaces:
ILcdPropertyChangeSource,ILcdUndoableSource
- All Known Subinterfaces:
ILcyCompositeCustomizerPanel
- All Known Implementing Classes:
ALcyCustomizerPanel,ALcyDataPropertyCustomizerPanel,ALcyDomainObjectCustomizerPanel,ALcyLayerCustomizerPanel,ALcyModelCustomizerPanel,ALcyShapeCustomizerPanel,TLcyCompositeCustomizerPanel,TLcyCompositeCustomizerTabbedPane,TLcyGXYAsynchronousLayerCustomizerPanel
ILcyCustomizerPanel to customize an ILcdGXYLayer could contain checkboxes to toggle the
visible state, editable state, etc. Another example would be a panel to customize the coordinates of the points of a
polyline.
Implementations must extend from java.awt.Component or one of its subclasses (e.g. JPanel).
This interface allows storing key-value pairs such as a name and an icon. The mechanism is
similar to that of ILcdAction.
The object to customize is set using setObject. applyChanges commits any pending changes.
Pending changes are modifications the user has made in the user interface, but that are not yet committed to the
actual object. cancelChanges reverts the possible pending changes, and restores the values of the actual
object. isChangesPending allows to check if there are any pending changes, isChangesValid
allows to check if the pending changes are valid. Whenever the return values of those methods change, a
PropertyChangeEvent must be fired.
ALcyCustomizerPanel, ALcyDomainObjectCustomizerPanel,
ALcyLayerCustomizerPanel and ALcyModelCustomizerPanel are abstract
implementations that facilitate the implementation of an ILcyCustomizerPanel.
Their documentation explains how and when they are useful.
Instances of this interface can be obtained by iterating over the ILcyCustomizerPanelFactory
objects registered in the Lucy backend.
TLcyUserInterfaceManager.getCompositeCustomizerPanelFactory() contains more information on this
subject.
Example
Consider the example of anILcyCustomizerPanel that allows to edit the coordinates of
the points of a polyline, by using a text field for every point. As described in the Lucy developer
guide, this type of interaction with the TLcySelectionEditorAddOn uses a
TLcyDomainObjectContext as the object to customize.
The polyline is set to the ILcyCustomizerPanel, using a TLcyDomainObjectContext,
which contains a reference to both the polyline and the ILcdModel of the polyline. The
ILcdModel can for example be used to retrieve the coordinate system of the points
(ILcdModel.getModelReference).
When the user has changed one of the coordinates using the text field, the panel fires a "changesPending"
property change event from false to true. The container holding this
ILcyCustomizerPanel can then enable its apply button. When the user clicks the apply button, the method
applyChanges is invoked by the external container, which effectively commits the changes to the
polyline. The ILcyCustomizerPanel will again fire a "changesPending" event from true
to false describing there are no pending changes any more. The panel can also (optionally) fire a
TLcdUndoableEvent to describe that the change can be undone. For this example, also the
ILcdModel needs to be informed about the change (ILcdModel.elementChanged).
If the cancel button was pressed instead of the apply button, the external container would invoke the
cancelChanges method which discards the changes in the text field and reverts it back to the current
coordinate of the polyline. Again a "changesPending" event from true to
false would be fired.
If the external container holding this ILcyCustomizerPanel preferred not to have an apply and cancel
button, it could immediately apply the changes whenever a "changesPending" false to true
property change event is received.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe key for a hint to indicate theILcyCustomizerPanelshould remain visible in the UI.static final StringThe key for a hint to indicate which horizontal alignment certain types of customizers should use, most notably, text fields and buttons.static final StringThe key used for storing a longerStringdescription for theILcyCustomizerPanel, could for example be used for context-sensitive help.static final StringThe key used for storing theStringdisplay name for theILcyCustomizerPanel.static final StringThe key used for storing a shortStringdescription for theILcyCustomizerPanel.static final StringThe key used for storing a smallILcdIcon, such asTLcdImageIcon. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPropertyChangeListener(String aPropertyName, PropertyChangeListener aListener) Adds the given listener for the specific property with nameaPropertyName.booleanUpdates the setObjectaccording to the current state of the user interface.voidUpdates the user interface state according to the current state of the setObject.booleancanSetObject(Object aObject) Returnstrueif and only ifsetObjectwould not throw anIllegalArgumentException.Returns the object that was set usingsetObject.Returns an array of all thePropertyChangeListeners registered on thisILcyCustomizerPanel.getPropertyChangeListeners(String aPropertyName) Returns an array of all thePropertyChangeListeners registered foraPropertyName.Gets the property value for the given key.booleanReturnstrueif changes are pending.booleanReturnstrueif the pending changes are valid, or if there are no pending changes.voidSets the property value foraKeytoaValue.voidremovePropertyChangeListener(String aPropertyName, PropertyChangeListener aListener) Removes the givenPropertyChangeListenerfor the specific propertyaPropertyName.voidSet the object to be edited.Methods inherited from interface com.luciad.util.ILcdPropertyChangeSource
addPropertyChangeListener, removePropertyChangeListenerMethods inherited from interface com.luciad.gui.ILcdUndoableSource
addUndoableListener, removeUndoableListener
-
Field Details
-
NAME
The key used for storing theStringdisplay name for theILcyCustomizerPanel.- See Also:
-
SHORT_DESCRIPTION
The key used for storing a shortStringdescription for theILcyCustomizerPanel. This can for example be used as a tooltip text.- See Also:
-
LONG_DESCRIPTION
The key used for storing a longerStringdescription for theILcyCustomizerPanel, could for example be used for context-sensitive help.- See Also:
-
SMALL_ICON
The key used for storing a smallILcdIcon, such asTLcdImageIcon.- See Also:
-
HINT_PINNED
The key for a hint to indicate the
ILcyCustomizerPanelshould remain visible in the UI. The corresponding value should be a Boolean.A possible use-case is to avoid removing a customizer panel which contains invalid user input. When the input is invalid, the customizer panel can decide to set the HINT_PINNED to
trueto indicate the customizer panel should remain visible. When the input becomes valid, the hint can be switched back tofalse. This avoids the customizer panel gets removed when.Note that this is only a hint. It is up to the users of the
ILcyCustomizerPanelinstances to decide whether they respect the hint or not.- See Also:
-
HORIZONTAL_ALIGNMENT_HINT
The key for a hint to indicate which horizontal alignment certain types of customizers should use, most notably, text fields and buttons. The corresponding value should be one of:
SwingConstants.RIGHTSwingConstants.LEFTSwingConstants.CENTERSwingConstants.LEADINGSwingConstants.TRAILING
An example use case is a text field customizer, where this hint specifies if the text should be left or right aligned. Notable implementations that respect this hint are the text field and button customizer panels created by the factories available in
TLcyDataPropertyValueCustomizerPanelFactories.- See Also:
-
-
Method Details
-
getValue
Gets the property value for the given key.- Parameters:
aKey- The key to retrieve the value for.- Returns:
- the property value for the given key.
- See Also:
-
putValue
Sets the property value foraKeytoaValue. If the value has changed, aPropertyChangeEventis sent to the listeners. The property name of the event equals the value ofaKey.- Parameters:
aKey- The key. Should preferably start with an uppercase letter to avoid confusion with regular properties.aValue- The value.- See Also:
-
getPropertyChangeListeners
PropertyChangeListener[] getPropertyChangeListeners()Returns an array of all thePropertyChangeListeners registered on thisILcyCustomizerPanel.- Returns:
- an array of all the
PropertyChangeListeners registered on thisILcyCustomizerPanel, or an empty array if noPropertyChangeListeners are currently registered.
-
addPropertyChangeListener
Adds the given listener for the specific property with name
aPropertyName.Property change events will be fired for the Bean properties of this class, as well for changes in the key-value pairs of this class (see
putValue(String, Object)).- Parameters:
aPropertyName- The property name for whichaListenerwill receive events.aListener- The listener. It only receives events for the given property name.- See Also:
-
removePropertyChangeListener
Removes the givenPropertyChangeListenerfor the specific propertyaPropertyName. This method should be used to removePropertyChangeListeners that were registered for a specific property name.- Parameters:
aPropertyName- The property name.aListener- The listener.- See Also:
-
getPropertyChangeListeners
Returns an array of all thePropertyChangeListeners registered foraPropertyName.- Parameters:
aPropertyName- The property name to retrieve the listeners for.- Returns:
- an array of all the
PropertyChangeListeners registered foraPropertyName, or an empty array if no listeners are registered for that property.
-
isChangesPending
boolean isChangesPending()Returnstrueif changes are pending. A change is a modification made by the user, e.g., the modified content of a text field. Pending means the methodapplyChangeswas not invoked after the change occurred. A property change event"changesPending"must be fired if the return value of this method is changed. This can for example be used to enable/disable an apply button.- Returns:
trueif there are pending changes,falseotherwise.
-
isChangesValid
boolean isChangesValid()Returnstrueif the pending changes are valid, or if there are no pending changes. Returnsfalseif there are invalid pending changes. A change is a modification made by the user, e.g., the modified content of a text field. Pending means the methodapplyChangeswas not invoked after the change occurred.Falsecould for example be returned if the user has entered invalid input that cannot be applied, such as text where a number is expected. A property change event"changesValid"must be fired if the return value of this method is changed. This can for example be used to enable/disable an apply button, or to inform the user that he must first correct the invalid content. Implementations can ignore this feature by always returningtrue.- Returns:
trueif the changes can be applied,falseotherwise.
-
canSetObject
Returnstrueif and only ifsetObjectwould not throw anIllegalArgumentException.- Parameters:
aObject- The object to check.- Returns:
trueifsetObjectwould accept the object,falseif it would throw an exception.
-
setObject
Set the object to be edited. This method should be called before theILcyCustomizerPanelhas been added to any parent AWT container. It can be called afterwards as well however. In this case the user interface should update itself to represent the newly set object. A value ofnullis set to inform thisILcyCustomizerPanelto (temporarily) deinitialize itself, it allows to perform cleanup tasks, such as removing listeners.- Parameters:
aObject- The object to be customized, ornullto inform that editing is temporarily disabled.- Throws:
IllegalArgumentException- In case the given object cannot be edited by thisILcyCustomizerPanel. This exception is thrown if and only ifcanSetObjectreturnsfalsefor the sameaObject.
-
getObject
Object getObject()Returns the object that was set usingsetObject. This can benull.- Returns:
- the object that was set using
setObject. - See Also:
-
applyChanges
boolean applyChanges()Updates the setObjectaccording to the current state of the user interface. This means all pending changes are committed. If there were any pending changes, soisChangesPendingreturnedtrue, it should returnfalseafter this method has finished, and therefore also a"changesPending"property change event must be fired. E.g. consider that aILcdGXYLayerobject is set and a new label text is entered in a text field. When this method is called, the new label text should be set to theILcdGXYLayer(usingILcdGXYLayer.setLabel).- Returns:
Trueif the changes were applied or if there were no changes,falseif the changes could not be applied because they are invalid. In that event,isChangesValidreturnsfalse.
-
cancelChanges
void cancelChanges()Updates the user interface state according to the current state of the setObject. Any changes that were made in the user interface but were not yet applied, should be discarded. E.g. consider that anILcdGXYLayeris being edited and a new label text was entered in a text field. When this method is called, the new label text should be cleared and the current label of theILcdGXYLayershould be put in the text field (ILcdGXYLayer.getLabel()).
-