Medical Imaging Interaction Toolkit  2018.4.99-a3d2e8fb
Medical Imaging Interaction Toolkit
QmitkOpenStdMultiWidgetEditorAction.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 "mitkCoreObjectFactory.h"
16 
17 #include <berryIEditorPart.h>
18 #include <berryIWorkbenchPage.h>
20 #include <berryIWorkbench.h>
21 #include <berryPlatform.h>
23 
24 #include "internal/QmitkCommonExtPlugin.h"
26 
27 class ctkPluginContext;
28 
30  : QAction(nullptr)
31 {
32  this->init(window);
33 }
34 
36  : QAction(nullptr)
37 {
38  this->setIcon(icon);
39 
40  this->init(window);
41 }
42 
43 void QmitkOpenStdMultiWidgetEditorAction::init(berry::IWorkbenchWindow::Pointer window)
44 {
45  m_Window = window;
46  this->setParent(static_cast<QWidget*>(m_Window->GetShell()->GetControl()));
47  this->setText("Standard Display");
48  this->setToolTip("Open the standard multi widget editor");
49 
51 
52  m_GeneralPreferencesNode = prefService->GetSystemPreferences()->Node("/General");
53 
54  this->connect(this, SIGNAL(triggered(bool)), this, SLOT(Run()));
55 }
56 
58 {
59  // check if there is an open perspective, if not open the default perspective
60  if (m_Window->GetActivePage().IsNull())
61  {
62  QString defaultPerspId = m_Window->GetWorkbench()->GetPerspectiveRegistry()->GetDefaultPerspective();
63  m_Window->GetWorkbench()->ShowPerspective(defaultPerspId, m_Window);
64  }
65 
66  ctkPluginContext* context = QmitkCommonExtPlugin::getContext();
67  ctkServiceReference serviceRef = context->getServiceReference<mitk::IDataStorageService>();
68  if (serviceRef)
69  {
70  mitk::IDataStorageService* dsService = context->getService<mitk::IDataStorageService>(serviceRef);
71  if (dsService)
72  {
75  m_Window->GetActivePage()->OpenEditor(editorInput, "org.mitk.editors.stdmultiwidget", true, berry::IWorkbenchPage::MATCH_ID);
76  }
77  }
78 }
virtual IDataStorageReference::Pointer GetDataStorage() const =0
virtual SmartPointer< IPreferences > GetSystemPreferences()=0
An editor input based on a mitk::DataStorage.
QmitkOpenStdMultiWidgetEditorAction(berry::IWorkbenchWindow::Pointer window)
static IPreferencesService * GetPreferencesService()