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