Medical Imaging Interaction Toolkit  2023.04.00
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 49 of file berryCommandManager.h.

Constructor & Destructor Documentation

◆ CommandManager()

berry::CommandManager::CommandManager ( )

The default constructor

Member Function Documentation

◆ AddCommandManagerListener()

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.

◆ AddExecutionListener()

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.

◆ DefineUncategorizedCategory()

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 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.

◆ Deserialize()

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()

◆ FireNotDefined()

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.

◆ FireNotEnabled()

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.

◆ FirePostExecuteFailure()

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.

◆ FirePostExecuteSuccess()

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.

◆ FirePreExecute()

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.

◆ GetAllCommands()

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.

◆ GetCategory()

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

◆ GetCommand()

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

◆ GetDefinedCategories()

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

Returns the categories that are defined.

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

◆ GetDefinedCategoryIds()

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.

◆ GetDefinedCommandIds()

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.

◆ GetDefinedCommands()

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.

◆ GetDefinedParameterTypeIds()

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.

◆ GetDefinedParameterTypes()

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.

◆ GetHelpContextId()

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.

◆ GetParameterType()

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.

◆ RemoveCommandManagerListener()

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

Removes a listener from this command manager.

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

◆ RemoveExecutionListener()

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

Removes an execution listener from this command manager.

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

◆ SetHandlersByCommandId()

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.

◆ SetHelpContextId()

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.

Member Data Documentation

◆ AUTOGENERATED_CATEGORY_ID

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 142 of file berryCommandManager.h.

◆ ESCAPE_CHAR

const char berry::CommandManager::ESCAPE_CHAR
staticprotected

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

Definition at line 476 of file berryCommandManager.h.

◆ ID_VALUE_CHAR

const char berry::CommandManager::ID_VALUE_CHAR
staticprotected

The character that separates a parameter id from its value.

Definition at line 481 of file berryCommandManager.h.

◆ PARAMETER_END_CHAR

const char berry::CommandManager::PARAMETER_END_CHAR
staticprotected

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

Definition at line 486 of file berryCommandManager.h.

◆ PARAMETER_SEPARATOR_CHAR

const char berry::CommandManager::PARAMETER_SEPARATOR_CHAR
staticprotected

The character that separators parameters from each other.

Definition at line 491 of file berryCommandManager.h.

◆ PARAMETER_START_CHAR

const char berry::CommandManager::PARAMETER_START_CHAR
staticprotected

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

Definition at line 496 of file berryCommandManager.h.


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