Revision: 3819
Author: [email protected]
Date: Fri Jul 30 09:40:47 2010
Log: Corrected the look of the domain and domain category nodes in the dbtree. The IconFilter was updated to handle SPObjects instead of just SQLObjects for this change.
http://code.google.com/p/power-architect/source/detail?r=3819

Added:
/trunk/src/main/java/ca/sqlpower/architect/swingui/DomainCategorySnapshotIconFilter.java
Modified:
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/ProfiledTableIconFilter.java /trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeCellRenderer.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/IconFilter.java

=======================================
--- /dev/null
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/DomainCategorySnapshotIconFilter.java Fri Jul 30 09:40:47 2010
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2010, SQL Power Group Inc.
+ *
+ * This file is part of SQL Power Architect.
+ *
+ * SQL Power Architect is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SQL Power Architect is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package ca.sqlpower.architect.swingui;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+import ca.sqlpower.architect.enterprise.DomainCategorySnapshot;
+import ca.sqlpower.architect.swingui.dbtree.IconFilter;
+import ca.sqlpower.object.SPObject;
+
+public class DomainCategorySnapshotIconFilter implements IconFilter {
+
+    public static final ImageIcon DOMAIN_CATEGORY_ICON =
+ new ImageIcon(DomainCategorySnapshotIconFilter.class.getResource("icons/category.png"));
+
+    @Override
+    public Icon filterIcon(Icon original, SPObject node) {
+        if (node instanceof DomainCategorySnapshot) {
+            return DOMAIN_CATEGORY_ICON;
+        }
+        return original;
+    }
+
+}
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java Thu Jul 29 14:36:01 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java Fri Jul 30 09:40:47 2010
@@ -76,6 +76,7 @@
 import ca.sqlpower.architect.swingui.action.NewDataSourceAction;
 import ca.sqlpower.architect.swingui.action.OpenProjectAction;
 import ca.sqlpower.architect.swingui.action.PreferencesAction;
+import ca.sqlpower.architect.swingui.dbtree.DBTreeCellRenderer;
 import ca.sqlpower.architect.swingui.olap.OLAPEditSession;
 import ca.sqlpower.architect.swingui.olap.OLAPSchemaManager;
 import ca.sqlpower.architect.undo.ArchitectUndoManager;
@@ -359,6 +360,10 @@
         olapSchemaManager = new OLAPSchemaManager(this);

         this.dbTree = new DBTree(this);
+
+        if (isEnterpriseSession()) {
+ ((DBTreeCellRenderer) dbTree.getCellRenderer()).addIconFilter(new DomainCategorySnapshotIconFilter());
+        }

         playPen = RelationalPlayPenFactory.createPlayPen(this, dbTree);
this.getWorkspace().setPlayPenContentPane(playPen.getContentPane());
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java Thu Jul 29 11:37:29 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java Fri Jul 30 09:40:47 2010
@@ -999,7 +999,8 @@
                         if (upstreamType.getUpstreamType() != null) {
                             //For domains
UserDefinedSQLType upUpStreamType = upstreamType.getUpstreamType(); - UserDefinedSQLTypeSnapshot upstreamSnapshot = new UserDefinedSQLTypeSnapshot(upUpStreamType, systemRevision, isDomainSnapshot); + boolean isUpstreamDomainSnapshot = upUpStreamType.getParent() instanceof DomainCategory; + UserDefinedSQLTypeSnapshot upstreamSnapshot = new UserDefinedSQLTypeSnapshot(upUpStreamType, systemRevision, isUpstreamDomainSnapshot); session.getWorkspace().addChild(upstreamSnapshot, 0); session.getWorkspace().addChild(upstreamSnapshot.getSPObject(), 0); snapshot = new UserDefinedSQLTypeSnapshot(upstreamType, systemRevision, isDomainSnapshot, upstreamSnapshot);
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ProfiledTableIconFilter.java Thu Jan 29 12:02:55 2009 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ProfiledTableIconFilter.java Fri Jul 30 09:40:47 2010
@@ -24,7 +24,7 @@

 import ca.sqlpower.architect.profile.ProfileManager;
 import ca.sqlpower.architect.swingui.dbtree.IconFilter;
-import ca.sqlpower.sqlobject.SQLObject;
+import ca.sqlpower.object.SPObject;
 import ca.sqlpower.sqlobject.SQLTable;
 import ca.sqlpower.swingui.SPSUtils;

@@ -37,9 +37,9 @@
public static final ImageIcon PROFILED_DATABASE_ICON = SPSUtils.createIcon("Database_profiled", "SQL Database", ArchitectSwingSessionContext.ICON_SIZE); //$NON-NLS-1$ //$NON-NLS-2$ public static final ImageIcon PROFILED_TABLE_ICON = SPSUtils.createIcon("Table_profiled", "SQL Table", ArchitectSwingSessionContext.ICON_SIZE); //$NON-NLS-1$ //$NON-NLS-2$

-    public Icon filterIcon(Icon original, SQLObject node) {
+    public Icon filterIcon(Icon original, SPObject node) {
         if (node instanceof SQLTable) {
- Object profileCount = node.getClientProperty(ProfileManager.class, ProfileManager.PROFILE_COUNT_PROPERTY); + Object profileCount = ((SQLTable) node).getClientProperty(ProfileManager.class, ProfileManager.PROFILE_COUNT_PROPERTY); if (profileCount != null && ((Integer) profileCount).intValue() > 0) {
                 return PROFILED_TABLE_ICON;
             }
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeCellRenderer.java Fri Jul 30 08:09:15 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeCellRenderer.java Fri Jul 30 09:40:47 2010
@@ -35,6 +35,7 @@
 import org.apache.log4j.Logger;

 import ca.sqlpower.architect.swingui.SQLTypeTreeCellRenderer;
+import ca.sqlpower.object.SPObject;
 import ca.sqlpower.sqlobject.SQLCatalog;
 import ca.sqlpower.sqlobject.SQLColumn;
 import ca.sqlpower.sqlobject.SQLDatabase;
@@ -176,6 +177,8 @@
value == ((DBTreeModel) tree.getModel()).getSnapshotContainer()) {
             setText("Types");
             setIcon(null);
+        } else if (value instanceof SPObject) {
+            setText(((SPObject) value).getName());
         } else {
                        setIcon(null);
                }
@@ -207,9 +210,9 @@
             }
         }

-           if (value instanceof SQLObject || value == null) {
+           if (value instanceof SPObject || value == null) {
                for (IconFilter filter : getIconFilterChain()) {
-                   setIcon(filter.filterIcon(getIcon(), (SQLObject) value));
+                   setIcon(filter.filterIcon(getIcon(), (SPObject) value));
                }
            }

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/IconFilter.java Thu Jan 29 12:02:55 2009 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/IconFilter.java Fri Jul 30 09:40:47 2010
@@ -21,7 +21,7 @@

 import javax.swing.Icon;

-import ca.sqlpower.sqlobject.SQLObject;
+import ca.sqlpower.object.SPObject;

 /**
  * This interface is a hook into the DBTreeCellRenderer that allows clients
@@ -50,6 +50,6 @@
      * @return The icon that should be used instead of original, or
* <code>null</code> if the tree node should have no icon at all.
      */
-    Icon filterIcon(Icon original, SQLObject node);
+    Icon filterIcon(Icon original, SPObject node);

 }

Reply via email to