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%2FStandardCutHandler.java;h=0c6d8ba3dcb27c736fc4fb1a5b83ffbcb2df7683;hp=350366e6cc621c6fa3fee4c8728224d1d2421777;hb=60509f4629d5ca644dd9533dd2abc64349aad328;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07 diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/StandardCutHandler.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/StandardCutHandler.java index 350366e6c..0c6d8ba3d 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/StandardCutHandler.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/StandardCutHandler.java @@ -17,6 +17,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.ui.PlatformUI; @@ -45,29 +50,38 @@ public class StandardCutHandler extends AbstractHandler { setStatus("Nothing to cut."); return null; } - - try { - final SimanticsClipboardImpl builder = new SimanticsClipboardImpl(); - - Simantics.getSession().syncRequest(new ReadRequest() { - @Override - public void run(ReadGraph graph) throws DatabaseException { - Set unique = new HashSet(); - for (Resource r : rs) { - if (!unique.add(r)) - continue; - CopyHandler handler = graph.adapt(r, CopyHandler.class); - handler.cutToClipboard(graph, builder); - } + Job job = new Job("Cut resources") { + + @Override + protected IStatus run(IProgressMonitor monitor) { + monitor.beginTask("Cut resources", rs.length); + try { + final SimanticsClipboardImpl builder = new SimanticsClipboardImpl(); + + Simantics.getSession().syncRequest(new ReadRequest() { + @Override + public void run(ReadGraph graph) throws DatabaseException { + Set unique = new HashSet(); + for (Resource r : rs) { + if (!unique.add(r)) + continue; + CopyHandler handler = graph.adapt(r, CopyHandler.class); + handler.cutToClipboard(graph, builder, SubMonitor.convert(monitor, 1)); + } + } + }); + + Simantics.setClipboard(builder); + setCutMessage(builder.getContents().size(), "resource"); + + } catch (DatabaseException e) { + Logger.defaultLogError(e); } - }); - - Simantics.setClipboard(builder); - setCutMessage(builder.getContents().size(), "resource"); - - } catch (DatabaseException e) { - Logger.defaultLogError(e); - } + return Status.OK_STATUS; + } + }; + job.setUser(true); + job.schedule(); return null; } @@ -95,7 +109,7 @@ public class StandardCutHandler extends AbstractHandler { public void run(ReadGraph graph) throws DatabaseException { for (Resource r : rs) { CopyHandler handler = graph.adapt(r, CopyHandler.class); - handler.cutToClipboard(graph, builder); + handler.cutToClipboard(graph, builder, null); } } });