Class ContextManager
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.core.commands.common.HandleObjectManager<Context>
org.eclipse.core.commands.contexts.ContextManager
- All Implemented Interfaces:
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.
- Since:
- 3.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic booleanThis flag can be set totrueif the context manager should print information toSystem.outwhen certain boundary conditions occur.Fields inherited from class org.eclipse.core.commands.common.HandleObjectManager
definedHandleObjects, handleObjectsById -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddActiveContext(String contextId) Activates a context in this context manager.final voidAdds a listener to this context manager.final voidcontextChanged(ContextEvent contextEvent) Notifies that one or more properties of an instance ofIContexthave changed.voiddeferUpdates(boolean defer) Informs the manager that a batch operation has started.final SetReturns the set of active context identifiers.final ContextgetContext(String contextId) Gets the context with the given identifier.final SetReturns the set of identifiers for those contexts that are defined.final Context[]Returns the those contexts that are defined.final voidremoveActiveContext(String contextId) Deactivates a context in this context manager.final voidRemoves a listener from this context manager.final voidsetActiveContextIds(Set activeContextIds) Changes the set of active contexts for this context manager.Methods inherited from class org.eclipse.core.commands.common.HandleObjectManager
checkId, getDefinedHandleObjectIdsMethods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
Field Details
-
DEBUG
public static boolean DEBUGThis flag can be set totrueif the context manager should print information toSystem.outwhen certain boundary conditions occur.
-
-
Constructor Details
-
ContextManager
public ContextManager()
-
-
Method Details
-
deferUpdates
public void deferUpdates(boolean defer) Informs the manager that a batch operation has started.Note: You must insure that if you call
deferUpdates(true)that nothing in your batched operation will prevent the matching call todeferUpdates(false).- Parameters:
defer- true when starting a batch operation false when ending the operation- Since:
- 3.5
-
addActiveContext
Activates a context in this context manager.- Parameters:
contextId- The identifier of the context to activate; must not benull.
-
addContextManagerListener
Adds a listener to this context manager. The listener will be notified when the set of defined contexts changes. This can be used to track the global appearance and disappearance of contexts.- Parameters:
listener- The listener to attach; must not benull.
-
contextChanged
Description copied from interface:IContextListenerNotifies that one or more properties of an instance ofIContexthave changed. Specific details are described in theContextEvent.- Specified by:
contextChangedin interfaceIContextListener- Parameters:
contextEvent- the context event. Guaranteed not to benull.
-
getActiveContextIds
Returns the set of active context identifiers.- Returns:
- The set of active context identifiers; this value may be
nullif no active contexts have been set yet. If the set is notnull, then it contains only instances ofString.
-
getContext
Gets the context with the given identifier. If no such context currently exists, then the context will be created (but be undefined).- Parameters:
contextId- The identifier to find; must not benull.- Returns:
- The context with the given identifier; this value will never be
null, but it might be undefined. - See Also:
-
getDefinedContextIds
Returns the set of identifiers for those contexts that are defined.- Returns:
- The set of defined context identifiers; this value may be empty,
but it is never
null.
-
getDefinedContexts
Returns the those contexts that are defined.- Returns:
- The defined contexts; this value may be empty, but it is never
null. - Since:
- 3.2
-
removeActiveContext
Deactivates a context in this context manager.- Parameters:
contextId- The identifier of the context to deactivate; must not benull.
-
removeContextManagerListener
Removes a listener from this context manager.- Parameters:
listener- The listener to be removed; must not benull.
-
setActiveContextIds
Changes the set of active contexts for this context manager. The whole set is required so that internal consistency can be maintained and so that excessive recomputations do nothing occur.- Parameters:
activeContextIds- The new set of active context identifiers; may benull.
-