diff --git a/Examples/BlueBerryExampleLauncher/Configurations/ExtensionPointDefinition.cmake b/Examples/BlueBerryExampleLauncher/Configurations/ExtensionPointDefinition.cmake index 206ecee457..261b518836 100644 --- a/Examples/BlueBerryExampleLauncher/Configurations/ExtensionPointDefinition.cmake +++ b/Examples/BlueBerryExampleLauncher/Configurations/ExtensionPointDefinition.cmake @@ -1,3 +1,4 @@ set(REQUIRED_PLUGINS org.mitk.example.gui.extensionpointdefinition + org.mitk.example.gui.extensionpointcontribution ) diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/files.cmake b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/files.cmake index 05c8589816..9666ea1277 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/files.cmake +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/files.cmake @@ -1,24 +1,28 @@ set(SRC_CPP_FILES ) set(INTERNAL_CPP_FILES - ExtensionPointContribution.cpp + ChangeTextToLowerCase.cpp + ChangeTextToUpperCase.cpp + org_mitk_example_gui_extensionpointcontribution_Activator.cpp ) set(MOC_H_FILES - + src/internal/ChangeTextToLowerCase.h + src/internal/ChangeTextToUpperCase.h + src/internal/org_mitk_example_gui_extensionpointcontribution_Activator.h ) set(CACHED_RESOURCE_FILES plugin.xml ) set(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/plugin.xml b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/plugin.xml index 5b988b8726..5fd21ff941 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/plugin.xml +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/plugin.xml @@ -1,9 +1,21 @@ + - - Example extension for the Plugin org.mitk.example.extensionpointdefinition - + + + Change the input string to lower case. + + + + Change the input string to upper case. + + + diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ChangeTextToLowerCase.cpp similarity index 59% copy from Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h copy to Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ChangeTextToLowerCase.cpp index 59e3e9d06c..e820ecaf42 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ChangeTextToLowerCase.cpp @@ -1,35 +1,22 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) 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 EXTENSIONPOINTCONTRIBUTION_H_ -#define EXTENSIONPOINTCONTRIBUTION_H_ +#include "ChangeTextToLowerCase.h" -// Qt includes -#include "IChangeText.h" - -class ExtensionPointContribution : public IChangeText +QString ChangeTextToLowerCase::ChangeText(const QString &s) { - -public: - - ExtensionPointContribution(); - ~ExtensionPointContribution(); - - void ChangeExtensionLabelText(const QString& s); - -}; - -#endif /*EXTENSIONPOINTCONTRIBUTION_H_*/ + return s.toLower(); +} diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ChangeTextToLowerCase.h similarity index 61% copy from Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h copy to Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ChangeTextToLowerCase.h index 59e3e9d06c..f3f5383da3 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ChangeTextToLowerCase.h @@ -1,35 +1,32 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) 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 EXTENSIONPOINTCONTRIBUTION_H_ -#define EXTENSIONPOINTCONTRIBUTION_H_ +#ifndef CHANGETEXTTOLOWERCASE_H +#define CHANGETEXTTOLOWERCASE_H -// Qt includes -#include "IChangeText.h" +#include -class ExtensionPointContribution : public IChangeText +class ChangeTextToLowerCase : public QObject, public IChangeText { + Q_OBJECT + Q_INTERFACES(IChangeText) public: - ExtensionPointContribution(); - ~ExtensionPointContribution(); - - void ChangeExtensionLabelText(const QString& s); - + QString ChangeText(const QString& s); }; -#endif /*EXTENSIONPOINTCONTRIBUTION_H_*/ +#endif // CHANGETEXTTOLOWERCASE_H diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ChangeTextToUpperCase.cpp similarity index 59% copy from Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h copy to Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ChangeTextToUpperCase.cpp index 59e3e9d06c..0cba17d23c 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ChangeTextToUpperCase.cpp @@ -1,35 +1,22 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) 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 EXTENSIONPOINTCONTRIBUTION_H_ -#define EXTENSIONPOINTCONTRIBUTION_H_ +#include "ChangeTextToUpperCase.h" -// Qt includes -#include "IChangeText.h" - -class ExtensionPointContribution : public IChangeText +QString ChangeTextToUpperCase::ChangeText(const QString &s) { - -public: - - ExtensionPointContribution(); - ~ExtensionPointContribution(); - - void ChangeExtensionLabelText(const QString& s); - -}; - -#endif /*EXTENSIONPOINTCONTRIBUTION_H_*/ + return s.toUpper(); +} diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.cpp b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ChangeTextToUpperCase.h similarity index 59% rename from Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.cpp rename to Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ChangeTextToUpperCase.h index a87a7cb6bb..b00ee1c25c 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.cpp +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ChangeTextToUpperCase.h @@ -1,34 +1,32 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) 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. ===================================================================*/ -#include "ExtensionPointContribution.h" +#ifndef CHANGETEXTTOUPPERCASE_H +#define CHANGETEXTTOUPPERCASE_H -// Qt includes -#include +#include -ExtensionPointContribution::ExtensionPointContribution() +class ChangeTextToUpperCase : public QObject, public IChangeText { -} + Q_OBJECT + Q_INTERFACES(IChangeText) -ExtensionPointContribution::~ExtensionPointContribution() -{ -} +public: -void ExtensionPointContribution::ChangeExtensionLabelText(const QString& /*s*/) -{ - QMessageBox::critical(0, "Error", "Provided by extension!"); -} + QString ChangeText(const QString &s); +}; +#endif // CHANGETEXTTOUPPERCASE_H diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/org_mitk_example_gui_extensionpointcontribution_Activator.cpp b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/org_mitk_example_gui_extensionpointcontribution_Activator.cpp new file mode 100644 index 0000000000..e44ad74007 --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/org_mitk_example_gui_extensionpointcontribution_Activator.cpp @@ -0,0 +1,35 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +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. + +===================================================================*/ + +#include "org_mitk_example_gui_extensionpointcontribution_Activator.h" + +#include "ChangeTextToLowerCase.h" +#include "ChangeTextToUpperCase.h" + +#include + +void org_mitk_example_gui_extensionpointcontribution_Activator::start(ctkPluginContext* context) +{ + BERRY_REGISTER_EXTENSION_CLASS(ChangeTextToLowerCase, context) + BERRY_REGISTER_EXTENSION_CLASS(ChangeTextToUpperCase, context) +} + +void org_mitk_example_gui_extensionpointcontribution_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) +} + +Q_EXPORT_PLUGIN2(org_mitk_example_gui_extensionpointcontribution, org_mitk_example_gui_extensionpointcontribution_Activator) diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/org_mitk_example_gui_extensionpointcontribution_Activator.h similarity index 52% rename from Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h rename to Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/org_mitk_example_gui_extensionpointcontribution_Activator.h index 59e3e9d06c..6cd46f0ada 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/org_mitk_example_gui_extensionpointcontribution_Activator.h @@ -1,35 +1,36 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) 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 EXTENSIONPOINTCONTRIBUTION_H_ -#define EXTENSIONPOINTCONTRIBUTION_H_ -// Qt includes -#include "IChangeText.h" +#ifndef org_mitk_example_gui_extensionpointcontribution_Activator_H +#define org_mitk_example_gui_extensionpointcontribution_Activator_H -class ExtensionPointContribution : public IChangeText +#include + +class org_mitk_example_gui_extensionpointcontribution_Activator : + public QObject, public ctkPluginActivator { + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) public: - ExtensionPointContribution(); - ~ExtensionPointContribution(); - - void ChangeExtensionLabelText(const QString& s); + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); }; -#endif /*EXTENSIONPOINTCONTRIBUTION_H_*/ +#endif // org_mitk_example_gui_extensionpointcontribution_Activator_H diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/plugin.xml b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/plugin.xml index 23df664827..be8c8f14b1 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/plugin.xml +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/plugin.xml @@ -1,28 +1,28 @@ diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/schema/changetext.exsd b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/schema/changetext.exsd index 7f009464ab..841f36bff1 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/schema/changetext.exsd +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/schema/changetext.exsd @@ -1,122 +1,109 @@ This extension point is used as an example for the extension point declaration (BlueBerry examples). - - - - - - + a fully qualified identifier of the target extension point an optional identifier of the extension instance an optional name of the extension instance - - - - - - + - the identifier of the input device + the identifier of the text changer - + - an optional name of the input device + the name of the text changer a fully qualified name of the class that implements <samp>IChangeText</samp>. - - - An optional subelement whose body should contain text providing a short description. The value of the <samp>class</samp> attribute must be a fully qualified name of the class that implements <samp>IChangeText</samp>. Copyright (c) 2012 Medical and Biological Informatics, DKFZ<br> All rights reserved. diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/IChangeText.h b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/IChangeText.h index 590ba92da8..d1e6bc8661 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/IChangeText.h +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/IChangeText.h @@ -1,37 +1,37 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) 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 ICHANGETEXT_H_ #define ICHANGETEXT_H_ #include #include "org_mitk_example_gui_extensionpointdefinition_Export.h" struct org_mitk_example_gui_extensionpointdefinition_EXPORT IChangeText : public virtual berry::Object { berryInterfaceMacro(IChangeText, ::) virtual ~IChangeText(); - virtual void ChangeExtensionLabelText(const QString& s) = 0; + virtual QString ChangeText(const QString& s) = 0; }; Q_DECLARE_INTERFACE(IChangeText, "org.mitk.example.IChangeText") #endif /*ICHANGETEXT_H_*/ diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextDescriptor.cpp b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextDescriptor.cpp index a69dc27a15..71435827fe 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextDescriptor.cpp +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextDescriptor.cpp @@ -1,75 +1,86 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) 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. ===================================================================*/ #include "ChangeTextDescriptor.h" #include "ExtensionPointDefinitionConstants.h" +#include "berryPlatformException.h" ChangeTextDescriptor::ChangeTextDescriptor(berry::IConfigurationElement::Pointer changeTextExtensionPoint) : m_ChangeTextExtensionPoint(changeTextExtensionPoint) { + std::string id; + std::string name; + + // Check if the "id" and "name" attributes are available + if (!this->m_ChangeTextExtensionPoint->GetAttribute(ExtensionPointDefinitionConstants::CHANGETEXT_XMLATTRIBUTE_ID, id) || + !this->m_ChangeTextExtensionPoint->GetAttribute(ExtensionPointDefinitionConstants::CHANGETEXT_XMLATTRIBUTE_NAME, name)) + { + throw berry::CoreException("Invalid changetext configuration element (missing id or name) from: " + + m_ChangeTextExtensionPoint->GetContributor()); + } + + this->m_Id = QString::fromStdString(id); + this->m_Name = QString::fromStdString(name); + + // Get the optional "description" child element + std::vector descriptions( + this->m_ChangeTextExtensionPoint->GetChildren(ExtensionPointDefinitionConstants::CHANGETEXT_CHILD_DESCRIPTION)); + + if(!descriptions.empty()) + { + this->m_Description = QString::fromStdString(descriptions[0]->GetValue()); + } } ChangeTextDescriptor::~ChangeTextDescriptor() { } IChangeText::Pointer ChangeTextDescriptor::CreateChangeText() { if(this->m_ChangeText == 0) { // "class" refers to xml attribute in a xml tag this->m_ChangeText = this->m_ChangeTextExtensionPoint ->CreateExecutableExtension(ExtensionPointDefinitionConstants::CHANGETEXT_XMLATTRIBUTE_CLASS); } return this->m_ChangeText; } QString ChangeTextDescriptor::GetID() const { - std::string idOfExtensionPoint; - this->m_ChangeTextExtensionPoint->GetAttribute(ExtensionPointDefinitionConstants::CHANGETEXT_XMLATTRIBUTE_ID,idOfExtensionPoint); - return QString::fromStdString(idOfExtensionPoint); + return this->m_Id; } QString ChangeTextDescriptor::GetDescription() const { - std::vector - descriptions(this->m_ChangeTextExtensionPoint->GetChildren(ExtensionPointDefinitionConstants::CHANGETEXT_XMLATTRIBUTE_DESCRIPTION)); - - if(!descriptions.empty()) - { - return QString::fromStdString(descriptions[0]->GetValue()); - } - return QString(); + return this->m_Description; } QString ChangeTextDescriptor::GetName() const { - std::string name; - this->m_ChangeTextExtensionPoint->GetAttribute(ExtensionPointDefinitionConstants::CHANGETEXT_XMLATTRIBUTE_NAME,name); - return QString::fromStdString(name); + return this->m_Name; } bool ChangeTextDescriptor::operator==(const Object* object) const { if (const ChangeTextDescriptor* other = dynamic_cast(object)) { return this->GetID() == other->GetID(); } return false; } - diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextDescriptor.h b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextDescriptor.h index 3e5b8097d9..eaaface1ab 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextDescriptor.h +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextDescriptor.h @@ -1,90 +1,94 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) 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 CHANGETEXTDESCRIPTOR_H_ #define CHANGETEXTDESCRIPTOR_H_ #include #include #include "IChangeText.h" class ChangeTextDescriptor : public berry::Object { public: berryObjectMacro(ChangeTextDescriptor) /** * Initialize the "ChangeText" Descriptor with the given extension point. * * @param changeTextExtensionPoint * element, that refers to a extension point (type, id, name, class) */ ChangeTextDescriptor(berry::IConfigurationElement::Pointer changeTextExtensionPoint); /** * Default destructor */ ~ChangeTextDescriptor(); /** * Creates an instance of "ChangeText" defined in the descriptor. * * @return change text */ IChangeText::Pointer CreateChangeText(); /** * Returns the description of this "ChangeText". * * @return the description */ QString GetDescription() const; /** * Returns the id of this "ChangeText". * * @return the id */ QString GetID() const; /** * Returns the name of this "ChangeText". * * @return the name */ QString GetName() const; /** * Equals this class with the given parameter. * * @param object * the object for the equation * @return true, if the objects are equal :: false, if they differ in any way */ bool operator==(const Object* object) const; private: // IConfigurationElements are used to access xml files (here: plugin.xml) berry::IConfigurationElement::Pointer m_ChangeTextExtensionPoint; IChangeText::Pointer m_ChangeText; + QString m_Id; + QString m_Name; + QString m_Description; + }; #endif /*CHANGETEXTDESCRIPTOR_H_*/ diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextRegistry.cpp b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextRegistry.cpp index d4545577f5..d2bfe8835d 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextRegistry.cpp +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextRegistry.cpp @@ -1,58 +1,58 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) 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. ===================================================================*/ #include #include #include #include "ChangeTextRegistry.h" #include "ExtensionPointDefinitionConstants.h" ChangeTextRegistry::ChangeTextRegistry() { //initialize the registry by copying all available extension points into a local variable berry::IExtensionPointService::Pointer extensionPointService = berry::Platform::GetExtensionPointService(); std::vector allExtensionsChangeTexts - = extensionPointService->GetConfigurationElementsFor(ExtensionPointDefinitionConstants::CHANGETEXT_EXTENSION_NAME); + = extensionPointService->GetConfigurationElementsFor(ExtensionPointDefinitionConstants::CHANGETEXT_XP_NAME); for(std::vector::const_iterator it = allExtensionsChangeTexts.begin(); it != allExtensionsChangeTexts.end();++it) { ChangeTextDescriptor::Pointer temp(new ChangeTextDescriptor(*it)); if(!this->m_ListRegisteredTexts.contains(temp->GetID())) { m_ListRegisteredTexts.insert(temp->GetID(),temp); } else { - throw ctkRuntimeException("The ChangeText ID: "+temp->GetID()+" is already registered."); + BERRY_WARN << "The ChangeText ID: " << qPrintable(temp->GetID()) << " is already registered."; } } } ChangeTextRegistry::~ChangeTextRegistry() { } ChangeTextDescriptor::Pointer ChangeTextRegistry::Find(const QString &id) const { return this->m_ListRegisteredTexts.value(id); } QList ChangeTextRegistry::GetChangeTexts() const { return m_ListRegisteredTexts.values(); } diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ExtensionPointDefinitionConstants.cpp b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ExtensionPointDefinitionConstants.cpp index b03b32fdfb..2800bb9896 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ExtensionPointDefinitionConstants.cpp +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ExtensionPointDefinitionConstants.cpp @@ -1,25 +1,25 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) 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. ===================================================================*/ #include "ExtensionPointDefinitionConstants.h" #include "ChangeTextRegistry.h" -const std::string ExtensionPointDefinitionConstants::CHANGETEXT_EXTENSION_NAME = "org.mitk.example.gui.extensionpointdefinition"; +const std::string ExtensionPointDefinitionConstants::CHANGETEXT_XP_NAME = "org.mitk.example.extensionpointdefinition.changetext"; +const std::string ExtensionPointDefinitionConstants::CHANGETEXT_CHILD_DESCRIPTION = "description"; const std::string ExtensionPointDefinitionConstants::CHANGETEXT_XMLATTRIBUTE_CLASS = "class"; -const std::string ExtensionPointDefinitionConstants::CHANGETEXT_XMLATTRIBUTE_DESCRIPTION = "description"; const std::string ExtensionPointDefinitionConstants::CHANGETEXT_XMLATTRIBUTE_NAME = "name"; const std::string ExtensionPointDefinitionConstants::CHANGETEXT_XMLATTRIBUTE_ID = "id"; diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ExtensionPointDefinitionConstants.h b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ExtensionPointDefinitionConstants.h index 8b5e21fe17..29ec307f27 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ExtensionPointDefinitionConstants.h +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ExtensionPointDefinitionConstants.h @@ -1,42 +1,42 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) 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 EXTENSIONPOINTDEFINITIONCONSTANTS_H_ #define EXTENSIONPOINTDEFINITIONCONSTANTS_H_ #include /** * The ExtensionPointDefinitionConstants contains a list of unique ids in the * following form:
* "org.mitk.mybundle.mytype.propername"
* * This ids have the purpose of connecting the plugin.xml of each bundle to the * appropriate classes. * * Additionally it includes names of tags, which are used in XML files
* regarding the BlueBerry example. */ struct ExtensionPointDefinitionConstants { - static const std::string CHANGETEXT_EXTENSION_NAME; + static const std::string CHANGETEXT_XP_NAME; + static const std::string CHANGETEXT_CHILD_DESCRIPTION; static const std::string CHANGETEXT_XMLATTRIBUTE_CLASS; - static const std::string CHANGETEXT_XMLATTRIBUTE_DESCRIPTION; static const std::string CHANGETEXT_XMLATTRIBUTE_NAME; static const std::string CHANGETEXT_XMLATTRIBUTE_ID; }; #endif /*EXTENSIONPOINTDEFINITIONCONSTANTS_H_*/ diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/MinimalView.cpp b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/MinimalView.cpp index 27afbb0476..349891d04d 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/MinimalView.cpp +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/MinimalView.cpp @@ -1,50 +1,65 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) 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. ===================================================================*/ #include "MinimalView.h" #include "org_mitk_example_gui_extensionpointdefinition_Activator.h" -#include +#include const std::string MinimalView::VIEW_ID = "org.mitk.views.minimalview"; MinimalView::MinimalView() : m_Parent(0) { } -MinimalView::~MinimalView() -{ -} - void MinimalView::CreateQtPartControl(QWidget *parent) { // create GUI widgets m_Parent = parent; m_Controls.setupUi(parent); - m_Parent->setEnabled(true); - + QVBoxLayout* layout = new QVBoxLayout(m_Controls.m_ButtonContainer); + QList changeTexts = m_Registry.GetChangeTexts(); + foreach(const ChangeTextDescriptor::Pointer& changeText, changeTexts) + { + // Create a push button for each "changetext" descriptor + QPushButton* button = new QPushButton(changeText->GetName(), m_Controls.m_ButtonContainer); + button->setToolTip(changeText->GetDescription()); + button->setObjectName(changeText->GetID()); + layout->addWidget(button); + + connect(button, SIGNAL(clicked()), &m_SignalMapper, SLOT(map())); + m_SignalMapper.setMapping(button, changeText->GetID()); + } + layout->addStretch(); + + connect(&m_SignalMapper, SIGNAL(mapped(QString)), this, SLOT(ChangeText(QString))); } void MinimalView::SetFocus () { + m_Controls.m_InputText->setFocus(); } -void MinimalView::ChangeExtensionLabelText(const QString& s) +void MinimalView::ChangeText(const QString& id) { - m_Controls.extensionLabel->setText(s); + ChangeTextDescriptor::Pointer changeTextDescr = m_Registry.Find(id); + + // lazily create an instance of IChangeText (the descriptor will cache it) + IChangeText::Pointer changeText = changeTextDescr->CreateChangeText(); + m_Controls.m_OutputText->setText(changeText->ChangeText(m_Controls.m_InputText->text())); } diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/MinimalView.h b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/MinimalView.h index 75f846e8b2..b7f4c16e10 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/MinimalView.h +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/MinimalView.h @@ -1,58 +1,60 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) 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 MINIMALVIEW_H_ #define MINIMALVIEW_H_ -// Berry #include -#include +#include "ChangeTextRegistry.h" #include "ui_MinimalViewControls.h" +#include + class MinimalView : public berry::QtViewPart { - Q_OBJECT public: static const std::string VIEW_ID; MinimalView(); - virtual ~MinimalView(); +protected: - virtual void CreateQtPartControl(QWidget *parent); + void CreateQtPartControl(QWidget *parent); - virtual void ChangeExtensionLabelText(const QString& s); + void SetFocus(); -protected: +private Q_SLOTS: - void SetFocus(); + void ChangeText(const QString& id); private: Ui::MinimalViewControls m_Controls; QWidget* m_Parent; + QSignalMapper m_SignalMapper; + ChangeTextRegistry m_Registry; }; #endif /*MINIMALVIEW_H_*/ diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/MinimalViewControls.ui b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/MinimalViewControls.ui index f8c2246639..5a534d026f 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/MinimalViewControls.ui +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/MinimalViewControls.ui @@ -1,87 +1,91 @@ MinimalViewControls true 0 0 - 238 - 386 + 453 + 361 0 0 QmitkTemplate - + - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 60 - 20 - - - - Label provided by extension point: - - - - - - - - 60 - 20 - - - - Nothing was changed by an extension! - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - + + + Extensions + + + false + + + + + + + Qt::Vertical + + + + + + + + + + Input text + + + + + + + + + + Changed text + + + + + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + +