From 77e2823e06765b79ff44b86dfb47ced49fe2392e Mon Sep 17 00:00:00 2001 From: lehtonen Date: Fri, 21 Aug 2015 08:32:10 +0000 Subject: [PATCH] Changed org.simantics.db.layer0.util.SimanticsClipboard.Representation.getValue to throw DatabaseExceptions to allow excepitons to be propagated out of ClipboardUtils.accept, etc. methods. Previously all Reprensentation implementations had to internally catch any problems they experienced, which is just wrong. refs #6001 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@31610 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/ui/handlers/PasteSpecialHandler.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/PasteSpecialHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/PasteSpecialHandler.java index 9ed9bde5..9a5e87b5 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/PasteSpecialHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/PasteSpecialHandler.java @@ -10,6 +10,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.handlers.HandlerUtil; import org.simantics.Simantics; +import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.util.ClipboardUtils; import org.simantics.db.layer0.util.SimanticsClipboard.Representation; import org.simantics.diagram.handler.CopyPasteHandler; @@ -65,7 +66,11 @@ public class PasteSpecialHandler extends AbstractHandler { ICanvasContext ctx = (ICanvasContext) v; CopyPasteHandler handler = ctx.getAtMostOneItemOfClass(CopyPasteHandler.class); if(handler != null) { - handler.paste(Commands.PASTE, getClipboardDiagramSelection()); + try { + handler.paste(Commands.PASTE, getClipboardDiagramSelection()); + } catch (DatabaseException e) { + throw new ExecutionException("Failed to get diagram selection from clipboard", e); + } } } @@ -75,7 +80,7 @@ public class PasteSpecialHandler extends AbstractHandler { return null; } - public DiagramSelection getClipboardDiagramSelection() { + public DiagramSelection getClipboardDiagramSelection() throws DatabaseException { for (Set content : Simantics.getClipboard().getContents()) { DiagramSelection sel = ClipboardUtils.accept(content, DiagramSelectionRepresentation.KEY_DIAGRAM_SELECTION); if (sel != null) -- 2.47.1