X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2FmodelBrowser%2Fhandlers%2FStandardCopyHandler.java;h=1ce5b2d3698ddee5ce7989059dc58de5d6a9fe04;hp=9730334ccc3dcaabf67ca3ec98c33c82eb729309;hb=21f12e54fc7907e26e49f26f95ee3b62cbecdc61;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07 diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/StandardCopyHandler.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/StandardCopyHandler.java index 9730334cc..1ce5b2d36 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/StandardCopyHandler.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/StandardCopyHandler.java @@ -19,6 +19,11 @@ import java.util.Set; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; @@ -91,13 +96,22 @@ public class StandardCopyHandler extends AbstractHandler { if(copyText(selection)) return null; formatSelectionToClipboardText(event); - final Resource[] rs = ResourceAdaptionUtils.toResources(selection); - copyResourcesToClipboard(rs, selection); + Job job = new Job("Copy resources") { + @Override + protected IStatus run(IProgressMonitor monitor) { + monitor.beginTask("Copy resources to clipboard", 1); + copyResourcesToClipboard(rs, selection, SubMonitor.convert(monitor, 1)); + return Status.OK_STATUS; + } + }; + job.setUser(true); + job.schedule(); + return null; } - public static String copyResourcesToClipboard(final Resource[] rs, ISelection selection) { + public static String copyResourcesToClipboard(final Resource[] rs, ISelection selection, IProgressMonitor monitor) { if(rs == null || rs.length == 0) { // This support was added for copying of properties (variables) @@ -105,7 +119,7 @@ public class StandardCopyHandler extends AbstractHandler { if(!variables.isEmpty()) { final SimanticsClipboardImpl builder = new SimanticsClipboardImpl(); for(Variable var : variables) { - builder.addContent(Collections.singleton(ClipboardUtils.createVariable(Simantics.getSession(), var))); + builder.addContent(Collections.singleton(ClipboardUtils.createVariable(Simantics.getSession(), var)), monitor); } Simantics.setClipboard(builder); setCopyMessage(builder.getContents().size(), "variable"); @@ -122,7 +136,7 @@ public class StandardCopyHandler extends AbstractHandler { public void run(ReadGraph graph) throws DatabaseException { for (Resource r : rs) { CopyHandler handler = graph.adapt(r, CopyHandler.class); - handler.copyToClipboard(graph, builder); + handler.copyToClipboard(graph, builder, monitor); } } }); @@ -145,8 +159,11 @@ public class StandardCopyHandler extends AbstractHandler { } private static void setStatus(String message) { - if (status != null) - status.setMessage(message); + if (status != null) { + SWTUtils.asyncExec( + PlatformUI.getWorkbench().getDisplay(), + () -> status.setMessage(message)); + } } private boolean formatSelectionToClipboardText(ExecutionEvent event) {