1 package org.simantics.scl.ui.editor2;
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.swt.widgets.Display;
7 import org.eclipse.ui.IWorkbenchPage;
8 import org.eclipse.ui.PartInitException;
9 import org.eclipse.ui.PlatformUI;
10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory;
13 public class OpenSCLModule extends AbstractHandler {
15 private static final Logger LOGGER = LoggerFactory.getLogger(OpenSCLModule.class);
18 public Object execute(ExecutionEvent event) throws ExecutionException {
19 SCLModuleSelectionDialog dialog = new SCLModuleSelectionDialog(
20 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
21 if(dialog.open() == SCLModuleSelectionDialog.OK) {
22 String moduleName = (String)dialog.getFirstResult();
23 scheduleOpenModule(moduleName);
28 public static Runnable openModule(String moduleName) {
30 IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
33 SCLModuleEditorInput input = new StandardSCLModuleEditorInput(moduleName);
35 page.openEditor(input, "org.simantics.scl.ui.editor2"); //$NON-NLS-1$
36 } catch (PartInitException e) {
37 LOGGER.error("Could not open module {} ", moduleName, e); //$NON-NLS-1$
42 public static void scheduleOpenModule(String moduleName) {
43 Display.getCurrent().asyncExec(openModule(moduleName));