From d4361a11a962437b51c72f51e1a913c089e4351e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Thu, 18 Oct 2018 14:58:26 +0300 Subject: [PATCH] Support Json content as drop data in Graphical Debugger gitlab #153 Change-Id: If756e157b7057534ea55a61745feb560904a64c0 --- .../src/org/simantics/debug/graphical/DebuggerCanvas.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/DebuggerCanvas.java b/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/DebuggerCanvas.java index 6430d029b..310d8a086 100644 --- a/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/DebuggerCanvas.java +++ b/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/DebuggerCanvas.java @@ -214,12 +214,11 @@ public class DebuggerCanvas extends JPanel { transferable.getTransferData(LocalObjectTransferable.FLAVOR); Object obj = LocalObjectTransfer.getTransfer().getObject(); handleDrop(dtde, obj); - - dtde.getDropTargetContext().dropComplete( true ); } else { DataFlavor textFlavor = DataFlavor.selectBestTextFlavor(transferable.getTransferDataFlavors()); if(textFlavor != null) { + // Try to read the textual content of the drop event as a JSON object containing a field named resourceId try(Reader reader = textFlavor.getReaderForText(transferable)) { ObjectMapper mapper = new ObjectMapper(); JsonNode node = mapper.readTree(reader); @@ -235,8 +234,6 @@ public class DebuggerCanvas extends JPanel { } })); handleDrop(dtde, obj); - - dtde.getDropTargetContext().dropComplete( true ); return; } } @@ -255,6 +252,8 @@ public class DebuggerCanvas extends JPanel { double x = canvasPosX+dtde.getLocation().getX()/canvasZoom; double y = canvasPosY+dtde.getLocation().getY()/canvasZoom; handleDrop(x, y, obj); + + dtde.getDropTargetContext().dropComplete( true ); } public void keyPressed(KeyEvent e) { -- 2.47.1