Update of /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/mainpanel/objecttree/tabs/table
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7692
Modified Files:
ContentsTab.java
Log Message:
hooks for EditWhereCols function
Index: ContentsTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/mainpanel/objecttree/tabs/table/ContentsTab.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** ContentsTab.java 25 Feb 2004 13:33:14 -0000 1.23
--- ContentsTab.java 20 Apr 2004 19:47:38 -0000 1.24
***************
*** 19,23 ****
*/
import java.sql.DatabaseMetaData;
- import java.sql.Types;
import java.sql.ResultSet;
import java.sql.SQLException;
--- 19,22 ----
***************
*** 25,28 ****
--- 24,28 ----
import java.sql.PreparedStatement;
import javax.swing.JOptionPane;
+ import java.util.HashMap;
import net.sourceforge.squirrel_sql.fw.datasetviewer.DataSetException;
***************
*** 37,42 ****
import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
- import net.sourceforge.squirrel_sql.fw.sql.ISQLDriver;
-
import net.sourceforge.squirrel_sql.client.session.ISession;
import net.sourceforge.squirrel_sql.client.session.properties.SessionProperties;
--- 37,40 ----
***************
*** 44,47 ****
--- 42,47 ----
import net.sourceforge.squirrel_sql.client.session.sqlfilter.SQLFilterClauses;
import net.sourceforge.squirrel_sql.client.session.sqlfilter.WhereClausePanel;
+ import net.sourceforge.squirrel_sql.client.session.properties.EditWhereCols;
+
/**
* This is the tab showing the contents (data) of the table.
***************
*** 62,65 ****
--- 62,71 ----
*/
String previousTableName = "";
+
+ /**
+ * This is the long name of the current table including everything that might be able to distinguish it
+ * from another table of the same name in a different DB.
+ */
+ String fullTableName = null;
/**
***************
*** 116,119 ****
--- 122,145 ----
return i18n.HINT;
}
+
+ /**
+ * Get the full name of this table, creating that name the first time we are called
+ */
+ private String getFullTableName() {
+ if (fullTableName == null) {
+ try {
+ final ISession session = getSession();
+ final ITableInfo ti = getTableInfo();
+
+ fullTableName = session.getAlias().getUrl()+":"+
+ ti.getCatalogName()+":"+ti.getSchemaName()+
+ ":"+ti.getSimpleName();
+ }
+ catch (Exception e) {
+ // not sure what to do with this exception???
+ }
+ }
+ return fullTableName;
+ }
/**
***************
*** 306,313 ****
// We also include the URL used to connect to the DB so that
// the same table/DB on different machines is treated differently.
! String fullTableName = session.getAlias().getUrl()+":"+
! ti.getCatalogName()+":"+ti.getSchemaName()+
! ":"+ti.getSimpleName();
! rsds.setContentsTabResultSet(rs, fullTableName, props.getLargeResultSetObjectInfo());
// KLUDGE:
--- 332,336 ----
// We also include the URL used to connect to the DB so that
// the same table/DB on different machines is treated differently.
! rsds.setContentsTabResultSet(rs, getFullTableName(), props.getLargeResultSetObjectInfo());
// KLUDGE:
***************
*** 618,623 ****
--- 641,659 ----
StringBuffer whereClause = new StringBuffer("");
+
+ // For tables that have a lot of columns, the user may have limited the set of columns
+ // to use in the where clause, so see if there is a table of col names
+ HashMap colNames = (EditWhereCols.getInstance()).get(getFullTableName());
for (int i=0; i< colDefs.length; i++) {
+
+ // if the user has said to not use this column, then skip it
+ if (colNames != null) {
+ // the user has restricted the set of columns to use.
+ // If this name is NOT in the list, then skip it; otherwise we fall through
+ // and use the column in the WHERE clause
+ if (colNames.get(colDefs[i].getLabel()) == null)
+ continue; // go on to the next item
+ }
// for the column that is being changed, use the value
***************
*** 635,639 ****
String clause = CellComponentFactory.getWhereClauseValue(colDefs[i], value);
-
if (clause != null && clause.length() > 0)
if (whereClause.length() == 0)
--- 671,674 ----
|