Project

General

Profile

Download (1.21 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.editor;
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
public class Application implements IApplication {
13

    
14
	/* (non-Javadoc)
15
	 * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
16
	 */
17
	public Object start(IApplicationContext context) {
18
		Display display = PlatformUI.createDisplay();
19
		try {
20
			int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
21
			if (returnCode == PlatformUI.RETURN_RESTART) {
22
				return IApplication.EXIT_RESTART;
23
			}
24
			return IApplication.EXIT_OK;
25
		} finally {
26
			display.dispose();
27
		}
28
	}
29

    
30
	/* (non-Javadoc)
31
	 * @see org.eclipse.equinox.app.IApplication#stop()
32
	 */
33
	public void stop() {
34
		final IWorkbench workbench = PlatformUI.getWorkbench();
35
		if (workbench == null)
36
			return;
37
		final Display display = workbench.getDisplay();
38
		display.syncExec(new Runnable() {
39
			public void run() {
40
				if (!display.isDisposed())
41
					workbench.close();
42
			}
43
		});
44
	}
45
}
(1-1/5)