Revision: 3720
Author: mo.jeff
Date: Tue Jul 13 09:47:40 2010
Log: Added SPObjectSnapshots as an allowed child type of ArchitectProject
http://code.google.com/p/power-architect/source/detail?r=3720

Modified:
 /trunk/src/main/java/ca/sqlpower/architect/ArchitectProject.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingProject.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/ArchitectProject.java Tue May 25 13:03:30 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/ArchitectProject.java Tue Jul 13 09:47:40 2010
@@ -30,14 +30,15 @@
 import ca.sqlpower.object.AbstractSPObject;
 import ca.sqlpower.object.ObjectDependentException;
 import ca.sqlpower.object.SPObject;
+import ca.sqlpower.object.SPObjectSnapshot;
 import ca.sqlpower.object.annotation.Accessor;
 import ca.sqlpower.object.annotation.Constructor;
 import ca.sqlpower.object.annotation.ConstructorParameter;
+import ca.sqlpower.object.annotation.ConstructorParameter.ParameterType;
 import ca.sqlpower.object.annotation.Mutator;
 import ca.sqlpower.object.annotation.NonBound;
 import ca.sqlpower.object.annotation.NonProperty;
 import ca.sqlpower.object.annotation.Transient;
-import ca.sqlpower.object.annotation.ConstructorParameter.ParameterType;
 import ca.sqlpower.sql.JDBCDataSource;
 import ca.sqlpower.sqlobject.SQLDatabase;
 import ca.sqlpower.sqlobject.SQLObject;
@@ -64,9 +65,9 @@
      */
     @SuppressWarnings("unchecked")
public static final List<Class<? extends SPObject>> allowedChildTypes = Collections - .unmodifiableList(new ArrayList<Class<? extends SPObject>>(Arrays.asList(SQLObjectRoot.class,
-                    ProfileManager.class, ProjectSettings.class,
-                    User.class, Group.class, UserDefinedSQLType.class)));
+ .unmodifiableList(new ArrayList<Class<? extends SPObject>>(Arrays.asList(SPObjectSnapshot.class, + SQLObjectRoot.class, ProfileManager.class, ProjectSettings.class, User.class, Group.class,
+                    UserDefinedSQLType.class)));

     /**
      * There is a 1:1 ratio between the session and the project.
@@ -79,6 +80,7 @@
     private List<User> users = new ArrayList<User>();
     private List<Group> groups = new ArrayList<Group>();
private final List<UserDefinedSQLType> sqlTypes = new ArrayList<UserDefinedSQLType>(); + private final List<SPObjectSnapshot> sqlTypeSnapshots = new ArrayList<SPObjectSnapshot>();

     /**
      * The current integrity watcher on the project.
@@ -247,6 +249,12 @@
             fireChildRemoved(UserDefinedSQLType.class, child, index);
             child.setParent(null);
             return true;
+        } else if (child instanceof SPObjectSnapshot) {
+            int index = sqlTypeSnapshots.indexOf((SPObjectSnapshot) child);
+            sqlTypeSnapshots.remove((SPObjectSnapshot) child);
+            fireChildRemoved(SPObjectSnapshot.class, child, index);
+            child.setParent(null);
+            return true;
         }
         return false;
     }
@@ -304,6 +312,7 @@
         allChildren.addAll(users);
         allChildren.addAll(groups);
         allChildren.addAll(sqlTypes);
+        allChildren.addAll(sqlTypeSnapshots);
         return allChildren;
     }

@@ -329,21 +338,35 @@
             addGroup((Group) child, index);
         } else if (child instanceof UserDefinedSQLType) {
             addSQLType((UserDefinedSQLType) child, index);
+        } else if (child instanceof SPObjectSnapshot) {
+            addSPObjectSnapshot((SPObjectSnapshot) child, index);
         } else {
throw new IllegalArgumentException("Cannot add child of type " + child.getClass() + " to the project once it has been created.");
         }
     }
+

     public void addSQLType(UserDefinedSQLType sqlType, int index) {
         sqlTypes.add(index, sqlType);
         sqlType.setParent(this);
         fireChildAdded(UserDefinedSQLType.class, sqlType, index);
     }
+
+    protected void addSPObjectSnapshot(SPObjectSnapshot child, int index) {
+        sqlTypeSnapshots.add(index, child);
+        child.setParent(this);
+        fireChildAdded(SPObjectSnapshot.class, child, index);
+    }

     protected List<UserDefinedSQLType> getSqlTypes() {
         return Collections.unmodifiableList(sqlTypes);
     }
+
+    @NonProperty
+    public List<SPObjectSnapshot> getSqlTypeSnapshots() {
+        return Collections.unmodifiableList(sqlTypeSnapshots);
+    }

     public void addUser(User user, int index) {
         users.add(index, user);
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingProject.java Tue Jun 8 13:39:34 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingProject.java Tue Jul 13 09:47:40 2010
@@ -42,13 +42,14 @@
 import ca.sqlpower.object.SPChildEvent;
 import ca.sqlpower.object.SPListener;
 import ca.sqlpower.object.SPObject;
+import ca.sqlpower.object.SPObjectSnapshot;
 import ca.sqlpower.object.annotation.Accessor;
 import ca.sqlpower.object.annotation.Constructor;
 import ca.sqlpower.object.annotation.ConstructorParameter;
+import ca.sqlpower.object.annotation.ConstructorParameter.ParameterType;
 import ca.sqlpower.object.annotation.NonBound;
 import ca.sqlpower.object.annotation.NonProperty;
 import ca.sqlpower.object.annotation.Transient;
-import ca.sqlpower.object.annotation.ConstructorParameter.ParameterType;
 import ca.sqlpower.sqlobject.SQLObject;
 import ca.sqlpower.sqlobject.SQLObjectException;
 import ca.sqlpower.sqlobject.SQLObjectRoot;
@@ -72,7 +73,7 @@
      */
     @SuppressWarnings("unchecked")
public static final List<Class<? extends SPObject>> allowedChildTypes = Collections - .unmodifiableList(new ArrayList<Class<? extends SPObject>>(Arrays.asList(SQLObjectRoot.class, + .unmodifiableList(new ArrayList<Class<? extends SPObject>>(Arrays.asList(SPObjectSnapshot.class, SQLObjectRoot.class, OLAPRootObject.class, PlayPenContentPane.class, ProfileManager.class, ProjectSettings.class, CriticManager.class, KettleSettings.class, User.class, Group.class, UserDefinedSQLType.class,
                     DomainCategory.class)));
@@ -275,6 +276,7 @@
         allChildren.addAll(getGroups());
         allChildren.addAll(getSqlTypes());
         allChildren.addAll(domainCategories);
+        allChildren.addAll(getSqlTypeSnapshots());
         return allChildren;
     }

@@ -315,6 +317,8 @@
             addSQLType((UserDefinedSQLType) child, index);
         } else if (child instanceof DomainCategory) {
             addDomainCategory((DomainCategory) child, index);
+        } else if (child instanceof SPObjectSnapshot) {
+            addSPObjectSnapshot((SPObjectSnapshot) child, index);
         } else {
throw new IllegalArgumentException("Cannot add child of type " + child.getClass() + " to the project once it has been created.");

Reply via email to