1 | package de.uka.ipd.sdq.pcmbench.application; |
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 | public class PCMBenchApplication implements IApplication { |
10 | |
11 | |
12 | public Object start(IApplicationContext context) throws Exception { |
13 | Display display = PlatformUI.createDisplay(); |
14 | try { |
15 | int returnCode = PlatformUI.createAndRunWorkbench(display, new PCMBenchWorkbenchAdvisor()); |
16 | if (returnCode == PlatformUI.RETURN_RESTART) { |
17 | return IApplication.EXIT_RESTART; |
18 | } |
19 | return IApplication.EXIT_OK; |
20 | } finally { |
21 | display.dispose(); |
22 | } |
23 | } |
24 | |
25 | |
26 | public void stop() { |
27 | final IWorkbench workbench = PlatformUI.getWorkbench(); |
28 | if (workbench == null) |
29 | return; |
30 | final Display display = workbench.getDisplay(); |
31 | display.syncExec(new Runnable() { |
32 | public void run() { |
33 | if (!display.isDisposed()) |
34 | workbench.close(); |
35 | } |
36 | }); |
37 | } |
38 | |
39 | } |