001: /*
002: LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
003:
004:
005: Copyright (C) 2003 Together
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:
022: package org.webdocwf.util.loader.wizard;
023:
024: // Java core packages
025: import java.awt.*;
026: import java.awt.event.*;
027: import java.net.*;
028:
029: // Java extension packages
030: import javax.swing.*;
031: import javax.swing.event.*;
032:
033: public class OctopusHelpToolBar extends JToolBar implements
034: HyperlinkListener {
035:
036: private OctopusHelpPane webBrowserPane;
037: private JButton backButton;
038: private JButton forwardButton;
039: private JTextField urlTextField;
040:
041: // WebToolBar constructor
042: public OctopusHelpToolBar(OctopusHelpPane browser) {
043: super ("Web Navigation");
044:
045: // register for HyperlinkEvents
046: webBrowserPane = browser;
047: webBrowserPane.addHyperlinkListener(this );
048:
049: // create JTextField for entering URLs
050: urlTextField = new JTextField(25);
051: urlTextField.setVisible(false);
052: urlTextField.addActionListener(new ActionListener() {
053:
054: // navigate webBrowser to user-entered URL
055: public void actionPerformed(ActionEvent event) {
056: // attempt to load URL in webBrowserPane
057: try {
058: URL url = new URL(urlTextField.getText());
059: webBrowserPane.goToURL(url);
060: }
061:
062: // handle invalid URL
063: catch (MalformedURLException urlException) {
064: urlException.printStackTrace();
065: }
066: }
067: });
068:
069: // create JButton for navigating to previous history URL
070: backButton = new JButton(new ImageIcon(getClass().getResource(
071: "images/Back16.gif")));
072:
073: backButton.addActionListener(new ActionListener() {
074:
075: public void actionPerformed(ActionEvent event) {
076: // navigate to previous URL
077: URL url = webBrowserPane.back();
078:
079: // display URL in urlTextField
080: urlTextField.setText(url.toString());
081: }
082: });
083:
084: // create JButton for navigating to next history URL
085: forwardButton = new JButton(new ImageIcon(getClass()
086: .getResource("images/Forward16.gif")));
087:
088: forwardButton.addActionListener(new ActionListener() {
089:
090: public void actionPerformed(ActionEvent event) {
091: // navigate to next URL
092: URL url = webBrowserPane.forward();
093:
094: // display new URL in urlTextField
095: urlTextField.setText(url.toString());
096: }
097: });
098:
099: // add JButtons and JTextField to WebToolBar
100: add(backButton);
101: add(forwardButton);
102: add(urlTextField);
103:
104: } // end WebToolBar constructor
105:
106: // listen for HyperlinkEvents in WebBrowserPane
107: public void hyperlinkUpdate(HyperlinkEvent event) {
108: // if hyperlink was activated, go to hyperlink's URL
109: if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
110:
111: // get URL from HyperlinkEvent
112: URL url = event.getURL();
113:
114: // navigate to URL and display URL in urlTextField
115: webBrowserPane.goToURL(url);
116: urlTextField.setText(url.toString());
117: }
118: }
119: }
|