]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/Copy.java
(refs #7561) Allow extra parameters to the application of type alias
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / actions / Copy.java
1 package org.simantics.modeling.ui.actions;
2
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import java.util.Collections;
6
7 import org.simantics.db.Resource;
8 import org.simantics.db.layer0.adapter.ActionFactory;
9 import org.simantics.db.layer0.adapter.ActionFactory2;
10 import org.simantics.modeling.ui.modelBrowser.handlers.StandardCopyHandler;
11
12 public class Copy implements ActionFactory, ActionFactory2 {
13
14         @Override
15     public Runnable create(Object target) {
16                 return create(Collections.singletonList(target));
17         }
18
19         @Override
20     public Runnable create(Collection<?> target) {
21
22                 final ArrayList<Resource> resources = new ArrayList<Resource>();
23                 
24                 for(Object o : target) {
25                         if(!(o instanceof Resource))
26                                 return null;
27                         resources.add((Resource)o);
28                 }
29         
30         return new Runnable() {
31             @Override
32             public void run() {
33                 
34                 StandardCopyHandler.copyResourcesToClipboard(resources.toArray(new Resource[resources.size()]), null);
35                 
36             }
37         };
38     }
39
40 }