Revision: 3231
Author: silva.josemanuel1
Date: Mon Jan 18 11:01:49 2010
Log: Revision of previous commit
ASSIGNED - bug 2507: Move the profile results settings to the project root
http://trillian.sqlpower.ca/bugzilla/show_bug.cgi?id=2507
http://code.google.com/p/power-architect/source/detail?r=3231

Modified:
 /trunk/src/ca/sqlpower/architect/profile/AbstractProfileResult.java
 /trunk/src/ca/sqlpower/architect/profile/ColumnProfileResult.java
 /trunk/src/ca/sqlpower/architect/profile/ProfileManagerImpl.java
 /trunk/src/ca/sqlpower/architect/profile/TableProfileResult.java

=======================================
--- /trunk/src/ca/sqlpower/architect/profile/AbstractProfileResult.java Mon Jan 18 09:19:18 2010 +++ /trunk/src/ca/sqlpower/architect/profile/AbstractProfileResult.java Mon Jan 18 11:01:49 2010
@@ -301,4 +301,22 @@
         dependencies.add(profiledObject);
         return dependencies;
     }
-}
+
+    /**
+ * Remove this profile result, whether it be a column or table, from its parent when its dependency is deleted. + * The children are expected to just be removed from their parent's list of children. + * TableProfileResult will continue existing when a child ColumnProfileResult is removed, as will
+     * ProfileManagerImpl will when a child TableProfileResult is removed.
+     */
+    public void removeDependency(SPObject dependency) {
+        if (dependency == getDependencies().get(0)) {
+            try {
+                getParent().removeChild(this);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        } else {
+ throw new IllegalArgumentException("ProfileResult is not dependant on that.");
+        }
+    }
+}
=======================================
--- /trunk/src/ca/sqlpower/architect/profile/ColumnProfileResult.java Mon Jan 18 09:19:18 2010 +++ /trunk/src/ca/sqlpower/architect/profile/ColumnProfileResult.java Mon Jan 18 11:01:49 2010
@@ -188,8 +188,5 @@
         children.addAll(topTen);
         return children;
     }
-
-    public void removeDependency(SPObject dependency) {
-
-    }
-}
+
+}
=======================================
--- /trunk/src/ca/sqlpower/architect/profile/ProfileManagerImpl.java Mon Jan 18 09:19:18 2010 +++ /trunk/src/ca/sqlpower/architect/profile/ProfileManagerImpl.java Mon Jan 18 11:01:49 2010
@@ -380,8 +380,12 @@
     }

     @Override
-    protected boolean removeChildImpl(SPObject child) {
-        return false;
+    protected boolean removeChildImpl(SPObject child) {
+        if (results.remove(child)) {
+            return true;
+        } else {
+            throw new IllegalArgumentException();
+        }
     }

     public boolean allowsChildren() {
@@ -391,7 +395,7 @@
     public int childPositionOffset(Class<? extends SPObject> childType) {
         if (childType.isAssignableFrom(ProfileSettings.class)) {
             return 0;
-        } else if (results.size() > 0) {
+        } else if (childType.isAssignableFrom(TableProfileResult.class)) {
             return 1;
         } else {
             throw new IllegalArgumentException();
@@ -401,9 +405,7 @@
     public List<Class<? extends SPObject>> getAllowedChildTypes() {
List<Class<? extends SPObject>> types = new ArrayList<Class<? extends SPObject>>();
         types.add(ProfileSettings.class);
-        if (results.size() > 0) {
-            types.add(TableProfileResult.class);
-        }
+        types.add(TableProfileResult.class);
         return types;
     }

=======================================
--- /trunk/src/ca/sqlpower/architect/profile/TableProfileResult.java Mon Jan 18 09:19:18 2010 +++ /trunk/src/ca/sqlpower/architect/profile/TableProfileResult.java Mon Jan 18 11:01:49 2010
@@ -209,7 +209,11 @@

     @Override
     protected boolean removeChildImpl(SPObject child) {
-        return false;
+        if (columnProfileResults.remove(child)) {
+            return true;
+        } else {
+            throw new IllegalArgumentException();
+        }
     }

     public boolean allowsChildren() {
@@ -236,7 +240,4 @@
         return children;
     }

-    public void removeDependency(SPObject dependency) {
-
-    }
-}
+}

Reply via email to