01: package net.sourceforge.squirrel_sql.client.session.action;
02:
03: /*
04: * Copyright (C) 2003 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.client.IApplication;
26: import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
27: import net.sourceforge.squirrel_sql.client.session.ISQLPanelAPI;
28: import net.sourceforge.squirrel_sql.fw.util.ICommand;
29: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
30: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
31:
32: /**
33: * This <TT>Action</TT> will display the next results tab for the
34: * current session.
35: *
36: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
37: */
38: public class GotoNextResultsTabAction extends SquirrelAction implements
39: ISQLPanelAction {
40: /** Logger for this class. */
41: private final static ILogger s_log = LoggerController
42: .createLogger(GotoNextResultsTabAction.class);
43:
44: /** Current panel. */
45: private ISQLPanelAPI _panel;
46:
47: /** Command that will be executed by this action. */
48: private ICommand _cmd;
49:
50: /**
51: * Ctor specifying Application API.
52: *
53: * @param app Application API.
54: */
55: public GotoNextResultsTabAction(IApplication app) {
56: super (app);
57: }
58:
59: public void setSQLPanel(ISQLPanelAPI panel) {
60: _panel = panel;
61: _cmd = null;
62: setEnabled(null != _panel);
63: }
64:
65: /**
66: * Display the next results tab.
67: *
68: * @param evt Event being executed.
69: */
70: public synchronized void actionPerformed(ActionEvent evt) {
71: if (_panel != null) {
72: if (_cmd == null) {
73: _cmd = new GotoNextResultsTabCommand(_panel);
74: }
75: try {
76: _cmd.execute();
77: } catch (Throwable ex) {
78: final String msg = "Error occured seting current results tab";
79: _panel.getSession().showErrorMessage(msg + ": " + ex);
80: s_log.error(msg, ex);
81: }
82: }
83: }
84: }
|