Revision: 3889
Author: [email protected]
Date: Mon Aug 16 16:05:11 2010
Log: NEW - bug 2774: Work remaining to complete domains and types UI.
http://trillian.sqlpower.ca/bugzilla/show_bug.cgi?id=2774
Removing Domains, Categories, and Types will now give snapshots an error
badge, and no longer explode on open. Also, if you manage to revive the
deleted object, the snapshot can hook back up to it.
http://code.google.com/p/power-architect/source/detail?r=3889
Modified:
/trunk/src/main/java/ca/sqlpower/architect/SPObjectSnapshotHierarchyListener.java
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
/trunk/src/main/java/ca/sqlpower/architect/enterprise/NetworkConflictResolver.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/DomainCategorySnapshotIconFilter.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeCellRenderer.java
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/SPObjectSnapshotHierarchyListener.java
Mon Aug 16 08:01:54 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/SPObjectSnapshotHierarchyListener.java
Mon Aug 16 16:05:11 2010
@@ -299,17 +299,19 @@
}
UserDefinedSQLType systemType =
session.findSystemTypeFromSnapshot(snapshot);
- SPObjectSnapshotUpdateListener udtSnapshotListener = new
SPObjectSnapshotUpdateListener(snapshot);
- SQLPowerUtils.listenToHierarchy(systemType,
udtSnapshotListener);
- listenerMap.put(snapshot, udtSnapshotListener);
- if (systemType.getParent() instanceof DomainCategory) {
- DomainCategory category = (DomainCategory)
systemType.getParent();
- for (SPObjectSnapshot<?> categorySnapshot :
collection.getSPObjectSnapshots()) {
- if
(categorySnapshot.getOriginalUUID().equals(category.getUUID())) {
- SPObjectSnapshotUpdateListener
categorySnapshotListener = new
SPObjectSnapshotUpdateListener(categorySnapshot);
- category.addSPListener(categorySnapshotListener);
- listenerMap.put(categorySnapshot,
categorySnapshotListener);
- break;
+ if (systemType != null) {
+ SPObjectSnapshotUpdateListener udtSnapshotListener = new
SPObjectSnapshotUpdateListener(snapshot);
+ SQLPowerUtils.listenToHierarchy(systemType,
udtSnapshotListener);
+ listenerMap.put(snapshot, udtSnapshotListener);
+ if (systemType.getParent() instanceof DomainCategory) {
+ DomainCategory category = (DomainCategory)
systemType.getParent();
+ for (SPObjectSnapshot<?> categorySnapshot :
collection.getSPObjectSnapshots()) {
+ if
(categorySnapshot.getOriginalUUID().equals(category.getUUID())) {
+ SPObjectSnapshotUpdateListener
categorySnapshotListener = new
SPObjectSnapshotUpdateListener(categorySnapshot);
+
category.addSPListener(categorySnapshotListener);
+ listenerMap.put(categorySnapshot,
categorySnapshotListener);
+ break;
+ }
}
}
}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
Wed Aug 11 15:32:36 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
Mon Aug 16 16:05:11 2010
@@ -75,6 +75,7 @@
import ca.sqlpower.object.AbstractPoolingSPListener;
import ca.sqlpower.object.AbstractSPListener;
import ca.sqlpower.object.SPChildEvent;
+import ca.sqlpower.object.SPObject;
import ca.sqlpower.object.SPObjectSnapshot;
import ca.sqlpower.object.SPObjectUUIDComparator;
import ca.sqlpower.sql.DataSourceCollection;
@@ -150,6 +151,7 @@
* Used to store sessions which hold nothing but security info.
*/
public static Map<String, ArchitectClientSideSession> securitySessions;
+ private AbstractPoolingSPListener deletionListener;
static {
securitySessions = new HashMap<String,
ArchitectClientSideSession>();
}
@@ -158,11 +160,11 @@
String name, ProjectLocation projectLocation) throws SQLObjectException
{
super(context, name, new ArchitectSwingProject());
- setupSnapshots();
-
this.projectLocation = projectLocation;
this.isEnterpriseSession = true;
+ setupSnapshots();
+
String ddlgClass = prefs.get(this.projectLocation.getUUID() + ".ddlg",
null);
if (ddlgClass != null) {
try {
@@ -230,22 +232,28 @@
public void childAddedImpl(SPChildEvent e) {
if (e.getChild() instanceof UserDefinedSQLTypeSnapshot) {
UserDefinedSQLTypeSnapshot snapshot =
(UserDefinedSQLTypeSnapshot) e.getChild();
- if (!snapshot.isObsolete()) {
- UserDefinedSQLType systemType =
findSystemTypeFromSnapshot(snapshot);
+ UserDefinedSQLType systemType =
findSystemTypeFromSnapshot(snapshot);
+ if (systemType == null) {
+ snapshot.setDeleted(true);
+ } else {
if
(!UserDefinedSQLType.areEqual(snapshot.getSPObject(), systemType)) {
snapshot.setObsolete(true);
}
+ snapshot.setDeleted(false);
}
} else if (e.getChild() instanceof DomainCategorySnapshot)
{
DomainCategorySnapshot snapshot =
(DomainCategorySnapshot) e.getChild();
- if (!snapshot.isObsolete()) {
- for (DomainCategory category :
getSystemWorkspace().getDomainCategories()) {
- if
(category.getUUID().equals(snapshot.getOriginalUUID()) &&
- !DomainCategory.areEqual(snapshot.getSPObject(),
category))
{
+ boolean deleted = true;
+ for (DomainCategory category :
getSystemWorkspace().getDomainCategories()) {
+ if
(category.getUUID().equals(snapshot.getOriginalUUID())) {
+ deleted = false;
+ if
(!DomainCategory.areEqual(snapshot.getSPObject(), category)) {
snapshot.setObsolete(true);
+ deleted = true;
}
}
}
+ snapshot.setDeleted(deleted);
}
}
};
@@ -264,10 +272,51 @@
obsolescenceListener.transactionRollback(TransactionEvent.createRollbackTransactionEvent(getWorkspace().getSnapshotCollection(), "Simulated
rollback: " + e.getMessage()));
}
});
+
+ // If this returns null, it means the system session hasn't been
+ // initialized yet. This means we are the system session, and
attaching
+ // the listener is unnecessary.
+ if (getSystemSession() != null) {
+ deletionListener = new AbstractPoolingSPListener() {
+ @Override
+ protected void childAddedImpl(SPChildEvent e) {
+ if (e.getChild() instanceof DomainCategory) {
+ e.getChild().addSPListener(deletionListener);
+ } else {
+ for (SPObjectSnapshot<SPObject> snapshot :
getWorkspace().getSnapshotCollection().getChildren(SPObjectSnapshot.class))
{
+ if
(snapshot.getOriginalUUID().equals(e.getChild().getUUID())) {
+ snapshot.setDeleted(false);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void childRemovedImpl(SPChildEvent e) {
+ if (e.getChild() instanceof DomainCategory) {
+ e.getChild().removeSPListener(deletionListener);
+ } else {
+ for (SPObjectSnapshot<SPObject> snapshot :
getWorkspace().getSnapshotCollection().getChildren(SPObjectSnapshot.class))
{
+ if
(snapshot.getOriginalUUID().equals(e.getChild().getUUID())) {
+ snapshot.setDeleted(true);
+ }
+ }
+ }
+ }
+ };
+
+ getSystemWorkspace().addSPListener(deletionListener);
+ for (DomainCategory cat :
getSystemWorkspace().getChildren(DomainCategory.class)) {
+ cat.addSPListener(deletionListener);
+ }
+ }
}
// -
-
+ /**
+ * Map of server addresses to system workspaces. Use
+ * {...@link SPServerInfo#getServerAddress()} as the key.
+ */
public static Map<String, ArchitectClientSideSession>
getSecuritySessions() {
return securitySessions;
}
@@ -307,6 +356,11 @@
if (dataSourceCollection != null) {
dataSourceCollectionUpdater.detach(dataSourceCollection);
}
+
+ getSystemWorkspace().removeSPListener(deletionListener);
+ for (DomainCategory cat :
getSystemWorkspace().getChildren(DomainCategory.class)) {
+ cat.removeSPListener(deletionListener);
+ }
return super.close();
}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/enterprise/NetworkConflictResolver.java
Mon Aug 16 11:37:28 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/enterprise/NetworkConflictResolver.java
Mon Aug 16 16:05:11 2010
@@ -989,7 +989,7 @@
} catch (AccessDeniedException ade) {
throw ade;
} catch (Exception ex) {
- throw new RuntimeException("Unable to post json to server:
\n"+ ex.getMessage());
+ throw new RuntimeException("Unable to post json to server",
ex);
}
}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/DomainCategorySnapshotIconFilter.java
Fri Jul 30 13:13:38 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/DomainCategorySnapshotIconFilter.java
Mon Aug 16 16:05:11 2010
@@ -43,7 +43,10 @@
if (node instanceof DomainCategorySnapshot) {
Icon icon = DOMAIN_CATEGORY_ICON;
- if (((DomainCategorySnapshot) node).isObsolete()) {
+ if (((DomainCategorySnapshot) node).isDeleted()) {
+ icon = ComposedIcon.getInstance(icon,
+ DBTreeCellRenderer.ERROR_BADGE);
+ } else if (((DomainCategorySnapshot) node).isObsolete()) {
final BufferedImage bufferedImage =
new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeCellRenderer.java
Fri Jul 30 13:13:38 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeCellRenderer.java
Mon Aug 16 16:05:11 2010
@@ -157,10 +157,14 @@
} else {
setIcon(SQLTypeTreeCellRenderer.DOMAIN_ICON);
}
- if (snapshot.isObsolete()) {
+ if (snapshot.isDeleted()) {
+ setIcon(ComposedIcon.getInstance(getIcon(),
+ ERROR_BADGE));
+ } else if (snapshot.isObsolete()) {
final BufferedImage bufferedImage =
new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
+ //TODO this should be done statically
Graphics2D g = bufferedImage.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);