1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.tagging.presets.items;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.util.Collection;
|
---|
7 |
|
---|
8 | import javax.swing.JPanel;
|
---|
9 |
|
---|
10 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
11 | import org.openstreetmap.josm.gui.widgets.UrlLabel;
|
---|
12 | import org.openstreetmap.josm.tools.GBC;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * Hyperlink type.
|
---|
16 | */
|
---|
17 | public class Link extends TextItem {
|
---|
18 |
|
---|
19 | /** The link to display. */
|
---|
20 | public String href; // NOSONAR
|
---|
21 |
|
---|
22 | /** The localized version of {@link #href}. */
|
---|
23 | public String locale_href; // NOSONAR
|
---|
24 |
|
---|
25 | @Override
|
---|
26 | public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {
|
---|
27 | 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));
|
---|
31 | }
|
---|
32 | return false;
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | protected String fieldsToString() {
|
---|
37 | return super.fieldsToString()
|
---|
38 | + (href != null ? "href=" + href + ", " : "")
|
---|
39 | + (locale_href != null ? "locale_href=" + locale_href + ", " : "");
|
---|
40 | }
|
---|
41 | }
|
---|