Revision: 3389
Author: silva.josemanuel1
Date: Mon Mar 22 07:16:15 2010
Log: Fixed auto-layout bug by making sure when PlayPenComponents are being revalidated, the revalidation call is only done once, and not multiple times by subsequent property changes.
http://code.google.com/p/power-architect/source/detail?r=3389

Modified:
 /trunk/src/ca/sqlpower/architect/swingui/BasicRelationshipUI.java
 /trunk/src/ca/sqlpower/architect/swingui/PlayPenComponent.java
 /trunk/src/ca/sqlpower/architect/swingui/Relationship.java

=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/BasicRelationshipUI.java Wed Mar 17 14:29:59 2010 +++ /trunk/src/ca/sqlpower/architect/swingui/BasicRelationshipUI.java Mon Mar 22 07:16:15 2010
@@ -985,7 +985,7 @@
         * correct.  A more sophisticated implementation is warranted when
         * time allows.
         */
-       public boolean isOrientationLegal() {
+       public boolean isOrientationLegal() {
            Point fkConnectionPoint = relationship.getFkConnectionPoint();
            Point pkConnectionPoint = relationship.getPkConnectionPoint();

=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/PlayPenComponent.java Wed Mar 17 14:29:59 2010 +++ /trunk/src/ca/sqlpower/architect/swingui/PlayPenComponent.java Mon Mar 22 07:16:15 2010
@@ -181,14 +181,20 @@
             return;
         } else {
             Rectangle r = new Rectangle(bounds);
-            if (isMagicEnabled()) {
+            if (isMagicEnabled()) {
+                // This temporary disabling of magic is under the
+                // assumption that this method properly revalidates
+                // the component in one pass, and does not rely
+                // on recursive calls due to magical side effects
+                setMagicEnabled(false);
                 PlayPenComponentUI ui = getUI();
                 if (ui != null) {
                     ui.revalidate();
                     Dimension ps = ui.getPreferredSize();
                     if (ps != null) setSize(ps);
                 }
- if (logger.isDebugEnabled()) logger.debug("Scheduling repaint at "+r); //$NON-NLS-1$ + if (logger.isDebugEnabled()) logger.debug("Scheduling repaint at "+r); //$NON-NLS-1$
+                setMagicEnabled(true);
             }
             pp.zoomRect(r);
             pp.repaint(r);
=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/Relationship.java Wed Mar 17 14:29:59 2010 +++ /trunk/src/ca/sqlpower/architect/swingui/Relationship.java Mon Mar 22 07:16:15 2010
@@ -403,8 +403,8 @@

        @Mutator
        public void setFkConnectionPoint(Point p) {
-           Point oldValue = new Point(fkConnectionPoint);
-               fkConnectionPoint = new Point(p);
+           Point oldValue = new Point(fkConnectionPoint);
+           fkConnectionPoint = new Point(p);
                firePropertyChange("fkConnectionPoint", oldValue, new Point(p));
        }

@@ -415,7 +415,7 @@
             /* (non-Javadoc)
* @see ca.sqlpower.architect.swingui.PlayPenComponentListener#componentResized(ca.sqlpower.architect.swingui.PlayPenComponentEvent)
              */
-            if (evt.getPropertyName().equals("bounds")) {
+ if (evt.getPropertyName().equals("bounds") && isMagicEnabled()) { logger.debug("Component "+((PlayPenComponent)(evt.getSource())).getName()+" changed size"); //$NON-NLS-1$ //$NON-NLS-2$
                 if (((PlayPenComponent)(evt.getSource())) == pkTable) {
setPkConnectionPoint(((RelationshipUI) getUI()).closestEdgePoint(true, getPkConnectionPoint())); // true == PK
@@ -428,8 +428,7 @@
                 Rectangle newVal = (Rectangle) evt.getNewValue();
                 if(oldVal.x != newVal.x || oldVal.y != newVal.y) {
logger.debug("Component "+((PlayPenComponent)(evt.getSource())).getName()+" moved"); //$NON-NLS-1$ //$NON-NLS-2$ - if (((PlayPenComponent)(evt.getSource())) == pkTable | | ((PlayPenComponent)(evt.getSource())) == fkTable
-                            && isMagicEnabled()) {
+ if (((PlayPenComponent)(evt.getSource())) == pkTable | | ((PlayPenComponent)(evt.getSource())) == fkTable) {
                         ((BasicRelationshipUI) getUI()).revalidate();
                     }
                 }

To unsubscribe from this group, send email to 
architect-commits+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to