- Timestamp:
- 2010-02-25T18:17:49+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/help
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/help/HelpBrowser.java
r2918 r3043 273 273 String content = null; 274 274 try { 275 content = reader.fetchHelpTopicContent(url); 275 content = reader.fetchHelpTopicContent(url, true); 276 276 } catch(MissingHelpContentException e) { 277 277 url = HelpUtil.getHelpTopicUrl(HelpUtil.buildAbsoluteHelpTopic(relativeHelpTopic, Locale.ENGLISH)); 278 278 try { 279 279 logger.info("fetching url: " + url); 280 content = reader.fetchHelpTopicContent(url); 280 content = reader.fetchHelpTopicContent(url, true); 281 281 } catch(MissingHelpContentException e1) { 282 282 handleMissingHelpContent(relativeHelpTopic); … … 308 308 String content = null; 309 309 try { 310 content = reader.fetchHelpTopicContent(url); 310 content = reader.fetchHelpTopicContent(url, true); 311 311 } catch(MissingHelpContentException e) { 312 312 handleMissingHelpContent(absoluteHelpTopic); … … 342 342 try { 343 343 this.url = url; 344 help.setPage(url); 345 } catch(IOException e) { 344 String content = reader.fetchHelpTopicContent(url, false); 345 help.setText(content); 346 history.setCurrentUrl(url); 347 this.url = url; 348 scrollToTop(); 349 } catch(Exception e) { 346 350 HelpAwareOptionPane.showOptionDialog( 347 351 Main.parent, -
trunk/src/org/openstreetmap/josm/gui/help/HelpBrowserHistory.java
r2715 r3043 50 50 51 51 public void setCurrentUrl(String url) { 52 if (historyPos == history.size() -1) { 52 boolean add=true; 53 54 if (historyPos >= 0 && historyPos < history.size() && history.get(historyPos).toString().equals(url.toString())) { 55 add = false; 56 } else if (historyPos == history.size() -1) { 53 57 // do nothing just append 54 58 } else if (historyPos ==0 && history.size() > 0) { … … 59 63 history = new ArrayList<String>(); 60 64 } 61 history.add(url); 62 historyPos = history.size()-1; 65 if(add) 66 { 67 history.add(url); 68 historyPos = history.size()-1; 69 } 63 70 setChanged(); 64 71 notifyObservers(); -
trunk/src/org/openstreetmap/josm/gui/help/HelpContentReader.java
r2900 r3043 45 45 * @throws MissingHelpContentException thrown if this helpTopicUrl doesn't point to an existing Wiki help page 46 46 */ 47 public String fetchHelpTopicContent(String helpTopicUrl) throws HelpContentReaderException { 47 public String fetchHelpTopicContent(String helpTopicUrl, boolean dotest) throws HelpContentReaderException { 48 48 URL url = null; 49 49 HttpURLConnection con = null; … … 54 54 con.connect(); 55 55 in = new BufferedReader(new InputStreamReader(con.getInputStream(),"utf-8")); 56 return prepareHelpContent(in); 56 return prepareHelpContent(in, dotest); 57 57 } catch(MalformedURLException e) { 58 58 throw new HelpContentReaderException(e); … … 90 90 * @throws MissingHelpContentException thrown, if the content read isn't a help page 91 91 */ 92 protected String prepareHelpContent(BufferedReader in) throws HelpContentReaderException { 92 protected String prepareHelpContent(BufferedReader in, boolean dotest) throws HelpContentReaderException { 93 93 boolean isInContent = false; 94 94 boolean isInTranslationsSideBar = false; 95 95 boolean isExistingHelpPage = false; 96 StringBuffer sball = new StringBuffer(); 96 97 StringBuffer sb = new StringBuffer(); 97 98 try { 98 99 for (String line = in.readLine(); line != null; line = in.readLine()) { 100 sball.append(line); 101 sball.append("\n"); 99 102 if (line.contains("<div id=\"searchable\">")) { 100 103 isInContent = true; … … 130 133 throw new HelpContentReaderException(e); 131 134 } 135 if(!dotest && sb.length() == 0) 136 sb = sball; 137 else if (dotest && !isExistingHelpPage) 138 throw new MissingHelpContentException(); 132 139 sb.insert(0, "<html>"); 133 140 sb.append("<html>"); 134 if (! isExistingHelpPage)135 throw new MissingHelpContentException();136 141 return sb.toString(); 137 142 }
Note:
See TracChangeset
for help on using the changeset viewer.