Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryExtensionFactory.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 BlueBerry Platform
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "berryExtensionFactory.h"
18 
20 
21 #include "berryCoreException.h"
22 #include "berryObjectString.h"
23 #include "berryPlatformUI.h"
24 #include "berryStatus.h"
25 
26 #include "internal/berryQtStylePreferencePage.h"
27 #include "internal/dialogs/berryPerspectivesPreferencePage.h"
28 
29 namespace berry {
30 
31 const QString ExtensionFactory::STYLE_PREFERENCE_PAGE = "stylePreferencePage";
32 const QString ExtensionFactory::PERSPECTIVES_PREFERENCE_PAGE = "perspectivesPreferencePage";
33 
35 {
36 }
37 
39 {
40  if (STYLE_PREFERENCE_PAGE == id)
41  {
42  return Configure(new QtStylePreferencePage());
43  }
45  {
46  return Configure(new PerspectivesPreferencePage());
47  }
48 // if (SHOW_IN_CONTRIBUTION == id)
49 // {
50 // ShowInMenu showInMenu = new ShowInMenu();
51 // return showInMenu;
52 // }
53 
55  QString("Unknown id in data argument for ") + this->metaObject()->className(),
57  throw CoreException(status);
58 }
59 
60 void ExtensionFactory::SetInitializationData(const SmartPointer<IConfigurationElement>& config, const QString& propertyName, const Object::Pointer& data)
61 {
62  if (ObjectString::Pointer strData = data.Cast<ObjectString>())
63  {
64  id = *strData;
65  }
66  else
67  {
69  QString("Data argument must be a String for ") + this->metaObject()->className(),
71  throw CoreException(status);
72  }
73  this->config = config;
74  this->propertyName = propertyName;
75 }
76 
77 QObject*ExtensionFactory::Configure(QObject* obj)
78 {
79  if (IExecutableExtension* execExt = qobject_cast<IExecutableExtension*>(obj))
80  {
81  execExt->SetInitializationData(config, propertyName, Object::Pointer());
82  }
83  return obj;
84 }
85 
86 }
static const QString STYLE_PREFERENCE_PAGE
#define BERRY_STATUS_LOC
Definition: berryStatus.h:257
static const QString PERSPECTIVES_PREFERENCE_PAGE
static QString PLUGIN_ID()
void SetInitializationData(const SmartPointer< IConfigurationElement > &config, const QString &propertyName, const Object::Pointer &data) override
SmartPointer< Other > Cast() const