Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryWorkbenchAdvisor.h
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 #ifndef BERRYWORKBENCHADVISOR_H_
18 #define BERRYWORKBENCHADVISOR_H_
19 
21 
22 #include "berryIMemento.h"
23 #include <berryIAdaptable.h>
24 
27 
28 namespace berry {
29 
97 
101  private: IWorkbenchConfigurer::Pointer workbenchConfigurer;
102 
103  /*
104  * The workbench error handler.
105  */
106  //private: AbstractStatusHandler workbenchErrorHandler;
107 
108  //private: bool introOpened;
109 
113  protected: WorkbenchAdvisor();
114  virtual ~WorkbenchAdvisor();
115 
125  public: void InternalBasicInitialize(IWorkbenchConfigurer::Pointer configurer);
126 
141  public: virtual void Initialize(IWorkbenchConfigurer::Pointer configurer);
142 
150  protected: IWorkbenchConfigurer::Pointer GetWorkbenchConfigurer();
151 
152  /*
153  * Returns the workbench error handler for the advisor.
154  *
155  * @return the workbench error handler
156  * @since 3.3
157  */
158 // public: AbstractStatusHandler getWorkbenchErrorHandler() {
159 // if (workbenchErrorHandler == null) {
160 // workbenchErrorHandler = new WorkbenchErrorHandler();
161 // }
162 // return workbenchErrorHandler;
163 // }
164 
175  public: virtual void PreStartup();
176 
187  public: virtual void PostStartup();
188 
207  public: virtual bool PreShutdown();
208 
218  public: virtual void PostShutdown();
219 
220  /*
221  * Performs arbitrary actions when the event loop crashes (the code that
222  * handles a UI event throws an exception that is not caught).
223  * <p>
224  * This method is called when the code handling a UI event throws an
225  * exception. In a perfectly functioning application, this method would
226  * never be called. In practice, it comes into play when there are bugs in
227  * the code that trigger unchecked runtime exceptions. It is also activated
228  * when the system runs short of memory, etc. Fatal errors (ThreadDeath) are
229  * not passed on to this method, as there is nothing that could be done.
230  * </p>
231  * <p>
232  * Clients must not call this method directly (although super calls are
233  * okay). The default implementation logs the problem so that it does not go
234  * unnoticed. Subclasses may override or extend this method. It is generally
235  * a bad idea to override with an empty method, and you should be especially
236  * careful when handling Errors.
237  * </p>
238  *
239  * @param exception
240  * the uncaught exception that was thrown inside the UI event
241  * loop
242  */
243 // public: void eventLoopException(Throwable exception) {
244 // // Protection from client doing super(null) call
245 // if (exception == null) {
246 // return;
247 // }
248 //
249 // try {
250 // StatusManager.getManager().handle(
251 // new Status(IStatus.ERR, WorkbenchPlugin.PI_WORKBENCH,
252 // "Unhandled event loop exception", exception)); //$NON-NLS-1$
253 //
254 // if (WorkbenchPlugin.DEBUG) {
255 // exception.printStackTrace();
256 // }
257 // } catch (Throwable e) {
258 // // One of the log listeners probably failed. Core should have logged
259 // // the
260 // // exception since its the first listener.
261 // System.err.println("Error while logging event loop exception:"); //$NON-NLS-1$
262 // exception.printStackTrace();
263 // System.err.println("Logging exception:"); //$NON-NLS-1$
264 // e.printStackTrace();
265 // }
266 // }
267 
268  /*
269  * Performs arbitrary work or yields when there are no events to be
270  * processed.
271  * <p>
272  * This method is called when there are currently no more events on the
273  * queue to be processed at the moment.
274  * </p>
275  * <p>
276  * Clients must not call this method directly (although super calls are
277  * okay). The default implementation yields until new events enter the
278  * queue. Subclasses may override or extend this method. It is generally a
279  * bad idea to override with an empty method. It is okay to call
280  * <code>IWorkbench.close()</code> from this method.
281  * </p>
282  *
283  * @param display
284  * the main display of the workbench UI
285  */
286 // public: void eventLoopIdle(Display display) {
287 // // default: yield cpu until new events enter the queue
288 // display.sleep();
289 // }
290 
300  public: virtual WorkbenchWindowAdvisor* CreateWorkbenchWindowAdvisor(
301  IWorkbenchWindowConfigurer::Pointer configurer) = 0;
302 
303 
317  public: virtual IAdaptable* GetDefaultPageInput();
318 
335  public: virtual QString GetInitialWindowPerspectiveId() = 0;
336 
347  public: virtual QString GetMainPreferencePageId();
348 
360  public: virtual bool OpenWindows();
361 
374  public: virtual bool SaveState(IMemento::Pointer memento);
375 
388  public: virtual bool RestoreState(IMemento::Pointer memento);
389 
390  /*
391  * Return the contribution comparator for the particular type of
392  * contribution. The default implementation of this class returns a
393  * comparator that sorts the items by label.
394  *
395  * The contributionType may be one of the constants in
396  * {@link IContributionService} or it can be a value defined by the user.
397  *
398  * @param contributionType
399  * the contribution type
400  * @return the comparator, must not return <code>null</code>
401  * @see IContributionService#GetComparatorFor(const QString&)
402  */
403 // public: ContributionComparator getComparatorFor(String contributionType) {
404 // return new ContributionComparator();
405 // }
406 };
407 
408 }
409 
410 #endif /*BERRYWORKBENCHADVISOR_H_*/
berry::SmartPointer< Self > Pointer
Definition: berryObject.h:88
#define BERRY_UI_QT