Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
berryExtensionFactory.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "berryExtensionFactory.h"
14 
16 
17 #include "berryCoreException.h"
18 #include "berryObjectString.h"
19 #include "berryPlatformUI.h"
20 #include "berryStatus.h"
21 
22 #include "internal/berryQtStylePreferencePage.h"
23 #include "internal/dialogs/berryPerspectivesPreferencePage.h"
24 
25 namespace berry {
26 
27 const QString ExtensionFactory::STYLE_PREFERENCE_PAGE = "stylePreferencePage";
28 const QString ExtensionFactory::PERSPECTIVES_PREFERENCE_PAGE = "perspectivesPreferencePage";
29 
31 {
32 }
33 
35 {
36  if (STYLE_PREFERENCE_PAGE == id)
37  {
38  return Configure(new QtStylePreferencePage());
39  }
41  {
42  return Configure(new PerspectivesPreferencePage());
43  }
44 // if (SHOW_IN_CONTRIBUTION == id)
45 // {
46 // ShowInMenu showInMenu = new ShowInMenu();
47 // return showInMenu;
48 // }
49 
51  QString("Unknown id in data argument for ") + this->metaObject()->className(),
53  throw CoreException(status);
54 }
55 
56 void ExtensionFactory::SetInitializationData(const SmartPointer<IConfigurationElement>& config, const QString& propertyName, const Object::Pointer& data)
57 {
58  if (ObjectString::Pointer strData = data.Cast<ObjectString>())
59  {
60  id = *strData;
61  }
62  else
63  {
65  QString("Data argument must be a String for ") + this->metaObject()->className(),
67  throw CoreException(status);
68  }
69  this->config = config;
70  this->propertyName = propertyName;
71 }
72 
73 QObject*ExtensionFactory::Configure(QObject* obj)
74 {
75  if (IExecutableExtension* execExt = qobject_cast<IExecutableExtension*>(obj))
76  {
77  execExt->SetInitializationData(config, propertyName, Object::Pointer());
78  }
79  return obj;
80 }
81 
82 }
SmartPointer< Other > Cast() const
static const QString STYLE_PREFERENCE_PAGE
#define BERRY_STATUS_LOC
Definition: berryStatus.h:253
static const QString PERSPECTIVES_PREFERENCE_PAGE
static QString PLUGIN_ID()
void SetInitializationData(const SmartPointer< IConfigurationElement > &config, const QString &propertyName, const Object::Pointer &data) override