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:
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.
TLcyActionBarUtil
Modifier and Type | Method and Description |
---|---|
void |
addActiveContext(Object aContext)
Adds the given context as an active context.
|
void |
addActiveContextListener(ILcyActiveContextListener aListener)
Adds the specified listener to the list of listeners that are notified when an active
context is added or removed.
|
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.
|
String |
generateDump()
Method which returns a dump of all the registered actions and active settables.
|
ILcyActionBar |
getActionBar(String aActionBarID,
Object aContext)
Retrieves the
ILcyActionBar for the given ID. |
Object |
getActiveContext(int aIndex)
Returns the active context corresponding to the given index.
|
int |
getActiveContextCount()
Returns the number of active contexts.
|
void |
removeActiveContext(Object aContext)
Removes the given context from the list of active contexts.
|
void |
removeActiveContextListener(ILcyActiveContextListener aListener)
Removes the specified listener from the list of listeners that are notified when an active
context is added or removed.
|
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.
aContext
- The context to be disposed. It must not be null
.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.
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.null
.IllegalArgumentException
- When the given context was disposed using disposeContext(Object)
public int getActiveContextCount()
Returns the number of active contexts.
getActiveContext(int)
public Object getActiveContext(int aIndex)
Returns the active context corresponding to the given index.
aIndex
- The index of the desired active context. Should be between zero and
getActiveContextCount
.null
.IndexOutOfBoundsException
- If the index is out of range ( index < 0 || index >=
getActiveContextCount
)public void addActiveContext(Object aContext)
Adds the given context as an active context. The registered listeners will be notified of this active context.
aContext
- The context to mark as active. Must not be null
. The context should
not have been disposed using the disposeContext
method.addActiveContextListener(ILcyActiveContextListener)
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.
aContext
- The context to remove from the list of active contexts.addActiveContextListener(ILcyActiveContextListener)
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.
aListener
- The listener that should from now on be notified of changes in the list of
active contexts. Must not be null
.getActiveContext(int)
,
addActiveContext(Object)
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.
aListener
- The listener that should no longer be notified of changes in the list of
active contexts.getActiveContext(int)
,
removeActiveContext(Object)
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.