Support Json content as drop data in Graphical Debugger 33/2333/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Thu, 18 Oct 2018 11:58:26 +0000 (14:58 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Thu, 18 Oct 2018 11:58:26 +0000 (14:58 +0300)
gitlab #153

Change-Id: If756e157b7057534ea55a61745feb560904a64c0

bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/DebuggerCanvas.java

index 6430d029beca6185d922dddd3e9a1bc41a4d3bb8..310d8a0865e824cfc8b0f6e51dd26af1bf41c78b 100644 (file)
@@ -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) {