Changeset 19085 in josm
- Timestamp:
- 2024-05-22T21:12:24+02:00 (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r19006 r19085 141 141 /** The preference storage of recent tags */ 142 142 public static final ListProperty PROPERTY_RECENT_TAGS = new ListProperty("properties.recent-tags", 143 Collections. <String>emptyList());143 Collections.emptyList()); 144 144 /** The preference list of tags which should not be remembered, since r9940 */ 145 145 public static final StringProperty PROPERTY_TAGS_TO_IGNORE = new StringProperty("properties.recent-tags.ignore", … … 181 181 /** 182 182 * Copy of recently added tags in sorted from newest to oldest order. 183 * 183 * <p> 184 184 * We store the maximum number of recent tags to allow dynamic change of number of tags shown in the preferences. 185 185 * Used to cache initial status. … … 278 278 if (activeDataSet == null) 279 279 return; 280 try { 281 activeDataSet.beginUpdate(); 282 Collection<OsmPrimitive> selection = OsmDataManager.getInstance().getInProgressSelection(); 283 this.sel = selection; 284 if (Utils.isEmpty(selection)) 285 return; 286 287 final AddTagsDialog addDialog = getAddTagsDialog(); 288 289 addDialog.showDialog(); 290 291 addDialog.destroyActions(); 280 final Collection<OsmPrimitive> selection = updateSelection(); 281 282 if (Utils.isEmpty(selection)) 283 return; 284 285 final AddTagsDialog addDialog = getAddTagsDialog(); 286 287 addDialog.showDialog(); 288 289 addDialog.destroyActions(); 290 activeDataSet.update(() -> { 292 291 // Remote control can cause the selection to change, see #23191. 293 if (addDialog.getValue() == 1 && (selection == sel|| warnSelectionChanged())) {292 if (addDialog.getValue() == 1 && (selection.equals(updateSelection()) || warnSelectionChanged())) { 294 293 addDialog.performTagAdding(selection); 295 294 } else { 296 295 addDialog.undoAllTagsAdding(); 297 296 } 298 } finally { 299 activeDataSet.endUpdate(); 300 } 297 }); 301 298 } 302 299 … … 317 314 public void editTag(final int row, boolean focusOnKey) { 318 315 changedKey = null; 319 sel = OsmDataManager.getInstance().getInProgressSelection();316 updateSelection(); 320 317 if (Utils.isEmpty(sel)) 321 318 return; … … 361 358 362 359 /** 360 * Update the current selection for this editor 361 */ 362 private Collection<OsmPrimitive> updateSelection() { 363 final DataSet activeDataSet = OsmDataManager.getInstance().getActiveDataSet(); 364 try { 365 activeDataSet.getReadLock().lock(); 366 Collection<OsmPrimitive> selection = new ArrayList<>(OsmDataManager.getInstance().getInProgressSelection()); 367 this.sel = selection; 368 return selection; 369 } finally { 370 activeDataSet.getReadLock().unlock(); 371 } 372 } 373 374 /** 363 375 * For a given key k, return a list of keys which are used as keys for 364 376 * auto-completing values to increase the search space. … … 370 382 return Arrays.asList("addr:street", "name"); 371 383 else 372 return Arrays.asList(key);384 return Collections.singletonList(key); 373 385 } 374 386 … … 552 564 p.add(new JLabel(tr("Key")), GBC.std()); 553 565 p.add(Box.createHorizontalStrut(10), GBC.std()); 554 p.add(keys, GBC.eol().fill(G BC.HORIZONTAL));566 p.add(keys, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 555 567 556 568 List<AutoCompletionItem> valueList = autocomplete.getTagValues(getAutocompletionKeys(key), usedValuesAwareComparator); … … 569 581 p.add(new JLabel(tr("Value")), GBC.std()); 570 582 p.add(Box.createHorizontalStrut(10), GBC.std()); 571 p.add(values, GBC.eol().fill(G BC.HORIZONTAL));583 p.add(values, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 572 584 p.add(Box.createVerticalStrut(2), GBC.eol()); 573 585 … … 829 841 mainPanel.add(new JLabel("<html>"+trn("This will change up to {0} object.", 830 842 "This will change up to {0} objects.", sel.size(), sel.size()) 831 +"<br><br>"+tr("Please select a key")), GBC.eol().fill(G BC.HORIZONTAL));843 +"<br><br>"+tr("Please select a key")), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 832 844 833 845 keys = new AutoCompComboBox<>(); … … 837 849 keys.setAutocompleteEnabled(AUTOCOMPLETE_KEYS.get()); 838 850 839 mainPanel.add(keys, GBC.eop().fill(G BC.HORIZONTAL));851 mainPanel.add(keys, GBC.eop().fill(GridBagConstraints.HORIZONTAL)); 840 852 mainPanel.add(new JLabel(tr("Choose a value")), GBC.eol()); 841 853 … … 846 858 values.setAutocompleteEnabled(AUTOCOMPLETE_VALUES.get()); 847 859 848 mainPanel.add(values, GBC.eop().fill(G BC.HORIZONTAL));860 mainPanel.add(values, GBC.eop().fill(GridBagConstraints.HORIZONTAL)); 849 861 850 862 cacheRecentTags(); … … 978 990 lines.add(sc.getKeyText() + ' ' + tr("to apply first suggestion")) 979 991 ); 980 lines.add(Shortcut.getKeyText(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK)) + ' '992 lines.add(Shortcut.getKeyText(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK)) + ' ' 981 993 +tr("to add without closing the dialog")); 982 Shortcut.findShortcut(KeyEvent.VK_1, commandDownMask | KeyEvent.SHIFT_DOWN_MASK).ifPresent(sc ->994 Shortcut.findShortcut(KeyEvent.VK_1, commandDownMask | InputEvent.SHIFT_DOWN_MASK).ifPresent(sc -> 983 995 lines.add(sc.getKeyText() + ' ' + tr("to add first suggestion without closing the dialog")) 984 996 ); … … 1013 1025 recentTagsPanel = new JPanel(new GridBagLayout()); 1014 1026 buildRecentTagsPanel(); 1015 mainPanel.add(recentTagsPanel, GBC.eol().fill(G BC.HORIZONTAL));1027 mainPanel.add(recentTagsPanel, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 1016 1028 } else { 1017 1029 Dimension panelOldSize = recentTagsPanel.getPreferredSize(); … … 1132 1144 JPanel tagPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); 1133 1145 tagPanel.add(tagLabel); 1134 recentTagsPanel.add(tagPanel, GBC.eol().fill(G BC.HORIZONTAL));1146 recentTagsPanel.add(tagPanel, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 1135 1147 } 1136 1148 // Clear label if no tags were added
Note:
See TracChangeset
for help on using the changeset viewer.