Update of /cvsroot/squirrel-sql/sql12/plugins/mysql/src/net/sourceforge/squirrel_sql/plugins/mysql/tab
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv28994/plugins/mysql/src/net/sourceforge/squirrel_sql/plugins/mysql/tab
Modified Files:
MysqlProcedureSourceTab.java MysqlTriggerSourceTab.java
MysqlViewSourceTab.java
Log Message:
refactoring to remove duplicate plugin code.
Index: MysqlViewSourceTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/plugins/mysql/src/net/sourceforge/squirrel_sql/plugins/mysql/tab/MysqlViewSourceTab.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MysqlViewSourceTab.java 15 Jul 2007 11:27:40 -0000 1.2
--- MysqlViewSourceTab.java 12 Dec 2009 18:06:05 -0000 1.3
***************
*** 1,3 ****
--- 1,4 ----
package net.sourceforge.squirrel_sql.plugins.mysql.tab;
+
/*
* Copyright (C) 2007 Rob Manning
***************
*** 18,75 ****
* 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 MySQL view.
! *
! * @author manningr
*/
public class MysqlViewSourceTab extends FormattedSourceTab
{
! /** SQL that retrieves the source of a view. */
! private static String SQL =
! "SELECT VIEW_DEFINITION " +
! "FROM INFORMATION_SCHEMA.VIEWS " +
! "WHERE TABLE_SCHEMA = ? " +
! "AND TABLE_NAME = ? ";
!
! /** Logger for this class. */
! private final static ILogger s_log =
! LoggerController.createLogger(MysqlViewSourceTab.class);
!
! public MysqlViewSourceTab(String hint, String stmtSep)
! {
super(hint);
! super.setupFormatter(stmtSep, null);
! super.setCompressWhitespace(true);
}
! 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 View source tab: "+SQL);
! s_log.debug("Binding catalog name "+doi.getCatalogName()+
! " as first bind value");
! s_log.debug("Binding table name "+doi.getSimpleName()+
! " as second bind value");
!
! }
! PreparedStatement pstmt = conn.prepareStatement(SQL);
!
! pstmt.setString(1, doi.getCatalogName());
! pstmt.setString(2, doi.getSimpleName());
! return pstmt;
}
! }
--- 19,57 ----
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
! import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
/**
! * This class provides the necessary information to the parent tab to display the source for an MySQL view.
*/
public class MysqlViewSourceTab extends FormattedSourceTab
{
! public MysqlViewSourceTab(String hint, String stmtSep) {
super(hint);
! super.setupFormatter(stmtSep, null);
! super.setCompressWhitespace(true);
}
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.PSFormattedSourceTab#getSqlStatement()
! */
! @Override
! protected String getSqlStatement()
! {
! return
! "SELECT VIEW_DEFINITION " +
! "FROM INFORMATION_SCHEMA.VIEWS " +
! "WHERE TABLE_SCHEMA = ? " +
! "AND TABLE_NAME = ? ";
! }
!
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.PSFormattedSourceTab#getBindValues()
! */
! @Override
! protected String[] getBindValues()
{
final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
! return new String[] { doi.getCatalogName(), doi.getSimpleName() };
}
! }
\ No newline at end of file
Index: MysqlProcedureSourceTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/plugins/mysql/src/net/sourceforge/squirrel_sql/plugins/mysql/tab/MysqlProcedureSourceTab.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MysqlProcedureSourceTab.java 18 Jul 2007 01:25:29 -0000 1.2
--- MysqlProcedureSourceTab.java 12 Dec 2009 18:06:05 -0000 1.3
***************
*** 18,47 ****
* 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 DB2 trigger.
! *
! * @author manningr
*/
public class MysqlProcedureSourceTab extends FormattedSourceTab {
- /** SQL that retrieves the source of a stored procedure. */
- private static String SQL =
- "select routine_definition " +
- "from information_schema.ROUTINES " +
- "where ROUTINE_SCHEMA = ? " +
- "and ROUTINE_NAME = ? ";
! /** Logger for this class. */
! private final static ILogger s_log =
! LoggerController.createLogger(MysqlProcedureSourceTab.class);
!
public MysqlProcedureSourceTab(String hint)
{
--- 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;
import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
/**
! * This class provides the necessary information to the parent tab to display the source for an MySQL
! * Stored Procedure.
*/
public class MysqlProcedureSourceTab extends FormattedSourceTab {
! /**
! * Constructor
! *
! * @param hint
! * what the user sees on mouse-over tool-tip
! */
public MysqlProcedureSourceTab(String hint)
{
***************
*** 50,69 ****
}
! 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.getCatalogName());
! s_log.debug("procedure name="+doi.getSimpleName());
! }
!
! ISQLConnection conn = session.getSQLConnection();
! PreparedStatement pstmt = conn.prepareStatement(SQL);
! pstmt.setString(1, doi.getCatalogName());
! pstmt.setString(2, doi.getSimpleName());
! return pstmt;
! }
}
--- 38,62 ----
}
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.PSFormattedSourceTab#getSqlStatement()
! */
! @Override
! protected String getSqlStatement()
! {
! return
! "select routine_definition " +
! "from information_schema.ROUTINES " +
! "where ROUTINE_SCHEMA = ? " +
! "and ROUTINE_NAME = ? ";
! }
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.PSFormattedSourceTab#getBindValues()
! */
! @Override
! protected String[] getBindValues()
! {
! final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
! return new String[] { doi.getCatalogName(), doi.getSimpleName() };
! }
}
Index: MysqlTriggerSourceTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/plugins/mysql/src/net/sourceforge/squirrel_sql/plugins/mysql/tab/MysqlTriggerSourceTab.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MysqlTriggerSourceTab.java 15 Jul 2007 11:27:40 -0000 1.1
--- MysqlTriggerSourceTab.java 12 Dec 2009 18:06:05 -0000 1.2
***************
*** 1,3 ****
--- 1,4 ----
package net.sourceforge.squirrel_sql.plugins.mysql.tab;
+
/*
* Copyright (C) 2007 Rob Manning
***************
*** 18,74 ****
* 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 MySQL view.
! *
! * @author manningr
*/
public class MysqlTriggerSourceTab extends FormattedSourceTab
{
! /** SQL that retrieves the source of a view. */
! private static String SQL =
! "SELECT ACTION_STATEMENT " +
! "FROM INFORMATION_SCHEMA.TRIGGERS " +
! "WHERE TRIGGER_SCHEMA = ? " +
! "AND TRIGGER_NAME = ? ";
!
! /** Logger for this class. */
! private final static ILogger s_log =
! LoggerController.createLogger(MysqlTriggerSourceTab.class);
! public MysqlTriggerSourceTab(String hint, String stmtSep)
{
! super(hint);
! super.setupFormatter(stmtSep, null);
! super.setCompressWhitespace(true);
}
! 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 View source tab: "+SQL);
! s_log.debug("Binding catalog name "+doi.getCatalogName()+
! " as first bind value");
! s_log.debug("Binding table name "+doi.getSimpleName()+
! " as second bind value");
! }
! PreparedStatement pstmt = conn.prepareStatement(SQL);
!
! pstmt.setString(1, doi.getCatalogName());
! pstmt.setString(2, doi.getSimpleName());
! return pstmt;
}
}
--- 19,59 ----
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
! import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab;
import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
/**
! * This class will display the source for an MySQL Trigger.
*/
public class MysqlTriggerSourceTab extends FormattedSourceTab
{
! public MysqlTriggerSourceTab(String hint, String stmtSep) {
! super(hint);
! super.setupFormatter(stmtSep, null);
! super.setCompressWhitespace(true);
! }
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.PSFormattedSourceTab#getSqlStatement()
! */
! @Override
! protected String getSqlStatement()
{
! return
! "SELECT ACTION_STATEMENT " +
! "FROM INFORMATION_SCHEMA.TRIGGERS " +
! "WHERE TRIGGER_SCHEMA = ? " +
! "AND TRIGGER_NAME = ? ";
}
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.PSFormattedSourceTab#getBindValues()
! */
! @Override
! protected String[] getBindValues()
{
final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
! return new String[]
! { doi.getCatalogName(), doi.getSimpleName() };
}
+
}
|