01: package net.sourceforge.squirrel_sql.client.mainframe.action;
02:
03: /*
04: * Copyright (C) 2002-2004 Colin Bell
05: * colbell@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.event.ActionEvent;
22: import java.beans.PropertyVetoException;
23: import java.net.URL;
24:
25: import net.sourceforge.squirrel_sql.fw.gui.Dialogs;
26: import net.sourceforge.squirrel_sql.fw.util.BaseException;
27: import net.sourceforge.squirrel_sql.fw.util.StringManager;
28: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
29: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
30: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
31:
32: import net.sourceforge.squirrel_sql.client.IApplication;
33: import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
34: import net.sourceforge.squirrel_sql.client.gui.db.DriversListInternalFrame;
35:
36: /**
37: * This <CODE>Action</CODE> will install the default drivers into the drivers
38: * list.
39: *
40: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
41: */
42: public class InstallDefaultDriversAction extends SquirrelAction {
43: /** Logger for this class. */
44: private static ILogger s_log = LoggerController
45: .createLogger(InstallDefaultDriversAction.class);
46:
47: /** Internationalized strings for this class. */
48: private static final StringManager s_stringMgr = StringManagerFactory
49: .getStringManager(InstallDefaultDriversAction.class);
50:
51: /**
52: * Ctor.
53: *
54: * @param app Application API.
55: */
56: public InstallDefaultDriversAction(IApplication app) {
57: super (app);
58: }
59:
60: /**
61: * Perform this action.
62: *
63: * @param evt The current event.
64: */
65: public void actionPerformed(ActionEvent evt) {
66: final IApplication app = getApplication();
67:
68: if (Dialogs.showYesNo(app.getMainFrame(), s_stringMgr
69: .getString("InstallDefaultDriversAction.confirm"))) {
70: final DriversListInternalFrame tw = app.getWindowManager()
71: .getDriversListInternalFrame();
72: tw.moveToFront();
73: try {
74: tw.setSelected(true);
75: } catch (PropertyVetoException ex) {
76: //i18n[InstallDefaultDriversAction.error.selectingwindow=Error selecting window]
77: s_log
78: .error(
79: s_stringMgr
80: .getString("InstallDefaultDriversAction.error.selectingwindow"),
81: ex);
82: }
83: final URL url = app.getResources().getDefaultDriversUrl();
84: try {
85: new InstallDefaultDriversCommand(app, url).execute();
86: } catch (BaseException ex) {
87: app
88: .showErrorDialog(
89: s_stringMgr
90: .getString("InstallDefaultDriversAction.error.install"),
91: ex);
92: }
93: }
94: }
95: }
|