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