Changeset 14646 in josm for trunk/src/org
- Timestamp:
- 2019-01-05T21:20:06+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Link.java
r11553 r14646 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.event.MouseEvent; 7 import java.util.Arrays; 6 8 import java.util.Collection; 9 import java.util.Optional; 7 10 8 11 import javax.swing.JPanel; 12 import javax.swing.SwingUtilities; 9 13 10 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 import org.openstreetmap.josm.gui.dialogs.properties.HelpAction; 11 16 import org.openstreetmap.josm.gui.widgets.UrlLabel; 17 import org.openstreetmap.josm.spi.preferences.Config; 12 18 import org.openstreetmap.josm.tools.GBC; 19 import org.openstreetmap.josm.tools.LanguageInfo; 13 20 14 21 /** … … 16 23 */ 17 24 public class Link extends TextItem { 25 26 /** The OSM wiki page to display. */ 27 public String wiki; // NOSONAR 18 28 19 29 /** The link to display. */ … … 26 36 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 27 37 initializeLocaleText(tr("More information about this feature")); 28 String url = java.util.Optional.ofNullable(locale_href).orElse(href); 29 if (url != null) { 30 p.add(new UrlLabel(url, locale_text, 2), GBC.eol().insets(0, 10, 0, 0).fill(GBC.HORIZONTAL)); 38 if (wiki != null) { 39 final String url = Config.getUrls().getOSMWiki() + "/wiki/" + wiki; 40 final UrlLabel label = new UrlLabel(url, locale_text, 2) { 41 @Override 42 public void mouseClicked(MouseEvent e) { 43 if (SwingUtilities.isLeftMouseButton(e)) { 44 // Open localized page if exists 45 HelpAction.displayHelp(Arrays.asList(LanguageInfo.getWikiLanguagePrefix() + wiki, wiki)); 46 } else { 47 super.mouseClicked(e); 48 } 49 } 50 }; 51 p.add(label, GBC.eol().insets(0, 10, 0, 0).fill(GBC.HORIZONTAL)); 52 } else { 53 final String url = Optional.ofNullable(locale_href).orElse(href); 54 final UrlLabel label = new UrlLabel(url, locale_text, 2); 55 p.add(label, GBC.eol().insets(0, 10, 0, 0).fill(GBC.HORIZONTAL)); 31 56 } 32 57 return false; … … 36 61 protected String fieldsToString() { 37 62 return super.fieldsToString() 63 + (wiki != null ? "wiki=" + wiki + ", " : "") 38 64 + (href != null ? "href=" + href + ", " : "") 39 65 + (locale_href != null ? "locale_href=" + locale_href + ", " : "");
Note:
See TracChangeset
for help on using the changeset viewer.