diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.h index 6679f6c7f8..d236995b51 100644 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryAbstractHandler.h @@ -1,163 +1,163 @@ /*=================================================================== BlueBerry Platform Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef BERRYABSTRACTHANDLER_H_ #define BERRYABSTRACTHANDLER_H_ #include "berryIHandler.h" #include "berryIHandlerListener.h" #include namespace berry { /** *

* This class is a partial implementation of IHandler. This * abstract implementation provides support for handler listeners. You should * subclass from this class unless you want to implement your own listener * support. Subclasses should call * {@link AbstractHandler#fireHandlerChanged(HandlerEvent)}when the handler * changes. Subclasses can also override {@link AbstractHandler#isEnabled()} and * {@link AbstractHandler#isHandled()}. *

*/ class BERRY_COMMANDS AbstractHandler : public QObject, public IHandler { // ,public EventManager { Q_OBJECT Q_INTERFACES(berry::IHandler) public: - berryObjectMacro(AbstractHandler); + berryObjectMacro(AbstractHandler) private: /** * Track this base class enabled state. */ bool baseEnabled; IHandlerListener::Events handlerListeners; public: AbstractHandler(); /** * @see IHandler#addHandlerListener(IHandlerListener) */ void AddHandlerListener(IHandlerListener* handlerListener); /** * The default implementation does nothing. Subclasses who attach listeners * to other objects are encouraged to detach them in this method. * * @see IHandler#Dispose() */ void Dispose(); /** * Whether this handler is capable of executing at this time. Subclasses may * override this method. If clients override this method they should also * consider overriding {@link #setEnabled(Object)} so they can be notified * about framework execution contexts. * * @return true * @see #setEnabled(Object) * @see #setBaseEnabled(boolean) */ bool IsEnabled() const; /** * Called by the framework to allow the handler to update its enabled state * by extracting the same information available at execution time. Clients * may override if they need to extract information from the application * context. * * @param evaluationContext * the application context. May be null * @see #SetBaseEnabled(bool) */ void SetEnabled(const Object::Pointer& evaluationContext); /** * Whether this handler is capable of handling delegated responsibilities at * this time. Subclasses may override this method. * * @return true */ bool IsHandled() const; /** * @see IHandler#removeHandlerListener(IHandlerListener) */ void RemoveHandlerListener(IHandlerListener* handlerListener); protected: /** * Fires an event to all registered listeners describing changes to this * instance. *

* Subclasses may extend the definition of this method (i.e., if a different * type of listener can be attached to a subclass). This is used primarily * for support of AbstractHandler in * org.blueberry.ui.workbench, and clients should be wary of * overriding this behaviour. If this method is overridden, then the first * line of the method should be "super.fireHandlerChanged(handlerEvent);". *

* * @param handlerEvent * the event describing changes to this instance. Must not be * null. */ void FireHandlerChanged(const SmartPointer& handlerEvent); /** * Allow the default {@link #isEnabled()} to answer our enabled state. It * will fire a HandlerEvent if necessary. If clients use this method they * should also consider overriding {@link #setEnabled(Object)} so they can * be notified about framework execution contexts. * * @param state * the enabled state */ void SetBaseEnabled(bool state); /** *

* Returns true iff there is one or more IHandlerListeners attached to this * AbstractHandler. *

*

* Subclasses may extend the definition of this method (i.e., if a different * type of listener can be attached to a subclass). This is used primarily * for support of AbstractHandler in * org.blueberry.ui.qt, and clients should be wary of * overriding this behaviour. If this method is overridden, then the return * value should include "super.hasListeners() ||". *

* * @return true iff there is one or more IHandlerListeners attached to this * AbstractHandler */ virtual bool HasListeners() const; }; } #endif /*BERRYABSTRACTHANDLER_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.h b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.h index 7ba97d93c2..34847d0d6b 100755 --- a/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.h +++ b/BlueBerry/Bundles/org.blueberry.core.commands/src/berryParameterizedCommand.h @@ -1,338 +1,338 @@ /*=================================================================== BlueBerry Platform Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef BERRYPARAMETERIZEDCOMMAND_H_ #define BERRYPARAMETERIZEDCOMMAND_H_ #include #include #include "common/berryCommandExceptions.h" #include #include #include namespace berry { struct IParameter; class Command; class Parameterization; /** *

