Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berry::CommandManager Class Reference

#include <berryCommandManager.h>

Inheritance diagram for berry::CommandManager:
Collaboration diagram for berry::CommandManager:

Public Member Functions

 CommandManager ()
 
void AddCommandManagerListener (ICommandManagerListener *listener)
 
void AddExecutionListener (IExecutionListener *listener)
 
void DefineUncategorizedCategory (const QString &name, const QString &description)
 
SmartPointer< ParameterizedCommandDeserialize (const QString &serializedParameterizedCommand)
 
QList< SmartPointer< Command > > GetAllCommands () const
 
SmartPointer< CommandCategoryGetCategory (const QString &categoryId)
 
SmartPointer< CommandGetCommand (const QString &commandId)
 
QList< SmartPointer< CommandCategory > > GetDefinedCategories ()
 
QSet< QString > GetDefinedCategoryIds () const
 
QSet< QString > GetDefinedCommandIds () const
 
QList< SmartPointer< Command > > GetDefinedCommands () const
 
QSet< QString > GetDefinedParameterTypeIds () const
 
QList< SmartPointer< ParameterType > > GetDefinedParameterTypes ()
 
QString GetHelpContextId (const SmartPointer< const Command > command) const
 
SmartPointer< ParameterTypeGetParameterType (const QString &parameterTypeId)
 
void RemoveCommandManagerListener (ICommandManagerListener *listener)
 
void RemoveExecutionListener (IExecutionListener *listener)
 
void SetHandlersByCommandId (const QHash< QString, SmartPointer< IHandler > > &handlersByCommandId)
 
void SetHelpContextId (const SmartPointer< IHandler > handler, const QString &helpContextId)
 
void FireNotEnabled (const QString &commandId, const NotEnabledException *exception)
 
void FireNotDefined (const QString &commandId, const NotDefinedException *exception)
 
void FirePreExecute (const QString &commandId, const SmartPointer< const ExecutionEvent > event)
 
void FirePostExecuteSuccess (const QString &commandId, Object::Pointer returnValue)
 
void FirePostExecuteFailure (const QString &commandId, const ExecutionException *exception)
 

Static Public Attributes

static const QString AUTOGENERATED_CATEGORY_ID
 

Static Protected Attributes

static const char ESCAPE_CHAR
 
static const char ID_VALUE_CHAR
 
static const char PARAMETER_END_CHAR
 
static const char PARAMETER_SEPARATOR_CHAR
 
static const char PARAMETER_START_CHAR
 

Additional Inherited Members

- Protected Types inherited from berry::HandleObjectManager
typedef QSet< SmartPointer< HandleObject > > HandleObjectsSet
 
typedef QHash< QString, SmartPointer< HandleObject > > HandleObjectsByIdMap
 
- Protected Member Functions inherited from berry::HandleObjectManager
void CheckId (const QString &id) const
 
QSet< QString > GetDefinedHandleObjectIds () const
 
- Protected Attributes inherited from berry::HandleObjectManager
HandleObjectsSet definedHandleObjects
 
HandleObjectsByIdMap handleObjectsById
 

Detailed Description

A central repository for commands – both in the defined and undefined states. Commands can be created and retrieved using this manager. It is possible to listen to changes in the collection of commands by attaching a listener to the manager.

See also
CommandManager::getCommand(String)
Since
3.1

Definition at line 53 of file berryCommandManager.h.

Constructor & Destructor Documentation

berry::CommandManager::CommandManager ( )

The default constructor

Definition at line 168 of file berryCommandManager.cpp.

Member Function Documentation

void berry::CommandManager::AddCommandManagerListener ( ICommandManagerListener listener)

Adds a listener to this command manager. The listener will be notified when the set of defined commands changes. This can be used to track the global appearance and disappearance of commands.

Parameters
listenerThe listener to attach; must not be null.

Definition at line 176 of file berryCommandManager.cpp.

References berry::ICommandManagerListener::Events::AddListener().

void berry::CommandManager::AddExecutionListener ( IExecutionListener listener)

Adds an execution listener to this manager. This listener will be notified if any of the commands controlled by this manager execute. This can be used to support macros and instrumentation of commands.

