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.StringManagerFactory;
25: import net.sourceforge.squirrel_sql.fw.util.StringManager;
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 remove "quote" from an SQL string.
36: *
37: * @author Gerd Wagner
38: */
39: class RemoveQuotesAction extends SquirrelAction implements
40: ISQLPanelAction {
41: private static final StringManager s_stringMgr = StringManagerFactory
42: .getStringManager(RemoveQuotesAction.class);
43:
44: /** Logger for this class. */
45: private static final ILogger s_log = LoggerController
46: .createLogger(RemoveQuotesAction.class);
47:
48: /** Current session. */
49: private ISession _session;
50:
51: private EditExtrasPlugin _plugin;
52:
53: RemoveQuotesAction(IApplication app, EditExtrasPlugin plugin) {
54: super (app, plugin.getResources());
55: _plugin = plugin;
56: }
57:
58: public void setSQLPanel(ISQLPanelAPI panel) {
59: if (null != panel) {
60: _session = panel.getSession();
61: } else {
62: _session = null;
63: }
64: setEnabled(null != _session);
65: }
66:
67: public void actionPerformed(ActionEvent evt) {
68: if (_session != null) {
69: try {
70: //new RemoveQuotesCommand(_session.getSQLPanelAPI(_plugin)).execute();
71: new RemoveQuotesCommand(FrameWorkAcessor
72: .getSQLPanelAPI(_session, _plugin)).execute();
73: } catch (Throwable ex) {
74: // i18n[editextras.errorRemoveQuotes=Error processing Remove Quotes SQL command: {0}]
75: final String msg = s_stringMgr.getString(
76: "editextras.errorRemoveQuotes", ex);
77:
78: _session.showErrorMessage(msg);
79: s_log.error(msg, ex);
80: }
81: }
82: }
83:
84: }
|