Update of /cvsroot/squirrel-sql/sql12/plugins/sybase/src/net/sourceforge/squirrel_sql/plugins/SybaseASE/tab
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv28994/plugins/sybase/src/net/sourceforge/squirrel_sql/plugins/SybaseASE/tab
Modified Files:
TriggerSourceTab.java ViewSourceTab.java
Log Message:
refactoring to remove duplicate plugin code.
Index: TriggerSourceTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/plugins/sybase/src/net/sourceforge/squirrel_sql/plugins/SybaseASE/tab/TriggerSourceTab.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TriggerSourceTab.java 3 Aug 2007 09:36:09 -0000 1.1
--- TriggerSourceTab.java 12 Dec 2009 18:06:05 -0000 1.2
***************
*** 18,77 ****
* 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 a Sybase trigger.
! *
*/
public class TriggerSourceTab extends FormattedSourceTab
! {
!
! /** Logger for this class. */
! private final static ILogger s_log =
! LoggerController.createLogger(TriggerSourceTab.class);
!
! /** SQL that retrieves the source of a stored procedure. */
! private static String SQL =
! "SELECT trigger_defs.text " +
! "FROM sysobjects tables , sysobjects triggers, syscomments trigger_defs " +
! "where triggers.type = 'TR' " +
! "and triggers.id = trigger_defs.id " +
! "and triggers.deltrig = tables.id " +
! "and tables.loginame = ? " +
! // TODO: figure out how to get then name of the table that the trigger
! // is on.
! //"and tables.name = ? " +
! "and triggers.name = ? ";
!
! 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 for View source tab: "+SQL);
! s_log.debug("Binding for param 1: "+doi.getCatalogName());
! s_log.debug("Binding for param 2: "+doi.getSimpleName());
! }
!
! ISQLConnection conn = session.getSQLConnection();
! PreparedStatement pstmt = conn.prepareStatement(SQL);
! pstmt.setString(1, doi.getCatalogName());
! pstmt.setString(2, doi.getSimpleName());
! return pstmt;
! }
}
--- 18,69 ----
* 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 a Sybase trigger.
*/
public class TriggerSourceTab 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 TriggerSourceTab(String hint, String stmtSep) {
super(hint);
! super.setCompressWhitespace(true);
! super.setupFormatter(stmtSep, null);
}
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.PSFormattedSourceTab#getSqlStatement()
! */
! @Override
! protected String getSqlStatement()
! {
! return
! "SELECT trigger_defs.text " +
! "FROM sysobjects tables , sysobjects triggers, syscomments trigger_defs " +
! "where triggers.type = 'TR' " +
! "and triggers.id = trigger_defs.id " +
! "and triggers.deltrig = tables.id " +
! "and tables.loginame = ? " +
! // TODO: figure out how to get the name of the table that the trigger
! // is on.
! //"and tables.name = ? " +
! "and triggers.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: ViewSourceTab.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/plugins/sybase/src/net/sourceforge/squirrel_sql/plugins/SybaseASE/tab/ViewSourceTab.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ViewSourceTab.java 3 Aug 2007 09:36:09 -0000 1.1
--- ViewSourceTab.java 12 Dec 2009 18:06:05 -0000 1.2
***************
*** 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 Sybase view.
! *
! * @author manningr
*/
public class ViewSourceTab extends FormattedSourceTab
! {
! /** SQL that retrieves the source of a stored procedure. */
! private static String SQL =
! "select text " +
! "from sysobjects " +
! "inner join syscomments on syscomments.id = sysobjects.id " +
! "where loginame = ? " +
! "and name = ? ";
!
! /** Logger for this class. */
! private final static ILogger s_log =
! LoggerController.createLogger(ViewSourceTab.class);
!
public ViewSourceTab(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;
+ import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
/**
! * This class provides the necessary information to the parent tab to display the source for an Sybase view.
*/
public class ViewSourceTab 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 ViewSourceTab(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 View source tab: "+SQL);
! s_log.debug("Binding for param 1: "+doi.getCatalogName());
! s_log.debug("Binding for param 2: "+doi.getSimpleName());
! }
! PreparedStatement pstmt = conn.prepareStatement(SQL);
!
! pstmt.setString(1, doi.getCatalogName());
! pstmt.setString(2, doi.getSimpleName());
! return pstmt;
! }
}
--- 40,66 ----
}
! /**
! * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.table.PSFormattedSourceTab#getSqlStatement()
! */
! @Override
! protected String getSqlStatement()
! {
! return
! "select text " +
! "from sysobjects " +
! "inner join syscomments on syscomments.id = sysobjects.id " +
! "where loginame = ? " +
! "and 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() };
! }
!
}
|