Changeset 15751 in josm for trunk/src/org
- Timestamp:
- 2020-01-22T21:18:17+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/properties
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/AbstractCopyAction.java
r15717 r15751 9 9 import java.util.function.Supplier; 10 10 import java.util.stream.Collectors; 11 import java.util.stream.Stream; 11 12 12 13 import javax.swing.AbstractAction; … … 40 41 protected abstract Collection<String> getString(Tagged p, String key); 41 42 42 @Override 43 public void actionPerformed(ActionEvent ae) { 43 protected Stream<String> valueStream() { 44 44 int[] rows = tagTable.getSelectedRows(); 45 45 Collection<? extends Tagged> sel = objectSupplier.get(); 46 if (rows.length == 0 || sel == null || sel.isEmpty()) return; 47 48 final String values = Arrays.stream(rows) 46 if (rows.length == 0 || sel == null || sel.isEmpty()) return Stream.empty(); 47 return Arrays.stream(rows) 49 48 .mapToObj(keySupplier) 50 49 .flatMap(key -> sel.stream().map(p -> getString(p, key))) 51 50 .filter(Objects::nonNull) 52 .flatMap(Collection::stream) 51 .flatMap(Collection::stream); 52 } 53 54 @Override 55 public void actionPerformed(ActionEvent ae) { 56 final String values = valueStream() 53 57 .sorted() 54 58 .collect(Collectors.joining("\n")); -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/CopyKeyValueAction.java
r13849 r15751 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trn; 5 6 6 7 import java.util.Collection; … … 10 11 11 12 import javax.swing.JTable; 13 import javax.swing.event.PopupMenuEvent; 14 import javax.swing.event.PopupMenuListener; 12 15 13 16 import org.openstreetmap.josm.data.osm.Tag; … … 18 21 * @since 13521 19 22 */ 20 public class CopyKeyValueAction extends AbstractCopyAction {23 public class CopyKeyValueAction extends AbstractCopyAction implements PopupMenuListener { 21 24 22 25 /** … … 28 31 public CopyKeyValueAction(JTable tagTable, IntFunction<String> keyFn, Supplier<Collection<? extends Tagged>> objectSp) { 29 32 super(tagTable, keyFn, objectSp); 30 putValue(NAME, tr("Copy selected Key(s)/Value(s)"));33 setName(0); 31 34 putValue(SHORT_DESCRIPTION, tr("Copy the key and value of the selected tag(s) to clipboard")); 35 } 36 37 private void setName(long n) { 38 putValue(NAME, trn("Copy selected {0} Key/Value", "Copy selected {0} Keys/Values", n, n)); 32 39 } 33 40 … … 37 44 return v == null ? null : Collections.singleton(new Tag(key, v).toString()); 38 45 } 46 47 @Override 48 public void popupMenuWillBecomeVisible(PopupMenuEvent e) { 49 setName(valueStream().count()); 50 } 51 52 @Override 53 public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { 54 // Do nothing 55 } 56 57 @Override 58 public void popupMenuCanceled(PopupMenuEvent e) { 59 // Do nothing 60 } 39 61 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r15707 r15751 447 447 tagMenu.add(copyValueAction); 448 448 tagMenu.add(copyKeyValueAction); 449 tagMenu.addPopupMenuListener(copyKeyValueAction); 449 450 tagMenu.add(copyAllKeyValueAction); 450 451 tagMenu.addSeparator();
Note:
See TracChangeset
for help on using the changeset viewer.