* A command that has had one or more of its parameters specified. This class * serves as a utility class for developers that need to manipulate commands * with parameters. It handles the behaviour of generating a parameter map and a * human-readable name. *

*/ class BERRY_COMMANDS ParameterizedCommand: public Object { //implements Comparable { public: - berryObjectMacro(ParameterizedCommand); + berryObjectMacro(ParameterizedCommand) /** * The index of the parameter id in the parameter values. * * @deprecated no longer used */ static const int INDEX_PARAMETER_ID; // = 0; /** * The index of the human-readable name of the parameter itself, in the * parameter values. * * @deprecated no longer used */ static const int INDEX_PARAMETER_NAME; // = 1; /** * The index of the human-readable name of the value of the parameter for * this command. * * @deprecated no longer used */ static const int INDEX_PARAMETER_VALUE_NAME; // = 2; /** * The index of the value of the parameter that the command can understand. * * @deprecated no longer used */ static const int INDEX_PARAMETER_VALUE_VALUE; // = 3; /** * Constructs a new instance of ParameterizedCommand with * specific values for zero or more of its parameters. * * @param command * The command that is parameterized; must not be * null. * @param parameterizations * An array of parameterizations binding parameters to values for * the command. This value may be null. */ ParameterizedCommand(const SmartPointer& command, const QList& parameterizations); bool operator<(const Object* object) const; bool operator==(const Object* object) const; /** * Executes this command with its parameters. This does extra checking to * see if the command is enabled and defined. If it is not both enabled and * defined, then the execution listeners will be notified and an exception * thrown. * * @param trigger * The object that triggered the execution; may be * null. * @param applicationContext * The state of the application at the time the execution was * triggered; may be null. * @return The result of the execution; may be null. * @throws ExecutionException * If the handler has problems executing this command. * @throws NotDefinedException * If the command you are trying to execute is not defined. * @throws NotEnabledException * If the command you are trying to execute is not enabled. * @throws NotHandledException * If there is no handler. */ Object::Pointer ExecuteWithChecks(const Object::ConstPointer& trigger, const Object::Pointer& applicationContext); /** * Returns the base command. It is possible for more than one parameterized * command to have the same identifier. * * @return The command; never null, but may be undefined. */ SmartPointer GetCommand() const; /** * Returns the command's base identifier. It is possible for more than one * parameterized command to have the same identifier. * * @return The command id; never null. */ QString GetId() const; /** * Returns a human-readable representation of this command with all of its * parameterizations. * * @return The human-readable representation of this parameterized command; * never null. * @throws NotDefinedException * If the underlying command is not defined. */ QString GetName() const; /** * Returns the parameter map, as can be used to construct an * ExecutionEvent. * * @return The map of parameter ids (String) to parameter * values (String). This map is never * null, but may be empty. */ QHash GetParameterMap() const; uint HashCode() const; /** * Returns a {@link String} containing the command id, parameter ids and * parameter values for this {@link ParameterizedCommand}. The returned * {@link String} can be stored by a client and later used to reconstruct an * equivalent {@link ParameterizedCommand} using the * {@link CommandManager#deserialize(String)} method. *

* The syntax of the returned {@link String} is as follows: *

* *
* serialization = commandId [ '(' parameters ')' ]
* parameters = parameter [ ',' parameters ]
* parameter = parameterId [ '=' parameterValue ] *
* *

* In the syntax above, sections inside square-brackets are optional. The * characters in single quotes ((, ), * , and =) indicate literal characters. *

*

* commandId represents the command id encoded with * separator characters escaped. parameterId and * parameterValue represent the parameter ids and * values encoded with separator characters escaped. The separator * characters (, ), , and * = are escaped by prepending a %. This * requires % to be escaped, which is also done by prepending * a %. *

*

* The order of the parameters is not defined (and not important). A missing * parameterValue indicates that the value of the * parameter is null. *

*

* For example, the string shown below represents a serialized parameterized * command that can be used to show the Resource perspective: *

*

* org.eclipse.ui.perspectives.showPerspective(org.eclipse.ui.perspectives.showPerspective.perspectiveId=org.eclipse.ui.resourcePerspective) *

*

* This example shows the more general form with multiple parameters, * null value parameters, and escaped = in the * third parameter value. *

*

* command.id(param1.id=value1,param2.id,param3.id=esc%=val3) *

* * @return A string containing the escaped command id, parameter ids and * parameter values; never null. * @see CommandManager#deserialize(String) */ QString Serialize(); QString ToString() const; /** *

* Generates all the possible combinations of command parameterizations for * the given command. If the command has no parameters, then this is simply * a parameterized version of that command. If a parameter is optional, both * the included and not included cases are considered. *

*

* If one of the parameters cannot be loaded due to a * ParameterValuesException, then it is simply ignored. *

* * @param command * The command for which the parameter combinations should be * generated; must not be null. * @return A collection of ParameterizedCommand instances * representing all of the possible combinations. This value is * never empty and it is never null. * @throws NotDefinedException * If the command is not defined. */ static QList GenerateCombinations(const SmartPointer command); /** * Take a command and a map of parameter IDs to values, and generate the * appropriate parameterized command. * * @param command * The command object. Must not be null. * @param parameters * A map of String parameter ids to objects. May be * null. * @return the parameterized command, or null if it could not * be generated */ static ParameterizedCommand::Pointer GenerateCommand(const SmartPointer command, const QHash& parameters); private: /** * The constant integer hash code value meaning the hash code has not yet * been computed. */ static const uint HASH_CODE_NOT_COMPUTED; // = 0; /** * A factor for computing the hash code for all parameterized commands. */ static const uint HASH_FACTOR; // = 89; /** * The seed for the hash code for all parameterized commands. */ static const uint HASH_INITIAL; /** * Escapes special characters in the command id, parameter ids and parameter * values for {@link #serialize()}. The special characters * {@link CommandManager#PARAMETER_START_CHAR}, * {@link CommandManager#PARAMETER_END_CHAR}, * {@link CommandManager#ID_VALUE_CHAR}, * {@link CommandManager#PARAMETER_SEPARATOR_CHAR} and * {@link CommandManager#ESCAPE_CHAR} are escaped by prepending a * {@link CommandManager#ESCAPE_CHAR} character. * * @param rawText * a String to escape special characters in for * serialization. * @return a String representing rawText with * special serialization characters escaped */ static QString Escape(const QString& rawText); /** * Generates every possible combination of parameter values for the given * parameters. Parameters values that cannot be initialized are just * ignored. Optional parameters are considered. * * @param startIndex * The index in the parameters that we should * process. This must be a valid index. * @param parameters * The parameters in to process; must not be null. * @return A collection (Collection) of combinations (List * of Parameterization). */ static QList > ExpandParameters(unsigned int startIndex, const QList >& parameters); /** * The base command which is being parameterized. This value is never * null. */ const SmartPointer command; /** * The hash code for this object. This value is computed lazily, and marked * as invalid when one of the values on which it is based changes. */ mutable uint hashCode; /** * This is an array of parameterization defined for this command. This value * may be null if the command has no parameters. */ QList parameterizations; mutable QString name; }; } #endif /* BERRYPARAMETERIZEDCOMMAND_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/plugin.xml b/BlueBerry/Bundles/org.blueberry.ui.qt/plugin.xml index 82a058d000..7b93c3b156 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/plugin.xml +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/plugin.xml @@ -1,167 +1,167 @@ - + diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryCommandContributionItem.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryCommandContributionItem.h index 4b8d52ee38..8da3b853be 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryCommandContributionItem.h +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryCommandContributionItem.h @@ -1,215 +1,214 @@ /*=================================================================== BlueBerry Platform Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef BERRYCOMMANDCONTRIBUTIONITEM_H_ #define BERRYCOMMANDCONTRIBUTIONITEM_H_ #include "berryContributionItem.h" #include namespace berry { struct IMenuService; struct ICommandService; struct ICommandListener; struct IHandlerService; struct IHandler; struct IElementReference; struct IServiceLocator; class CommandEvent; class ParameterizedCommand; class CommandContributionItemParameter; class UIElement; /** * A contribution item which delegates to a command. It can be used in {@link * AbstractContributionFactory#CreateContributionItems(IServiceLocator, * IContributionRoot)}. *

* It currently supports placement in menus and toolbars. *

*

* This class may be instantiated; it is not intended to be subclassed. *

*/ class BERRY_UI_QT CommandContributionItem : public QObject, public ContributionItem { Q_OBJECT public: /** * Mode bit: Show text on tool items or buttons, even if an image is * present. If this mode bit is not set, text is only shown on tool items if * there is no image present. */ static Modes modes; private: //LocalResourceManager localResourceManager; //Listener menuItemListener; QAction* action; IMenuService* menuService; ICommandService* commandService; IHandlerService* handlerService; //IBindingService bindingService; SmartPointer command; QIcon icon; QString label; QString tooltip; QChar mnemonic; SmartPointer elementRef; bool checkedState; Style style; QScopedPointer commandListener; QString dropDownMenuOverride; //IWorkbenchHelpSystem workbenchHelpSystem; QString helpContextId; Modes mode; /** * This is true when the menu contribution's visibleWhen * checkEnabled attribute is true. */ bool visibleEnabled; // items contributed QString contributedLabel; QIcon contributedIcon; SmartPointer serviceLocator; public: /** * Create a CommandContributionItem to place in a ContributionManager. * * @param contributionParameters * parameters necessary to render this contribution item. */ CommandContributionItem( const SmartPointer& contributionParameters); ~CommandContributionItem(); using ContributionItem::Fill; QAction* Fill(QMenu* parent, QAction* before); QAction* Fill(QToolBar* parent, QAction* before); void Update(); void Update(const QString& id); bool IsEnabled() const; bool IsVisible() const; - void UpdateCommandPropertiesInUI(const SmartPointer< - const CommandEvent>& commandEvent); + void UpdateCommandPropertiesInUI(const SmartPointer& commandEvent); private: void SetImages(IServiceLocator* locator, const QString &iconStyle); ICommandListener *GetCommandListener(); void UpdateMenuItem(); void UpdateToolItem(); void UpdateCommandProperties(const SmartPointer commandEvent); bool ShouldRestoreAppearance(const SmartPointer& handler); SmartPointer GetCommand() const; void CreateCommand(const QString& commandId, const QHash& parameters); QString GetToolTipText(const QString& text) const; QString UpdateMnemonic(const QString& s); // void disposeOldImages() { // if (localResourceManager != null) { // localResourceManager.dispose(); // localResourceManager = null; // } // } //SmartPointer GetItemListener(); void connectNotify(const char *signal); void disconnectNotify(const char *signal); /** * Determines if the selection was on the dropdown affordance and, if so, * opens the drop down menu (populated using the same id as this item... * * @param event * The SWT.Selection event to be tested * * @return true iff a drop down menu was opened */ //TODO Tool item drop down menu contributions //bool OpenDropDownMenu(SmartPointer event); void SetIcon(const QIcon& icon); void UpdateIcons(); void SetText(const QString& text); void SetChecked(bool checked); void SetToolTip(const QString& text); private slots: void HandleWidgetSelection(); }; } #endif /* BERRYCOMMANDCONTRIBUTIONITEM_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.h index 005293585f..cf063650ee 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.h +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.h @@ -1,47 +1,47 @@ /*=================================================================== BlueBerry Platform Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef BERRYQTWORKBENCHTWEAKLET_H_ #define BERRYQTWORKBENCHTWEAKLET_H_ #include #include namespace berry { class BERRY_UI_QT QtWorkbenchTweaklet : public QObject, public WorkbenchTweaklet { Q_OBJECT Q_INTERFACES(berry::WorkbenchTweaklet) public: - berryObjectMacro(QtWorkbenchTweaklet); + berryObjectMacro(QtWorkbenchTweaklet) QtWorkbenchTweaklet(); Display* CreateDisplay(); bool IsRunning(); IDialog::Pointer CreateStandardDialog(const QString& id); }; } // namespace berry #endif /*BERRYQTWORKBENCHTWEAKLET_H_*/