Revision: 3447
Author: silva.josemanuel1
Date: Fri Apr  9 11:56:35 2010
Log: Made parent setters for PlayPenContentPane and PlayPenComponent actually check the type and throw an exception in the case of an incorrect type.
http://code.google.com/p/power-architect/source/detail?r=3447

Modified:
 /trunk/buildlib/sqlpower_library-apt.jar
 /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/UsageComponent.java

=======================================
--- /trunk/buildlib/sqlpower_library-apt.jar    Tue Apr  6 14:44:35 2010
+++ /trunk/buildlib/sqlpower_library-apt.jar    Fri Apr  9 11:56:35 2010
Binary file, no diff available.
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenComponent.java Tue Apr 6 14:44:35 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenComponent.java Fri Apr 9 11:56:35 2010
@@ -683,8 +683,13 @@
     }

     @Mutator
-    public void setParent(PlayPenContentPane parent) {
-        super.setParent(parent);
+    public void setParent(SPObject parent) {
+        if (parent instanceof PlayPenContentPane || parent == null) {
+            super.setParent(parent);
+        } else {
+ throw new IllegalArgumentException("Parent of PlayPenComponent must be " + + "PlayPenContentPane, not " + parent.getClass().getSimpleName());
+        }
     }

     public List<? extends SPObject> getChildren() {
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java Thu Apr 8 07:59:33 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java Fri Apr 9 11:56:35 2010
@@ -284,8 +284,13 @@
     }

     @Mutator
-    public void setParent(ArchitectProject parent) {
-        super.setParent(parent);
+    public void setParent(SPObject parent) {
+        if (parent instanceof ArchitectProject || parent == null) {
+            super.setParent(parent);
+        } else {
+ throw new IllegalArgumentException("Parent of PlayPenContentPane must be " + + "ArchitectProject, not " + parent.getClass().getSimpleName());
+        }
     }

     public boolean allowsChildren() {
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/olap/UsageComponent.java Thu Apr 8 07:59:33 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/olap/UsageComponent.java Fri Apr 9 11:56:35 2010
@@ -184,10 +184,12 @@
         public void childRemoved(SPChildEvent evt) {
             if (evt.getChild() == pane1 || evt.getChild() == pane2) {
                 try {
- getPlayPen().getContentPane().removeChild(UsageComponent.this);
+                    getParent().removeChild(UsageComponent.this);
                 } catch (ObjectDependentException e) {
                     throw new RuntimeException(e);
                 }
+            } else if (evt.getChild() == UsageComponent.this) {
+                getParent().removeSPListener(this);
             }
         }
     }


--
To unsubscribe, reply using "remove me" as the subject.

Reply via email to