Parameters
listenerThe listener to attach; must not be null.

Definition at line 181 of file berryCommandManager.cpp.

References berry::IExecutionListenerWithChecks::Events::AddListener(), berry::SmartPointer< TObjectType >::Cast(), berry::HandleObjectManager::handleObjectsById, and berry::IExecutionListenerWithChecks::Events::IsEmpty().

void berry::CommandManager::DefineUncategorizedCategory ( const QString &  name,
const QString &  description 
)

Sets the name and description of the category for uncategorized commands. This is the category that will be returned if getCategory(String) is called with null.

Parameters
nameThe name of the category for uncategorized commands; must not be null.
descriptionThe description of the category for uncategorized commands; may be null.

Definition at line 207 of file berryCommandManager.cpp.

References AUTOGENERATED_CATEGORY_ID, and GetCategory().

SmartPointer< ParameterizedCommand > berry::CommandManager::Deserialize ( const QString &  serializedParameterizedCommand)

Returns a ParameterizedCommand with a command and parameterizations as specified in the provided serializedParameterizedCommand string. The serializedParameterizedCommand must use the format returned by ParameterizedCommand#serialize() and described in the Javadoc for that method.

If a parameter id encoded in the serializedParameterizedCommand does not exist in the encoded command, that parameter id and value are ignored. A given parameter id should not be used more than once in serializedParameterizedCommand. This will not result in an exception, but in this case the value of the parameter when the command is executed is unspecified.

This method will never return null, however it may throw an exception if there is a problem processing the serialization string or the encoded command is undefined.

Parameters
serializedParameterizedCommanda string representing a command id and parameter ids and values; must not be null
Returns
a ParameterizedCommand with the command and parameterizations encoded in the serializedParameterizedCommand; never null.
Exceptions
NotDefinedExceptionif the command indicated in serializedParameterizedCommand is not defined
SerializationExceptionif there is an error deserializing serializedParameterizedCommand
See also
ParameterizedCommand::serialize()

Definition at line 214 of file berryCommandManager.cpp.

References GetCommand(), PARAMETER_END_CHAR, PARAMETER_START_CHAR, and ParameterizedCommand.

void berry::CommandManager::FireNotDefined ( const QString &  commandId,
const NotDefinedException *  exception 
)

Fires the notDefined event for executionListeners.

Note: This supports bridging actions to the command framework, and should not be used outside the framework.

Parameters
commandIdThe command id of the command about to execute, never null.
exceptionThe exception, never null.

Definition at line 480 of file berryCommandManager.cpp.

References berry::IExecutionListenerWithChecks::Events::notDefined.

void berry::CommandManager::FireNotEnabled ( const QString &  commandId,
const NotEnabledException *  exception 
)

Fires the notEnabled event for executionListeners.

Note: This supports bridging actions to the command framework, and should not be used outside the framework.

Parameters
commandIdThe command id of the command about to execute, never null.
exceptionThe exception, never null.

Definition at line 475 of file berryCommandManager.cpp.

References berry::IExecutionListenerWithChecks::Events::notEnabled.

void berry::CommandManager::FirePostExecuteFailure ( const QString &  commandId,
const ExecutionException *  exception 
)

Fires the postExecuteFailure event for executionListeners.

Note: This supports bridging actions to the command framework, and should not be used outside the framework.

Parameters
commandIdThe command id of the command executed, never null.
exceptionThe exception, never null.

Definition at line 495 of file berryCommandManager.cpp.

References berry::IExecutionListener::Events::postExecuteFailure.

void berry::CommandManager::FirePostExecuteSuccess ( const QString &  commandId,
Object::Pointer  returnValue 
)

Fires the postExecuteSuccess event for executionListeners.

Note: This supports bridging actions to the command framework, and should not be used outside the framework.

Parameters
commandIdThe command id of the command executed, never null.
returnValueThe value returned from the command, may be null.

Definition at line 490 of file berryCommandManager.cpp.

References berry::IExecutionListener::Events::postExecuteSuccess.

