Revision: 3458
Author: mo.jeff
Date: Fri Apr 16 12:57:41 2010
Log: Allow Architect Projects to store types as children.
http://code.google.com/p/power-architect/source/detail?r=3458
Modified:
/trunk/src/main/java/ca/sqlpower/architect/ArchitectProject.java
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/ArchitectProject.java Wed
Apr 14 09:10:02 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/ArchitectProject.java Fri
Apr 16 12:57:41 2010
@@ -50,6 +50,7 @@
import ca.sqlpower.sqlobject.SQLObject;
import ca.sqlpower.sqlobject.SQLObjectException;
import ca.sqlpower.sqlobject.SQLObjectRoot;
+import ca.sqlpower.sqlobject.UserDefinedSQLType;
import ca.sqlpower.util.RunnableDispatcher;
import ca.sqlpower.util.SessionNotFoundException;
import ca.sqlpower.util.WorkspaceContainer;
@@ -74,7 +75,7 @@
Arrays.asList(SQLObjectRoot.class, OLAPRootObject.class,
PlayPenContentPane.class, ProfileManager.class,
ProjectSettings.class, KettleSettings.class,
- User.class, Group.class)));
+ User.class, Group.class,
UserDefinedSQLType.class)));
/**
* There is a 1:1 ratio between the session and the project.
@@ -87,6 +88,7 @@
private List<User> users = new ArrayList<User>();
private List<Group> groups = new ArrayList<Group>();
+ private final List<UserDefinedSQLType> sqlTypes = new
ArrayList<UserDefinedSQLType>();
/**
* This OLAP object contains the OLAP session.
@@ -264,6 +266,12 @@
fireChildRemoved(Group.class, child, index);
child.setParent(null);
return true;
+ } else if (child instanceof UserDefinedSQLType) {
+ int index = sqlTypes.indexOf((UserDefinedSQLType) child);
+ sqlTypes.remove((UserDefinedSQLType) child);
+ fireChildRemoved(UserDefinedSQLType.class, child, index);
+ child.setParent(null);
+ return true;
}
return false;
}
@@ -326,6 +334,7 @@
allChildren.add(kettleSettings);
allChildren.addAll(users);
allChildren.addAll(groups);
+ allChildren.addAll(sqlTypes);
return allChildren;
}
@@ -357,11 +366,19 @@
addUser((User) child, index);
} else if (child instanceof Group) {
addGroup((Group) child, index);
+ } else if (child instanceof UserDefinedSQLType) {
+ addSQLType((UserDefinedSQLType) child, index);
} else {
throw new IllegalArgumentException("Cannot add child of type "
+
child.getClass() + " to the project once it has been
created.");
}
}
+
+ private void addSQLType(UserDefinedSQLType sqlType, int index) {
+ sqlTypes.add(index, sqlType);
+ sqlType.setParent(this);
+ fireChildAdded(UserDefinedSQLType.class, sqlType, index);
+ }
private void addUser(User user, int index) {
users.add(index, user);
@@ -469,5 +486,4 @@
olapContentPane.setParent(null);
return true;
}
-
-}
+}
--
Subscription settings:
http://groups.google.com/group/architect-commits/subscribe?hl=en