bug 5425 fixed - Drag and drop of blocks between different scilab versions produced... 10/3810/2
Clément DAVID [Thu, 14 Apr 2011 12:21:21 +0000 (14:21 +0200)]
Change-Id: Ic033b045a89874d32adfcebabd1a3ace72ff37bd

scilab/CHANGES_5.3.X
scilab/modules/xcos/src/java/org/scilab/modules/xcos/graph/swing/handler/GraphHandler.java

index 17e6f45..ae4b413 100644 (file)
@@ -62,6 +62,9 @@ Xcos:
   - RAMP
   - DELAY_f
 
+* bug 5425 fixed - Drag and drop of blocks between different scilab versions
+                   produced an exception
+
 * bug 5605 fixed - REGISTER block was not present into the discrete palette.
 
 * bug 6416 fixed - GENSQR_f block documentation was not complete.
index 729867c..817f8c3 100644 (file)
 
 package org.scilab.modules.xcos.graph.swing.handler;
 
+import java.awt.datatransfer.DataFlavor;
 import java.awt.event.MouseEvent;
 import java.util.ArrayList;
 import java.util.List;
 
 import javax.swing.SwingUtilities;
 
+import org.apache.commons.logging.LogFactory;
 import org.scilab.modules.graph.ScilabGraph;
 import org.scilab.modules.xcos.block.BasicBlock;
 import org.scilab.modules.xcos.block.BlockFactory;
@@ -32,6 +34,7 @@ import org.scilab.modules.xcos.utils.XcosMessages;
 import com.mxgraph.model.mxGeometry;
 import com.mxgraph.model.mxIGraphModel;
 import com.mxgraph.swing.handler.mxGraphHandler;
+import com.mxgraph.swing.util.mxGraphTransferable;
 import com.mxgraph.util.mxPoint;
 import com.mxgraph.view.mxGraph;
 
@@ -41,6 +44,18 @@ import com.mxgraph.view.mxGraph;
 public class GraphHandler extends mxGraphHandler {
 
        /**
+        * Reduce the dropped data to JVM local transferable. 
+        */
+       static {
+               try {
+                       mxGraphTransferable.dataFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType
+                                             + "; class=com.mxgraph.swing.util.mxGraphTransferable");
+               } catch (ClassNotFoundException e) {
+                       LogFactory.getLog(GraphHandler.class).error(e);
+               }
+       }
+       
+       /**
         * Default constructor
         * 
         * @param graphComponent the graph