Project

General

Profile

Download (1.28 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.bulkeditor;
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
import eu.etaxonomy.taxeditor.bulkeditor.ApplicationWorkbenchAdvisor;
10

    
11
/**
12
 * This class controls all aspects of the application's execution
13
 */
14
public class Application implements IApplication {
15

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

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