void berry::CommandManager::FirePreExecute ( const QString &  commandId,
const SmartPointer< const ExecutionEvent event 
)

Fires the preExecute event for executionListeners.

Note: This supports bridging actions to the command framework, and should not be used outside the framework.

Parameters
commandIdThe command id of the command about to execute, never null.
eventThe event that triggered the command, may be null.

Definition at line 485 of file berryCommandManager.cpp.

References berry::IExecutionListener::Events::preExecute.

QList< SmartPointer< Command > > berry::CommandManager::GetAllCommands ( ) const

Returns all of the commands known by this manager – defined and undefined.

Returns
All of the commands; may be empty, but never null.

Definition at line 254 of file berryCommandManager.cpp.

References berry::SmartPointer< TObjectType >::Cast(), and berry::HandleObjectManager::handleObjectsById.

SmartPointer< CommandCategory > berry::CommandManager::GetCategory ( const QString &  categoryId)

Gets the category with the given identifier. If no such category currently exists, then the category will be created (but be undefined).

Parameters
categoryIdThe identifier to find; must not be null. If the category is null, then a category suitable for uncategorized items is defined and returned.
Returns
The category with the given identifier; this value will never be null, but it might be undefined.
See also
Category

Definition at line 268 of file berryCommandManager.cpp.

References AUTOGENERATED_CATEGORY_ID, and berry::HandleObjectManager::CheckId().

Referenced by DefineUncategorizedCategory(), and GetDefinedCategories().

SmartPointer< Command > berry::CommandManager::GetCommand ( const QString &  commandId)

Gets the command with the given identifier. If no such command currently exists, then the command will be created (but will be undefined).

Parameters
commandIdThe identifier to find; must not be null and must not be zero-length.
Returns
The command with the given identifier; this value will never be null, but it might be undefined.
See also
Command

Definition at line 288 of file berryCommandManager.cpp.

References berry::HandleObjectManager::CheckId(), and berry::HandleObjectManager::handleObjectsById.

Referenced by Deserialize(), and SetHandlersByCommandId().

QList< CommandCategory::Pointer > berry::CommandManager::GetDefinedCategories ( )

Returns the categories that are defined.

Returns
The defined categories; this value may be empty, but it is never null.

Definition at line 308 of file berryCommandManager.cpp.

References GetCategory().

QSet< QString > berry::CommandManager::GetDefinedCategoryIds ( ) const

Returns the set of identifiers for those category that are defined.

Returns
The set of defined category identifiers; this value may be empty, but it is never null.

Definition at line 319 of file berryCommandManager.cpp.

QSet< QString > berry::CommandManager::GetDefinedCommandIds ( ) const

Returns the set of identifiers for those commands that are defined.

Returns
The set of defined command identifiers; this value may be empty, but it is never null.

Definition at line 324 of file berryCommandManager.cpp.

References berry::HandleObjectManager::GetDefinedHandleObjectIds().

QList< SmartPointer< Command > > berry::CommandManager::GetDefinedCommands ( ) const

Returns the commands that are defined.

Returns
The defined commands; this value may be empty, but it is never null.

Definition at line 329 of file berryCommandManager.cpp.

References berry::SmartPointer< TObjectType >::Cast(), and berry::HandleObjectManager::definedHandleObjects.

QSet< QString > berry::CommandManager::GetDefinedParameterTypeIds ( ) const

Returns the set of identifiers for those parameter types that are defined.

Returns
The set of defined command parameter type identifiers; this value may be empty, but it is never null.

Definition at line 341 of file berryCommandManager.cpp.

QList< SmartPointer< ParameterType > > berry::CommandManager::GetDefinedParameterTypes ( )

Returns the command parameter types that are defined.

Returns
The defined command parameter types; this value may be empty, but it is never null.

Definition at line 346 of file berryCommandManager.cpp.

References GetParameterType().

QString berry::CommandManager::GetHelpContextId ( const SmartPointer< const Command command) const

Gets the help context identifier for a particular command. The command's handler is first checked for a help context identifier. If the handler does not have a help context identifier, then the help context identifier for the command is returned. If neither has a help context identifier, then null is returned.

