Author: jfuerth
Date: Thu Jul  2 16:31:05 2009
New Revision: 3110

Modified:
   trunk/src/ca/sqlpower/architect/ArchitectUtils.java
   trunk/src/ca/sqlpower/architect/DepthFirstSearch.java
   trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java
trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java
   trunk/src/ca/sqlpower/architect/swingui/PlayPen.java
   trunk/src/ca/sqlpower/architect/swingui/Relationship.java
   trunk/src/ca/sqlpower/architect/swingui/action/ProfileAction.java

Log:
Moved the findDescendantsOfClass() method to SQLObjectUtils because it's now needed by a new method in SQLDatabase.

Modified: trunk/src/ca/sqlpower/architect/ArchitectUtils.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/ArchitectUtils.java (original)
+++ trunk/src/ca/sqlpower/architect/ArchitectUtils.java Thu Jul 2 16:31:05 2009
@@ -22,7 +22,6 @@
 import java.io.IOException;
 import java.net.URL;
 import java.sql.Types;
-import java.util.List;

 import javax.swing.JFileChooser;
 import javax.swing.JOptionPane;
@@ -31,7 +30,6 @@

 import ca.sqlpower.architect.swingui.ASUtils;
 import ca.sqlpower.sqlobject.SQLColumn;
-import ca.sqlpower.sqlobject.SQLObject;
 import ca.sqlpower.sqlobject.SQLObjectException;
 import ca.sqlpower.swingui.SPSUtils;
 import ca.sqlpower.util.ExceptionReport;
@@ -85,28 +83,6 @@
                else if (o1 == null || o2 == null) return false;
                else return o1.equals(o2);
        }
-
-    /**
- * Searches for all SQLObjects under a given starting point which are of the
-     * given type. Keep in mind that if you go after anything lower than
- * SQLTable, you will invoke many potentially expensive populate() methods.
-     *
-     * @param source
-     *            the source object (usually the database)
-     */
-       public static <T extends SQLObject>
- List<T> findDescendentsByClass(SQLObject so, java.lang.Class<T> clazz, List<T> addTo)
-       throws SQLObjectException {
-               if (clazz == so.getClass()) {
-                       addTo.add(clazz.cast(so));
-               } else {
-                       for (SQLObject child : (List<? extends SQLObject>) 
so.getChildren()) {
-                               findDescendentsByClass(child, clazz, addTo);
-                       }
-               }
-               return addTo;
-       }
-

        /**
         * Chop long strings down to size for display purposes

Modified: trunk/src/ca/sqlpower/architect/DepthFirstSearch.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/DepthFirstSearch.java       (original)
+++ trunk/src/ca/sqlpower/architect/DepthFirstSearch.java Thu Jul 2 16:31:05 2009
@@ -27,8 +27,9 @@

 import org.apache.log4j.Logger;

-import ca.sqlpower.sqlobject.SQLObjectException;
 import ca.sqlpower.sqlobject.SQLDatabase;
+import ca.sqlpower.sqlobject.SQLObjectException;
+import ca.sqlpower.sqlobject.SQLObjectUtils;
 import ca.sqlpower.sqlobject.SQLRelationship;
 import ca.sqlpower.sqlobject.SQLTable;

@@ -157,7 +158,7 @@

     public DepthFirstSearch(SQLDatabase db) throws SQLObjectException {
         List<SQLTable> tables = new ArrayList<SQLTable>();
-        ArchitectUtils.findDescendentsByClass(db, SQLTable.class, tables);
+        SQLObjectUtils.findDescendentsByClass(db, SQLTable.class, tables);
         performSearch(tables);
     }


Modified: trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java  (original)
+++ trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java Thu Jul 2 16:31:05 2009
@@ -31,7 +31,6 @@

 import org.apache.log4j.Logger;

-import ca.sqlpower.architect.ArchitectUtils;
 import ca.sqlpower.architect.olap.MondrianModel.Cube;
 import ca.sqlpower.architect.olap.MondrianModel.CubeDimension;
 import ca.sqlpower.architect.olap.MondrianModel.CubeUsage;
@@ -427,7 +426,7 @@
         SQLDatabase db = osession.getDatabase();
         List<SQLTable> tables;
         if (db != null) {
- tables = ArchitectUtils.findDescendentsByClass(db, SQLTable.class, new ArrayList<SQLTable>()); + tables = SQLObjectUtils.findDescendentsByClass(db, SQLTable.class, new ArrayList<SQLTable>());
         } else {
             tables = Collections.emptyList();
         }

Modified: trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java Thu Jul 2 16:31:05 2009
@@ -161,9 +161,10 @@
* Important note: This constructor must be called on the Swing Event Dispatch * Thread. See SwingUtilities.invokeLater() for a way of ensuring this method
      * is called on the proper thread.
+     *
      * @throws SQLObjectException
      */
