- Timestamp:
- 2014-05-18T00:55:26+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r7029 r7137 216 216 } 217 217 218 /** 219 * Warns user about a key being overwritten. 220 * @param action The action done by the user. Must state what key is changed 221 * @param togglePref The preference to save the checkbox state to 222 * @return {@code true} if the user accepts to overwrite key, {@code false} otherwise 223 */ 224 private boolean warnOverwriteKey(String action, String togglePref) { 225 ExtendedDialog ed = new ExtendedDialog( 226 Main.parent, 227 tr("Overwrite key"), 228 new String[]{tr("Replace"), tr("Cancel")}); 229 ed.setButtonIcons(new String[]{"purge", "cancel"}); 230 ed.setContent(action+"\n"+ tr("The new key is already used, overwrite values?")); 231 ed.setCancelButton(2); 232 ed.toggleEnable(togglePref); 233 ed.showDialog(); 234 235 return ed.getValue() == 1; 236 } 237 218 238 public final class EditTagDialog extends AbstractTagsDialog { 219 239 final String key; … … 351 371 } else { 352 372 for (OsmPrimitive osm: sel) { 353 if(osm.get(newkey) != null) { 354 ExtendedDialog ed = new ExtendedDialog( 355 Main.parent, 356 tr("Overwrite key"), 357 new String[]{tr("Replace"), tr("Cancel")}); 358 ed.setButtonIcons(new String[]{"purge", "cancel"}); 359 ed.setContent(tr("You changed the key from ''{0}'' to ''{1}''.\n" 360 + "The new key is already used, overwrite values?", key, newkey)); 361 ed.setCancelButton(2); 362 ed.toggleEnable("overwriteEditKey"); 363 ed.showDialog(); 364 365 if (ed.getValue() != 1) 373 if (osm.get(newkey) != null) { 374 if (!warnOverwriteKey(tr("You changed the key from ''{0}'' to ''{1}''.", key, newkey), 375 "overwriteEditKey")) 366 376 return; 367 377 break; … … 748 758 String value = Tag.removeWhiteSpaces(values.getEditor().getItem().toString()); 749 759 if (key.isEmpty() || value.isEmpty()) return; 760 for (OsmPrimitive osm: sel) { 761 String val = osm.get(key); 762 if (val != null) { 763 if (!warnOverwriteKey(tr("You changed the value of ''{0}'' from ''{1}'' to ''{2}''.", key, val, value), 764 "overwriteAddKey")) 765 return; 766 break; 767 } 768 } 750 769 lastAddKey = key; 751 770 lastAddValue = value;
Note:
See TracChangeset
for help on using the changeset viewer.