Class ALcyTool

java.lang.Object
com.luciad.lucy.util.ALcyTool
All Implemented Interfaces:
ILcdPropertyChangeSource
Direct Known Subclasses:
ALcyApplicationPaneTool, TLcyFormatTool, TLcyLspFormatTool, TLcyPreferencesTool

public abstract class ALcyTool extends Object implements ILcdPropertyChangeSource

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 Details

    • ALcyTool

      public ALcyTool()
  • Method Details

    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener aListener)
      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 interface ILcdPropertyChangeSource
      Parameters:
      aListener - The listener to be notified
      See Also:
    • addPropertyChangeListener

      public void addPropertyChangeListener(String aProperty, PropertyChangeListener aListener)
      Adds the given listener to the list of listeners, so that it will receive notifications about changes in aProperty.
      Parameters:
      aProperty - The property to watch for changes.
      aListener - The listener to add.
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener aListener)
      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 interface ILcdPropertyChangeSource
      Parameters:
      aListener - the listener that should no longer be notified of changes of this object's properties
      See Also:
    • removePropertyChangeListener

      public void removePropertyChangeListener(String aProperty, PropertyChangeListener aListener)
      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

      protected void firePropertyChange(String aProperty, Object aOldValue, Object aNewValue)
      Fires the given event to the associated listeners.
      Parameters:
      aProperty - The property that was changed.
      aOldValue - The old value.
      aNewValue - The new value.
    • getLucyEnv

      public ILcyLucyEnv getLucyEnv()
      Returns the ILcyLucyEnv that was provided in plugInto.
      Returns:
      The ILcyLucyEnv.
    • plugInto

      public void plugInto(ILcyLucyEnv aLucyEnv)

      Plugs this tool. This method is usually called from ALcyAddOn#plugInto.

      Parameters:
      aLucyEnv - The environment to plug into.
    • unplugFrom

      public void unplugFrom(ILcyLucyEnv aLucyEnv)

      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 to plugInto.
    • assertPlugged

      protected void assertPlugged()

      This method checks if the plugInto method of this ALcyTool has been called correctly, and throws an IllegalStateException 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 NullPointerExceptions because the ILcyLucyEnv is null.

      Throws:
      IllegalStateException - If not plugged correctly, that is getLucyEnv() returns null.
    • getLongPrefix

      public 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 (.). It can for example be used as the long prefix in TLcyPreferencesTool

      For example, the class com.luciad.lucy.addons.about.TLcyAboutBoxAddon has com.luciad.lucy.addons.about. as its long prefix.

      Warning: Avoid getLongPrefix(getClass()) as it returns a different value in sub-classes. Instead use for example getLongPrefix(TLcyAboutBoxAddOn.class). Also, when multiple add-ons exist in the same package, the getLongPrefixWithClassName(Class) should be used because the package name is then no longer unique.

      Parameters:
      aClass - The class to derive the long prefix from, normally an ALcyAddOn sub-class.
      Returns:
      The long prefix.
      See Also:
    • getLongPrefixWithClassName

      public 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 (.). It can for example be used as the long prefix in TLcyPreferencesTool

      For example, the class com.luciad.lucy.addons.about.TLcyAboutBoxAddon has com.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 example getLongPrefixWithClassName(TLcyAboutBoxAddOn.class).

      Parameters:
      aClass - The class to derive the long prefix from, normally an ALcyAddOn sub-class.
      Returns:
      The long prefix.
    • getShortPrefix

      public 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 (.). It can for example be used as the short prefix in TLcyPreferencesTool

      For example, the class com.luciad.lucy.addons.about.TLcyAboutBoxAddon has TLcyAboutBoxAddon. as its short prefix.

      Warning: Avoid getShortPrefix(getClass()) as it returns a different value in sub-classes. Instead use for example getShortPrefix(TLcyAboutBoxAddOn.class).

      Parameters:
      aClass - The class to derive the short prefix from, normally an ALcyAddOn sub-class.
      Returns:
      The short prefix.