Medical Imaging Interaction Toolkit
2016.11.0
Medical Imaging Interaction Toolkit
|
#include <berryCommandManager.h>
Public Member Functions | |
CommandManager () | |
void | AddCommandManagerListener (ICommandManagerListener *listener) |
void | AddExecutionListener (IExecutionListener *listener) |
void | DefineUncategorizedCategory (const QString &name, const QString &description) |
SmartPointer< ParameterizedCommand > | Deserialize (const QString &serializedParameterizedCommand) |
QList< SmartPointer< Command > > | GetAllCommands () const |
SmartPointer< CommandCategory > | GetCategory (const QString &categoryId) |
SmartPointer< Command > | GetCommand (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< ParameterType > | GetParameterType (const QString ¶meterTypeId) |
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 |
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.
Definition at line 53 of file berryCommandManager.h.
berry::CommandManager::CommandManager | ( | ) |
The default constructor
Definition at line 168 of file berryCommandManager.cpp.
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.
listener | The 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.
listener | The 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
.
name | The name of the category for uncategorized commands; must not be null . |
description | The 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.
serializedParameterizedCommand | a string representing a command id and parameter ids and values; must not be null |
serializedParameterizedCommand
; never null
. NotDefinedException | if the command indicated in serializedParameterizedCommand is not defined |
SerializationException | if there is an error deserializing serializedParameterizedCommand |
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.
commandId | The command id of the command about to execute, never null . |
exception | The 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.
commandId | The command id of the command about to execute, never null . |
exception | The 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.
commandId | The command id of the command executed, never null . |
exception | The 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.
commandId | The command id of the command executed, never null . |
returnValue | The 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.
commandId | The command id of the command about to execute, never null . |
event | The 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.
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).
categoryId | The identifier to find; must not be null . If the category is null , then a category suitable for uncategorized items is defined and returned. |
null
, but it might be undefined. 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).
commandId | The identifier to find; must not be null and must not be zero-length. |
null
, but it might be undefined. 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.
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.
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.
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.
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.
null
. Definition at line 341 of file berryCommandManager.cpp.
QList< SmartPointer< ParameterType > > berry::CommandManager::GetDefinedParameterTypes | ( | ) |
Returns the command parameter types that are defined.
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.
command | The command for which the help context should be retrieved; must not be null . |
null
. NotDefinedException | If 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).
parameterTypeId | The identifier to find; must not be null and must not be zero-length. |
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.
listener | The 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.
listener | The 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.
handlersByCommandId | A 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.
handler | The handler with which to register a help context identifier; must not be null . |
helpContextId | The help context identifier to register; may be null if the help context identifier should be removed. |
Definition at line 457 of file berryCommandManager.cpp.
|
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().
|
staticprotected |
The escape character to use for serialization and deserialization of parameterized commands.
Definition at line 480 of file berryCommandManager.h.
|
staticprotected |
The character that separates a parameter id from its value.
Definition at line 485 of file berryCommandManager.h.
Referenced by berry::ParameterizedCommand::Serialize().
|
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().
|
staticprotected |
The character that separators parameters from each other.
Definition at line 495 of file berryCommandManager.h.
Referenced by berry::ParameterizedCommand::Serialize().
|
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().