Changeset 3734 in josm
- Timestamp:
- 2010-12-21T11:44:19+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java
r3722 r3734 195 195 } 196 196 197 private boolean confirmOverwriteBookmark() { 198 ExtendedDialog dialog = new ExtendedDialog( 199 Main.parent, 200 tr("Overwrite"), 201 new String[] {tr("Overwrite"), tr("Cancel")} 202 ) {{ 203 contentInsets = new Insets(10, 15, 10, 15); 204 }}; 205 dialog.setContent(tr("Offset bookmark already exists. Overwrite?")); 206 dialog.setButtonIcons(new String[] {"ok.png", "cancel.png"}); 207 dialog.setupDialog(); 208 dialog.setVisible(true); 209 return dialog.getValue() == 1; 210 } 211 197 212 @Override 198 213 protected void buttonAction(int buttonIndex, ActionEvent evt) { 214 if (buttonIndex != 1 && tBookmarkName.getText() != null && !"".equals(tBookmarkName.getText()) && 215 OffsetBookmark.getBookmarkByName(layer, tBookmarkName.getText()) != null) { 216 if (!confirmOverwriteBookmark()) return; 217 } 199 218 super.buttonAction(buttonIndex, evt); 200 219 offsetDialog = null; … … 202 221 layer.setOffset(oldDx, oldDy); 203 222 } else if (tBookmarkName.getText() != null && !"".equals(tBookmarkName.getText())) { 204 OffsetBookmark b = new OffsetBookmark( 205 Main.proj,layer.getInfo().getName(), 206 tBookmarkName.getText(), 207 layer.getDx(),layer.getDy()); 208 OffsetBookmark.allBookmarks.add(b); 209 OffsetBookmark.saveBookmarks(); 223 OffsetBookmark.bookmarkOffset(tBookmarkName.getText(), layer); 210 224 } 211 225 Main.main.menu.imageryMenuUpdater.refreshOffsetMenu(); -
trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java
r3720 r3734 9 9 import java.util.LinkedList; 10 10 import java.util.List; 11 import java.util.ListIterator; 11 12 12 13 import org.openstreetmap.josm.Main; … … 76 77 } 77 78 79 public static OffsetBookmark getBookmarkByName(ImageryLayer layer, String name) { 80 for (OffsetBookmark b : allBookmarks) { 81 if (b.isUsable(layer) && name.equals(b.name)) 82 return b; 83 } 84 return null; 85 } 86 87 public static void bookmarkOffset(String name, ImageryLayer layer) { 88 OffsetBookmark nb = new OffsetBookmark( 89 Main.proj, layer.getInfo().getName(), 90 name, layer.getDx(), layer.getDy()); 91 for (ListIterator<OffsetBookmark> it = allBookmarks.listIterator();it.hasNext();) { 92 OffsetBookmark b = it.next(); 93 if (b.isUsable(layer) && name.equals(b.name)) { 94 it.set(nb); 95 saveBookmarks(); 96 return; 97 } 98 } 99 allBookmarks.add(nb); 100 saveBookmarks(); 101 } 78 102 }
Note:
See TracChangeset
for help on using the changeset viewer.