Update of /cvsroot/squirrel-sql/sql12/plugins/h2/src/net/sourceforge/squirrel_sql/plugins/h2/tab
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv28994/plugins/h2/src/net/sourceforge/squirrel_sql/plugins/h2/tab
Modified Files:
IndexSourceTab.java TriggerSourceTab.java
Log Message:
refactoring to remove duplicate plugin code.
Index: TriggerSourceTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/plugins/h2/src/net/sourceforge/squirrel_sql/plugins/h2/tab/TriggerSourceTab.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TriggerSourceTab.java 27 Jul 2007 00:14:28 -0000 1.3
--- TriggerSourceTab.java 12 Dec 2009 18:06:05 -0000 1.4
***************
*** 1,3 ****
--- 1,4 ----
package net.sourceforge.squirrel_sql.plugins.h2.tab;
+
/*
* Copyright (C) 2007 Rob Manning
***************
*** 18,67 ****
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
-
- import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
- import net.sourceforge.squirrel_sql.fw.sql.ISQLConnection;
- import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
- import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
-
- import net.sourceforge.squirrel_sql.client.session.ISession;
import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
/**
! * This class will display the source for an H2 trigger.
! *
! * @author manningr
*/
public class TriggerSourceTab extends FormattedSourceTab
{
! /** SQL that retrieves the source of a trigger. */
! private static String SQL = "No support for trigger source in H2";
!
! /** Logger for this class. */
! private final static ILogger s_log =
! LoggerController.createLogger(TriggerSourceTab.class);
!
! public TriggerSourceTab(String hint, String stmtSep)
! {
super(hint);
! super.setCompressWhitespace(true);
! super.setupFormatter(stmtSep, null);
}
! protected PreparedStatement createStatement() throws SQLException
{
! final ISession session = getSession();
! final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
!
! if (s_log.isDebugEnabled()) {
! s_log.debug("Running SQL: "+SQL);
! s_log.debug("schema="+doi.getSchemaName());
! s_log.debug("trigname="+doi.getSimpleName());
! }
! ISQLConnection conn = session.getSQLConnection();
! PreparedStatement pstmt = conn.prepareStatement(SQL);
! pstmt.setString(1, doi.getSchemaName());
! pstmt.setString(2, doi.getSimpleName());
! return pstmt;
}
}
--- 19,39 ----
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
+
/**
! * This class provides the necessary information to the parent tab to display the source for an H2 trigger.
*/
public class TriggerSourceTab extends FormattedSourceTab
{
! public TriggerSourceTab(String hint, String stmtSep) {
super(hint);
! super.setCompressWhitespace(true);
! super.setupFormatter(stmtSep, null);
}
! @Override
! protected String getSqlStatement()
{
! return "No support for trigger source in H2";
}
}
Index: IndexSourceTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/plugins/h2/src/net/sourceforge/squirrel_sql/plugins/h2/tab/IndexSourceTab.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** IndexSourceTab.java 30 Mar 2009 01:23:42 -0000 1.4
--- IndexSourceTab.java 12 Dec 2009 18:06:05 -0000 1.5
***************
*** 18,50 ****
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
-
- import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
- import net.sourceforge.squirrel_sql.fw.sql.ISQLConnection;
- import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
- import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
-
- import net.sourceforge.squirrel_sql.client.session.ISession;
import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
/**
! * This class will display the source for an H2 index.
! *
! * @author manningr
*/
public class IndexSourceTab extends FormattedSourceTab
{
! /** SQL that retrieves the source of an index. */
! private static String SQL =
! "select " +
! "'create '||index_type_name||' '||index_name||' ON '||table_name||'('||column_name||')' " +
! "from INFORMATION_SCHEMA.INDEXES " +
! "where table_schema = ? " +
! "and index_name = ? ";
!
! /** Logger for this class. */
! private final static ILogger s_log =
! LoggerController.createLogger(IndexSourceTab.class);
!
public IndexSourceTab(String hint, String stmtSep)
{
--- 18,35 ----
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
/**
! * This class provides the necessary information to the parent tab to display the source for an H2 index.
*/
public class IndexSourceTab extends FormattedSourceTab
{
! /**
! * Constructor
! *
! * @param hint
! * what the user sees on mouse-over tool-tip
! * @param stmtSep
! * the character that separates SQL statements
! */
public IndexSourceTab(String hint, String stmtSep)
{
***************
*** 54,73 ****
}
! protected PreparedStatement createStatement() throws SQLException
! {
! final ISession session = getSession();
! final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
!
! ISQLConnection conn = session.getSQLConnection();
! if (s_log.isDebugEnabled()) {
! s_log.debug("Running SQL for index source tab: "+SQL);
! s_log.debug("schema name: "+doi.getSchemaName());
! s_log.debug("index name: "+doi.getSimpleName());
! }
! PreparedStatement pstmt = conn.prepareStatement(SQL);
!
! pstmt.setString(1, doi.getSchemaName());
! pstmt.setString(2, doi.getSimpleName());
! return pstmt;
! }
}
--- 39,54 ----
}
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.PSFormattedSourceTab#getSqlStatement()
! */
! @Override
! protected String getSqlStatement()
! {
! return
! "select " +
! "'create '||index_type_name||' '||index_name||' ON '||table_name||'('||column_name||')' " +
! "from INFORMATION_SCHEMA.INDEXES " +
! "where table_schema = ? " +
! "and index_name = ? ";
! }
}
|