Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r945 - trunk/src/org/tigris/gef/base/SelectionManager.java

gef
Discussion topic

Back to topic list

svn commit: r945 - trunk/src/org/tigris/gef/base/SelectionManager.java

Author mashawl
Full name Mike Shawl
Date 2006-11-12 14:13:13 PST
Message Author: mashawl
Date: 2006-11-12 14:13:12-0800
New Revision: 945

Modified:
   trunk/src/org/tigris​/gef/base/SelectionM​anager.java

Log:
Enable Undo/Redo for dragging of Figs

Modified: trunk/src/org/tigris​/gef/base/SelectionM​anager.java
Url: http://gef.tigris.or​g/source/browse/gef/​trunk/src/org/tigris​/gef/base/SelectionM​anager.java?view=dif​f&rev=945&p1​=trunk/src/org/tigri​s/gef/base/Selection​Manager.java&p2=​trunk/src/org/tigris​/gef/base/SelectionM​anager.java&r1=9​44&r2=945
====================​====================​====================​==================
--- trunk/src/org/tigris​/gef/base/SelectionM​anager.java (original)
+++ trunk/src/org/tigris​/gef/base/SelectionM​anager.java 2006-11-12 14:13:12-0800
@@ -1060,10 +1060,15 @@
             
             Iterator boundsIt = bounds.iterator();
             
+ //Create an array to store each node's current boundaries
+ List oldBounds = new ArrayList(draggingNodes.size() + draggingOthers.size());
+
             Iterator nodeIt = draggingNodes.iterator();
             while (nodeIt.hasNext()) {
                 FigNode figNode = (FigNode)nodeIt.next();
                 Rectangle rect = (Rectangle)boundsIt.next();
+ //Save the current boundaries for redo
+ oldBounds.add(figNod​e.getBounds());
                 figNode.setBounds(rect);
                 figNode.damage();
             }
@@ -1072,16 +1077,26 @@
             while (otherIt.hasNext()) {
                 Fig fig = (Fig)otherIt.next();
                 Rectangle rect = (Rectangle)boundsIt.next();
+ //Save the current boundaries for redo
+ oldBounds.add(fig.getBounds());
                 fig.setBounds(rect);
                 fig.damage();
             }
             
+ //Set the undo boundaries to the boundaries we just replaced
+ bounds = oldBounds;
+
             Iterator pointsIt = points.iterator();
             
+ //Create an array to store each edge's current points
+ List oldPoints = new ArrayList(nonMovingEdges.size() + movingEdges.size());
+
             Iterator edgeIt = movingEdges.iterator();
             while (edgeIt.hasNext()) {
                 FigEdge figEdge = (FigEdge)edgeIt.next();
                 Point[] pts = (Point[])pointsIt.next();
+ //Save the current boundaries for redo
+ oldPoints.add(figEdg​e.getPoints());
                 figEdge.setPoints(pts);
                 figEdge.damage();
             }
@@ -1090,15 +1105,20 @@
             while (nMedgeIt.hasNext()) {
                 FigEdge figEdge = (FigEdge)nMedgeIt.next();
                 Point[] pts = (Point[])pointsIt.next();
+ //Save the current boundaries for redo
+ oldPoints.add(figEdg​e.getPoints());
                 figEdge.setPoints(pts);
                 figEdge.damage();
             }
             
+ //Set the undo points to the points we just replaced
+ points = oldPoints;
+
             UndoManager.getInsta​nce().setGenerateMem​entos(wasGenerateMem​entos);
         }
         public void redo() {
-// _fig.translate(dx, dy);
-// calcBounds();
+ //Simply undo the previous undo
+ undo();
         }
         
         public String toString() {

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r945 - trunk/src/org/tigris/gef/base/SelectionManager.java mashawl Mike Shawl 2006-11-12 14:13:13 PST
Messages per page: