API compatibility with jgraphx-1.2.0.5
Clément DAVID [Mon, 11 Jan 2010 14:43:59 +0000 (15:43 +0100)]
Conflicts:

scilab/modules/xcos/src/java/org/scilab/modules/graph/ScilabGraph.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/graph/XcosDiagram.java

scilab/modules/xcos/src/java/org/scilab/modules/graph/ScilabGraph.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/BasicBlock.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/SuperBlock.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/io/EventInBlock.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/io/EventOutBlock.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/io/ExplicitInBlock.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/io/ExplicitOutBlock.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/io/ImplicitInBlock.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/io/ImplicitOutBlock.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/graph/XcosDiagram.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/palette/XcosPalette.java

index 5d8023d..167f8a8 100644 (file)
@@ -74,7 +74,7 @@ public class ScilabGraph extends mxGraph {
 
                        if (!redoInAction) {
                                undoManager.undoableEditHappened((mxUndoableEdit) evt
-                                               .getArgAt(0));
+                                               .getProperty("edit"));
                                incrementUndoCounter();
                        }
                }
@@ -85,8 +85,7 @@ public class ScilabGraph extends mxGraph {
         */
        private mxIEventListener selectionHandler = new mxIEventListener() {
                public void invoke(Object source, mxEventObject evt) {
-                       List<mxUndoableChange> changes = ((mxUndoableEdit) evt.getArgAt(0))
-                                       .getChanges();
+                       List<mxUndoableChange> changes = ((mxUndoableEdit) evt.getProperty("edit")).getChanges();
                        setSelectionCells(getSelectionCellsForChanges(changes));
                }
        };
@@ -195,10 +194,13 @@ public class ScilabGraph extends mxGraph {
         * Redo the last action com.mxgraph.util.mxUndoManager
         */
        public void redo() {
+           if (!redoInAction) {
+
                incrementUndoCounter();
                redoInAction = true;
                undoManager.redo();
                redoInAction = false;
+           }
        }
 
        /**
index 56a7cd6..f0dbf6b 100644 (file)
@@ -516,7 +516,7 @@ public class BasicBlock extends XcosUIDObject {
         */
        if (getParentDiagram() instanceof SuperBlockDiagram) {
            SuperBlock parentBlock = ((SuperBlockDiagram) getParentDiagram()).getContainer();
-           parentBlock.getParentDiagram().fireEvent(XcosEvent.SUPER_BLOCK_UPDATED,new mxEventObject(new Object[] { parentBlock }));
+           parentBlock.getParentDiagram().fireEvent(new mxEventObject(XcosEvent.SUPER_BLOCK_UPDATED, "block", parentBlock));
        }
        
     }
@@ -559,7 +559,7 @@ public class BasicBlock extends XcosUIDObject {
                                        // Now read new Block
                                    BasicBlock modifiedBlock = BlockReader.readBlockFromFile(tempInput.getAbsolutePath());
                                    updateBlockSettings(modifiedBlock);
-                                   getParentDiagram().fireEvent(XcosEvent.ADD_PORTS, new mxEventObject(new Object[] {currentBlock}));
+                                   getParentDiagram().fireEvent(new mxEventObject(XcosEvent.ADD_PORTS, "block", currentBlock));
                                    setLocked(false);
                                }
                        });
