1 | /**
|
---|
2 | *#########################################################################
|
---|
3 | *
|
---|
4 | * A component of the Gatherer application, part of the Greenstone digital
|
---|
5 | * library suite from the New Zealand Digital Library Project at the
|
---|
6 | * University of Waikato, New Zealand.
|
---|
7 | *
|
---|
8 | * <BR><BR>
|
---|
9 | *
|
---|
10 | * Author: John Thompson, Greenstone Digital Library, University of Waikato
|
---|
11 | *
|
---|
12 | * <BR><BR>
|
---|
13 | *
|
---|
14 | * Copyright (C) 1999 New Zealand Digital Library Project
|
---|
15 | *
|
---|
16 | * <BR><BR>
|
---|
17 | *
|
---|
18 | * This program is free software; you can redistribute it and/or modify
|
---|
19 | * it under the terms of the GNU General Public License as published by
|
---|
20 | * the Free Software Foundation; either version 2 of the License, or
|
---|
21 | * (at your option) any later version.
|
---|
22 | *
|
---|
23 | * <BR><BR>
|
---|
24 | *
|
---|
25 | * This program is distributed in the hope that it will be useful,
|
---|
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
28 | * GNU General Public License for more details.
|
---|
29 | *
|
---|
30 | * <BR><BR>
|
---|
31 | *
|
---|
32 | * You should have received a copy of the GNU General Public License
|
---|
33 | * along with this program; if not, write to the Free Software
|
---|
34 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
35 | *########################################################################
|
---|
36 | */
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 | package org.greenstone.gatherer.gui.browser;
|
---|
44 | /**
|
---|
45 | * @date: 23/11/01
|
---|
46 | */
|
---|
47 | import java.awt.Component;
|
---|
48 | import java.awt.Dimension;
|
---|
49 | import java.awt.image.BufferedImage;
|
---|
50 | import java.net.URL;
|
---|
51 | import javax.swing.ImageIcon;
|
---|
52 | import javax.swing.JProgressBar;
|
---|
53 | import org.greenstone.gatherer.gui.browser.GBrowserListener;
|
---|
54 | import org.greenstone.gatherer.util.GURL;
|
---|
55 | /** HTMLViewPane provides the interface that all implementations must adhere to. The methods shown are used by Gatherer to interact with the rendered HTML pane, and in turn recieve messages back. */
|
---|
56 | public interface HTMLViewPane {
|
---|
57 | /** Add a GBrowserListener to this browser.
|
---|
58 | * @param listener an object which implements the GBrowserListener interface.
|
---|
59 | */
|
---|
60 | public void addGBrowserListener(GBrowserListener listener);
|
---|
61 |
|
---|
62 | public void afterDisplay();
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Back tells the browser to display a previous page if there is one. All
|
---|
66 | * implementations of HTMLViewPane should remember pages visited within this
|
---|
67 | * session, and react appropriately to calls to this function. Any caller of
|
---|
68 | * back should then immediately call canBack to determine if the function
|
---|
69 | * should be enabled.
|
---|
70 | * @return value - whether or not the operation was successful
|
---|
71 | */
|
---|
72 | public boolean back();
|
---|
73 | /**
|
---|
74 | * CanBack is used to determine if there are further pages to 'back' to, and
|
---|
75 | * based on the result whether the functionality should be available
|
---|
76 | */
|
---|
77 | public boolean canBack();
|
---|
78 | /**
|
---|
79 | * CanForward performs approximately the same duty as canBack except, of
|
---|
80 | * course, in the opposite direction.
|
---|
81 | */
|
---|
82 | public boolean canForward();
|
---|
83 | /**
|
---|
84 | * CanStop determines whether the stop functionality is available. In general
|
---|
85 | * you have to be doing something before you can stop it!
|
---|
86 | */
|
---|
87 | public boolean canStop();
|
---|
88 | /**
|
---|
89 | * Capture is used to grab a buffered image of the current graphics context of
|
---|
90 | * the HTML pane. Note that this may not actually be feasible in embedded
|
---|
91 | * applications such as Mozilla, as the apllication has a seperate graphics
|
---|
92 | * buffer.
|
---|
93 | * @return img - a buffered image containing a clipped section of the HTML
|
---|
94 | * panes graphics buffer.
|
---|
95 | */
|
---|
96 | public BufferedImage capture();
|
---|
97 | /**
|
---|
98 | * When called this method returns the URL of the resource currently being
|
---|
99 | * displayed (or rendered). If no resource has been requested the return URL
|
---|
100 | * is null. The URL can point to local files, web-based resources etc.
|
---|
101 | * @return url - the GURL of the currently displayed resource.
|
---|
102 | */
|
---|
103 | public GURL current();
|
---|
104 | /**
|
---|
105 | * This method is used to tell the HTML pane whether it should attempt to
|
---|
106 | * follow hyperlinks when a user clicks them. Whether this is set or not the
|
---|
107 | * fetch method should still be called by the HTML pane implementation apon
|
---|
108 | * a hyperlink click.
|
---|
109 | * @param on - whether followHyperlinks is; on (= true) or off.
|
---|
110 | */
|
---|
111 | public void followHyperlinks(boolean value);
|
---|
112 | /**
|
---|
113 | * Forward is a call for the HTMLViewPane implementation to move forward one
|
---|
114 | * page in its browser history. It should react appropriately to calls to this
|
---|
115 | * method and should retain a history of forward pages.
|
---|
116 | * @return value - whether of not the operation was successfull
|
---|
117 | */
|
---|
118 | public boolean forward();
|
---|
119 | /** In order to add the class that implements this interface to a component hierarchy you require some way to get at the component. This is that way.
|
---|
120 | * @return a component reference of this class (as compared to the interface one you started with).
|
---|
121 | */
|
---|
122 | public Component getContent();
|
---|
123 | /**
|
---|
124 | * If called, getProgressBar should return a reference to a JProgress bar. The
|
---|
125 | * HTML pane is then resposible for updating the progress bar for its lifetime
|
---|
126 | * whereapon the caller will dispose of it. If no page is currently being
|
---|
127 | * downloaded/rendered then the call should return null.
|
---|
128 | * @return progress - a JProgressBar indicating the HTML panes progress
|
---|
129 | * towards displaying a url or null.
|
---|
130 | */
|
---|
131 | public JProgressBar getProgress();
|
---|
132 | /** Before attempting to issue futher instructions to the HTML pane, Gatherer must first ensure that its ready. A pane should always be responsive but there are foreseeable times when an interrupt to go to a new page may cause the renderer to become unstable, or perhaps a user is filling out a form and thus shouldn't be pre-empted.
|
---|
133 | * @return <i>true</i> if the pane is ready for further instructions, <i>false</i> if not.
|
---|
134 | */
|
---|
135 | public boolean isReady();
|
---|
136 | /**
|
---|
137 | * SetEnabled is used to temporarily prevent further user interaction with the
|
---|
138 | * pane. This may be caused by certain user requests in other parts of Gatherer
|
---|
139 | * or is called when a modal dialogue is opened by the Gatherer application.
|
---|
140 | * Any implementation of setEnabled should in turn call an equivent method
|
---|
141 | * within its subcomponents and update its appearance to indicate its current
|
---|
142 | * state (ie greyed out boxes or background, wait cursor).
|
---|
143 | * @param on - what state the component should be in; on (= true) or off.
|
---|
144 | */
|
---|
145 | public void setEnabled(boolean value);
|
---|
146 | /** Remove a GBrowserListener from this browser.
|
---|
147 | * @param listener an object which implements the GBrowserListener interface.
|
---|
148 | */
|
---|
149 | public void removeGBrowserListener(GBrowserListener listener);
|
---|
150 | /**
|
---|
151 | * Show, in both of its forms, allows Gatherer to display a certain URL or file
|
---|
152 | * in the HTML pane.
|
---|
153 | * @param filename a string representing a valid local file path.
|
---|
154 | * @param update whether this action should update the history queues.
|
---|
155 | * @return whether a page has been queued to be rendered.
|
---|
156 | */
|
---|
157 | public boolean show(String filename);
|
---|
158 | /**
|
---|
159 | * Show, in both of its forms, allows Gatherer to display a certain URL or file
|
---|
160 | * in the HTML pane.
|
---|
161 | * @param url a url representing a valid URI.
|
---|
162 | * @param update whether this action should update the history queues.
|
---|
163 | * @return whether a page has been queued to be rendered.
|
---|
164 | */
|
---|
165 | public boolean show(GURL url);
|
---|
166 | /**
|
---|
167 | * Stop() kills the current rendering.
|
---|
168 | * @return whether the rendering was successfully killed.
|
---|
169 | */
|
---|
170 | public boolean stop();
|
---|
171 | }
|
---|
172 |
|
---|