diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.cpp b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.cpp index 8f15cb5670..a87a7cb6bb 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.cpp +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.cpp @@ -1,34 +1,34 @@ /*=================================================================== 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" // Qt includes #include ExtensionPointContribution::ExtensionPointContribution() { } ExtensionPointContribution::~ExtensionPointContribution() { } -void ExtensionPointContribution::ChangeExtensionLabelText(QString /*s*/) +void ExtensionPointContribution::ChangeExtensionLabelText(const QString& /*s*/) { QMessageBox::critical(0, "Error", "Provided by extension!"); } diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h index 3fac0f30ac..59e3e9d06c 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h @@ -1,35 +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. ===================================================================*/ #ifndef EXTENSIONPOINTCONTRIBUTION_H_ #define EXTENSIONPOINTCONTRIBUTION_H_ // Qt includes #include "IChangeText.h" class ExtensionPointContribution : public IChangeText { public: ExtensionPointContribution(); ~ExtensionPointContribution(); - void ChangeExtensionLabelText(QString s); + void ChangeExtensionLabelText(const QString& s); }; #endif /*EXTENSIONPOINTCONTRIBUTION_H_*/ diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/files.cmake b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/files.cmake index c8f149dc23..a06e310306 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/files.cmake +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/files.cmake @@ -1,37 +1,38 @@ set(SRC_CPP_FILES + IChangeText.cpp ) set(INTERNAL_CPP_FILES org_mitk_example_gui_extensionpointdefinition_Activator.cpp ExtensionPointDefinition.cpp MinimalPerspective.cpp MinimalView.cpp ChangeTextDescriptor.cpp ChangeTextRegistry.cpp ExtensionPointDefinitionConstants.cpp ) set(UI_FILES src/internal/MinimalViewControls.ui ) set(MOC_H_FILES src/internal/org_mitk_example_gui_extensionpointdefinition_Activator.h src/internal/ExtensionPointDefinition.h src/internal/MinimalPerspective.h src/internal/MinimalView.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/src/internal/ExtensionPointContribution.h b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/IChangeText.cpp similarity index 62% copy from Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h copy to Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/IChangeText.cpp index 3fac0f30ac..209e550522 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointcontribution/src/internal/ExtensionPointContribution.h +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/IChangeText.cpp @@ -1,35 +1,21 @@ /*=================================================================== 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" -class ExtensionPointContribution : public IChangeText +IChangeText::~IChangeText() { - -public: - - ExtensionPointContribution(); - ~ExtensionPointContribution(); - - void ChangeExtensionLabelText(QString s); - -}; - -#endif /*EXTENSIONPOINTCONTRIBUTION_H_*/ +} 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 d13d2bf611..590ba92da8 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/IChangeText.h +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/IChangeText.h @@ -1,34 +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 +#include "org_mitk_example_gui_extensionpointdefinition_Export.h" - class IChangeText : public virtual berry::Object - { - public: - virtual void ChangeExtensionLabelText(QString s) = 0; +struct org_mitk_example_gui_extensionpointdefinition_EXPORT IChangeText + : public virtual berry::Object +{ + berryInterfaceMacro(IChangeText, ::) - virtual ~IChangeText() {} - }; + virtual ~IChangeText(); - Q_DECLARE_INTERFACE(IChangeText, "org.mitk.example.IChangeText") + virtual void ChangeExtensionLabelText(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 1f59f5ae05..a69dc27a15 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,75 @@ /*=================================================================== 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" ChangeTextDescriptor::ChangeTextDescriptor(berry::IConfigurationElement::Pointer changeTextExtensionPoint) : m_ChangeTextExtensionPoint(changeTextExtensionPoint) { } 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; } -std::string ChangeTextDescriptor::GetID() const +QString ChangeTextDescriptor::GetID() const { std::string idOfExtensionPoint; this->m_ChangeTextExtensionPoint->GetAttribute(ExtensionPointDefinitionConstants::CHANGETEXT_XMLATTRIBUTE_ID,idOfExtensionPoint); - return idOfExtensionPoint; + return QString::fromStdString(idOfExtensionPoint); } -std::string ChangeTextDescriptor::GetDescription() const +QString ChangeTextDescriptor::GetDescription() const { std::vector descriptions(this->m_ChangeTextExtensionPoint->GetChildren(ExtensionPointDefinitionConstants::CHANGETEXT_XMLATTRIBUTE_DESCRIPTION)); if(!descriptions.empty()) { - return descriptions[0]->GetValue(); + return QString::fromStdString(descriptions[0]->GetValue()); } - return ""; + return QString(); } -std::string ChangeTextDescriptor::GetName() const +QString ChangeTextDescriptor::GetName() const { std::string name; this->m_ChangeTextExtensionPoint->GetAttribute(ExtensionPointDefinitionConstants::CHANGETEXT_XMLATTRIBUTE_NAME,name); - return name; + return QString::fromStdString(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 87d1de536a..3e5b8097d9 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,92 +1,90 @@ /*=================================================================== 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 - #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 */ - std::string GetDescription() const; + QString GetDescription() const; /** * Returns the id of this "ChangeText". * * @return the id */ - std::string GetID() const; + QString GetID() const; /** * Returns the name of this "ChangeText". * * @return the name */ - std::string GetName() const; + 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; }; #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 6f29a0c8e6..d4545577f5 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,73 +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); for(std::vector::const_iterator it = allExtensionsChangeTexts.begin(); it != allExtensionsChangeTexts.end();++it) { - ChangeTextDescriptorPtr temp(new ChangeTextDescriptor(*it)); + ChangeTextDescriptor::Pointer temp(new ChangeTextDescriptor(*it)); - // The equation with the end means, that if there is no such element and - // the pointer will be at end (not the last element, actually after it) - if(this->m_ListRegisteredTexts.find(temp->GetID()) == this->m_ListRegisteredTexts.end()) + if(!this->m_ListRegisteredTexts.contains(temp->GetID())) { - m_ListRegisteredTexts.insert(std::make_pair(temp->GetID(),temp)); + m_ListRegisteredTexts.insert(temp->GetID(),temp); } else { - throw std::runtime_error("The ChangeText ID: "+temp->GetID()+" is already registered."); + throw ctkRuntimeException("The ChangeText ID: "+temp->GetID()+" is already registered."); } } } ChangeTextRegistry::~ChangeTextRegistry() { } -ChangeTextRegistry::ChangeTextDescriptorPtr ChangeTextRegistry::Find(const std::string &id) const +ChangeTextDescriptor::Pointer ChangeTextRegistry::Find(const QString &id) const { - Poco::HashMap::ConstIterator result = this->m_ListRegisteredTexts.find(id); - - // first = key, second = element or vice versa, if inserted different in the hash map - if(result != this->m_ListRegisteredTexts.end()) return result->second; - - return ChangeTextDescriptorPtr(0); + return this->m_ListRegisteredTexts.value(id); } -std::vector ChangeTextRegistry::GetChangeTexts() const +QList ChangeTextRegistry::GetChangeTexts() const { - std::vector temp; - for(Poco::HashMap::ConstIterator it = m_ListRegisteredTexts.begin(); - it != m_ListRegisteredTexts.end();++it) - { - // first = key, second = element or vice versa, if inserted different in the hash map - temp.push_back(it->second); - } - return temp; + return m_ListRegisteredTexts.values(); } - diff --git a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextRegistry.h b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextRegistry.h index c3d66113bc..714379967a 100644 --- a/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextRegistry.h +++ b/Examples/Plugins/org.mitk.example.gui.extensionpointdefinition/src/internal/ChangeTextRegistry.h @@ -1,62 +1,55 @@ /*=================================================================== 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 CHANGETEXTREGISTRY_H_ #define CHANGETEXTREGISTRY_H_ -#include -#include -#include - #include #include "ChangeTextDescriptor.h" class ChangeTextRegistry : public berry::Object { public: - // easier maintenance - typedef ChangeTextDescriptor::Pointer ChangeTextDescriptorPtr; - ChangeTextRegistry(); ~ChangeTextRegistry(); /** * Return an "change text" descriptor with the given extension id. If no "change text" exists, * with the id return null. * * @param id * the id to search for * @return the descriptor or null */ - ChangeTextDescriptorPtr Find(const std::string& id) const; + ChangeTextDescriptor::Pointer Find(const QString& id) const; /** * Return a list of "change texts" defined in the registry. * * @return the change texts. */ - std::vector GetChangeTexts() const; + QList GetChangeTexts() const; private: - Poco::HashMap m_ListRegisteredTexts; + QHash m_ListRegisteredTexts; }; #endif /*CHANGETEXTREGISTRY_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 ec2174aba4..27afbb0476 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,50 @@ /*=================================================================== 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 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); } void MinimalView::SetFocus () { } -void MinimalView::ChangeExtensionLabelText(QString s) +void MinimalView::ChangeExtensionLabelText(const QString& s) { m_Controls.extensionLabel->setText(s); } 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 8e156a544c..75f846e8b2 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,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. ===================================================================*/ #ifndef MINIMALVIEW_H_ #define MINIMALVIEW_H_ // Berry #include #include #include "ui_MinimalViewControls.h" class MinimalView : public berry::QtViewPart { Q_OBJECT public: static const std::string VIEW_ID; MinimalView(); virtual ~MinimalView(); virtual void CreateQtPartControl(QWidget *parent); - virtual void ChangeExtensionLabelText(QString s); + virtual void ChangeExtensionLabelText(const QString& s); protected: void SetFocus(); private: Ui::MinimalViewControls m_Controls; QWidget* m_Parent; }; #endif /*MINIMALVIEW_H_*/