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 javax.swing.JDialog;
23:
24: import net.sourceforge.squirrel_sql.fw.util.Resources;
25: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
26: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
27:
28: import net.sourceforge.squirrel_sql.client.IApplication;
29: import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
30: import net.sourceforge.squirrel_sql.client.session.ISession;
31: import net.sourceforge.squirrel_sql.client.session.action.ISessionAction;
32:
33: import net.sourceforge.squirrel_sql.plugins.sqlval.LogonDialog;
34: import net.sourceforge.squirrel_sql.plugins.sqlval.SQLValidatorPlugin;
35: import net.sourceforge.squirrel_sql.plugins.sqlval.WebServicePreferences;
36: import net.sourceforge.squirrel_sql.plugins.sqlval.WebServiceSessionProperties;
37:
38: /**
39: * This action will connect to the SQL Validation web service.
40: *
41: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
42: */
43: public class ConnectAction extends SquirrelAction implements
44: ISessionAction {
45: /** Logger for this class. */
46: private final static ILogger s_log = LoggerController
47: .createLogger(ConnectAction.class);
48:
49: /** Preferences. */
50: private final WebServicePreferences _prefs;
51:
52: /** Current plugin. */
53: private final SQLValidatorPlugin _plugin;
54:
55: /** Current session. */
56: private ISession _session;
57:
58: /**
59: * Ctor.
60: *
61: * @param app Application API.
62: * @param rsrc Resources to build this action from.
63: * @param prefs Plugin preferences.
64: * @param plugin Plugin
65: *
66: * @throws IllegalArgumentException
67: * Thrown if <TT>null</TT>WebServicePreferences</TT> passed.
68: */
69: public ConnectAction(IApplication app, Resources rsrc,
70: WebServicePreferences prefs, SQLValidatorPlugin plugin) {
71: super (app, rsrc);
72: if (prefs == null) {
73: throw new IllegalArgumentException(
74: "WebServicePreferences == null");
75: }
76: _prefs = prefs;
77: _plugin = plugin;
78: }
79:
80: public void actionPerformed(ActionEvent evt) {
81: if (_session != null) {
82: final WebServiceSessionProperties sessionProps = _plugin
83: .getWebServiceSessionProperties(_session);
84: final JDialog dlog = new LogonDialog(_session, _prefs,
85: sessionProps);
86: dlog.setVisible(true);
87: }
88: }
89:
90: public void setSession(ISession session) {
91: _session = session;
92: }
93:
94: }
|