1 package org.simantics.modeling.ui.actions;
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;
14 public class Paste implements ActionFactory {
17 public Runnable create(Object target) {
19 if (!(target instanceof Resource))
22 final Resource resource = (Resource)target;
24 return new Runnable() {
29 PasteHandler handler = Simantics.getSession().syncRequest(new Adapter<PasteHandler>(resource, PasteHandler.class));
30 if (handler != null) {
31 Simantics.getSession().markUndoPoint();
32 StandardPasteHandler.pasteResourceFromClipboardWithoutMonitor(handler);
34 } catch (DatabaseException e) {
35 Logger.defaultLogError(e);