Medical Imaging Interaction Toolkit  2016.11.0
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,
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 
18 
19 #include <berryPlatform.h>
20 #include <berryIAdapterManager.h>
21 #include <berryIMemento.h>
22 
24 
25 #include "internal/org_mitk_gui_common_Activator.h"
26 #include "internal/mitkDataStorageEditorInputFactory.h"
27 
28 #include <QIcon>
29 
30 namespace mitk
31 {
32 
34 {
35 }
36 
38 {
39  m_DataStorageRef = ref;
40 }
41 
43 {
44  return true;
45 }
46 
48 {
49  return "DataStorage Scene";
50 }
51 
53 {
54  return "";
55 }
56 
58 {
59  return QIcon();
60 }
61 
63 {
64  //return this;
65  return nullptr;
66 }
67 
68 berry::Object* DataStorageEditorInput::GetAdapter(const QString& adapterType) const
69 {
71  if (adapterManager)
72  {
73  return adapterManager->GetAdapter(this, adapterType);
74  }
75  return nullptr;
76 }
77 
78 //QString DataStorageEditorInput::GetFactoryId() const
79 //{
80 // return DataStorageEditorInputFactory::GetFactoryId();
81 //}
82 
83 //void DataStorageEditorInput::SaveState(const berry::IMemento::Pointer& memento) const
84 //{
85 // return DataStorageEditorInputFactory::SaveState(memento, this);
86 //}
87 
89 {
90  if (const DataStorageEditorInput* input = dynamic_cast<const DataStorageEditorInput*>(o))
91  return this->m_DataStorageRef == input->m_DataStorageRef;
92 
93  return false;
94 }
95 
98 {
99  if (m_DataStorageRef.IsNull())
100  {
101  ctkPluginContext* context = PluginActivator::GetContext();
102  ctkServiceReference serviceRef = context->getServiceReference<IDataStorageService>();
103  if (!serviceRef) return IDataStorageReference::Pointer(nullptr);
104  IDataStorageService* dataService = context->getService<IDataStorageService>(serviceRef);
105  if (!dataService) return IDataStorageReference::Pointer(nullptr);
106  m_DataStorageRef = dataService->GetDefaultDataStorage();
107  }
108 
109  return m_DataStorageRef;
110 }
111 
112 }
DataStorageEditorInput(IDataStorageReference::Pointer ref)
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:78
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:88
static IAdapterManager * GetAdapterManager()
bool operator==(const berry::Object *) const override