Revision: 3622
Author: [email protected]
Date: Mon Jun 14 12:44:23 2010
Log: The PlayPenContentPane's model object is now final. This makes working with the content pane more simpler and fixes tests.
http://code.google.com/p/power-architect/source/detail?r=3622

Modified:
 /trunk/regress/ca/sqlpower/architect/swingui/TestPlayPenContentPane.java
 /trunk/regress/ca/sqlpower/architect/undo/TestArchitectUndoManager.java
 /trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java

=======================================
--- /trunk/regress/ca/sqlpower/architect/swingui/TestPlayPenContentPane.java Tue Apr 6 14:44:35 2010 +++ /trunk/regress/ca/sqlpower/architect/swingui/TestPlayPenContentPane.java Mon Jun 14 12:44:23 2010
@@ -25,6 +25,7 @@
 import ca.sqlpower.object.SPObject;
 import ca.sqlpower.sql.DataSourceCollection;
 import ca.sqlpower.sql.SPDataSource;
+import ca.sqlpower.sqlobject.SQLDatabase;
 import ca.sqlpower.sqlobject.SQLRelationship;
 import ca.sqlpower.sqlobject.SQLTable;
 import ca.sqlpower.testutil.NewValueMaker;
@@ -63,7 +64,7 @@
                pp.addTablePane(tp2, new Point(-10,0));
                SQLRelationship sqlrel = new SQLRelationship();
                sqlrel.attachRelationship(t1, t2, false);
-               ppcp = new PlayPenContentPane();
+               ppcp = new PlayPenContentPane(new SQLDatabase());
                ppcp.setPlayPen(pp);
                rel1 = new Relationship(sqlrel,pp.getContentPane());
                rel2 = new Relationship(sqlrel,pp.getContentPane());
