01: package net.sourceforge.squirrel_sql.client.session.action;
02:
03: /*
04: * Copyright (C) 2003-2004 Colin Bell
05: * colbell@users.sourceforge.net
06: *
07: * Modifications Copyright (C) 2003-2004 Jason Height
08: *
09: * This library is free software; you can redistribute it and/or
10: * modify it under the terms of the GNU Lesser General Public
11: * License as published by the Free Software Foundation; either
12: * version 2.1 of the License, or (at your option) any later version.
13: *
14: * This library is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: * Lesser General Public License for more details.
18: *
19: * You should have received a copy of the GNU Lesser General Public
20: * License along with this library; if not, write to the Free Software
21: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: */
23: import java.awt.event.ActionEvent;
24:
25: import net.sourceforge.squirrel_sql.fw.util.ICommand;
26: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
27: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
28:
29: import net.sourceforge.squirrel_sql.client.IApplication;
30: import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
31: import net.sourceforge.squirrel_sql.client.session.ISQLPanelAPI;
32:
33: /**
34: * This <TT>Action</TT> will display the previous results tab for the
35: * current session.
36: *
37: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
38: */
39: public class GotoPreviousResultsTabAction extends SquirrelAction
40: implements ISQLPanelAction {
41: /** Logger for this class. */
42: private final static ILogger s_log = LoggerController
43: .createLogger(GotoPreviousResultsTabAction.class);
44:
45: /** Current panel. */
46: private ISQLPanelAPI _panel;
47:
48: /** Command that will be executed by this action. */
49: private ICommand _cmd;
50:
51: /**
52: * Ctor specifying Application API.
53: *
54: * @param app Application API.
55: */
56: public GotoPreviousResultsTabAction(IApplication app) {
57: super (app);
58: }
59:
60: public void setSQLPanel(ISQLPanelAPI panel) {
61: _panel = panel;
62: _cmd = null;
63: setEnabled(null != _panel);
64: }
65:
66: /**
67: * Display the previous results tab.
68: *
69: * @param evt Event being executed.
70: */
71: public synchronized void actionPerformed(ActionEvent evt) {
72: if (_panel != null) {
73: if (_cmd == null) {
74: _cmd = new GotoPreviousResultsTabCommand(_panel);
75: }
76: try {
77: _cmd.execute();
78: } catch (Throwable ex) {
79: final String msg = "Error occured seting current results tab";
80: _panel.getSession().showErrorMessage(msg + ": " + ex);
81: s_log.error(msg, ex);
82: }
83: }
84: }
85: }
|