Changeset 4400
- Timestamp:
- 2003-05-29T11:09:36+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/PreviewPane.java
r4367 r4400 57 57 private JLabel status = null; 58 58 private Observer observer = null; 59 private String args[] = null; 60 private String current_url = null; 61 private String page_showing = null; 62 private URL homepage = null; 59 private URL homepage = null; 60 61 static final public String BLANK_PAGE = "<html><head><title>No Page</title></head><body></body></html>"; 63 62 64 63 public PreviewPane() { … … 83 82 observer = new Observer(); 84 83 view = new CalHTMLPane(prefs, observer, "Default"); 85 //view.setSize(new Dimension(770, 440));86 84 87 85 status = new JLabel(get("Ready")); … … 89 87 90 88 public void collectionChanged(boolean ready) { 89 // If we were showing a page, but that page is no longer available, then return to a blank page 90 if(!ready && homepage != null) { 91 homepage = null; 92 view.showHTMLDocument(BLANK_PAGE); 93 } 91 94 } 92 95 … … 115 118 public void gainFocus() { 116 119 if(Gatherer.c_man.ready() && Gatherer.c_man.built()) { 117 // Now load the collection 118 String url = Gatherer.config.exec_address.toString() + "?a=p&p=about&c=" + Gatherer.c_man.getCollection().getName(); 119 Gatherer.println("Loading " + url); 120 args = new String[1]; 121 args[0] = url; 122 status.setText(get("Loading", args)); 123 args = null; 124 view.showHTMLDocument((new GURL(url)).getURL()); 125 page_showing = url; 126 homepage = (new GURL(url)).getURL(); 127 url = null; 120 if(homepage == null) { 121 try { 122 // Now load the collection 123 homepage = new URL(Gatherer.config.exec_address.toString() + "?a=p&p=about&c=" + Gatherer.c_man.getCollection().getName()); 124 ///atherer.println("Loading " + url); 125 status.setText(get("Loading", homepage.toString())); 126 view.showHTMLDocument(homepage); 127 } 128 catch (MalformedURLException exception) { 129 Gatherer.printStackTrace(exception); 130 } 131 } 128 132 } 129 133 validate(); … … 136 140 } 137 141 138 public String get(String key, String arg s[]) {142 public String get(String key, String arg) { 139 143 if(key.indexOf(".") == -1) { 140 144 key = "Browser." + key; 141 145 } 142 return Gatherer.dictionary.get(key, arg s);146 return Gatherer.dictionary.get(key, arg); 143 147 } 144 148 … … 146 150 try { 147 151 String url = Gatherer.config.exec_address.toString() + command; 148 System.err.println("Action: " + url);152 ///ystem.err.println("Action: " + url); 149 153 view.setLoadSynchronously(true); 150 154 view.showHTMLDocument(new URL(url)); 151 155 view.setLoadSynchronously(false); 152 System.err.println("Complete.");156 ///ystem.err.println("Complete."); 153 157 url = null; 154 158 } 155 159 catch(MalformedURLException error) { 156 System.err.println("Bad URL.");160 ///ystem.err.println("Bad URL."); 157 161 } 158 162 } 159 163 160 164 public void validate() { 161 if(back_count > 0) { 162 back.setEnabled(true); 163 } 164 else { 165 back.setEnabled(false); 166 } 167 if(homepage != null) { 168 home.setEnabled(true); 169 } 170 else { 171 home.setEnabled(false); 172 } 173 if(forward_count > 0) { 174 forward.setEnabled(true); 175 } 176 else { 177 forward.setEnabled(false); 178 } 179 reload.setEnabled(true); 165 back.setEnabled(back_count > 0); 166 home.setEnabled(homepage != null); 167 forward.setEnabled(forward_count > 0); 168 reload.setEnabled(homepage != null); 180 169 } 181 170 … … 203 192 implements ActionListener { 204 193 public void actionPerformed(ActionEvent event) { 205 if(homepage != null) { 206 view.showHTMLDocument(homepage); 207 back_count++; 208 validate(); 209 } 194 view.showHTMLDocument(homepage); 195 back_count++; 196 forward_count = 0; 197 validate(); 210 198 } 211 199 } … … 222 210 public int state = CalCons.DOC_LOADED; 223 211 public void linkActivatedUpdate(CalHTMLPane pane, URL url, String target_frame, String j_name) { 224 if(!url.toString().equals(current_url)) { 225 back_count++; 226 forward_count = 0; 227 validate(); 228 } 212 back_count++; 213 forward_count = 0; 214 validate(); 229 215 } 230 216 public void linkFocusUpdate(CalHTMLPane pane, URL url) { 231 ///ystem.err.println("Link in focus " + url.toString()); 232 args = new String[1]; 233 args[0] = url.toString(); 234 status.setText(get("Follow")); 235 args = null; 217 ///ystem.err.println("Link in focus " + url.toString()); 218 status.setText(get("Follow", url.toString())); 236 219 } 237 220 public void statusUpdate(CalHTMLPane pane, int state, URL url, int value, String message) { … … 245 228 case CalCons.PARSE_FAILED: 246 229 ///ystem.err.println("Parse Failed: " + state + " - " + message); 247 status.setText(get("CannotConnect" ) + message);230 status.setText(get("CannotConnect", url.toString())); 248 231 break; 249 232 // The Pane has established a connection to the given URL and is receiving any content. 250 233 case CalCons.CONNECTED: 251 234 ///ystem.err.println("Connected: " + state + " - " + message); 252 args = new String[1]; 253 args[0] = url.toString(); 254 status.setText(get("Loading", args)); 255 args = null; 235 status.setText(get("Loading", url.toString())); 256 236 break; 257 237 // The size of the content at the given URL is known and is contained in the value argument. … … 266 246 case CalCons.PARSE_FAILED_POST_CONNECT: 267 247 ///ystem.err.println("Parse Failed Post Connect: " + state + " - " + message); 268 status.setText(get("TimedOut" ) + message);248 status.setText(get("TimedOut", url.toString())); 269 249 break; 270 250 // The document has been parsed but formatting cannot be completed because the document contains images of unspecified size. The parsing thread is waiting for image updates to give it the information it needs to format and display the document. 271 251 case CalCons.WAITING_FOR_IMAGES: 272 ///ystem.err.println("Waiting For Images: " + state + " - " + message );252 ///ystem.err.println("Waiting For Images: " + state + " - " + message + " - " + url.toString()); 273 253 break; 274 254 // All text and image data has been received, parsed and the document structure determined.
Note:
See TracChangeset
for help on using the changeset viewer.