Parameters
commandThe command for which the help context should be retrieved; must not be null.
Returns
The help context identifier to use for the given command; may be null.
Exceptions
NotDefinedExceptionIf the given command is not defined.

Definition at line 357 of file berryCommandManager.cpp.

References us::handler.

SmartPointer< ParameterType > berry::CommandManager::GetParameterType ( const QString &  parameterTypeId)

Gets the command ParameterType with the given identifier. If no such command parameter type currently exists, then the command parameter type will be created (but will be undefined).

Parameters
parameterTypeIdThe identifier to find; must not be null and must not be zero-length.
Returns
The ParameterType with the given identifier; this value will never be null, but it might be undefined.

Definition at line 383 of file berryCommandManager.cpp.

References berry::HandleObjectManager::CheckId().

Referenced by GetDefinedParameterTypes().

void berry::CommandManager::RemoveCommandManagerListener ( ICommandManagerListener listener)

Removes a listener from this command manager.

Parameters
listenerThe listener to be removed; must not be null.

Definition at line 398 of file berryCommandManager.cpp.

References berry::ICommandManagerListener::Events::RemoveListener().

void berry::CommandManager::RemoveExecutionListener ( IExecutionListener listener)

Removes an execution listener from this command manager.

Parameters
listenerThe listener to be removed; must not be null.

Definition at line 403 of file berryCommandManager.cpp.

References berry::HandleObjectManager::handleObjectsById, berry::IExecutionListenerWithChecks::Events::IsEmpty(), and berry::IExecutionListenerWithChecks::Events::RemoveListener().

void berry::CommandManager::SetHandlersByCommandId ( const QHash< QString, SmartPointer< IHandler > > &  handlersByCommandId)

Block updates all of the handlers for all of the commands. If the handler is null or the command id does not exist in the map, then the command becomes unhandled. Otherwise, the handler is set to the corresponding value in the map.

Parameters
handlersByCommandIdA map of command identifiers (String) to handlers (IHandler). This map may be null if all handlers should be cleared. Similarly, if the map is empty, then all commands will become unhandled.

Definition at line 430 of file berryCommandManager.cpp.

References GetCommand(), and berry::HandleObjectManager::handleObjectsById.

void berry::CommandManager::SetHelpContextId ( const SmartPointer< IHandler handler,
const QString &  helpContextId 
)

Sets the help context identifier to associate with a particular handler.

Parameters
handlerThe handler with which to register a help context identifier; must not be null.
helpContextIdThe help context identifier to register; may be null if the help context identifier should be removed.

Definition at line 457 of file berryCommandManager.cpp.

Member Data Documentation

const QString berry::CommandManager::AUTOGENERATED_CATEGORY_ID
static

The identifier of the category in which all auto-generated commands will appear. This value must never be null.

Definition at line 146 of file berryCommandManager.h.

Referenced by DefineUncategorizedCategory(), and GetCategory().

const char berry::CommandManager::ESCAPE_CHAR
staticprotected

The escape character to use for serialization and deserialization of parameterized commands.

Definition at line 480 of file berryCommandManager.h.

const char berry::CommandManager::ID_VALUE_CHAR
staticprotected

The character that separates a parameter id from its value.

Definition at line 485 of file berryCommandManager.h.

Referenced by berry::ParameterizedCommand::Serialize().

const char berry::CommandManager::PARAMETER_END_CHAR
staticprotected

The character that indicates the end of a list of parameters.

Definition at line 490 of file berryCommandManager.h.

Referenced by Deserialize(), and berry::ParameterizedCommand::Serialize().

const char berry::CommandManager::PARAMETER_SEPARATOR_CHAR
staticprotected

The character that separators parameters from each other.

Definition at line 495 of file berryCommandManager.h.

Referenced by berry::ParameterizedCommand::Serialize().

const char berry::CommandManager::PARAMETER_START_CHAR
staticprotected

The character that indicates the start of a list of parameters.

Definition at line 500 of file berryCommandManager.h.

Referenced by Deserialize(), and berry::ParameterizedCommand::Serialize().


The documentation for this class was generated from the following files: