performed javacscript:fix and worked on documentation
[taxeditor.git] / taxeditor-application / src / main / java / eu / etaxonomy / taxeditor / Application.java
1 package eu.etaxonomy.taxeditor;
2
3 import org.eclipse.equinox.app.IApplication;
4 import org.eclipse.equinox.app.IApplicationContext;
5 import org.eclipse.swt.widgets.Display;
6 import org.eclipse.ui.IWorkbench;
7 import org.eclipse.ui.PlatformUI;
8
9 /**
10 * This class controls all aspects of the application's execution
11 *
12 * @author n.hoffmann
13 * @version $Id: $
14 */
15 public class Application implements IApplication {
16
17 /* (non-Javadoc)
18 * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
19 */
20 /** {@inheritDoc} */
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 /**
38 * <p>stop</p>
39 */
40 public void stop() {
41 final IWorkbench workbench = PlatformUI.getWorkbench();
42 if (workbench == null)
43 return;
44 final Display display = workbench.getDisplay();
45 display.syncExec(new Runnable() {
46 public void run() {
47 if (!display.isDisposed())
48 workbench.close();
49 }
50 });
51 }
52 }