]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/OpenSCLModule.java
a0208e5b24d28f2dc0696f512062920af53e281a
[simantics/platform.git] / bundles / org.simantics.scl.ui / src / org / simantics / scl / ui / editor2 / OpenSCLModule.java
1 package org.simantics.scl.ui.editor2;
2
3 import org.eclipse.core.commands.AbstractHandler;
4 import org.eclipse.core.commands.ExecutionEvent;
5 import org.eclipse.core.commands.ExecutionException;
6 import org.eclipse.ui.IWorkbenchPage;
7 import org.eclipse.ui.PartInitException;
8 import org.eclipse.ui.PlatformUI;
9
10 public class OpenSCLModule extends AbstractHandler {
11
12     @Override
13     public Object execute(ExecutionEvent event) throws ExecutionException {
14         SCLModuleSelectionDialog dialog = new SCLModuleSelectionDialog(
15                 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
16         if(dialog.open() == SCLModuleSelectionDialog.OK) {
17             String moduleName = (String)dialog.getFirstResult();
18             openModule(moduleName);
19         }
20         return null;
21     }
22
23     public static void openModule(String moduleName) {
24         IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
25         if(page == null)
26             return;
27         SCLModuleEditorInput input = new StandardSCLModuleEditorInput(moduleName);
28         try {
29             page.openEditor(input, "org.simantics.scl.ui.editor2");
30         } catch (PartInitException e) {
31             e.printStackTrace();
32         }
33     }
34
35 }