Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkExtActionBarAdvisor.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 "QmitkFileOpenAction.h"
20 #include "QmitkFileSaveAction.h"
23 #include <QmitkFileExitAction.h>
24 
26 
28 #include <berryIContributionItem.h>
29 #include <berryMenuManager.h>
35 #include <berryIWorkbenchWindow.h>
36 #include <berryIWorkbench.h>
37 
38 #include <berryGroupMarker.h>
39 #include <berrySeparator.h>
41 
43  : berry::ActionBarAdvisor(configurer)
44 {
45  window = configurer->GetWindowConfigurer()->GetWindow().GetPointer();
46 }
47 
49 {
50  QAction* fileOpenAction = new QmitkFileOpenAction(
51  QIcon::fromTheme("document-open",
52  QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-open.svg")),
53  window);
54  fileOpenAction->setShortcut(QKeySequence::Open);
56 
57  QAction* fileSaveAction = new QmitkFileSaveAction(
58  QIcon(":/org.mitk.gui.qt.ext/Save_48.png"),
59  window);
60  fileSaveAction->setShortcut(QKeySequence::Save);
62 
63  QAction* fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window);
64  fileSaveProjectAction->setIcon(QIcon::fromTheme("document-save",
65  QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-save.svg")));
66  this->Register(fileSaveProjectAction, mitk::WorkbenchCommandConstants::PROJECT_SAVE);
67 
68  QAction* closeProjectAction = new QmitkCloseProjectAction(window);
69  closeProjectAction->setIcon(QIcon::fromTheme("edit-delete",
70  QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-delete.svg")));
72 
73  QAction* fileExitAction = new QmitkFileExitAction(window);
74  fileExitAction->setIcon(QIcon::fromTheme("system-log-out", QIcon(":/org_mitk_icons/icons/tango/scalable/actions/system-log-out.svg")));
75  fileExitAction->setShortcut(QKeySequence::Quit);
77 }
78 
80 {
81  menuBar->Add(CreateFileMenu());
82  menuBar->Add(CreateEditMenu());
84  menuBar->Add(CreateWindowMenu());
85  menuBar->Add(CreateHelpMenu());
86 }
87 
88 void QmitkExtActionBarAdvisor::FillToolBar(berry::IToolBarManager* /*toolBar*/)
89 {
90 }
91 
92 berry::SmartPointer<berry::MenuManager> QmitkExtActionBarAdvisor::CreateFileMenu()
93 {
96 
98  {
99  // create the New submenu, using the same id for it as the New action
100  QString newText = "&New";
101  QString newId = "org.blueberry.ui.newWizard";
102  berry::MenuManager::Pointer newMenu(new berry::MenuManager(newText, newId));
103  newMenu->SetCommandId("org.blueberry.ui.file.newQuickMenu");
104  newMenu->Add(berry::IContributionItem::Pointer(new berry::Separator(newId)));
105  //this.newWizardMenu = new NewWizardMenu(getWindow());
106  //newMenu.add(this.newWizardMenu);
108  menu->Add(newMenu);
109  }
110 
113 
116 
117  //menu.add(closeAction);
118  //menu.add(closeAllAction);
119  // // menu.add(closeAllSavedAction);
120 
125 
133 
135 
139 
140  // If we're on OS X we shouldn't show this command in the File menu. It
141  // should be invisible to the user. However, we should not remove it -
142  // the carbon UI code will do a search through our menu structure
143  // looking for it when Cmd-Q is invoked (or Quit is chosen from the
144  // application menu.
145  //ActionContributionItem quitItem = new ActionContributionItem(quitAction);
146  //quitItem.setVisible(!Util.isMac());
147  //menu.add(quitItem);
151 
152  return menu;
153 }
154 
155 berry::SmartPointer<berry::MenuManager> QmitkExtActionBarAdvisor::CreateEditMenu()
156 {
159 
161 
162  menu->Add(GetItem(berry::IWorkbenchCommandConstants::EDIT_UNDO, "&Undo"));
163  menu->Add(GetItem(berry::IWorkbenchCommandConstants::EDIT_REDO, "&Redo"));
166 /*
167  menu.add(getCutItem());
168  menu.add(getCopyItem());
169  menu.add(getPasteItem());
170  menu.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT));
171  menu.add(new Separator());
172 
173  menu.add(getDeleteItem());
174  menu.add(getSelectAllItem());
175  menu.add(new Separator());
176 
177  menu.add(getFindItem());
178  menu.add(new GroupMarker(IWorkbenchActionConstants.FIND_EXT));
179  menu.add(new Separator());
180 
181  menu.add(getBookmarkItem());
182  menu.add(getTaskItem());
183  menu.add(new GroupMarker(IWorkbenchActionConstants.ADD_EXT));
184 */
187 
188  return menu;
189 }
190 
191 berry::SmartPointer<berry::MenuManager> QmitkExtActionBarAdvisor::CreateHelpMenu()
192 {
195 
197 
198  menu->Add(berry::IContributionItem::Pointer(new berry::Separator("group.intro")));
199  // See if a welcome or intro page is specified
200  if (window->GetWorkbench()->GetIntroManager()->HasIntro())
201  {
202  menu->Add(GetItem(berry::IWorkbenchCommandConstants::HELP_WELCOME, "Welcome"));
203  }
204  menu->Add(berry::IContributionItem::Pointer(new berry::GroupMarker("group.intro.ext")));
206  menu->Add(GetItem(berry::IWorkbenchCommandConstants::HELP_HELP_CONTENTS, "Help &Contents"));
207  //menu->Add(GetItem(berry::IWorkbenchCommandConstants::HELP_HELP_SEARCH, "Help Search"));
208  menu->Add(GetItem(berry::IWorkbenchCommandConstants::HELP_DYNAMIC_HELP, "Conte&xt Help", "", QIcon(), QKeySequence::HelpContents));
211 
212  // about should always be at the bottom
213  menu->Add(berry::IContributionItem::Pointer(new berry::Separator("group.about")));
214 
215  menu->Add(GetItem(berry::IWorkbenchCommandConstants::HELP_ABOUT, "&About"));
216  menu->Add(berry::IContributionItem::Pointer(new berry::GroupMarker("group.about.ext")));
217 
218  return menu;
219 }
220 
221 berry::MenuManager::Pointer QmitkExtActionBarAdvisor::CreateWindowMenu()
222 {
225 
226  // See bug 19059.
227  // menu->Add(GetItem(berry::IWorkbenchCommandConstants::WINDOW_NEW_WINDOW, "New Window"));
228  // menu->Add(GetItem(berry::IWorkbenchCommandConstants::WINDOW_NEW_EDITOR, "New Editor"));
229 
231  AddPerspectiveActions(menu.GetPointer());
232  //menu.add(new Separator());
233  //AddKeyboardShortcuts(menu);
235  //sep.setVisible(!Util.isMac());
236  menu->Add(berry::IContributionItem::Pointer(sep.GetPointer()));
237 
238  //if(Util.isCocoa())
239  // menu.add(arrangeWindowsItem);
240 
241  // See the comment for quit in createFileMenu
242  berry::IContributionItem::Pointer openPreferencesItem =
244  //openPreferencesItem.setVisible(!Util.isMac());
245  menu->Add(openPreferencesItem);
246 
248  return menu;
249 }
250 
251 void QmitkExtActionBarAdvisor::AddPerspectiveActions(berry::MenuManager* menu)
252 {
253  {
254  berry::MenuManager::Pointer changePerspMenuMgr(new berry::MenuManager("Open Perspective", "openPerspective"));
255  berry::IContributionItem::Pointer changePerspMenuItem =
257  changePerspMenuMgr->Add(changePerspMenuItem);
258  menu->Add(changePerspMenuMgr);
259  }
260  {
261  berry::MenuManager::Pointer showViewMenuMgr(new berry::MenuManager("Show &View", "showView"));
262  berry::IContributionItem::Pointer showViewMenu =
264  showViewMenuMgr->Add(showViewMenu);
265  menu->Add(showViewMenuMgr);
266  }
268  //menu.add(editActionSetAction);
269  menu->Add(GetItem(berry::IWorkbenchCommandConstants::WINDOW_SAVE_PERSPECTIVE_AS, "Save Perspective &As..."));
270  menu->Add(GetItem(berry::IWorkbenchCommandConstants::WINDOW_RESET_PERSPECTIVE, "&Reset Perspective..."));
271  menu->Add(GetItem(berry::IWorkbenchCommandConstants::WINDOW_CLOSE_PERSPECTIVE, "&Close Perspective"));
272  menu->Add(GetItem(berry::IWorkbenchCommandConstants::WINDOW_CLOSE_ALL_PERSPECTIVES, "Close All Perspectives"));
273 }
274 
275 berry::SmartPointer<berry::IContributionItem> QmitkExtActionBarAdvisor::GetItem(const QString& commandId, const QString& label,
276  const QString& tooltip, const QIcon& icon, const QKeySequence& shortcut)
277 {
280  param->icon = icon;
281  param->label = label;
282  param->tooltip = tooltip;
283  param->shortcut = shortcut;
285  return item;
286 }
void Register() const
itk::SmartPointer< Self > Pointer
virtual QAction * GetAction(const QString &id) const
virtual IIntroManager * GetIntroManager() const =0
QmitkExtActionBarAdvisor(berry::SmartPointer< berry::IActionBarConfigurer > configurer)
virtual bool HasIntro() const =0
void FillMenuBar(berry::IMenuManager *menuBar) override
void Add(QAction *action, const QString &id) override
static const QScopedPointer< ContributionItemFactory > REOPEN_EDITORS
static const QScopedPointer< ContributionItemFactory > PERSPECTIVES_SHORTLIST
void MakeActions(berry::IWorkbenchWindow *window) override
The custom viewer plugin implements simple viewer functionality presented in a customized look and feel It was developed to demonstrate extensibility and customizability of the blueberry application framework As an example for the GUI customization capabilities provided by the BlueBerry application the custom viewer plugin was developed It features simple viewer functionality presented in a customized look and feel The custom viewer consists of two i e a viewer perspective and a DICOM perspective As part of the viewer an instance of QmitkDataManagerView allows for data selection Visualization of the selected data is then performed by a simple render window view According data can either be directly loaded from file or be imported as DICOM data DICOM import functionality is accessible from the DICOM perspective incorporating the QmitkDicomExternalDataWidget The customization of Qt Stylesheets is used to give the application a non native look and feel This is further emphasized by a Tab Widget like unification of the perspectives with the according perspective bar In addition to an absence of menu
ObjectType * GetPointer() const
void FillToolBar(berry::IToolBarManager *toolBar) override
static const QScopedPointer< ContributionItemFactory > VIEWS_SHORTLIST
virtual void Add(const SmartPointer< IContributionItem > &item)=0
virtual IWorkbench * GetWorkbench() const =0
static const QScopedPointer< ContributionItemFactory > OPEN_WINDOWS