-    ArchitectSwingSessionContextImpl() throws SQLObjectException {
+    public ArchitectSwingSessionContextImpl() throws SQLObjectException {
         delegateContext = new ArchitectSessionContextImpl();

System.setProperty("apple.laf.useScreenMenuBar", "true"); //$NON-NLS-1$ //$NON-NLS-2$

Modified: trunk/src/ca/sqlpower/architect/swingui/PlayPen.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/PlayPen.java        (original)
+++ trunk/src/ca/sqlpower/architect/swingui/PlayPen.java Thu Jul 2 16:31:05 2009
@@ -438,7 +438,7 @@
      */
     public List<SQLTable> getTables() throws SQLObjectException {
         List<SQLTable> tables = new ArrayList<SQLTable>();
- ArchitectUtils.findDescendentsByClass(session.getTargetDatabase(), SQLTable.class, tables); + SQLObjectUtils.findDescendentsByClass(session.getTargetDatabase(), SQLTable.class, tables);
         return tables;

     }

Modified: trunk/src/ca/sqlpower/architect/swingui/Relationship.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/Relationship.java   (original)
+++ trunk/src/ca/sqlpower/architect/swingui/Relationship.java Thu Jul 2 16:31:05 2009
@@ -575,10 +575,9 @@
                 (new ActionEvent(evt.getSource(),
                         ActionEvent.ACTION_PERFORMED,
                         PlayPen.ACTION_COMMAND_SRC_PLAYPEN));
- } else if (evt.getClickCount() == 1 && evt.getButton() == MouseEvent.BUTTON1){
-                if (isSelected() && componentPreviouslySelected) {
-                    setSelected(false, SelectionEvent.SINGLE_SELECT);
-                }
+ } else if (evt.getClickCount() == 1 && evt.getButton() == MouseEvent.BUTTON1 &&
+                    isSelected() && componentPreviouslySelected) {
+                setSelected(false, SelectionEvent.SINGLE_SELECT);
             }
session.getArchitectFrame().getCreateIdentifyingRelationshipAction().cancel(); session.getArchitectFrame().getCreateNonIdentifyingRelationshipAction().cancel();

Modified: trunk/src/ca/sqlpower/architect/swingui/action/ProfileAction.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/action/ProfileAction.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/action/ProfileAction.java Thu Jul 2 16:31:05 2009
@@ -29,7 +29,6 @@

 import org.apache.log4j.Logger;

-import ca.sqlpower.architect.ArchitectUtils;
 import ca.sqlpower.architect.profile.ProfileManager;
 import ca.sqlpower.architect.swingui.ASUtils;
 import ca.sqlpower.architect.swingui.ArchitectSwingSession;
@@ -124,7 +123,7 @@
                     if ( db != null && sqlObject.contains(db))
                         sqlObject.remove(db);
} else if ( tp.getLastPathComponent() instanceof SQLTable.Folder ) { - SQLTable tab = SQLObjectUtils.getAncestor((Folder)tp.getLastPathComponent(),SQLTable.class); + SQLTable tab = SQLObjectUtils.getAncestor((Folder<?>) tp.getLastPathComponent(),SQLTable.class);
                     sqlObject.add(tab);
SQLSchema sch = SQLObjectUtils.getAncestor(tab,SQLSchema.class);
                     if ( sch != null && sqlObject.contains(sch))
@@ -156,7 +155,7 @@
                 if ( o instanceof SQLColumn){
                     tables.add(((SQLColumn)o).getParentTable());
                 } else {
- tables.addAll(ArchitectUtils.findDescendentsByClass(o, SQLTable.class, new ArrayList<SQLTable>())); + tables.addAll(SQLObjectUtils.findDescendentsByClass(o, SQLTable.class, new ArrayList<SQLTable>()));
                 }
             }

Reply via email to