Changeset 16274 in josm for trunk/src/org
- Timestamp:
- 2020-04-12T16:21:14+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/HelpTagAction.java
r15581 r16274 8 8 import java.util.Objects; 9 9 import java.util.function.IntFunction; 10 import java.util.function.Supplier; 10 11 11 12 import javax.swing.JTable; 12 13 14 import org.openstreetmap.josm.data.osm.Tag; 13 15 import org.openstreetmap.josm.gui.MainApplication; 14 16 … … 18 20 */ 19 21 public class HelpTagAction extends HelpAction { 20 private final JTable tagTable; 21 private final IntFunction<String> tagKeySupplier; 22 private final IntFunction<Map<String, Integer>> tagValuesSupplier; 22 private final Supplier<Tag> tagSupplier; 23 24 /** 25 * Constructs a new {@code HelpAction}. 26 * @param tagSupplier Supplies the tag for which the help should be shown 27 * @since 16274 28 */ 29 public HelpTagAction(Supplier<Tag> tagSupplier) { 30 this.tagSupplier = Objects.requireNonNull(tagSupplier); 31 putValue(NAME, tr("Go to OSM wiki for tag help")); 32 } 23 33 24 34 /** … … 29 39 */ 30 40 public HelpTagAction(JTable tagTable, IntFunction<String> tagKeySupplier, IntFunction<Map<String, Integer>> tagValuesSupplier) { 31 this.tagTable = Objects.requireNonNull(tagTable); 32 this.tagKeySupplier = Objects.requireNonNull(tagKeySupplier); 33 this.tagValuesSupplier = Objects.requireNonNull(tagValuesSupplier); 41 this.tagSupplier = () -> { 42 if (tagTable.getSelectedRowCount() == 1) { 43 int row = tagTable.getSelectedRow(); 44 String key = tagKeySupplier.apply(row); 45 Map<String, Integer> m = tagValuesSupplier.apply(row); 46 if (!m.isEmpty()) { 47 String val = m.entrySet().iterator().next().getKey(); 48 return new Tag(key, val); 49 } 50 } 51 return null; 52 }; 34 53 putValue(NAME, tr("Go to OSM wiki for tag help")); 35 54 } … … 37 56 @Override 38 57 public void actionPerformed(ActionEvent e) { 39 if (tagTable.getSelectedRowCount() == 1) { 40 int row = tagTable.getSelectedRow(); 41 String key = tagKeySupplier.apply(row); 42 Map<String, Integer> m = tagValuesSupplier.apply(row); 43 if (!m.isEmpty()) { 44 String val = m.entrySet().iterator().next().getKey(); 45 MainApplication.worker.execute(() -> displayTagHelp(key, val)); 46 } 58 Tag tag = tagSupplier.get(); 59 if (tag != null) { 60 MainApplication.worker.execute(() -> displayTagHelp(tag.getKey(), tag.getValue())); 47 61 } else { 48 62 super.actionPerformed(e);
Note:
See TracChangeset
for help on using the changeset viewer.