Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryContributionItemFactory.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 
19 
20 #include <berryIContributionItem.h>
21 #include <berryIWorkbenchWindow.h>
22 
23 #include "internal/berryChangeToPerspectiveMenu.h"
24 #include "internal/berryShowViewMenu.h"
25 #include "internal/berryReopenEditorMenu.h"
26 #include "internal/berrySwitchToWindowMenu.h"
27 
28 namespace berry {
29 
30 ContributionItemFactory::ContributionItemFactory(const QString& contributionItemId)
31  : contributionItemId(contributionItemId)
32 {}
33 
35 {
36  return contributionItemId;
37 }
38 
39 class OpenWindowsFactory : public ContributionItemFactory
40 {
41 public:
42 
43  OpenWindowsFactory()
44  : ContributionItemFactory("openWindows")
45  {}
46 
47  IContributionItem::Pointer Create(IWorkbenchWindow *window) override
48  {
49  if (window == nullptr)
50  {
51  throw ctkInvalidArgumentException("window must not be null");
52  }
53  IContributionItem::Pointer item(new SwitchToWindowMenu(window, GetId(), true));
54  return item;
55  }
56 };
57 
58 const QScopedPointer<ContributionItemFactory>
59 ContributionItemFactory::OPEN_WINDOWS(new OpenWindowsFactory());
60 
61 class ViewsShortlistFactory : public ContributionItemFactory
62 {
63 public:
64 
65  ViewsShortlistFactory()
66  : ContributionItemFactory("viewsShortlist")
67  {}
68 
69  IContributionItem::Pointer Create(IWorkbenchWindow* window) override
70  {
71  if (window == nullptr)
72  {
73  throw ctkInvalidArgumentException("window must not be null");
74  }
75  IContributionItem::Pointer item(new ShowViewMenu(window, GetId()));
76  return item;
77  }
78 };
79 
80 const QScopedPointer<ContributionItemFactory>
81 ContributionItemFactory::VIEWS_SHORTLIST(new ViewsShortlistFactory());
82 
83 class ReopenEditorsFactory : public ContributionItemFactory
84 {
85 public:
86 
87  ReopenEditorsFactory()
88  : ContributionItemFactory("reopenEditors")
89  {}
90 
91  IContributionItem::Pointer Create(IWorkbenchWindow* window) override
92  {
93  if (window == nullptr)
94  {
95  throw ctkInvalidArgumentException("window must not be null");
96  }
97  IContributionItem::Pointer item(new ReopenEditorMenu(window, GetId(), true));
98  return item;
99  }
100 };
101 
102 const QScopedPointer<ContributionItemFactory>
103 ContributionItemFactory::REOPEN_EDITORS(new ReopenEditorsFactory());
104 
105 class PerspectivesShortlistFactory : public ContributionItemFactory
106 {
107 public:
108 
109  PerspectivesShortlistFactory()
110  : ContributionItemFactory("perspectivesShortlist")
111  {}
112 
113  IContributionItem::Pointer Create(IWorkbenchWindow* window) override
114  {
115  if (window == nullptr)
116  {
117  throw ctkInvalidArgumentException("window must not be null");
118  }
119  IContributionItem::Pointer item(new ChangeToPerspectiveMenu(window, GetId()));
120  return item;
121  }
122 };
123 
124 const QScopedPointer<ContributionItemFactory>
125 ContributionItemFactory::PERSPECTIVES_SHORTLIST(new PerspectivesShortlistFactory());
126 
127 }
berry::SmartPointer< Self > Pointer
Definition: berryObject.h:88
static const QScopedPointer< ContributionItemFactory > REOPEN_EDITORS
static const QScopedPointer< ContributionItemFactory > PERSPECTIVES_SHORTLIST
ContributionItemFactory(const QString &contributionItemId)
static const QScopedPointer< ContributionItemFactory > VIEWS_SHORTLIST
static const QScopedPointer< ContributionItemFactory > OPEN_WINDOWS