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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPropertyChangeListener
(PropertyChangeListener aListener) Registers the givenPropertyChangeListener
to be notified when this object's properties change.void
addPropertyChangeListener
(String aProperty, PropertyChangeListener aListener) Adds the given listener to the list of listeners, so that it will receive notifications about changes inaProperty
.protected void
This method checks if theplugInto
method of thisALcyTool
has been called correctly, and throws anIllegalStateException
if not.protected void
firePropertyChange
(String aProperty, Object aOldValue, Object aNewValue) Fires the given event to the associated listeners.static String
getLongPrefix
(Class aClass) Returns the long prefix for a given class (normally an add-on), which is its package name, suffixed with a dot (.).static String
getLongPrefixWithClassName
(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 theILcyLucyEnv
that was provided inplugInto
.static String
getShortPrefix
(Class aClass) Returns the short prefix for a given class (normally an add-on), which is its short class name, suffixed with a dot (.).void
plugInto
(ILcyLucyEnv aLucyEnv) Plugs this tool.void
De-registers the givenPropertyChangeListener
from receiving property change events for this object.void
removePropertyChangeListener
(String aProperty, PropertyChangeListener aListener) Removes the given listener for the given property, so that it no longer receives those change events.void
unplugFrom
(ILcyLucyEnv aLucyEnv) Unplugs this tool.
-
Constructor Details
-
ALcyTool
public ALcyTool()
-
-
Method Details
-
addPropertyChangeListener
Description copied from interface:ILcdPropertyChangeSource
Registers the given
PropertyChangeListener
to 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
ALcdWeakPropertyChangeListener
instance as property change listener.- Specified by:
addPropertyChangeListener
in 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:ILcdPropertyChangeSource
De-registers the given
PropertyChangeListener
from 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:
removePropertyChangeListener
in 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 theILcyLucyEnv
that 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
plugInto
method of thisALcyTool
has been called correctly, and throws anIllegalStateException
if 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
NullPointerException
s because theILcyLucyEnv
isnull
.- 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
TLcyPreferencesTool
For example, the class
com.luciad.lucy.addons.about.TLcyAboutBoxAddon
hascom.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 anALcyAddOn
sub-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
TLcyPreferencesTool
For example, the class
com.luciad.lucy.addons.about.TLcyAboutBoxAddon
hascom.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 anALcyAddOn
sub-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
TLcyPreferencesTool
For example, the class
com.luciad.lucy.addons.about.TLcyAboutBoxAddon
hasTLcyAboutBoxAddon.
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 anALcyAddOn
sub-class.- Returns:
- The short prefix.
-