index ba87c43..0a677e0 100644 (file)
@@ -431,8 +431,7 @@ public final class SuperBlock extends BasicBlock {
                updateExportedExplicitOutputPort();
                updateExportedImplicitOutputPort();
                updateExportedEventOutputPort();
-               getParentDiagram().fireEvent(XcosEvent.SUPER_BLOCK_UPDATED,
-                               new mxEventObject(new Object[] { this }));
+               getParentDiagram().fireEvent(new mxEventObject(XcosEvent.SUPER_BLOCK_UPDATED, "block", this));
        }
 
        private void updateExportedExplicitInputPort() {
index 1413fb6..5361279 100644 (file)
@@ -56,7 +56,7 @@ public final class EventInBlock extends ContextUpdate {
        double newValue = ((ScilabDouble)getIntegerParameters()).getRealPart()[0][0];
 
        if(oldValue != newValue){
-           getParentDiagram().fireEvent(XcosEvent.IN_EVENT_VALUE_UPDATED, new mxEventObject(new Object[]{oldValue,newValue}));
+           getParentDiagram().fireEvent(new mxEventObject(XcosEvent.IN_EVENT_VALUE_UPDATED, "old", oldValue, "new", newValue));
        }
     }
 
index 679eec6..98d3300 100644 (file)
@@ -56,7 +56,7 @@ public final class EventOutBlock extends ContextUpdate {
        double newValue = ((ScilabDouble)getIntegerParameters()).getRealPart()[0][0];
 
        if(oldValue != newValue){
-           getParentDiagram().fireEvent(XcosEvent.OUT_EVENT_VALUE_UPDATED, new mxEventObject(new Object[]{oldValue,newValue}));
+           getParentDiagram().fireEvent(new mxEventObject(XcosEvent.OUT_EVENT_VALUE_UPDATED, "old", oldValue, "new", newValue));
        }
     }
 
index 28f7190..1992806 100644 (file)
@@ -55,7 +55,7 @@ public final class ExplicitInBlock extends ContextUpdate {
        double newValue = ((ScilabDouble)getIntegerParameters()).getRealPart()[0][0];
 
        if(oldValue != newValue){
-           getParentDiagram().fireEvent(XcosEvent.IN_EXPLICIT_VALUE_UPDATED, new mxEventObject(new Object[]{oldValue,newValue}));
+           getParentDiagram().fireEvent(new mxEventObject(XcosEvent.IN_EXPLICIT_VALUE_UPDATED, "old", oldValue, "new", newValue));
        }
     }
 
index 6d8525f..9ff6574 100644 (file)
@@ -56,7 +56,7 @@ public final class ExplicitOutBlock extends ContextUpdate {
        double newValue = ((ScilabDouble)getIntegerParameters()).getRealPart()[0][0];
 
        if(oldValue != newValue){
-           getParentDiagram().fireEvent(XcosEvent.OUT_EXPLICIT_VALUE_UPDATED, new mxEventObject(new Object[]{oldValue,newValue}));
+           getParentDiagram().fireEvent(new mxEventObject(XcosEvent.OUT_EXPLICIT_VALUE_UPDATED, "old", oldValue, "new", newValue));
        }
     }
 
index 1b4bdbb..b31a07d 100644 (file)
@@ -56,7 +56,7 @@ public final class ImplicitInBlock extends ContextUpdate {
                double newValue = ((ScilabDouble)getIntegerParameters()).getRealPart()[0][0];
 
                if(oldValue != newValue){
-                   getParentDiagram().fireEvent(XcosEvent.IN_IMPLICIT_VALUE_UPDATED, new mxEventObject(new Object[]{oldValue,newValue}));
+                   getParentDiagram().fireEvent(new mxEventObject(XcosEvent.IN_IMPLICIT_VALUE_UPDATED, "old", oldValue, "new", newValue));
                }
            }
 
index 59c3e29..ede1a5a 100644 (file)
@@ -56,7 +56,7 @@ public final class ImplicitOutBlock extends ContextUpdate {
        double newValue = ((ScilabDouble)getIntegerParameters()).getRealPart()[0][0];
 
        if(oldValue != newValue){
-           getParentDiagram().fireEvent(XcosEvent.OUT_IMPLICIT_VALUE_UPDATED, new mxEventObject(new Object[]{oldValue,newValue}));
+           getParentDiagram().fireEvent(new mxEventObject(XcosEvent.OUT_IMPLICIT_VALUE_UPDATED, "old", oldValue, "new", newValue));
        }
     }
 
index 6249dfd..85e3088 100644 (file)
@@ -107,6 +107,7 @@ import com.mxgraph.model.mxGraphModel;
 import com.mxgraph.model.mxICell;
 import com.mxgraph.model.mxGraphModel.mxChildChange;
 import com.mxgraph.model.mxGraphModel.mxStyleChange;
+import com.mxgraph.model.mxIGraphModel.mxAtomicGraphModelChange;
 import com.mxgraph.util.mxEvent;
 import com.mxgraph.util.mxEventObject;
 import com.mxgraph.util.mxPoint;
@@ -621,7 +622,7 @@ public class XcosDiagram extends ScilabGraph {
            public void invoke(Object source, mxEventObject evt) {
                getModel().beginUpdate();
                refresh();
-               BasicBlock updatedBlock = (BasicBlock) evt.getArgAt(0);
+               BasicBlock updatedBlock = (BasicBlock) evt.getProperty("block");
                BlockPositioning.updateBlockView(updatedBlock);
                getModel().endUpdate();
            }
@@ -635,7 +636,7 @@ public class XcosDiagram extends ScilabGraph {
      */
     private class ModelTracker implements mxIEventListener {
        public void invoke(Object source, mxEventObject evt) {
-           List<mxUndoableChange> changes = (List<mxUndoableChange>) evt.getArgAt(0);
+           List<mxAtomicGraphModelChange> changes = (List<mxAtomicGraphModelChange>) (evt.getProperty("changes"));
            List<Object> objects = new ArrayList<Object>();
            getModel().beginUpdate();
            for (int i = 0; i < changes.size(); ++i) {
@@ -656,7 +657,7 @@ public class XcosDiagram extends ScilabGraph {
                    firedCells[j] = objects.get(j);
                }
                //fireEvent(XcosEvent.FORCE_CELL_RESHAPE, new mxEventObject(new Object[] {firedCells}));
-               fireEvent(XcosEvent.FORCE_CELL_VALUE_UPDATE, new mxEventObject(new Object[] {firedCells}));
+               fireEvent(new mxEventObject(XcosEvent.FORCE_CELL_VALUE_UPDATE, "cells", firedCells));
            }
            getModel().endUpdate();
        }
@@ -667,7 +668,7 @@ public class XcosDiagram extends ScilabGraph {
      */
     private class ForceCellValueUpdate implements mxIEventListener {
        public void invoke(Object source, mxEventObject evt) {
-           Object[] cells = (Object[]) evt.getArgs()[0];
+           Object[] cells = (Object[]) evt.getProperty("cells");
 
            getModel().beginUpdate();
 
@@ -695,22 +696,41 @@ public class XcosDiagram extends ScilabGraph {
     }
     
     /**
+<<<<<<< HEAD:scilab/modules/xcos/src/java/org/scilab/modules/xcos/graph/XcosDiagram.java
+=======
+     *  ForceCellReshapeTracker
+     *  Called when we want a Block to reshape for it's ports positions.
+     */
+    private class ForceCellReshapeTracker implements mxIEventListener {
+       public void invoke(Object source, mxEventObject evt) {
+           Object[] cells =  (Object[]) evt.getProperty("cells");
+           getModel().beginUpdate();
+           for (int i = 0; i <  cells.length; ++i) {
+               Object cell = cells[i];
+               if (cell instanceof BasicBlock) {
+                   BlockPositioning.updateBlockView((BasicBlock) cell);
+               }
+           }
+           getModel().endUpdate();
+       }
+    }
+    
+    /**
+>>>>>>> e48febf... API compatibility with jgraphx-1.2.0.5:scilab/modules/xcos/src/java/org/scilab/modules/xcos/graph/XcosDiagram.java
      *  SuperBlockUpdateTracker
      *  Called when adding some port in a SuperBlock diagram
      *  to update current sub-diagram (i.e SuperBlock) representation.
      */
     private class SuperBlockUpdateTracker implements mxIEventListener {
        public void invoke(Object source, mxEventObject evt) {
-           assert evt.getArgs()[0] instanceof SuperBlock;
-           SuperBlock updatedBlock = (SuperBlock) evt.getArgs()[0];
+           assert evt.getProperty("block") instanceof SuperBlock;
+           SuperBlock updatedBlock = (SuperBlock) evt.getProperty("block");
            updatedBlock.setRealParameters(BlockWriter
                    .convertDiagramToMList(updatedBlock.getChild()));
            if (updatedBlock.getParentDiagram() instanceof SuperBlockDiagram) {
                SuperBlock parentBlock = ((SuperBlockDiagram) updatedBlock
                        .getParentDiagram()).getContainer();
-               parentBlock.getParentDiagram().fireEvent(
-                       XcosEvent.SUPER_BLOCK_UPDATED,
-                       new mxEventObject(new Object[] { parentBlock }));
+               parentBlock.getParentDiagram().fireEvent(new mxEventObject(XcosEvent.SUPER_BLOCK_UPDATED, "block", parentBlock));
            }
            BlockPositioning.updateBlockView(updatedBlock);
            refresh();
@@ -729,7 +749,7 @@ public class XcosDiagram extends ScilabGraph {
        }
 
        public void invoke(Object source, mxEventObject evt) {
-               Object[] cells = (Object[]) evt.getArgs()[0];
+               Object[] cells = (Object[]) evt.getProperty("cells");
                
                diagram.getModel().beginUpdate();
                for (int i = 0; i < cells.length; ++i) {
@@ -760,7 +780,7 @@ public class XcosDiagram extends ScilabGraph {
        }
 
        public void invoke(Object source, mxEventObject evt) {
-           Object[] cells = (Object[]) evt.getArgs()[0];
+           Object[] cells = (Object[]) evt.getProperty("cells");
            for (int i = 0; i < cells.length; i++) {
                if (cells[i] instanceof BasicLink) {
                    BasicLink link = (BasicLink) cells[i];
@@ -878,7 +898,7 @@ public class XcosDiagram extends ScilabGraph {
      */
     private class CellResizedTracker implements mxIEventListener {
        public void invoke(Object source, mxEventObject evt) {
-           Object[] cells = (Object[]) evt.getArgs()[0];
+           Object[] cells = (Object[]) evt.getProperty("cells");
            getModel().beginUpdate();
            for (int i = 0; i < cells.length; ++i) {
                if (cells[i] instanceof BasicBlock) {
@@ -894,7 +914,7 @@ public class XcosDiagram extends ScilabGraph {
      */
    private class UndoUpdateTracker implements mxIEventListener {
         public void invoke(Object source, mxEventObject evt) {
-            List<mxUndoableChange> changes = ((mxUndoableEdit) evt.getArgAt(0)).getChanges();
+            List<mxUndoableChange> changes = ((mxUndoableEdit) evt.getProperty("edit")).getChanges();
             Object[] changedCells = getSelectionCellsForChanges(changes);
             getModel().beginUpdate();
             for (Object object : changedCells) {
@@ -1706,7 +1726,7 @@ public class XcosDiagram extends ScilabGraph {
        //getParentTab().setName((String) properties.get("title"));
 
        // Clear all undo events in Undo Manager
-       getUndoManager().reset();
+       getUndoManager().clear();
        setModified(false);
     }
 
@@ -2048,7 +2068,7 @@ public class XcosDiagram extends ScilabGraph {
      * This function will reset the UndoManager in a stable state.
      */
     public void resetUndoManager() {
-       getUndoManager().reset();
+       getUndoManager().clear();
 
        resetUndoCounter();
 
index 165e705..3438a96 100644 (file)
@@ -187,8 +187,8 @@ public class XcosPalette extends JScrollPane implements ComponentListener {
            selectedEntry.setOpaque(true);
        }
 
-       eventSource.fireEvent(mxEvent.SELECT, new mxEventObject(new Object[] {
-               selectedEntry, t, last }));
+       eventSource.fireEvent(new mxEventObject(mxEvent.SELECT, "entry",
+                       selectedEntry, "transferable", t, "previous", last));
     }