Update of /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31947/app/src/net/sourceforge/squirrel_sql/client/session
Modified Files:
ISession.java SchemaInfo.java Session.java
Log Message:
Gerd Wagners patch - adds SQL parser
Index: ISession.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/ISession.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** ISession.java 3 Feb 2004 10:45:31 -0000 1.13
--- ISession.java 4 Apr 2004 10:36:31 -0000 1.14
***************
*** 35,38 ****
--- 35,39 ----
import net.sourceforge.squirrel_sql.client.session.properties.SessionProperties;
import net.sourceforge.squirrel_sql.client.session.sqlfilter.SQLFilterClauses;
+ import net.sourceforge.squirrel_sql.client.session.parser.IParserEventsProcessor;
/**
* The current session.
***************
*** 156,159 ****
--- 157,165 ----
/**
+ * TODO: Javadoc
+ */
+ SchemaInfo getSchemaInfo(String catalogName, String schemaName);
+
+ /**
* Select a tab in the main tabbed pane.
*
***************
*** 224,226 ****
--- 230,237 ----
*/
void addToToolbar(Action action);
+
+ /**
+ * TODO: Javadoc
+ */
+ IParserEventsProcessor getParserEventsProcessor();
}
Index: SchemaInfo.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/SchemaInfo.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SchemaInfo.java 15 Dec 2003 11:12:00 -0000 1.4
--- SchemaInfo.java 4 Apr 2004 10:36:31 -0000 1.5
***************
*** 41,44 ****
--- 41,46 ----
private final List _tables = new ArrayList();
private final List _columns = new ArrayList();
+ private final List _catalogs = new ArrayList();
+ private final List _schemas = new ArrayList();
private final List _extendedtableInfos = new ArrayList();
***************
*** 54,57 ****
--- 56,64 ----
public SchemaInfo(SQLConnection conn)
{
+ this(conn, null, null);
+ }
+
+ public SchemaInfo(SQLConnection conn, String catalogName, String schemaName)
+ {
super();
if (conn == null)
***************
*** 59,67 ****
throw new IllegalArgumentException("SQLConnection == null");
}
! load(conn);
}
public void load(SQLConnection conn)
{
if (conn == null)
{
--- 66,80 ----
throw new IllegalArgumentException("SQLConnection == null");
}
! load(conn, catalogName, schemaName);
}
public void load(SQLConnection conn)
{
+ load(conn, null, null);
+ }
+
+
+ public void load(SQLConnection conn, String catalogName, String schemaName)
+ {
if (conn == null)
{
***************
*** 115,120 ****
try
{
s_log.debug("Loading tables");
! loadTables(dmd);
s_log.debug("Tables loaded");
}
--- 128,155 ----
try
{
+ s_log.debug("Loading functions");
+ loadCatalogs(dmd);
+ s_log.debug("Functions loaded");
+ }
+ catch (Exception ex)
+ {
+ s_log.error("Error loading functions", ex);
+ }
+
+ try
+ {
+ s_log.debug("Loading functions");
+ loadSchemas(dmd);
+ s_log.debug("Functions loaded");
+ }
+ catch (Exception ex)
+ {
+ s_log.error("Error loading functions", ex);
+ }
+
+ try
+ {
s_log.debug("Loading tables");
! loadTables(dmd, catalogName, schemaName);
s_log.debug("Tables loaded");
}
***************
*** 131,134 ****
--- 166,201 ----
}
+ private void loadCatalogs(DatabaseMetaData dmd)
+ {
+ try
+ {
+ ResultSet res = dmd.getCatalogs();
+ while(res.next())
+ {
+ _catalogs.add(res.getString("TABLE_CAT"));
+ }
+ }
+ catch (Throwable th)
+ {
+ s_log.error("failed to load catalog names", th);
+ }
+ }
+
+ private void loadSchemas(DatabaseMetaData dmd)
+ {
+ try
+ {
+ ResultSet res = dmd.getSchemas();
+ while(res.next())
+ {
+ _schemas.add(res.getString("TABLE_SCHEM"));
+ }
+ }
+ catch (Throwable th)
+ {
+ s_log.error("failed to load schema names", th);
+ }
+ }
+
/**
* Retrieve whether the passed string is a keyword.
***************
*** 517,520 ****
--- 584,597 ----
}
+ public String[] getCatalogs()
+ {
+ return (String[]) _catalogs.toArray(new String[_catalogs.size()]);
+ }
+
+ public String[] getSchemas()
+ {
+ return (String[]) _schemas.toArray(new String[_schemas.size()]);
+ }
+
public ExtendedTableInfo[] getExtendedTableInfos()
{
***************
*** 527,531 ****
}
! private void loadTables(DatabaseMetaData dmd)
{
try
--- 604,608 ----
}
! private void loadTables(DatabaseMetaData dmd, String catalogName, String schemaName)
{
try
***************
*** 533,537 ****
// TODO: Use table types from meta data?
final String[] tabTypes = new String[] { "TABLE", "VIEW" };
! final ResultSet rs = dmd.getTables(null, null, null, tabTypes);
try
{
--- 610,614 ----
// TODO: Use table types from meta data?
final String[] tabTypes = new String[] { "TABLE", "VIEW" };
! final ResultSet rs = dmd.getTables(catalogName, schemaName, null, tabTypes);
try
{
Index: Session.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/app/src/net/sourceforge/squirrel_sql/client/session/Session.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** Session.java 3 Feb 2004 10:45:31 -0000 1.13
--- Session.java 4 Apr 2004 10:36:31 -0000 1.14
***************
*** 24,27 ****
--- 24,28 ----
import java.util.ArrayList;
import java.util.HashMap;
+ import java.util.Hashtable;
import java.util.List;
import java.util.ListIterator;
***************
*** 54,57 ****
--- 55,60 ----
import net.sourceforge.squirrel_sql.client.session.properties.SessionProperties;
import net.sourceforge.squirrel_sql.client.session.sqlfilter.SQLFilterClauses;
+ import net.sourceforge.squirrel_sql.client.session.parser.ParserEventsProcessor;
+ import net.sourceforge.squirrel_sql.client.session.parser.IParserEventsProcessor;
import net.sourceforge.squirrel_sql.client.util.IdentifierFactory;
/**
***************
*** 115,119 ****
/** Xref info about the current connection. */
! private final SchemaInfo _schemaInfo = new SchemaInfo();
/** Set to <TT>true</TT> once session closed. */
--- 118,124 ----
/** Xref info about the current connection. */
! private final SchemaInfo _defaultSchemaInfo = new SchemaInfo();
!
! private final Hashtable _schemaInfosByCatalogAndSchema = new Hashtable();
/** Set to <TT>true</TT> once session closed. */
***************
*** 126,129 ****
--- 131,135 ----
private List _statusBarToBeAdded = new ArrayList();
+ private ParserEventsProcessor _parserEventsProcessor;
/**
***************
*** 177,180 ****
--- 183,188 ----
_sqlPanelAPI = new SQLPanelAPI(this);
+ _parserEventsProcessor = new ParserEventsProcessor(this);
+
// Start loading table/column info about the current database.
_app.getThreadPool().addTask(new Runnable()
***************
*** 200,203 ****
--- 208,221 ----
{
s_log.debug("Closing session: " + _id);
+
+ try
+ {
+ _parserEventsProcessor.endProcessing();
+ }
+ catch(Exception e)
+ {
+ s_log.info("Error stopping parser event processor", e);
+ }
+
try
{
***************
*** 289,293 ****
public SchemaInfo getSchemaInfo()
{
! return _schemaInfo;
}
--- 307,325 ----
public SchemaInfo getSchemaInfo()
{
! return _defaultSchemaInfo;
! }
!
! public SchemaInfo getSchemaInfo(String catalogName, String schemaName)
! {
! String key = catalogName + "," + schemaName;
!
! SchemaInfo ret = (SchemaInfo) _schemaInfosByCatalogAndSchema.get(key);
! if(null == ret)
! {
! ret = new SchemaInfo(getSQLConnection(), catalogName, schemaName);
! _schemaInfosByCatalogAndSchema.put(key, ret);
! }
!
! return ret;
}
***************
*** 648,652 ****
private void loadTableInfo()
{
! _schemaInfo.load(getSQLConnection());
}
--- 680,684 ----
private void loadTableInfo()
{
! _defaultSchemaInfo.load(getSQLConnection());
}
***************
*** 671,673 ****
--- 703,710 ----
return title.toString();
}
+
+ public IParserEventsProcessor getParserEventsProcessor()
+ {
+ return _parserEventsProcessor;
+ }
}
|