-
- try {
- final SimanticsClipboardImpl builder = new SimanticsClipboardImpl();
-
- Simantics.getSession().syncRequest(new ReadRequest() {
- @Override
- public void run(ReadGraph graph) throws DatabaseException {
- Set<Resource> unique = new HashSet<Resource>();
- 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<Resource> unique = new HashSet<Resource>();
+ 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);