01: package net.sourceforge.squirrel_sql.plugins.editextras;
02:
03: /*
04: * Copyright (C) 2003 Gerd Wagner
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License
08: * as published by the Free Software Foundation; either version 2
09: * of the License, or any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19: */
20: import java.awt.event.ActionEvent;
21:
22: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
23: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
24: import net.sourceforge.squirrel_sql.fw.util.StringManager;
25: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
26:
27: import net.sourceforge.squirrel_sql.client.IApplication;
28: import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
29: import net.sourceforge.squirrel_sql.client.session.ISession;
30: import net.sourceforge.squirrel_sql.client.session.ISQLPanelAPI;
31: import net.sourceforge.squirrel_sql.client.session.action.ISessionAction;
32: import net.sourceforge.squirrel_sql.client.session.action.ISQLPanelAction;
33:
34: /**
35: * This action will "quote" an SQL string.
36: *
37: * @author Gerd Wagner
38: */
39: class InQuotesAction extends SquirrelAction implements ISQLPanelAction {
40: private static final StringManager s_stringMgr = StringManagerFactory
41: .getStringManager(InQuotesAction.class);
42:
43: /** Logger for this class. */
44: private static final ILogger s_log = LoggerController
45: .createLogger(InQuotesAction.class);
46:
47: /** Current session. */
48: private ISession _session;
49:
50: private EditExtrasPlugin _plugin;
51:
52: InQuotesAction(IApplication app, EditExtrasPlugin plugin) {
53: super (app, plugin.getResources());
54: _plugin = plugin;
55: }
56:
57: public void setSQLPanel(ISQLPanelAPI panel) {
58: if (null != panel) {
59: _session = panel.getSession();
60: } else {
61: _session = null;
62: }
63: setEnabled(null != _session);
64: }
65:
66: public void actionPerformed(ActionEvent evt) {
67: if (_session != null) {
68: try {
69: //new InQuotesCommand(_session.getSQLPanelAPI(_plugin)).execute();
70: new InQuotesCommand(FrameWorkAcessor.getSQLPanelAPI(
71: _session, _plugin)).execute();
72: } catch (Throwable ex) {
73: // i18n[editextras.errorQuoteSql=Error processing Quote SQL command: {0}]
74: final String msg = s_stringMgr.getString(
75: "editextras.errorQuoteSql", ex);
76: _session.showErrorMessage(msg);
77: s_log.error(msg, ex);
78: }
79: }
80: }
81:
82: }
|