1 package org.simantics.modeling.ui.actions;
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import java.util.Collections;
7 import org.eclipse.core.runtime.IProgressMonitor;
8 import org.eclipse.core.runtime.IStatus;
9 import org.eclipse.core.runtime.Status;
10 import org.eclipse.core.runtime.jobs.Job;
11 import org.simantics.db.Resource;
12 import org.simantics.db.layer0.adapter.ActionFactory;
13 import org.simantics.db.layer0.adapter.ActionFactory2;
14 import org.simantics.modeling.ui.modelBrowser.handlers.StandardCopyHandler;
16 public class Copy implements ActionFactory, ActionFactory2 {
19 public Runnable create(Object target) {
20 return create(Collections.singletonList(target));
24 public Runnable create(Collection<?> target) {
26 final ArrayList<Resource> resources = new ArrayList<Resource>();
28 for(Object o : target) {
29 if(!(o instanceof Resource))
31 resources.add((Resource)o);
34 Job job = new Job(Messages.Copy_Copy) {
37 protected IStatus run(IProgressMonitor monitor) {
38 StandardCopyHandler.copyResourcesToClipboard(resources.toArray(new Resource[resources.size()]), null, monitor);
39 return Status.OK_STATUS;