Revision: 3502
Author: [email protected]
Date: Thu May 6 09:12:07 2010
Log: Fixed an exception where the relationships were not loading correctly.
The problem was only the location and not the bounds
of any play pen component were being persisted by a recent change. Now the
location and size of the PPCs are always stored
but container pane overrides the size to not persist it.
The revalidate on persist calls from the server has been updated to have
the revalidate come later at a better time.
http://code.google.com/p/power-architect/source/detail?r=3502
Modified:
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/ContainerPane.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenComponent.java
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
Wed May 5 12:48:15 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
Thu May 6 09:12:07 2010
@@ -49,10 +49,11 @@
import ca.sqlpower.architect.ArchitectSessionContext;
import ca.sqlpower.architect.ArchitectSessionImpl;
import ca.sqlpower.architect.ddl.DDLGenerator;
+import
ca.sqlpower.architect.enterprise.NetworkConflictResolver.UpdateListener;
import ca.sqlpower.architect.swingui.ArchitectSwingSessionContext;
+import ca.sqlpower.architect.swingui.PlayPenComponent;
import ca.sqlpower.dao.SPPersistenceException;
import ca.sqlpower.dao.SPPersisterListener;
-import ca.sqlpower.dao.SPSessionPersister;
import ca.sqlpower.dao.json.SPJSONMessageDecoder;
import ca.sqlpower.dao.json.SPJSONPersister;
import ca.sqlpower.dao.session.SessionPersisterSuperConverter;
@@ -110,7 +111,7 @@
* The persister that will update the project in this session with
changes from
* the server.
*/
- private final SPSessionPersister sessionPersister;
+ private final ArchitectSessionPersister sessionPersister;
/**
* Used to convert JSON sent from the server into persist calls to
forward the
@@ -131,6 +132,34 @@
securitySessions = new HashMap<String,
ArchitectClientSideSession>();
}
+ /**
+ * Calls revalidate on all UI components changed in the last commit
since this
+ * must be done at a point when magic is enabled again so the
revalidate
+ * actually takes effect.
+ */
+ private final UpdateListener revalidateUIComponentsListener = new
UpdateListener() {
+
+ public void workspaceDeleted() {
+ //do nothing
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean updatePerformed(NetworkConflictResolver resolver) {
+ for (PlayPenComponent cp :
sessionPersister.getComponentsToRevalidate()) {
+ cp.revalidate();
+ }
+ return false;
+ }
+
+ public boolean updateException(NetworkConflictResolver resolver) {
+ //do nothing
+ return false;
+ }
+
+ public void preUpdatePerformed(NetworkConflictResolver resolver) {
+ //do nothing
+ }
+ };
public ArchitectClientSideSession(ArchitectSessionContext context,
String name, ProjectLocation projectLocation) throws SQLObjectException
{
@@ -169,6 +198,8 @@
createHttpClient(projectLocation.getServiceInfo()),
outboundHttpClient, this);
+ updater.addListener(revalidateUIComponentsListener);
+
jsonPersister = new SPJSONPersister(updater);
}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java
Wed May 5 12:48:15 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java
Thu May 6 09:12:07 2010
@@ -21,6 +21,7 @@
import java.beans.PropertyChangeEvent;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -91,16 +92,22 @@
super(name, root, converter);
SQLPowerUtils.listenToHierarchy(root, ppcRevalidateListener);
}
+
+ /**
+ * Returns a collection of components that were updated by the
+ * last commit to the server. These components may need to be
revalidated as
+ * they are used to display the UI.
+ */
+ public Set<PlayPenComponent> getComponentsToRevalidate() {
+ return Collections.unmodifiableSet(componentsToRevalidate);
+ }
+
@Override
public void commit() throws SPPersistenceException {
synchronized(getWorkspaceContainer().getWorkspace()) {
componentsToRevalidate.clear();
super.commit();
- for (PlayPenComponent ppc : componentsToRevalidate) {
- ppc.revalidate();
- }
- componentsToRevalidate.clear();
}
}
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ContainerPane.java
Wed Apr 7 12:43:35 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ContainerPane.java
Thu May 6 09:12:07 2010
@@ -20,6 +20,7 @@
package ca.sqlpower.architect.swingui;
import java.awt.Color;
+import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
@@ -654,4 +655,16 @@
public String getNodeName() {
return getName();
}
-}
+
+ @Transient @Accessor
+ @Override
+ public Dimension getSize() {
+ return super.getSize();
+ }
+
+ @Transient @Mutator
+ @Override
+ public void setSize(Dimension size) {
+ super.setSize(size);
+ }
+}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenComponent.java
Tue May 4 14:26:07 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenComponent.java
Thu May 6 09:12:07 2010
@@ -62,8 +62,13 @@
private static final Logger logger =
Logger.getLogger(PlayPenComponent.class);
public static final List<Class<? extends SPObject>> allowedChildTypes
= Collections.emptyList();
-
- private Rectangle bounds = new Rectangle();
+
+ /**
+ * The top left point of the component.
+ */
+ private Point location = new Point();
+ private Dimension size = new Dimension();
+
private Dimension minimumSize = new Dimension();
protected Color backgroundColor;
protected Color foregroundColor;
@@ -135,8 +140,11 @@
protected PlayPenComponent(PlayPenComponent copyMe, PlayPenContentPane
parent) {
this(copyMe.getName(), parent);
backgroundColor = copyMe.backgroundColor;
- if (copyMe.bounds != null) {
- bounds = new Rectangle(copyMe.bounds);
+ if (copyMe.location != null) {
+ location = new Point(copyMe.location);
+ }
+ if (copyMe.size != null) {
+ size = new Dimension(copyMe.size);
}
componentPreviouslySelected = copyMe.componentPreviouslySelected;
foregroundColor = copyMe.foregroundColor;
@@ -216,7 +224,7 @@
logger.debug("getPlayPen() returned null. Not generating
repaint request."); //$NON-NLS-1$
return;
} else {
- Rectangle r = new Rectangle(bounds);
+ Rectangle r = new Rectangle(location.x, location.y,
size.width, size.height);
if (isMagicEnabled()) {
// This temporary disabling of magic is under the
// assumption that this method properly revalidates
@@ -262,8 +270,10 @@
+" to ["+r.x+","+r.y+","+r.width+","+r.height+"]");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
- bounds.setBounds(r.x,r.y,r.width,r.height);
- firePropertyChange("bounds", oldBounds, new Rectangle(bounds));
+ setLocation(r.x, r.y);
+ setSize(new Dimension(r.width, r.height));
+ firePropertyChange("bounds", oldBounds, new
Rectangle(getLocation().x, getLocation().y,
+ getSize().width, getSize().height));
repaint();
}
@@ -310,13 +320,13 @@
@NonBound
public Rectangle getBounds(Rectangle r) {
if (r == null) r = new Rectangle();
- r.setBounds(bounds);
+ r.setBounds(getLocation().x, getLocation().y, getSize().width,
getSize().height);
return r;
}
- @Transient @Accessor(isInteresting=true)
+ @Accessor(isInteresting=true)
public Dimension getSize() {
- return new Dimension(bounds.width, bounds.height);
+ return new Dimension(size);
}
/**
@@ -344,8 +354,8 @@
@Accessor
public Point getLocation(Point p) {
if (p == null) p = new Point();
- p.x = bounds.x;
- p.y = bounds.y;
+ p.x = location.x;
+ p.y = location.y;
return p;
}
@@ -356,26 +366,31 @@
*/
@Mutator
public void setLocation(Point point) {
- Point oldLocation = bounds.getLocation();
+ Point oldLocation = location;
+ repaint();
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;
+ if (isMagicEnabled()) {
+ if (getPlayPen() != null) {
+ PlayPenComponentUI ui = getUI();
+
+ if (ui != null) {
+ ui.revalidate();
+ Dimension ps = ui.getPreferredSize();
+ if (ps != null) {
+ width = ps.width;
+ height = ps.height;
+ }
}
}
+ setSize(new Dimension(width, height));
}
- setBounds(point.x,point.y, width, height);
+ location = new Point(point.x, point.y);
firePropertyChange("location", oldLocation, point);
+ repaint();
}
/**
@@ -395,9 +410,11 @@
return (oldVal.x != newVal.x || oldVal.y != newVal.y);
}
- @Transient @Mutator
+ @Mutator
public void setSize(Dimension size) {
- setBounds(getX(), getY(), size.width, size.height);
+ Dimension oldSize = this.size;
+ this.size = new Dimension(size);
+ firePropertyChange("size", oldSize, this.size);
}
/**
@@ -424,22 +441,22 @@
@Transient @Accessor
public int getX() {
- return bounds.x;
+ return getLocation().x;
}
@Transient @Accessor
public int getY() {
- return bounds.y;
+ return getLocation().y;
}
@Transient @Accessor
public int getWidth() {
- return bounds.width;
+ return getSize().width;
}
@Transient @Accessor
public int getHeight() {
- return bounds.height;
+ return getSize().height;
}
@Transient @Accessor