]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/Paste.java
Allow client-logic in component type interface property name editing
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / actions / Paste.java
1 package org.simantics.modeling.ui.actions;
2
3 import org.simantics.Simantics;
4 import org.simantics.browsing.ui.BuiltinKeys;
5 import org.simantics.browsing.ui.NodeContext;
6 import org.simantics.db.Resource;
7 import org.simantics.db.common.primitiverequest.Adapter;
8 import org.simantics.db.common.utils.Logger;
9 import org.simantics.db.exception.DatabaseException;
10 import org.simantics.db.layer0.adapter.ActionFactory;
11 import org.simantics.db.layer0.adapter.PasteHandler;
12 import org.simantics.modeling.ui.modelBrowser.handlers.StandardPasteHandler;
13
14 public class Paste implements ActionFactory {
15
16         @Override
17     public Runnable create(Object target) {
18
19                 if (!(target instanceof Resource))
20                         return null;
21                 
22                 final Resource resource = (Resource)target;
23                 
24         return new Runnable() {
25             @Override
26             public void run() {
27
28                 try {
29                         PasteHandler handler = Simantics.getSession().syncRequest(new Adapter<PasteHandler>(resource, PasteHandler.class));
30                         if (handler != null) {
31                             Simantics.getSession().markUndoPoint();
32                                 StandardPasteHandler.pasteResourceFromClipboardWithoutMonitor(handler);
33                         }
34                 } catch (DatabaseException e) {
35                         Logger.defaultLogError(e);
36                 }
37                 
38             }
39         };
40     }
41
42 }