01: package net.sourceforge.squirrel_sql.plugins.sqlval.action;
02:
03: /*
04: * Copyright (C) 2002-2003 Colin Bell
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library 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 GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; 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.BaseException;
23: import net.sourceforge.squirrel_sql.fw.util.Resources;
24: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
25: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
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.action.ISessionAction;
31:
32: import net.sourceforge.squirrel_sql.plugins.sqlval.SQLValidatorPlugin;
33: import net.sourceforge.squirrel_sql.plugins.sqlval.WebServicePreferences;
34: import net.sourceforge.squirrel_sql.plugins.sqlval.WebServiceSessionProperties;
35: import net.sourceforge.squirrel_sql.plugins.sqlval.cmd.DisconnectCommand;
36:
37: /**
38: * This action will disconnect from the SQL Validation web service.
39: *
40: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
41: */
42: public class DisconnectAction extends SquirrelAction implements
43: ISessionAction {
44: /** Logger for this class. */
45: private final static ILogger s_log = LoggerController
46: .createLogger(DisconnectAction.class);
47:
48: /** Preferences. */
49: private final WebServicePreferences _prefs;
50:
51: /** Current plugin. */
52: private final SQLValidatorPlugin _plugin;
53:
54: /** Current session. */
55: private ISession _session;
56:
57: /**
58: * Ctor.
59: *
60: * @param app Application API.
61: * @param rsrc Resources to build this action from.
62: * @param prefs Plugin preferences.
63: * @param plugin Plugin
64: *
65: * @throws IllegalArgumentException
66: * Thrown if <TT>null</TT>WebServicePreferences</TT> passed.
67: */
68: public DisconnectAction(IApplication app, Resources rsrc,
69: WebServicePreferences prefs, SQLValidatorPlugin plugin) {
70: super (app, rsrc);
71: if (prefs == null) {
72: throw new IllegalArgumentException(
73: "WebServicePreferences == null");
74: }
75: _prefs = prefs;
76: _plugin = plugin;
77: }
78:
79: public void actionPerformed(ActionEvent evt) {
80: if (_session != null) {
81: WebServiceSessionProperties wss = _plugin
82: .getWebServiceSessionProperties(_session);
83: try {
84: new DisconnectCommand(_session, _prefs, wss).execute();
85: } catch (BaseException ex) {
86: _session.getApplication().showErrorDialog(
87: "Error closing SQL Validation web service", ex);
88: }
89: }
90: }
91:
92: public void setSession(ISession session) {
93: _session = session;
94: }
95: }
|