Class ALcyTool
- All Implemented Interfaces:
ILcdPropertyChangeSource
- Direct Known Subclasses:
ALcyApplicationPaneTool,TLcyFormatTool,TLcyLspFormatTool,TLcyPreferencesTool
Abstract class that represents a piece of functionality that assists in achieving a specific task. For examples of such tasks, please check out the subclasses.
This tool is activated using its plugInto method, usually called from
ALcyAddOn#plugInto.
It is deactivated using unplugFrom, usually called from
ALcyAddOn#unplugFrom.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPropertyChangeListener(PropertyChangeListener aListener) Registers the givenPropertyChangeListenerto be notified when this object's properties change.voidaddPropertyChangeListener(String aProperty, PropertyChangeListener aListener) Adds the given listener to the list of listeners, so that it will receive notifications about changes inaProperty.protected voidThis method checks if theplugIntomethod of thisALcyToolhas been called correctly, and throws anIllegalStateExceptionif not.protected voidfirePropertyChange(String aProperty, Object aOldValue, Object aNewValue) Fires the given event to the associated listeners.static StringgetLongPrefix(Class aClass) Returns the long prefix for a given class (normally an add-on), which is its package name, suffixed with a dot (.).static StringgetLongPrefixWithClassName(Class aClass) Returns the long prefix for a given class (normally an add-on), which is its fully qualified class name suffixed with a dot (.).Returns theILcyLucyEnvthat was provided inplugInto.static StringgetShortPrefix(Class aClass) Returns the short prefix for a given class (normally an add-on), which is its short class name, suffixed with a dot (.).voidplugInto(ILcyLucyEnv aLucyEnv) Plugs this tool.voidDe-registers the givenPropertyChangeListenerfrom receiving property change events for this object.voidremovePropertyChangeListener(String aProperty, PropertyChangeListener aListener) Removes the given listener for the given property, so that it no longer receives those change events.voidunplugFrom(ILcyLucyEnv aLucyEnv) Unplugs this tool.
-
Constructor Details
-
ALcyTool
public ALcyTool()
-
-
Method Details
-
addPropertyChangeListener
Description copied from interface:ILcdPropertyChangeSourceRegisters the given
PropertyChangeListenerto be notified when this object's properties change.In case you need to register a listener which keeps a reference to an object with a shorter life-time than this change source, you can use a
ALcdWeakPropertyChangeListenerinstance as property change listener.- Specified by:
addPropertyChangeListenerin interfaceILcdPropertyChangeSource- Parameters:
aListener- The listener to be notified- See Also:
-
addPropertyChangeListener
Adds the given listener to the list of listeners, so that it will receive notifications about changes inaProperty.- Parameters:
aProperty- The property to watch for changes.aListener- The listener to add.
-
removePropertyChangeListener
Description copied from interface:ILcdPropertyChangeSourceDe-registers the given
PropertyChangeListenerfrom receiving property change events for this object.If the listener was added more than once, it will be notified one less time after being removed. If the listener is
null, or was never added, no exception is thrown and no action is taken.- Specified by:
removePropertyChangeListenerin interfaceILcdPropertyChangeSource- Parameters:
aListener- the listener that should no longer be notified of changes of this object's properties- See Also:
-
removePropertyChangeListener
Removes the given listener for the given property, so that it no longer receives those change events.- Parameters:
aProperty- The property to stop listening to.aListener- The listener to remove.
-
firePropertyChange
Fires the given event to the associated listeners.- Parameters:
aProperty- The property that was changed.aOldValue- The old value.aNewValue- The new value.
-
getLucyEnv
Returns theILcyLucyEnvthat was provided inplugInto.- Returns:
- The
ILcyLucyEnv.
-
plugInto
Plugs this tool. This method is usually called from
ALcyAddOn#plugInto.- Parameters:
aLucyEnv- The environment to plug into.
-
unplugFrom
Unplugs this tool. This method is usually called from
ALcyAddOn#unplugFrom.- Parameters:
aLucyEnv- The environment to unplug from, must be identical to the environment given toplugInto.
-
assertPlugged
protected void assertPlugged()This method checks if the
plugIntomethod of thisALcyToolhas been called correctly, and throws anIllegalStateExceptionif not.Calling this method is in no way mandatory, but it can be convenient for subclasses in order to avoid developers struggling with for example obscure
NullPointerExceptions because theILcyLucyEnvisnull.- Throws:
IllegalStateException- If not plugged correctly, that isgetLucyEnv()returnsnull.
-
getLongPrefix
Returns the long prefix for a given class (normally an add-on), which is its package name, suffixed with a dot (.). It can for example be used as the long prefix in
TLcyPreferencesToolFor example, the class
com.luciad.lucy.addons.about.TLcyAboutBoxAddonhascom.luciad.lucy.addons.about.as its long prefix.Warning: Avoid
getLongPrefix(getClass())as it returns a different value in sub-classes. Instead use for examplegetLongPrefix(TLcyAboutBoxAddOn.class). Also, when multiple add-ons exist in the same package, thegetLongPrefixWithClassName(Class)should be used because the package name is then no longer unique.- Parameters:
aClass- The class to derive the long prefix from, normally anALcyAddOnsub-class.- Returns:
- The long prefix.
- See Also:
-
getLongPrefixWithClassName
Returns the long prefix for a given class (normally an add-on), which is its fully qualified class name suffixed with a dot (.). It can for example be used as the long prefix in
TLcyPreferencesToolFor example, the class
com.luciad.lucy.addons.about.TLcyAboutBoxAddonhascom.luciad.lucy.addons.about.TLcyAboutBoxAddon.as its long prefix.Warning: Avoid
getLongPrefixWithClassName(getClass())as it returns a different value in sub-classes. Instead use for examplegetLongPrefixWithClassName(TLcyAboutBoxAddOn.class).- Parameters:
aClass- The class to derive the long prefix from, normally anALcyAddOnsub-class.- Returns:
- The long prefix.
-
getShortPrefix
Returns the short prefix for a given class (normally an add-on), which is its short class name, suffixed with a dot (.). It can for example be used as the short prefix in
TLcyPreferencesToolFor example, the class
com.luciad.lucy.addons.about.TLcyAboutBoxAddonhasTLcyAboutBoxAddon.as its short prefix.Warning: Avoid
getShortPrefix(getClass())as it returns a different value in sub-classes. Instead use for examplegetShortPrefix(TLcyAboutBoxAddOn.class).- Parameters:
aClass- The class to derive the short prefix from, normally anALcyAddOnsub-class.- Returns:
- The short prefix.
-