X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.ui%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fui%2Feditor2%2FOpenSCLModule.java;h=b2df02fb4f0dc22e661926b34a8eac157c8f4b30;hp=a0208e5b24d28f2dc0696f512062920af53e281a;hb=de6536eb0ff08cf9b3f75a25b35ff44b33a6038b;hpb=a0c282689925d3b29dbb5239426163decc61689d 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..b2df02fb4 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"); + } catch (PartInitException e) { + LOGGER.error("Could not open module {} ", moduleName, e); + } + }; + } + + public static void scheduleOpenModule(String moduleName) { + Display.getCurrent().asyncExec(openModule(moduleName)); } }