01: package org.firebirdsql.squirrel.tab;
02:
03: /*
04: * Copyright (C) 2002 Colin Bell
05: * colbell@users.sourceforge.net
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: */
21: import java.sql.PreparedStatement;
22: import java.sql.SQLException;
23:
24: import net.sourceforge.squirrel_sql.client.session.ISession;
25: import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BasePreparedStatementTab;
26: import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
27: import net.sourceforge.squirrel_sql.fw.util.StringManager;
28: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
29: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
30: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
31:
32: /**
33: * This class will display the details for a Firebird trigger.
34: *
35: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
36: */
37: public class TriggerDetailsTab extends BasePreparedStatementTab {
38: private static final StringManager s_stringMgr = StringManagerFactory
39: .getStringManager(TriggerDetailsTab.class);
40:
41: /**
42: * This interface defines locale specific strings. This should be
43: * replaced with a property file.
44: */
45: private interface i18n {
46: // i18n[firebird.trigDetails=Details]
47: String TITLE = s_stringMgr.getString("firebird.trigDetails");
48: // i18n[firebird.triggerDetails=Display trigger details]
49: String HINT = s_stringMgr.getString("firebird.triggerDetails");
50: }
51:
52: /** SQL that retrieves the data. */
53: private static String SQL = "select rdb$trigger_name, "
54: + "rdb$trigger_sequence, " + "case rdb$trigger_type "
55: + " when 1 then 'BEFORE INSERT' "
56: + " when 2 then 'AFTER INSERT' "
57: + " when 3 then 'BEFORE UPDATE' "
58: + " when 4 then 'AFTER UPDATE' "
59: + " when 5 then 'BEFORE DELETE' "
60: + " when 6 then 'AFTER DELETE' "
61: + " else 'UNKNOWN TYPE' || rdb$trigger_type "
62: + "end as rdb$trigger_type, "
63: + "case rdb$trigger_inactive " + " when 0 then 'ACTIVE' "
64: + " when 1 then 'INACTIVE' " + " else 'UNKNOWN' "
65: + "end as rdb$trigger_active, " + "rdb$description "
66: + "from rdb$triggers where " + " rdb$trigger_name = ?";
67:
68: /** Logger for this class. */
69: private final static ILogger s_log = LoggerController
70: .createLogger(TriggerDetailsTab.class);
71:
72: public TriggerDetailsTab() {
73: super (i18n.TITLE, i18n.HINT, true);
74: }
75:
76: protected PreparedStatement createStatement() throws SQLException {
77: ISession session = getSession();
78: if (s_log.isDebugEnabled()) {
79: s_log.debug("Preparing SQL: " + SQL);
80: }
81: PreparedStatement pstmt = session.getSQLConnection()
82: .prepareStatement(SQL);
83: IDatabaseObjectInfo doi = getDatabaseObjectInfo();
84: if (s_log.isDebugEnabled()) {
85: s_log.debug("setString param: " + doi.getSimpleName());
86: }
87: pstmt.setString(1, doi.getSimpleName());
88: return pstmt;
89: }
90: }
|