=======================================
--- /trunk/regress/ca/sqlpower/architect/undo/TestArchitectUndoManager.java Tue Apr 6 14:44:35 2010 +++ /trunk/regress/ca/sqlpower/architect/undo/TestArchitectUndoManager.java Mon Jun 14 12:44:23 2010
@@ -190,7 +190,7 @@
      * Tests PropertyChangeEdit functionalities
      */
     public void testPropertyChangeEdit() {
- TestPlayPenComp comp = new TestPlayPenComp(new PlayPenContentPane()); + TestPlayPenComp comp = new TestPlayPenComp(new PlayPenContentPane(new SQLDatabase())); PropertyChangeEvent e = new PropertyChangeEvent(comp, "bounds", null, null);
         PropertyChangeEdit edit = new PropertyChangeEdit(e);
         assertEquals("property change edit", edit.getPresentationName());
@@ -230,7 +230,7 @@
         TestSQLObject testObject = new TestSQLObject();
ArchitectUndoManager undoManager = new ArchitectUndoManager(testObject);
         final PropertyChangeListener l = undoManager.getEventAdapter();
- TestPlayPenComp comp = new TestPlayPenComp(new PlayPenContentPane()); + TestPlayPenComp comp = new TestPlayPenComp(new PlayPenContentPane(new SQLDatabase()));
         comp.addSPListener(new AbstractSPListener() {
             public void propertyChanged(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("bounds") && PlayPenComponent.isLocationChange(evt)) {
@@ -260,7 +260,7 @@
         TestSQLObject testObject = new TestSQLObject();
ArchitectUndoManager undoManager = new ArchitectUndoManager(testObject);
         final PropertyChangeListener l = undoManager.getEventAdapter();
- TestPlayPenComp comp = new TestPlayPenComp(new PlayPenContentPane()); + TestPlayPenComp comp = new TestPlayPenComp(new PlayPenContentPane(new SQLDatabase()));
         comp.addSPListener(new AbstractSPListener() {
             public void propertyChanged(PropertyChangeEvent evt) {
                 if (evt.getPropertyName().equals("connectionPoints")) {
=======================================
--- /trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java Wed Jun 9 10:52:12 2010 +++ /trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java Mon Jun 14 12:44:23 2010
@@ -47,6 +47,7 @@
 import ca.sqlpower.sql.PlDotIni;
 import ca.sqlpower.sql.SPDataSource;
 import ca.sqlpower.sqlobject.SQLColumn;
+import ca.sqlpower.sqlobject.SQLDatabase;
 import ca.sqlpower.sqlobject.SQLObjectException;
 import ca.sqlpower.sqlobject.SQLTable;
 import ca.sqlpower.testutil.GenericNewValueMaker;
@@ -65,7 +66,7 @@
         super(root, dsCollection);
         mondrianValueMaker = new MondrianNewValueMaker(root, dsCollection);
valueMakerProject = (ArchitectSwingProject) makeNewValue(ArchitectSwingProject.class, null, null);
-        valueMakerProject.setPlayPenContentPane(new PlayPenContentPane());
+ valueMakerProject.setPlayPenContentPane(new PlayPenContentPane(new SQLDatabase()));
     }

     @Override
@@ -119,7 +120,7 @@
             valueMakerProject.setProfileManager(profileManager);
             return profileManager;
         } else if (valueType == PlayPenContentPane.class) {
-            PlayPenContentPane pane = new PlayPenContentPane();
+ PlayPenContentPane pane = new PlayPenContentPane(new SQLDatabase()); ((ArchitectSwingProject) makeNewValue(ArchitectSwingProject.class, null, null)).setPlayPenContentPane(pane);
             return pane;
         } else if (valueType == PlayPenComponent.class) {
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java Fri Jun 11 09:19:49 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java Mon Jun 14 12:44:23 2010
@@ -84,9 +84,14 @@
         * They come after that list in terms of the overall children list.
         * Currently stores Relationships and UsageComponents
         */
- private List<PlayPenComponent> dependentComponents = new ArrayList<PlayPenComponent>();
-
-    private SPObject modelContainer;
+ private List<PlayPenComponent> dependentComponents = new ArrayList<PlayPenComponent>();
+
+    /**
+ * The object this content pane is displaying information about. Must be one + * of either SQLDatabase or OLAPSession and it must have a valid parent to
+     * attach a listener to which watches for this model being removed.
+     */
+    private final SPObject modelContainer;

     /**
      * Maps component listeners by the listener that was passed in
@@ -171,20 +176,25 @@
             }
         }
     };
-
+
+    /**
+     * @param modelContainer
+ * Must be either a SQLDatabase or OLAPSession and must not be + * null. If the model is an OLAPSession it must also have a valid + * parent to listen to for removing the content pane correctly if
+     *            the model is removed.
+     */
        @Constructor
public PlayPenContentPane(@ConstructorParameter(propertyName="modelContainer") SPObject modelContainer) {
-           this("PlayPenContentPane");
-           setModelContainer(modelContainer);
-       }
-
-       public PlayPenContentPane() {
-           this("PlayPenContentPane");
-       }
-
-       public PlayPenContentPane(String name) {
            super();
-           setName(name);
+           setName("PlayPenContentPane");
+ if (!(modelContainer instanceof SQLDatabase || modelContainer instanceof OLAPSession)) { + throw new IllegalArgumentException("modelContainer must either be a SQLDatabase or OLAPSession");
+           }
+           this.modelContainer = modelContainer;
+           if (modelContainer instanceof OLAPSession) {
+               
modelContainer.getParent().addSPListener(modelContainerListener);
+           }
        }

        @Accessor
@@ -192,18 +202,6 @@
            return modelContainer;
        }

-       @Mutator
-       public void setModelContainer(SPObject modelContainer) {
-           if (this.modelContainer != null) throw new IllegalStateException(
-                   "Cannot set the model container once it is already set!");
- if (!(modelContainer instanceof SQLDatabase || modelContainer instanceof OLAPSession)) { - throw new IllegalArgumentException("modelContainer must either be a SQLDatabase or OLAPSession");
-           }
-           this.modelContainer = modelContainer;
-           modelContainer.getParent().addSPListener(modelContainerListener);
-           firePropertyChange("modelContainer", null, modelContainer);
-       }
-
     /**
      * Returns the PlayPen that this content pane belongs to.
      */

Reply via email to