Class TLcyActionBarManager

java.lang.Object
com.luciad.lucy.gui.TLcyActionBarManager

public class TLcyActionBarManager extends Object

The TLcyActionBarManager class is the central repository for actions and active settables in the Lucy application.

Typically you do not interact with this class directly. Lucy offers utility methods for all common operations which involve the TLcyActionBarManager in the TLcyActionBarUtil class. This is illustrated in the Lucy developer guide in the "Modifying the menu and tool bars" chapter. The developer guide also contains code examples for all common operations.

When you encounter a problem related to actions or active settables and action bars like for example action which do not appear, appear in the wrong location, appear in the wrong order, ... the TLcyDebugAddOn can be of great help.

This central repository has two important functions:

  • It allows add-ons to register an action or active settable to be inserted into a certain action bar (or multiple ones).
  • It allows an action bar to ask which actions were registered for it, and insert those.

The TLcyActionBarManager uses a unique identifier to indicate an action bar. This identifier is used when an action or active settable is registered, and when an action bar wants to know which entries were registered for it. The identifier consists out of a name and a context. The name is a simple String, and the context is either null or a map component.

Typically you do not interact with this class directly. Lucy offers utility methods for all common operations which involve the TLcyActionBarManager in the TLcyActionBarUtil class. This is illustrated in the Lucy developer guide in the "Modifying the menu and tool bars" chapter. The developer guide also contains code examples for all common operations.

Since:
8.1
See Also:
  • Method Details

    • disposeContext

      public void disposeContext(Object aContext)

      Informs this manager that the given context is no longer in use, and that action bars associated with this context can be discarded. Any future calls to getActionBar(String, Object) with this disposed context as context will throw an exception.

      If the context to be disposed is an active context, it will be removed from the active contexts.

      Parameters:
      aContext - The context to be disposed. It must not be null.
    • getActionBar

      public ILcyActionBar getActionBar(String aActionBarID, Object aContext)

      Retrieves the ILcyActionBar for the given ID. If this is the first time this ILcyActionBar is requested, an instance is automatically created.

      The returned action bar must be seen as a container for actions and active settables. It cannot be added to the user interface.

      Parameters:
      aActionBarID - The ID for the given action bar. Must not be null.
      aContext - The context of the requested action bar. This context should not yet have been disposed. This may be null, in which case a global action bar is returned.
      Returns:
      The action bar for the given ID, guaranteed not to be null.
      Throws:
      IllegalArgumentException - When the given context was disposed using disposeContext(Object)
    • getActiveContextCount

      public int getActiveContextCount()

      Returns the number of active contexts.

      Returns:
      The number of active contexts. Always equal to or greater than zero.
      See Also:
    • getActiveContext

      public Object getActiveContext(int aIndex)

      Returns the active context corresponding to the given index.

      Parameters:
      aIndex - The index of the desired active context. Should be between zero and getActiveContextCount.
      Returns:
      The active context corresponding to the given index. Never null.
      Throws:
      IndexOutOfBoundsException - If the index is out of range ( index < 0 || index >= getActiveContextCount )
    • addActiveContext

      public void addActiveContext(Object aContext)

      Adds the given context as an active context. The registered listeners will be notified of this active context.

      Parameters:
      aContext - The context to mark as active. Must not be null. The context should not have been disposed using the disposeContext method.
      See Also:
    • removeActiveContext

      public void removeActiveContext(Object aContext)

      Removes the given context from the list of active contexts. The registered listeners are notified of this removal. If the given context was not in the list of active contexts, nothing happens.

      Parameters:
      aContext - The context to remove from the list of active contexts.
      See Also:
    • addActiveContextListener

      public void addActiveContextListener(ILcyActiveContextListener aListener)

      Adds the specified listener to the list of listeners that are notified when an active context is added or removed.

      Parameters:
      aListener - The listener that should from now on be notified of changes in the list of active contexts. Must not be null.
      See Also:
    • removeActiveContextListener

      public void removeActiveContextListener(ILcyActiveContextListener aListener)

      Removes the specified listener from the list of listeners that are notified when an active context is added or removed. If the specified listener was not in the list, nothing happens.

      Parameters:
      aListener - The listener that should no longer be notified of changes in the list of active contexts.
      See Also:
    • generateDump

      public final String generateDump()

      Method which returns a dump of all the registered actions and active settables.

      The purpose of this method is to facilitate debugging. For example when an action does not appear in the UI, you can investigate the dump to see for which action bar the action is registered. Note that the format of the dump might change in future releases.

      The TLcyDebugAddOn adds an action which shows this information on the console. Consult the class javadoc of that add-on for more information.

      Returns:
      a dump of all the registered actions and active settables.