Revision: 3825
Author: [email protected]
Date: Fri Jul 30 13:13:38 2010
Log: Added the snapshot update listener to the domain category snapshots and added the ability to have the refresh badges appear on the domain categories when they are not in sync with the repository.
http://code.google.com/p/power-architect/source/detail?r=3825

Modified:
 /trunk/src/main/java/ca/sqlpower/architect/ArchitectProject.java
/trunk/src/main/java/ca/sqlpower/architect/SPObjectSnapshotHierarchyListener.java
 /trunk/src/main/java/ca/sqlpower/architect/enterprise/DomainCategory.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingProject.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/ArchitectProject.java Tue Jul 27 09:09:22 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/ArchitectProject.java Fri Jul 30 13:13:38 2010
@@ -86,7 +86,12 @@
     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 list of all snapshots in our current system. This includes types,
+     * domains, and domain category snapshots.
+     */
+ private final List<SPObjectSnapshot<?>> spobjectSnapshots = new ArrayList<SPObjectSnapshot<?>>(); private final List<DomainCategory> domainCategories = new ArrayList<DomainCategory>();

     // Metadata children
@@ -253,7 +258,7 @@
             return removeSQLType((UserDefinedSQLType) child);
         } else if (child instanceof DomainCategory) {
             return removeDomainCategory((DomainCategory) child);
-        } else if (child instanceof SPObjectSnapshot) {
+        } else if (child instanceof SPObjectSnapshot<?>) {
             return removeSPObjectSnapshot((SPObjectSnapshot<?>) child);
         } else if (child instanceof BusinessDefinition) {
             return removeBusinessDefinition((BusinessDefinition) child);
@@ -304,8 +309,8 @@
     }

     public boolean removeSPObjectSnapshot(SPObjectSnapshot<?> child) {
-        int index = sqlTypeSnapshots.indexOf(child);
-        boolean removed = sqlTypeSnapshots.remove(child);
+        int index = spobjectSnapshots.indexOf(child);
+        boolean removed = spobjectSnapshots.remove(child);
         if (removed) {
             fireChildRemoved(SPObjectSnapshot.class, child, index);
             child.setParent(null);
@@ -364,7 +369,7 @@
// When changing this, ensure you maintain the order specified by allowedChildTypes
         allChildren.addAll(sqlTypes);
         allChildren.addAll(domainCategories);
-        allChildren.addAll(sqlTypeSnapshots);
+        allChildren.addAll(spobjectSnapshots);
         allChildren.add(rootObject);
         if (profileManager != null) {
             allChildren.add(profileManager);
@@ -401,7 +406,7 @@
             addSQLType((UserDefinedSQLType) child, index);
         } else if (child instanceof DomainCategory) {
             addDomainCategory((DomainCategory) child, index);
-        } else if (child instanceof SPObjectSnapshot) {
+        } else if (child instanceof SPObjectSnapshot<?>) {
             addSPObjectSnapshot((SPObjectSnapshot<?>) child, index);
         } else if (child instanceof BusinessDefinition) {
             addBusinessDefinition((BusinessDefinition) child, index);
@@ -432,7 +437,7 @@
     }

protected void addSPObjectSnapshot(SPObjectSnapshot<?> child, int index) {
-        sqlTypeSnapshots.add(index, child);
+        spobjectSnapshots.add(index, child);
         child.setParent(this);
         fireChildAdded(SPObjectSnapshot.class, child, index);
     }
@@ -443,8 +448,8 @@
     }

     @NonProperty
-    protected List<SPObjectSnapshot<?>> getSqlTypeSnapshots() {
-        return Collections.unmodifiableList(sqlTypeSnapshots);
+    protected List<SPObjectSnapshot<?>> getSPObjectSnapshots() {
+        return Collections.unmodifiableList(spobjectSnapshots);
     }

     @NonProperty
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/SPObjectSnapshotHierarchyListener.java Fri Jul 30 12:56:08 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/SPObjectSnapshotHierarchyListener.java Fri Jul 30 13:13:38 2010
@@ -93,19 +93,29 @@

     private void addUpdateListener(UserDefinedSQLType columnProxyType) {
UserDefinedSQLType upstreamSnapshotType = columnProxyType.getUpstreamType(); - for (SPObjectSnapshot<?> snapshot : session.getWorkspace().getSqlTypeSnapshots()) {
+
+        //find snapshot by matching snapshot object
+ for (SPObjectSnapshot<?> snapshot : session.getWorkspace().getSPObjectSnapshots()) {
             if (snapshot.getSPObject() == upstreamSnapshotType) {
+                //find system UDT by uuid
for (UserDefinedSQLType systemType : session.getSystemWorkspace().getSqlTypes()) { if (systemType.getUUID().equals(snapshot.getOriginalUUID())) { systemType.addSPListener(new SPObjectSnapshotUpdateListener(snapshot));
                         break;
                     }
                 }
+                //find system domain by uuid
for (DomainCategory category : session.getSystemWorkspace().getDomainCategories()) {
                     boolean typeFound = false;
for (UserDefinedSQLType systemType : category.getChildren(UserDefinedSQLType.class)) { if (systemType.getUUID().equals(snapshot.getOriginalUUID())) { systemType.addSPListener(new SPObjectSnapshotUpdateListener(snapshot)); + for (SPObjectSnapshot<?> categorySnapshot : session.getWorkspace().getSPObjectSnapshots()) { + if (categorySnapshot.getOriginalUUID().equals(category.getUUID())) { + category.addSPListener(new SPObjectSnapshotUpdateListener(categorySnapshot));
+                                    break;
+                                }
+                            }
                             typeFound = true;
                             break;
                         }
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/enterprise/DomainCategory.java Fri Jul 16 07:18:35 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/enterprise/DomainCategory.java Fri Jul 30 13:13:38 2010
@@ -24,6 +24,7 @@
 import java.util.List;

 import ca.sqlpower.object.AbstractSPObject;
+import ca.sqlpower.object.SPListener;
 import ca.sqlpower.object.SPObject;
 import ca.sqlpower.object.annotation.Constructor;
 import ca.sqlpower.object.annotation.ConstructorParameter;
@@ -93,4 +94,16 @@
         }
         return childRemoved;
     }
-}
+
+    @Override
+    public void addSPListener(SPListener l) {
+        // TODO Auto-generated method stub
+        super.addSPListener(l);
+    }
+
+    @Override
+    public void removeSPListener(SPListener l) {
+        // TODO Auto-generated method stub
+        super.removeSPListener(l);
+    }
+}
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingProject.java Tue Jul 27 09:09:22 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingProject.java Fri Jul 30 13:13:38 2010
@@ -241,7 +241,7 @@
// When changing this, ensure you maintain the order specified by allowedChildTypes
         allChildren.addAll(getSqlTypes());
         allChildren.addAll(getDomainCategories());
-        allChildren.addAll(getSqlTypeSnapshots());
+        allChildren.addAll(getSPObjectSnapshots());
         allChildren.add(getRootObject());
         allChildren.add(olapRootObject);
         if (playPenContentPane != null) {
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/DomainCategorySnapshotIconFilter.java Fri Jul 30 09:40:47 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/DomainCategorySnapshotIconFilter.java Fri Jul 30 13:13:38 2010
@@ -19,12 +19,19 @@

 package ca.sqlpower.architect.swingui;

+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+
 import javax.swing.Icon;
 import javax.swing.ImageIcon;

 import ca.sqlpower.architect.enterprise.DomainCategorySnapshot;
+import ca.sqlpower.architect.swingui.dbtree.DBTreeCellRenderer;
 import ca.sqlpower.architect.swingui.dbtree.IconFilter;
 import ca.sqlpower.object.SPObject;
+import ca.sqlpower.swingui.ComposedIcon;

 public class DomainCategorySnapshotIconFilter implements IconFilter {

@@ -34,7 +41,22 @@
     @Override
     public Icon filterIcon(Icon original, SPObject node) {
         if (node instanceof DomainCategorySnapshot) {
-            return DOMAIN_CATEGORY_ICON;
+            Icon icon = DOMAIN_CATEGORY_ICON;
+
+            if (((DomainCategorySnapshot) node).isObsolete()) {
+                final BufferedImage bufferedImage =
+                    new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
+
+                Graphics2D g = bufferedImage.createGraphics();
+                g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
+                        RenderingHints.VALUE_INTERPOLATION_BILINEAR);
+ g.drawImage(DBTreeCellRenderer.REFRESH_ICON.getImage(), 8, 8, 8, 8,
+                        new Color(0xffffffff, true), null);
+                g.dispose();
+
+ icon = ComposedIcon.getInstance(icon, new ImageIcon(bufferedImage));
+            }
+            return icon;
         }
         return original;
     }
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeCellRenderer.java Fri Jul 30 10:06:06 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeCellRenderer.java Fri Jul 30 13:13:38 2010
@@ -164,7 +164,7 @@
                 Graphics2D g = bufferedImage.createGraphics();
                 g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                         RenderingHints.VALUE_INTERPOLATION_BILINEAR);
- g.drawImage(REFRESH_ICON.getImage(), 8, 8, 8, 8, new Color(0xffffffff, true), null); + g.drawImage(REFRESH_ICON.getImage(), 8, 8, 8, 8, new Color(0x00ffffff, true), null);
                 g.dispose();

                 setIcon(ComposedIcon.getInstance(getIcon(),

Reply via email to