p2izing the editor
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / Application.java
1 package eu.etaxonomy.taxeditor;
2
3 import org.apache.log4j.Logger;
4 import org.eclipse.equinox.app.IApplication;
5 import org.eclipse.equinox.app.IApplicationContext;
6 import org.eclipse.swt.widgets.Display;
7 import org.eclipse.ui.IWorkbench;
8 import org.eclipse.ui.PlatformUI;
9
10 /**
11 * This class controls all aspects of the application's execution
12 *
13 * but thorws errors on osx
14 */
15 public class Application implements IApplication {
16 private static final Logger logger = Logger.getLogger(Application.class);
17
18 /* (non-Javadoc)
19 * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
20 */
21 public Object start(IApplicationContext context) {
22 Display display = PlatformUI.createDisplay();
23 try {
24 int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
25 if (returnCode == PlatformUI.RETURN_RESTART) {
26 return IApplication.EXIT_RESTART;
27 }
28 return IApplication.EXIT_OK;
29 } finally {
30 display.dispose();
31 }
32 }
33
34 /* (non-Javadoc)
35 * @see org.eclipse.equinox.app.IApplication#stop()
36 */
37 public void stop() {
38 final IWorkbench workbench = PlatformUI.getWorkbench();
39 if (workbench == null)
40 return;
41 final Display display = workbench.getDisplay();
42 display.syncExec(new Runnable() {
43 public void run() {
44 if (!display.isDisposed())
45 workbench.close();
46 }
47 });
48 }
49 }