01: package net.sourceforge.squirrel_sql.client.mainframe.action;
02:
03: /*
04: * Copyright (C) 2006 Rob Manning
05: * manningr@users.sourceforge.net
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: */
21: import java.awt.Frame;
22:
23: import net.sourceforge.squirrel_sql.client.IApplication;
24: import net.sourceforge.squirrel_sql.fw.gui.Dialogs;
25: import net.sourceforge.squirrel_sql.fw.sql.ISQLDriver;
26: import net.sourceforge.squirrel_sql.fw.util.ICommand;
27: import net.sourceforge.squirrel_sql.fw.util.StringManager;
28: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
29:
30: /**
31: * This <CODE>ICommand</CODE> allows the user to launch the default
32: * web-browser to view the driver's website.
33: *
34: * @author <A HREF="mailto:manningr@users.sourceforge.net">Rob Manning</A>
35: */
36: public class ShowDriverWebsiteCommand implements ICommand {
37: /** Application API. */
38: private final IApplication _app;
39:
40: /** <TT>ISQLDriver</TT> to view the website for. */
41: private final ISQLDriver _sqlDriver;
42:
43: /** Internationalized strings for this class. */
44: private static final StringManager s_stringMgr = StringManagerFactory
45: .getStringManager(ShowDriverWebsiteCommand.class);
46:
47: /** Owner of the maintenance dialog. */
48: private Frame _frame;
49:
50: /**
51: * Ctor.
52: *
53: * @param app Application API.
54: * @param sqlDriver <TT>ISQLDriver</TT> to be copied.
55: *
56: * @throws IllegalArgumentException
57: * Thrown if a <TT>null</TT> <TT>ISQLDriver</TT> passed.
58: */
59: public ShowDriverWebsiteCommand(IApplication app,
60: ISQLDriver sqlDriver) throws IllegalArgumentException {
61: super ();
62: if (app == null) {
63: throw new IllegalArgumentException("IApplication == null");
64: }
65: if (sqlDriver == null) {
66: throw new IllegalArgumentException("ISQLDriver == null");
67: }
68:
69: _app = app;
70: _sqlDriver = sqlDriver;
71: }
72:
73: public void execute() {
74: String url = _sqlDriver.getWebSiteUrl();
75: if (url == null || "".equals(url)) {
76: // prompt the user to add a website url for this driver
77: final Object[] args = { _sqlDriver.getName() };
78: // i18n[ShowDriverWebsiteCommand.comfirm=No WebSite URL for the
79: // specified driver. Would you like to add one?]
80: String msg = s_stringMgr.getString(
81: "ShowDriverWebsiteCommand.comfirm", args);
82: if (Dialogs.showYesNo(_frame, msg)) {
83: new ModifyDriverCommand(_app, _sqlDriver).execute();
84: url = _sqlDriver.getUrl();
85: }
86: }
87: if (url != null && !"".equals(url)) {
88: _app.openURL(url);
89: }
90: }
91: }
|