Medical Imaging Interaction Toolkit  2018.4.99-936b789b
Medical Imaging Interaction Toolkit
mitkDataStorageEditorInput.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 
14 
15 #include <berryPlatform.h>
16 #include <berryIAdapterManager.h>
17 #include <berryIMemento.h>
18 
20 
21 #include "internal/org_mitk_gui_common_Activator.h"
22 #include "internal/mitkDataStorageEditorInputFactory.h"
23 
24 #include <QIcon>
25 
26 namespace mitk
27 {
28 
30 {
31 }
32 
34 {
35  m_DataStorageRef = ref;
36 }
37 
39 {
40  return true;
41 }
42 
44 {
45  return "DataStorage Scene";
46 }
47 
49 {
50  return "";
51 }
52 
54 {
55  return QIcon();
56 }
57 
59 {
60  //return this;
61  return nullptr;
62 }
63 
64 berry::Object* DataStorageEditorInput::GetAdapter(const QString& adapterType) const
65 {
67  if (adapterManager)
68  {
69  return adapterManager->GetAdapter(this, adapterType);
70  }
71  return nullptr;
72 }
73 
74 //QString DataStorageEditorInput::GetFactoryId() const
75 //{
76 // return DataStorageEditorInputFactory::GetFactoryId();
77 //}
78 
79 //void DataStorageEditorInput::SaveState(const berry::IMemento::Pointer& memento) const
80 //{
81 // return DataStorageEditorInputFactory::SaveState(memento, this);
82 //}
83 
85 {
86  if (const DataStorageEditorInput* input = dynamic_cast<const DataStorageEditorInput*>(o))
87  return this->m_DataStorageRef == input->m_DataStorageRef;
88 
89  return false;
90 }
91 
94 {
95  if (m_DataStorageRef.IsNull())
96  {
97  ctkPluginContext* context = PluginActivator::GetContext();
98  ctkServiceReference serviceRef = context->getServiceReference<IDataStorageService>();
99  if (!serviceRef) return IDataStorageReference::Pointer(nullptr);
100  IDataStorageService* dataService = context->getService<IDataStorageService>(serviceRef);
101  if (!dataService) return IDataStorageReference::Pointer(nullptr);
102  m_DataStorageRef = dataService->GetDefaultDataStorage();
103  }
104 
105  return m_DataStorageRef;
106 }
107 
108 }
virtual IDataStorageReference::Pointer GetDefaultDataStorage() const =0
IDataStorageReference::Pointer GetDataStorageReference()
const berry::IPersistableElement * GetPersistable() const override
Light weight base class for most BlueBerry classes.
Definition: berryObject.h:72
DataCollection - Class to facilitate loading/accessing structured data.
A * GetAdapter(const Object *adaptable)
An editor input based on a mitk::DataStorage.
berry::SmartPointer< Self > Pointer
Definition: berryObject.h:82
static IAdapterManager * GetAdapterManager()
bool operator==(const berry::Object *) const override