Medical Imaging Interaction Toolkit  2018.4.99-07c45cb1
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 (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 "QmitkFileOpenAction.h"
16 #include "QmitkFileSaveAction.h"
19 #include <QmitkFileExitAction.h>
20 
22 
24 #include <berryIContributionItem.h>
25 #include <berryMenuManager.h>
31 #include <berryIWorkbenchWindow.h>
32 #include <berryIWorkbench.h>
33 
34 #include <berryGroupMarker.h>
35 #include <berrySeparator.h>
37 
39  : berry::ActionBarAdvisor(configurer)
40 {
41  window = configurer->GetWindowConfigurer()->GetWindow().GetPointer();
42 }
43 
45 {
46  QAction* fileOpenAction = new QmitkFileOpenAction(
47  QIcon::fromTheme("document-open",
48  QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-open.svg")),
49  window);
50  fileOpenAction->setShortcut(QKeySequence::Open);
52 
53  QAction* fileSaveAction = new QmitkFileSaveAction(
54  QIcon(":/org.mitk.gui.qt.ext/Save_48.png"),
55  window);
56  fileSaveAction->setShortcut(QKeySequence::Save);
58 
59  QAction* fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window);
60  fileSaveProjectAction->setIcon(QIcon::fromTheme("document-save",
61  QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-save.svg")));
62  this->Register(fileSaveProjectAction, mitk::WorkbenchCommandConstants::PROJECT_SAVE);
63 
64  QAction* closeProjectAction = new QmitkCloseProjectAction(window);
65  closeProjectAction->setIcon(QIcon::fromTheme("edit-delete",
66  QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-delete.svg")));
68 
69  QAction* fileExitAction = new QmitkFileExitAction(window);
70  fileExitAction->setIcon(QIcon::fromTheme("system-log-out", QIcon(":/org_mitk_icons/icons/tango/scalable/actions/system-log-out.svg")));
71  fileExitAction->setShortcut(QKeySequence::Quit);
73 }
74 
76 {
77  menuBar->Add(CreateFileMenu());
78  menuBar->Add(CreateEditMenu());
80  menuBar->Add(CreateWindowMenu());
81  menuBar->Add(CreateHelpMenu());
82 }
83 
84 void QmitkExtActionBarAdvisor::FillToolBar(berry::IToolBarManager* /*toolBar*/)
85 {
86 }
87 
88 berry::SmartPointer<berry::MenuManager> QmitkExtActionBarAdvisor::CreateFileMenu()
89 {
92 
94  {
95  // create the New submenu, using the same id for it as the New action
96  QString newText = "&New";
97  QString newId = "org.blueberry.ui.newWizard";
98  berry::MenuManager::Pointer newMenu(new berry::MenuManager(newText, newId));
99  newMenu->SetCommandId("org.blueberry.ui.file.newQuickMenu");
100  newMenu->Add(berry::IContributionItem::Pointer(new berry::Separator(newId)));
101  //this.newWizardMenu = new NewWizardMenu(getWindow());
102  //newMenu.add(this.newWizardMenu);
104  menu->Add(newMenu);
105  }
106 
109 
112 
113  //menu.add(closeAction);
114  //menu.add(closeAllAction);
115  // // menu.add(closeAllSavedAction);
116 
121 
129 
131 
132  menu->Add(berry::ContributionItemFactory::REOPEN_EDITORS->Create(window));
135 
136  // If we're on OS X we shouldn't show this command in the File menu. It
137  // should be invisible to the user. However, we should not remove it -
138  // the carbon UI code will do a search through our menu structure
139  // looking for it when Cmd-Q is invoked (or Quit is chosen from the
140  // application menu.
141  //ActionContributionItem quitItem = new ActionContributionItem(quitAction);
142  //quitItem.setVisible(!Util.isMac());
143  //menu.add(quitItem);
147 
148  return menu;
149 }
150 
151 berry::SmartPointer<berry::MenuManager> QmitkExtActionBarAdvisor::CreateEditMenu()
152 {
155 
157 
158  menu->Add(GetItem(berry::IWorkbenchCommandConstants::EDIT_UNDO, "&Undo"));
159  menu->Add(GetItem(berry::IWorkbenchCommandConstants::EDIT_REDO, "&Redo"));
162 /*
163  menu.add(getCutItem());
164  menu.add(getCopyItem());
165  menu.add(getPasteItem());
166  menu.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT));
167  menu.add(new Separator());
168 
169  menu.add(getDeleteItem());
170  menu.add(getSelectAllItem());
171  menu.add(new Separator());
172 
173  menu.add(getFindItem());
174  menu.add(new GroupMarker(IWorkbenchActionConstants.FIND_EXT));
175  menu.add(new Separator());
176 
177  menu.add(getBookmarkItem());
178  menu.add(getTaskItem());
179  menu.add(new GroupMarker(IWorkbenchActionConstants.ADD_EXT));
180 */
183 
184  return menu;
185 }
186 
187 berry::SmartPointer<berry::MenuManager> QmitkExtActionBarAdvisor::CreateHelpMenu()
188 {
191 
193 
194  menu->Add(berry::IContributionItem::Pointer(new berry::Separator("group.intro")));
195  // See if a welcome or intro page is specified
196  if (window->GetWorkbench()->GetIntroManager()->HasIntro())
197  {
198  menu->Add(GetItem(berry::IWorkbenchCommandConstants::HELP_WELCOME, "Welcome"));
199  }
200  menu->Add(berry::IContributionItem::Pointer(new berry::GroupMarker("group.intro.ext")));
201  menu->Add(berry::IContributionItem::Pointer(new berry::Separator("group.main")));
202  menu->Add(GetItem(berry::IWorkbenchCommandConstants::HELP_HELP_CONTENTS, "Help &Contents"));
203  //menu->Add(GetItem(berry::IWorkbenchCommandConstants::HELP_HELP_SEARCH, "Help Search"));
204  menu->Add(GetItem(berry::IWorkbenchCommandConstants::HELP_DYNAMIC_HELP, "Conte&xt Help", "", QIcon(), QKeySequence::HelpContents));
207 
208  // about should always be at the bottom
209  menu->Add(berry::IContributionItem::Pointer(new berry::Separator("group.about")));
210 
211  menu->Add(GetItem(berry::IWorkbenchCommandConstants::HELP_ABOUT, "&About"));
212  menu->Add(berry::IContributionItem::Pointer(new berry::GroupMarker("group.about.ext")));
213 
214  return menu;
215 }
216 
217 berry::MenuManager::Pointer QmitkExtActionBarAdvisor::CreateWindowMenu()
218 {
221 
222  // See bug 19059.
223  // menu->Add(GetItem(berry::IWorkbenchCommandConstants::WINDOW_NEW_WINDOW, "New Window"));
224  // menu->Add(GetItem(berry::IWorkbenchCommandConstants::WINDOW_NEW_EDITOR, "New Editor"));
225 
227  AddPerspectiveActions(menu.GetPointer());
228  //menu.add(new Separator());
229  //AddKeyboardShortcuts(menu);
230  berry::Separator::Pointer sep(new berry::Separator(berry::WorkbenchActionConstants::MB_ADDITIONS));
231  //sep.setVisible(!Util.isMac());
232  menu->Add(berry::IContributionItem::Pointer(sep.GetPointer()));
233 
234  //if(Util.isCocoa())
235  // menu.add(arrangeWindowsItem);
236 
237  // See the comment for quit in createFileMenu
238  berry::IContributionItem::Pointer openPreferencesItem =
240  //openPreferencesItem.setVisible(!Util.isMac());
241  menu->Add(openPreferencesItem);
242 
243  menu->Add(berry::ContributionItemFactory::OPEN_WINDOWS->Create(window));
244  return menu;
245 }
246 
247 void QmitkExtActionBarAdvisor::AddPerspectiveActions(berry::MenuManager* menu)
248 {
249  {
250  berry::MenuManager::Pointer changePerspMenuMgr(new berry::MenuManager("Open Perspective", "openPerspective"));
251  berry::IContributionItem::Pointer changePerspMenuItem =
253  changePerspMenuMgr->Add(changePerspMenuItem);
254  menu->Add(changePerspMenuMgr);
255  }
256  {
257  berry::MenuManager::Pointer showViewMenuMgr(new berry::MenuManager("Show &View", "showView"));
258  berry::IContributionItem::Pointer showViewMenu =
260  showViewMenuMgr->Add(showViewMenu);
261  menu->Add(showViewMenuMgr);
262  }
264  //menu.add(editActionSetAction);
265  menu->Add(GetItem(berry::IWorkbenchCommandConstants::WINDOW_SAVE_PERSPECTIVE_AS, "Save Perspective &As..."));
266  menu->Add(GetItem(berry::IWorkbenchCommandConstants::WINDOW_RESET_PERSPECTIVE, "&Reset Perspective..."));
267  menu->Add(GetItem(berry::IWorkbenchCommandConstants::WINDOW_CLOSE_PERSPECTIVE, "&Close Perspective"));
268  menu->Add(GetItem(berry::IWorkbenchCommandConstants::WINDOW_CLOSE_ALL_PERSPECTIVES, "Close All Perspectives"));
269 }
270 
271 berry::SmartPointer<berry::IContributionItem> QmitkExtActionBarAdvisor::GetItem(const QString& commandId, const QString& label,
272  const QString& tooltip, const QIcon& icon, const QKeySequence& shortcut)
273 {
276  param->icon = icon;
277  param->label = label;
278  param->tooltip = tooltip;
279  param->shortcut = shortcut;
281  return item;
282 }
virtual QAction * GetAction(const QString &id) const
virtual IIntroManager * GetIntroManager() const =0
void Register() const
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
virtual void Add(QAction *action, const QString &id)=0
void FillToolBar(berry::IToolBarManager *toolBar) override
static const QScopedPointer< ContributionItemFactory > VIEWS_SHORTLIST
virtual IWorkbench * GetWorkbench() const =0
static const QScopedPointer< ContributionItemFactory > OPEN_WINDOWS
ObjectType * GetPointer() const