Changeset 11087 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2016-10-07T10:20:53+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r10827 r11087 1163 1163 } 1164 1164 1165 Main.worker.execute(() -> { 1166 try { 1167 // find a page that actually exists in the wiki 1168 HttpClient.Response conn; 1169 for (URI u : uris) { 1170 conn = HttpClient.create(u.toURL(), "HEAD").connect(); 1171 1172 if (conn.getResponseCode() != 200) { 1173 conn.disconnect(); 1174 } else { 1175 long osize = conn.getContentLength(); 1176 if (osize > -1) { 1177 conn.disconnect(); 1178 1179 final URI newURI = new URI(u.toString() 1180 .replace("=", "%3D") /* do not URLencode whole string! */ 1181 .replaceFirst("/wiki/", "/w/index.php?redirect=no&title=") 1182 ); 1183 conn = HttpClient.create(newURI.toURL(), "HEAD").connect(); 1184 } 1185 1186 /* redirect pages have different content length, but retrieving a "nonredirect" 1187 * page using index.php and the direct-link method gives slightly different 1188 * content lengths, so we have to be fuzzy.. (this is UGLY, recode if u know better) 1189 */ 1190 if (conn.getContentLength() != -1 && osize > -1 && Math.abs(conn.getContentLength() - osize) > 200) { 1191 Main.info("{0} is a mediawiki redirect", u); 1192 conn.disconnect(); 1193 } else { 1194 conn.disconnect(); 1195 1196 OpenBrowser.displayUrl(u.toString()); 1197 break; 1198 } 1199 } 1165 Main.worker.execute(() -> displayHelp(uris)); 1166 } catch (URISyntaxException e1) { 1167 Main.error(e1); 1168 } 1169 } 1170 1171 private void displayHelp(final List<URI> uris) { 1172 try { 1173 // find a page that actually exists in the wiki 1174 HttpClient.Response conn; 1175 for (URI u : uris) { 1176 conn = HttpClient.create(u.toURL(), "HEAD").connect(); 1177 1178 if (conn.getResponseCode() != 200) { 1179 conn.disconnect(); 1180 } else { 1181 long osize = conn.getContentLength(); 1182 if (osize > -1) { 1183 conn.disconnect(); 1184 1185 final URI newURI = new URI(u.toString() 1186 .replace("=", "%3D") /* do not URLencode whole string! */ 1187 .replaceFirst("/wiki/", "/w/index.php?redirect=no&title=") 1188 ); 1189 conn = HttpClient.create(newURI.toURL(), "HEAD").connect(); 1200 1190 } 1201 } catch (URISyntaxException | IOException e1) { 1202 Main.error(e1); 1191 1192 /* redirect pages have different content length, but retrieving a "nonredirect" 1193 * page using index.php and the direct-link method gives slightly different 1194 * content lengths, so we have to be fuzzy.. (this is UGLY, recode if u know better) 1195 */ 1196 if (conn.getContentLength() != -1 && osize > -1 && Math.abs(conn.getContentLength() - osize) > 200) { 1197 Main.info("{0} is a mediawiki redirect", u); 1198 conn.disconnect(); 1199 } else { 1200 conn.disconnect(); 1201 1202 OpenBrowser.displayUrl(u.toString()); 1203 break; 1204 } 1203 1205 } 1204 } );1205 } catch (URISyntaxException e1) {1206 } 1207 } catch (URISyntaxException | IOException e1) { 1206 1208 Main.error(e1); 1207 1209 } -
trunk/src/org/openstreetmap/josm/gui/history/HistoryLoadTask.java
r10106 r11087 171 171 break; 172 172 } 173 String msg = getLoadingMessage(pid); 174 progressMonitor.indeterminateSubTask(tr(msg, Long.toString(pid.getUniqueId()))); 175 reader = null; 176 HistoryDataSet ds; 177 try { 178 reader = new OsmServerHistoryReader(pid.getType(), pid.getUniqueId()); 179 ds = loadHistory(reader, progressMonitor); 180 } catch (OsmTransferException e) { 181 if (canceled) 182 return; 183 throw e; 184 } 185 loadedData.mergeInto(ds); 173 loadHistory(pid); 186 174 } 187 175 } catch (OsmTransferException e) { … … 189 177 return; 190 178 } 179 } 180 181 private void loadHistory(PrimitiveId pid) throws OsmTransferException { 182 String msg = getLoadingMessage(pid); 183 progressMonitor.indeterminateSubTask(tr(msg, Long.toString(pid.getUniqueId()))); 184 reader = null; 185 HistoryDataSet ds; 186 try { 187 reader = new OsmServerHistoryReader(pid.getType(), pid.getUniqueId()); 188 ds = loadHistory(reader, progressMonitor); 189 } catch (OsmTransferException e) { 190 if (canceled) 191 return; 192 throw e; 193 } 194 loadedData.mergeInto(ds); 191 195 } 192 196 -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r10982 r11087 588 588 for (PreferenceSetting setting : settings) { 589 589 if (setting instanceof SubPreferenceSetting) { 590 SubPreferenceSetting sps = (SubPreferenceSetting) setting; 591 if (sps.getTabPreferenceSetting(this) == preferenceSettings) { 592 try { 593 sps.addGui(this); 594 } catch (SecurityException ex) { 595 Main.error(ex); 596 } catch (RuntimeException ex) { 597 BugReportExceptionHandler.handleException(ex); 598 } finally { 599 settingsInitialized.add(sps); 600 } 601 } 590 addSubPreferenceSetting(preferenceSettings, (SubPreferenceSetting) setting); 602 591 } 603 592 } … … 618 607 } 619 608 } 609 610 private void addSubPreferenceSetting(TabPreferenceSetting preferenceSettings, SubPreferenceSetting sps) { 611 if (sps.getTabPreferenceSetting(this) == preferenceSettings) { 612 try { 613 sps.addGui(this); 614 } catch (SecurityException ex) { 615 Main.error(ex); 616 } catch (RuntimeException ex) { 617 BugReportExceptionHandler.handleException(ex); 618 } finally { 619 settingsInitialized.add(sps); 620 } 621 } 622 } 620 623 }
Note:
See TracChangeset
for help on using the changeset viewer.