Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryWorkbenchAdvisor.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 #include "berryWorkbenchAdvisor.h"
18 
19 #include <Poco/Exception.h>
20 
21 namespace berry
22 {
23 
25 {
26  // do nothing
27 }
28 
30 {
31 }
32 
34 {
35  if (workbenchConfigurer.IsNotNull())
36  {
37  throw Poco::IllegalStateException();
38  }
39  this->workbenchConfigurer = configurer;
40  this->Initialize(configurer);
41 }
42 
44 {
45  // do nothing
46 }
47 
49 {
50  return workbenchConfigurer;
51 }
52 
54 {
55  // do nothing
56 }
57 
59 {
60  // do nothing
61 }
62 
64 {
65  return true;
66 }
67 
69 {
70  // do nothing
71 }
72 
74 {
75  // default: no input
76  return nullptr;
77 }
78 
80 {
81  // default: no opinion
82  return "";
83 }
84 
86 {
87  // final Display display = PlatformUI.getWorkbench().getDisplay();
88  // final boolean result [] = new boolean[1];
89  //
90  // // spawn another init thread. For API compatibility We guarantee this method is called from
91  // // the UI thread but it could take enough time to disrupt progress reporting.
92  // // spawn a new thread to do the grunt work of this initialization and spin the event loop
93  // // ourselves just like it's done in Workbench.
94  // final boolean[] initDone = new boolean[]{false};
95  // final Throwable [] error = new Throwable[1];
96  // Thread initThread = new Thread() {
97  // /* (non-Javadoc)
98  // * @see java.lang.Thread#run()
99  // */
100  // void run() {
101  // try {
102  // //declare us to be a startup thread so that our syncs will be executed
103  // UISynchronizer.startupThread.set(Boolean.TRUE);
104  // final IWorkbenchConfigurer [] myConfigurer = new IWorkbenchConfigurer[1];
105  // StartupThreading.runWithoutExceptions(new StartupRunnable() {
106  //
107  // void runWithException() throws Throwable {
108  // myConfigurer[0] = getWorkbenchConfigurer();
109  //
110  // }});
111  //
112  // IStatus status = myConfigurer[0].restoreState();
113  // if (!status.isOK()) {
114  // if (status.getCode() == IWorkbenchConfigurer.RESTORE_CODE_EXIT) {
115  // result[0] = false;
116  // return;
117  // }
118  // if (status.getCode() == IWorkbenchConfigurer.RESTORE_CODE_RESET) {
119  // myConfigurer[0].openFirstTimeWindow();
120  // }
121  // }
122  // result[0] = true;
123  // } catch (Throwable e) {
124  // error[0] = e;
125  // }
126  // finally {
127  // initDone[0] = true;
128  // display.wake();
129  // }
130  // }};
131  // initThread.start();
132  //
133  // while (true) {
134  // if (!display.readAndDispatch()) {
135  // if (initDone[0])
136  // break;
137  // display.sleep();
138  // }
139  //
140  // }
141  //
142  // // can only be a runtime or error
143  // if (error[0] instanceof Error)
144  // throw (Error)error[0];
145  // else if (error[0] instanceof RuntimeException)
146  // throw (RuntimeException)error[0];
147  //
148  // return result[0];
149 
151 
152  bool status = myConfigurer->RestoreState();
153  if (!status)
154  {
155  myConfigurer->OpenFirstTimeWindow();
156  }
157  return true;
158 }
159 
161 {
162  return true;
163 }
164 
166 {
167  return true;
168 }
169 
170 }
virtual bool RestoreState(IMemento::Pointer memento)
virtual QString GetMainPreferencePageId()
berry::SmartPointer< Self > Pointer
Definition: berryObject.h:88
virtual IAdaptable * GetDefaultPageInput()
virtual void Initialize(IWorkbenchConfigurer::Pointer configurer)
void InternalBasicInitialize(IWorkbenchConfigurer::Pointer configurer)
IWorkbenchConfigurer::Pointer GetWorkbenchConfigurer()
virtual bool SaveState(IMemento::Pointer memento)