X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.ui%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fui%2Feditor2%2FOpenSCLModule.java;h=2be6609ce7ceb82df2480827362506fc46571db3;hb=HEAD;hp=a0208e5b24d28f2dc0696f512062920af53e281a;hpb=a5e69e900dcfcf54a9f39ab754f20467d99b64d3;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/OpenSCLModule.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/OpenSCLModule.java index a0208e5b2..2be6609ce 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/OpenSCLModule.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/OpenSCLModule.java @@ -3,33 +3,44 @@ package org.simantics.scl.ui.editor2; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class OpenSCLModule extends AbstractHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(OpenSCLModule.class); + @Override public Object execute(ExecutionEvent event) throws ExecutionException { SCLModuleSelectionDialog dialog = new SCLModuleSelectionDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); if(dialog.open() == SCLModuleSelectionDialog.OK) { String moduleName = (String)dialog.getFirstResult(); - openModule(moduleName); + scheduleOpenModule(moduleName); } return null; } - public static void openModule(String moduleName) { - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - if(page == null) - return; - SCLModuleEditorInput input = new StandardSCLModuleEditorInput(moduleName); - try { - page.openEditor(input, "org.simantics.scl.ui.editor2"); - } catch (PartInitException e) { - e.printStackTrace(); - } + public static Runnable openModule(String moduleName) { + return () -> { + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + if(page == null) + return; + SCLModuleEditorInput input = new StandardSCLModuleEditorInput(moduleName); + try { + page.openEditor(input, "org.simantics.scl.ui.editor2"); //$NON-NLS-1$ + } catch (PartInitException e) { + LOGGER.error("Could not open module {} ", moduleName, e); //$NON-NLS-1$ + } + }; + } + + public static void scheduleOpenModule(String moduleName) { + Display.getCurrent().asyncExec(openModule(moduleName)); } }