001: package net.sourceforge.squirrel_sql.client.gui;
002:
003: /*
004: * Copyright (C) 2003 Colin Bell
005: * colbell@users.sourceforge.net
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */
021: import java.awt.event.ActionEvent;
022:
023: import net.sourceforge.squirrel_sql.fw.gui.ToolBar;
024:
025: import net.sourceforge.squirrel_sql.client.IApplication;
026: import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
027:
028: /**
029: * This toolbar will navigate through a <TT>HtmlViewerPanel</TT>.
030: *
031: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
032: */
033: public class HtmlViewerPanelToolBar extends ToolBar {
034: /** Application API. */
035: private final IApplication _app;
036:
037: /** Panel that this toolbar is responsible for. */
038: private final HtmlViewerPanel _pnl;
039:
040: /**
041: * Ctor.
042: *
043: * @param app Applciation API.
044: * @param pnl Panel that this toolbar will navigate.
045: *
046: * @throws IllegalArgumentException
047: * Thrown if <TT>null</TT> <TT>IApplciation</TT> or
048: * <TT>HtmlViewerPanel</TT> passed.
049: */
050: public HtmlViewerPanelToolBar(IApplication app, HtmlViewerPanel pnl) {
051: super ();
052:
053: if (app == null) {
054: throw new IllegalArgumentException("IApplication == null");
055: }
056: if (pnl == null) {
057: throw new IllegalArgumentException(
058: "HtmlViewerPanel == null");
059: }
060:
061: _app = app;
062: _pnl = pnl;
063:
064: setUseRolloverButtons(true);
065: setFloatable(false);
066: add(new HomeAction(_app));
067: add(new BackAction(_app));
068: add(new ForwardAction(_app));
069: add(new RefreshAction(_app));
070: }
071:
072: private final class BackAction extends SquirrelAction {
073: public BackAction(IApplication app) {
074: super (app);
075: if (app == null) {
076: throw new IllegalArgumentException(
077: "Null IApplication passed");
078: }
079: }
080:
081: public void actionPerformed(ActionEvent evt) {
082: _pnl.goBack();
083: }
084: }
085:
086: private final class ForwardAction extends SquirrelAction {
087: public ForwardAction(IApplication app) {
088: super (app);
089: if (app == null) {
090: throw new IllegalArgumentException(
091: "Null IApplication passed");
092: }
093: }
094:
095: public void actionPerformed(ActionEvent evt) {
096: _pnl.goForward();
097: }
098: }
099:
100: private final class RefreshAction extends SquirrelAction {
101: public RefreshAction(IApplication app) {
102: super (app);
103: if (app == null) {
104: throw new IllegalArgumentException(
105: "Null IApplication passed");
106: }
107: }
108:
109: public void actionPerformed(ActionEvent evt) {
110: _pnl.refreshPage();
111: }
112: }
113:
114: private final class HomeAction extends SquirrelAction {
115: public HomeAction(IApplication app) {
116: super (app);
117: if (app == null) {
118: throw new IllegalArgumentException(
119: "Null IApplication passed");
120: }
121: }
122:
123: public void actionPerformed(ActionEvent evt) {
124: _pnl.goHome();
125: }
126: }
127: }
|