X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2FmodelBrowser%2Fhandlers%2FStandardPasteHandler.java;h=fa4f59530aa71290639d328ee64cd00d5db0d5d3;hp=32e3ef60ff13afa83a43e6061d6f1ae6b1c284b9;hb=f7073364d424fb9b1ef84ade1cfa49553a694c22;hpb=54512ce682c4d11e4d119505be480a31560fa7e4 diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/StandardPasteHandler.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/StandardPasteHandler.java index 32e3ef60f..fa4f59530 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/StandardPasteHandler.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/StandardPasteHandler.java @@ -28,15 +28,18 @@ import org.eclipse.ui.handlers.HandlerUtil; import org.simantics.Simantics; import org.simantics.db.Resource; import org.simantics.db.common.primitiverequest.Adapter; -import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.adapter.PasteHandler; import org.simantics.ui.SimanticsUI; import org.simantics.utils.ui.ErrorLogger; import org.simantics.utils.ui.ExceptionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class StandardPasteHandler extends AbstractHandler implements IHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(StandardPasteHandler.class); + @Override public Object execute(ExecutionEvent event) throws ExecutionException { @@ -90,28 +93,22 @@ public class StandardPasteHandler extends AbstractHandler implements IHandler { return op; } - + public static void pasteResourceFromClipboardWithoutMonitor (final PasteHandler handler) { - try { - handler.pasteFromClipboard(Simantics.getClipboard()); - } catch (DatabaseException e) { - try { - throw new InvocationTargetException(e); - } catch (InvocationTargetException e1) { - e1.getCause().printStackTrace(); - } - e.printStackTrace(); - } + try { + handler.pasteFromClipboard(Simantics.getClipboard()); + } catch (DatabaseException e) { + LOGGER.error("Failed to paste resource from clipboard with handler {}", handler, e); //$NON-NLS-1$ + } } - + public static T getPasteHandlerFromResource (Resource resource, Class assignableFrom) { - - try { - return Simantics.getSession().syncRequest(new Adapter(resource, assignableFrom)); - } catch (DatabaseException e) { - Logger.defaultLogError(e); - return null; - } + try { + return Simantics.getSession().syncRequest(new Adapter(resource, assignableFrom)); + } catch (DatabaseException e) { + LOGGER.error("Failed to get paste handler from resource {}", resource, e); //$NON-NLS-1$ + return null; + } } -} +} \ No newline at end of file