public final class ContextManager extends HandleObjectManager implements IContextListener
A context manager tracks the sets of defined and enabled contexts within the application. The manager sends notification events to listeners when these sets change. It is also possible to retrieve any given context with its identifier.
This class is not intended to be extended by clients.
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG
This flag can be set to
true if the context manager should
print information to System.out when certain boundary
conditions occur. |
definedHandleObjects, handleObjectsById
Constructor and Description |
---|
ContextManager() |
Modifier and Type | Method and Description |
---|---|
void |
addActiveContext(String contextId)
Activates a context in this context manager.
|
void |
addContextManagerListener(IContextManagerListener listener)
Adds a listener to this context manager.
|
void |
contextChanged(ContextEvent contextEvent)
Notifies that one or more properties of an instance of
IContext have changed. |
void |
deferUpdates(boolean defer)
Informs the manager that a batch operation has started.
|
Set |
getActiveContextIds()
Returns the set of active context identifiers.
|
Context |
getContext(String contextId)
Gets the context with the given identifier.
|
Set |
getDefinedContextIds()
Returns the set of identifiers for those contexts that are defined.
|
Context[] |
getDefinedContexts()
Returns the those contexts that are defined.
|
void |
removeActiveContext(String contextId)
Deactivates a context in this context manager.
|
void |
removeContextManagerListener(IContextManagerListener listener)
Removes a listener from this context manager.
|
void |
setActiveContextIds(Set activeContextIds)
Changes the set of active contexts for this context manager.
|
checkId, getDefinedHandleObjectIds
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
public static boolean DEBUG
true
if the context manager should
print information to System.out
when certain boundary
conditions occur.public void deferUpdates(boolean defer)
Note: You must insure that if you call
deferUpdates(true)
that nothing in your batched operation
will prevent the matching call to deferUpdates(false)
.
defer
- true when starting a batch operation false when ending the
operationpublic final void addActiveContext(String contextId)
contextId
- The identifier of the context to activate; must not be
null
.public final void addContextManagerListener(IContextManagerListener listener)
listener
- The listener to attach; must not be null
.public final void contextChanged(ContextEvent contextEvent)
IContextListener
IContext
have changed. Specific details are described in
the ContextEvent
.contextChanged
in interface IContextListener
contextEvent
- the context event. Guaranteed not to be null
.public final Set getActiveContextIds()
null
if no active contexts have been set yet. If
the set is not null
, then it contains only
instances of String
.public final Context getContext(String contextId)
contextId
- The identifier to find; must not be null
.null
, but it might be undefined.Context
public final Set getDefinedContextIds()
null
.public final Context[] getDefinedContexts()
null
.public final void removeActiveContext(String contextId)
contextId
- The identifier of the context to deactivate; must not be
null
.public final void removeContextManagerListener(IContextManagerListener listener)
listener
- The listener to be removed; must not be null
.public final void setActiveContextIds(Set activeContextIds)
activeContextIds
- The new set of active context identifiers; may be
null
.
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.