From: Hannu Niemistö Date: Thu, 18 Oct 2018 11:58:26 +0000 (+0300) Subject: Support Json content as drop data in Graphical Debugger X-Git-Tag: v1.43.0~136^2~320^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F33%2F2333%2F1;p=simantics%2Fplatform.git Support Json content as drop data in Graphical Debugger gitlab #153 Change-Id: If756e157b7057534ea55a61745feb560904a64c0 --- 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) {