Revision: 3512
Author: [email protected]
Date: Fri May  7 08:33:40 2010
Log: Put the lid back on the can of worms that is changing the bounds so only the location is persisted. It turns out this will need some re-working of the UI components to be done correctly and have the UI still work correctly.
http://code.google.com/p/power-architect/source/detail?r=3512

Modified:
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/BasicRelationshipUI.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenComponent.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/olap/OLAPPaneUI.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java Thu May 6 15:50:49 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java Fri May 7 08:33:40 2010
@@ -19,91 +19,31 @@

 package ca.sqlpower.architect.enterprise;

-import java.beans.PropertyChangeEvent;
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;

 import ca.sqlpower.architect.ArchitectProject;
 import ca.sqlpower.architect.etl.kettle.KettleSettings;
 import ca.sqlpower.architect.olap.OLAPRootObject;
 import ca.sqlpower.architect.profile.ProfileManagerImpl;
-import ca.sqlpower.architect.swingui.PlayPenComponent;
-import ca.sqlpower.architect.swingui.PlayPenContentPane;
 import ca.sqlpower.dao.PersistedSPOProperty;
 import ca.sqlpower.dao.PersistedSPObject;
-import ca.sqlpower.dao.SPPersistenceException;
 import ca.sqlpower.dao.SPSessionPersister;
 import ca.sqlpower.dao.helper.AbstractSPPersisterHelper;
 import ca.sqlpower.dao.session.SessionPersisterSuperConverter;
-import ca.sqlpower.object.AbstractSPListener;
-import ca.sqlpower.object.SPChildEvent;
-import ca.sqlpower.object.SPListener;
 import ca.sqlpower.object.SPObject;
 import ca.sqlpower.sqlobject.SQLDatabase;
 import ca.sqlpower.sqlobject.SQLObjectRoot;
-import ca.sqlpower.util.SQLPowerUtils;

 /**
  * An architect specific persister.
  */
 public class ArchitectSessionPersister extends SPSessionPersister {

-    /**
- * This listener is only attached to the {...@link PlayPenContentPane} and it's
-     * children. It will cause the viewable components to revalidate after
-     * changes from the server since the persister has magic disabled while
- * making changes and the components only revalidate if magic is enabled.
-     */
- private final SPListener ppcRevalidateListener = new AbstractSPListener() {
-
-        public void childAdded(SPChildEvent e) {
-            if (e.getChild() instanceof PlayPenContentPane) {
-                e.getChild().addSPListener(this);
- for (PlayPenComponent ppc : ((PlayPenContentPane) e.getChild()).getChildren(PlayPenComponent.class)) {
-                    ppc.addSPListener(this);
-                }
-            } else if (e.getChild() instanceof PlayPenComponent) {
-                e.getChild().addSPListener(this);
-            }
-        }
-
-        public void childRemoved(SPChildEvent e) {
-            e.getChild().removeSPListener(this);
-        }
-
-        public void propertyChanged(PropertyChangeEvent evt) {
-            if (evt.getSource() instanceof PlayPenComponent) {
- componentsToRevalidate.add(((PlayPenComponent) evt.getSource()));
-            }
-        }
-
-    };
-
-    /**
- * This is the set of components that need to be revalidated at the end of
-     * a commit so they are revalidated when magic is enabled.
-     */
- private final Set<PlayPenComponent> componentsToRevalidate = new HashSet<PlayPenComponent>();
-
public ArchitectSessionPersister(String name, SPObject root, SessionPersisterSuperConverter converter) {
         super(name, root, converter);
-        SQLPowerUtils.listenToHierarchy(root, ppcRevalidateListener);
     }

-    @Override
-    public void commit() throws SPPersistenceException {
-        synchronized(getWorkspaceContainer().getWorkspace()) {
-            componentsToRevalidate.clear();
-            super.commit();
-            for (PlayPenComponent ppc : componentsToRevalidate) {
-                ppc.repaint();
-            }
-            componentsToRevalidate.clear();
-        }
-    }
-
     @Override
     protected void refreshRootNode(PersistedSPObject pso) {
         root.setUUID(pso.getUUID());
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/BasicRelationshipUI.java Thu May 6 15:50:49 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/BasicRelationshipUI.java Fri May 7 08:33:40 2010
@@ -118,7 +118,7 @@
        public void revalidate() {
            Rectangle OldBounds = computedBounds;
            Rectangle bounds = computeBounds();
- if (computedBounds.x != OldBounds.x || computedBounds.y != OldBounds.y) {
+           if (!computedBounds.equals(OldBounds)) {
relationship.setBounds(bounds.x,bounds.y,bounds.width,bounds.height);
            }
        }
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenComponent.java Thu May 6 15:50:49 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenComponent.java Fri May 7 08:33:40 2010
@@ -226,6 +226,8 @@
                 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$
                 setMagicEnabled(true);
@@ -354,26 +356,7 @@
      */
     @Transient @Mutator
     public void setLocation(Point point) {
-        Point oldLocation = bounds.getLocation();
-
-        int width = getWidth();
-        int height = getHeight();
-
-        if (getPlayPen() != null) {
-            PlayPenComponentUI ui = getUI();
-
-            if (ui != null) {
-                ui.revalidate();
-                Dimension ps = ui.getPreferredSize();
-                if (ps != null) {
-                    width = ps.width;
-                    height = ps.height;
-                }
-            }
-        }
-
-        setBounds(point.x,point.y, width, height);
-        firePropertyChange("location", oldLocation, point);
+        setBounds(point.x,point.y, getWidth(), getHeight());
     }

     /**
@@ -383,7 +366,7 @@
      */
     @Transient @Mutator
     public void setLocation(int x, int y) {
-        setLocation(new Point(x, y));
+               setBounds(x, y, getWidth(), getHeight());
     }

     @NonBound
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java Tue May 4 14:26:07 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java Fri May 7 08:33:40 2010
@@ -149,10 +149,6 @@
         if (owner != null) {
owner.addPropertyChangeListener("zoom", new ZoomFixer()); //$NON-NLS-1$
             firePropertyChange("playPen", null, owner);
-
-            for (PlayPenComponent ppc : getChildren()) {
-                ppc.revalidate();
-            }
         }
     }

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/olap/OLAPPaneUI.java Thu May 6 15:50:49 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/olap/OLAPPaneUI.java Fri May 7 08:33:40 2010
@@ -283,6 +283,7 @@
     }

     public void revalidate() {
+        olapPane.setSize(getPreferredSize());
     }

     /**

Reply via email to