Update of /cvsroot/squirrel-sql/sql12/plugins/postgres/src/net/sourceforge/squirrel_sql/plugins/postgres/tab
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv28994/plugins/postgres/src/net/sourceforge/squirrel_sql/plugins/postgres/tab
Modified Files:
IndexSourceTab.java ProcedureSourceTab.java
Log Message:
refactoring to remove duplicate plugin code.
Index: IndexSourceTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/plugins/postgres/src/net/sourceforge/squirrel_sql/plugins/postgres/tab/IndexSourceTab.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** IndexSourceTab.java 30 Mar 2009 01:23:42 -0000 1.5
--- IndexSourceTab.java 12 Dec 2009 18:06:05 -0000 1.6
***************
*** 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;
- import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.ViewSourceTab;
/**
! * This class will display the source for an PostgreSQL index.
! *
! * @author manningr
*/
public class IndexSourceTab extends FormattedSourceTab
{
! /** SQL that retrieves the source of an index. */
! private static String SQL =
! "select indexdef " +
! "from pg_indexes " +
! "where schemaname = ? " +
! "and indexname = ? ";
!
! /** Logger for this class. */
! private final static ILogger s_log =
! LoggerController.createLogger(ViewSourceTab.class);
!
public IndexSourceTab(String hint, String stmtSep)
{
--- 18,36 ----
* 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 PostgreSQL
! * index.
*/
public class IndexSourceTab extends FormattedSourceTab
{
! /**
! * Constructor
! *
! * @param hint
! * what the user sees on mouse-over tool-tip
! * @param stmtSep
! * the string to use to separate 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;
! }
}
--- 40,55 ----
}
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.PSFormattedSourceTab#getSqlStatement()
! */
! @Override
! protected String getSqlStatement()
! {
! return
! "select indexdef " +
! "from pg_indexes " +
! "where schemaname = ? " +
! "and indexname = ? ";
! }
!
}
Index: ProcedureSourceTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/plugins/postgres/src/net/sourceforge/squirrel_sql/plugins/postgres/tab/ProcedureSourceTab.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ProcedureSourceTab.java 18 Jul 2007 01:24:26 -0000 1.5
--- ProcedureSourceTab.java 12 Dec 2009 18:06:05 -0000 1.6
***************
*** 1,3 ****
--- 1,4 ----
package net.sourceforge.squirrel_sql.plugins.postgres.tab;
+
/*
* Copyright (C) 2007 Rob Manning
***************
*** 18,72 ****
* 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.client.session.ISession;
import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
! 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;
/**
! * This class will display the source for an PostgreSQL trigger.
! *
! * @author manningr
*/
public class ProcedureSourceTab extends FormattedSourceTab
{
! /** SQL that retrieves the source of a stored procedure. */
! private static String SQL =
! "SELECT p.prosrc FROM pg_proc p, pg_namespace n " +
! "where p.pronamespace = n.oid " +
! "and n.nspname = ? " +
! "and p.proname = ? ";
!
! /** Logger for this class. */
! private final static ILogger s_log =
! LoggerController.createLogger(ProcedureSourceTab.class);
!
! public ProcedureSourceTab(String hint)
! {
super(hint);
super.setCompressWhitespace(false);
}
! protected PreparedStatement createStatement() throws SQLException
{
! final ISession session = getSession();
! final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
!
! if (s_log.isDebugEnabled()) {
! s_log.debug("Running SQL for procedure source: "+SQL);
! s_log.debug("schema="+doi.getSchemaName());
! s_log.debug("procedure name="+doi.getSimpleName());
! }
!
! ISQLConnection conn = session.getSQLConnection();
! PreparedStatement pstmt = conn.prepareStatement(SQL);
! // Postgres pg_proc table doesn't appear to have schema. I couldn't
! // locate another table to join with to get this info either.
! pstmt.setString(1, doi.getSchemaName());
! pstmt.setString(2, doi.getSimpleName());
! return pstmt;
}
}
--- 19,45 ----
* 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 will display the source for an PostgreSQL procedure.
*/
public class ProcedureSourceTab extends FormattedSourceTab
{
! public ProcedureSourceTab(String hint) {
super(hint);
super.setCompressWhitespace(false);
}
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.PSFormattedSourceTab#getSqlStatement()
! */
! @Override
! protected String getSqlStatement()
{
! return
! "SELECT p.prosrc FROM pg_proc p, pg_namespace n " +
! "where p.pronamespace = n.oid " +
! "and n.nspname = ? " +
! "and p.proname = ? ";
}
}
|