Changeset 15423 in josm for trunk/src/org/openstreetmap/josm
- Timestamp:
- 2019-10-05T19:23:20+02:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Link.java
r14649 r15423 7 7 import java.util.Arrays; 8 8 import java.util.Collection; 9 import java.util.List;10 9 import java.util.Optional; 11 10 … … 22 21 /** 23 22 * Hyperlink type. 23 * @since 8863 24 24 */ 25 25 public class Link extends TextItem { … … 37 37 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 38 38 initializeLocaleText(tr("More information about this feature")); 39 Optional.ofNullable(buildUrlLabel()).ifPresent(label -> p.add(label, GBC.eol().insets(0, 10, 0, 0).fill(GBC.HORIZONTAL))); 40 return false; 41 } 42 43 protected UrlLabel buildUrlLabel() { 44 final String url = getUrl(); 39 45 if (wiki != null) { 40 final String url = Config.getUrls().getOSMWiki() + "/wiki/" + wiki; 41 final UrlLabel label = new UrlLabel(url, locale_text, 2) { 46 return new UrlLabel(url, locale_text, 2) { 42 47 @Override 43 48 public void mouseClicked(MouseEvent e) { 44 49 if (SwingUtilities.isLeftMouseButton(e)) { 45 50 // Open localized page if exists 46 final List<String> pages =Arrays.asList(51 HelpAction.displayHelp(Arrays.asList( 47 52 LanguageInfo.getWikiLanguagePrefix(LanguageInfo.LocaleType.OSM_WIKI) + wiki, 48 wiki); 49 HelpAction.displayHelp(pages); 53 wiki)); 50 54 } else { 51 55 super.mouseClicked(e); … … 53 57 } 54 58 }; 55 p.add(label, GBC.eol().insets(0, 10, 0, 0).fill(GBC.HORIZONTAL));56 59 } else if (href != null || locale_href != null) { 57 final String url = Optional.ofNullable(locale_href).orElse(href); 58 final UrlLabel label = new UrlLabel(url, locale_text, 2); 59 p.add(label, GBC.eol().insets(0, 10, 0, 0).fill(GBC.HORIZONTAL)); 60 return new UrlLabel(url, locale_text, 2); 60 61 } 61 return false; 62 return null; 63 } 64 65 /** 66 * Returns the link URL. 67 * @return the link URL 68 * @since 15423 69 */ 70 public String getUrl() { 71 if (wiki != null) { 72 return Config.getUrls().getOSMWiki() + "/wiki/" + wiki; 73 } else if (href != null || locale_href != null) { 74 return Optional.ofNullable(locale_href).orElse(href); 75 } 76 return null; 62 77 } 63 78 -
trunk/src/org/openstreetmap/josm/tools/HttpClient.java
r15389 r15423 821 821 } 822 822 823 private static boolean isRedirect(final int statusCode) { 823 /** 824 * Determines if the given status code is an HTTP redirection. 825 * @param statusCode HTTP status code 826 * @return {@code true} if the given status code is an HTTP redirection 827 * @since 15423 828 */ 829 public static boolean isRedirect(final int statusCode) { 824 830 switch (statusCode) { 825 831 case HttpURLConnection.HTTP_MOVED_PERM: // 301
Note:
See TracChangeset
for help on using the changeset viewer.