- Timestamp:
- 2009-09-02T21:17:52+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 17 added
- 55 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r2017 r2025 2 2 package org.openstreetmap.josm; 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 import static org.openstreetmap.josm.tools.I18n.trn; 4 5 5 6 import java.awt.BorderLayout; … … 12 13 import java.net.URI; 13 14 import java.net.URISyntaxException; 15 import java.util.ArrayList; 14 16 import java.util.Collection; 17 import java.util.List; 15 18 import java.util.Map; 16 19 import java.util.StringTokenizer; … … 22 25 import javax.swing.JComponent; 23 26 import javax.swing.JFrame; 27 import javax.swing.JLabel; 24 28 import javax.swing.JOptionPane; 25 29 import javax.swing.JPanel; … … 45 49 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 46 50 import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask; 51 import org.openstreetmap.josm.gui.io.SaveLayersDialog; 47 52 import org.openstreetmap.josm.gui.layer.Layer; 48 53 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 393 398 } 394 399 395 public static boolean breakBecauseUnsavedChanges() { 400 public static boolean saveUnsavedModifications() { 401 if (map == null) return true; 402 SaveLayersDialog dialog = new SaveLayersDialog(Main.parent); 403 List<OsmDataLayer> layersWithUnmodifiedChanges = new ArrayList<OsmDataLayer>(); 404 for (OsmDataLayer l: Main.map.mapView.getLayersOfType(OsmDataLayer.class)) { 405 if (l.requiresSaveToFile() || l.requiresUploadToServer()) { 406 layersWithUnmodifiedChanges.add(l); 407 } 408 } 409 dialog.prepareForSavingAndUpdatingLayersBeforeExit(); 410 if (!layersWithUnmodifiedChanges.isEmpty()) { 411 dialog.getModel().populate(layersWithUnmodifiedChanges); 412 dialog.setVisible(true); 413 switch(dialog.getUserAction()) { 414 case CANCEL: return false; 415 case PROCEED: return true; 416 default: return false; 417 } 418 } 419 return true; 420 } 421 422 /** 423 * Saves all {@see OsmDataLayer}s with an associated file and with unsaved 424 * data modifications. 425 * 426 * @return true, if the save operation was successful; false, otherwise 427 */ 428 public static boolean saveUnsavedModifications_old() { 396 429 Shortcut.savePrefs(); 397 if (map != null) { 398 boolean modified = false; 399 boolean uploadedModified = false; 400 for (final Layer l : map.mapView.getAllLayers()) { 401 if (l instanceof OsmDataLayer && ((OsmDataLayer)l).isModified()) { 402 modified = true; 403 uploadedModified = ((OsmDataLayer)l).uploadedModified; 404 break; 405 } 406 } 407 if (modified) { 408 final String msg = uploadedModified ? "\n" 409 +tr("Hint: Some changes came from uploading new data to the server.") : ""; 410 int result = new ExtendedDialog(parent, tr("Unsaved Changes"), 411 new javax.swing.JLabel(tr("There are unsaved changes. Discard the changes and continue?")+msg), 412 new String[] {tr("Save and Exit"), tr("Discard and Exit"), tr("Cancel")}, 413 new String[] {"save.png", "exit.png", "cancel.png"}).getValue(); 414 415 // Save before exiting 416 if(result == 1) { 417 Boolean savefailed = false; 418 for (final Layer l : map.mapView.getAllLayers()) { 419 if (l instanceof OsmDataLayer && ((OsmDataLayer)l).isModified()) { 420 SaveAction save = new SaveAction(); 421 if(!save.doSave(l)) { 422 savefailed = true; 423 } 424 } 425 } 426 return savefailed; 427 } 428 else if(result != 2) // Cancel exiting unless the 2nd button was clicked 429 return true; 430 } 431 } 432 return false; 430 if (map == null) 431 return true; // nothing to save, return success 432 433 int numUnsavedLayers = 0; 434 for (final OsmDataLayer l : map.mapView.getLayersOfType(OsmDataLayer.class)) { 435 if (l.requiresSaveToFile()) { 436 numUnsavedLayers++; 437 } 438 } 439 if (numUnsavedLayers == 0) 440 return true; // nothing to save, return success 441 442 String msg = trn( 443 "There are unsaved changes in {0} layer. Discard the changes and continue?", 444 "There are unsaved changes in {0} layers. Discard the changes and continue?", 445 numUnsavedLayers, 446 numUnsavedLayers 447 ); 448 int result = new ExtendedDialog(parent, tr("Unsaved Changes"), 449 new JLabel(msg), 450 new String[] {tr("Save and Exit"), tr("Discard and Exit"), tr("Cancel")}, 451 new String[] {"save.png", "exit.png", "cancel.png"}).getValue(); 452 453 switch(result) { 454 case 2: /* discard and exit */ return true; 455 case 3: /* cancel */ return false; 456 } 457 boolean savefailed = false; 458 for (OsmDataLayer l : map.mapView.getLayersOfType(OsmDataLayer.class)) { 459 if(!new SaveAction().doSave(l)) { 460 savefailed = true; 461 } 462 } 463 return !savefailed; 433 464 } 434 465 -
trunk/src/org/openstreetmap/josm/actions/AbstractInfoAction.java
r2017 r2025 52 52 Iterator<OsmPrimitive> it = primitivesToShow.iterator(); 53 53 while(it.hasNext()) { 54 if (it.next(). id== 0) {54 if (it.next().getId() == 0) { 55 55 it.remove(); 56 56 } -
trunk/src/org/openstreetmap/josm/actions/ApiPreconditionChecker.java
r2017 r2025 1 // License: GPL. For details, see LICENSE file.2 1 package org.openstreetmap.josm.actions; 3 2 … … 71 70 for (Entry<String,String> e : osmPrimitive.entrySet()) { 72 71 if(e.getValue().length() > 255) { 73 if (osmPrimitive. deleted) {72 if (osmPrimitive.isDeleted()) { 74 73 // if OsmPrimitive is going to be deleted we automatically shorten the 75 74 // value … … 77 76 tr("Warning: automatically truncating value of tag ''{0}'' on deleted primitive {1}", 78 77 e.getKey(), 79 Long.toString(osmPrimitive. id)78 Long.toString(osmPrimitive.getId()) 80 79 ) 81 80 ); … … 85 84 JOptionPane.showMessageDialog(Main.parent, 86 85 tr("Length of value for tag ''{0}'' on primitive {1} exceeds the max. allowed length {2}. Values length is {3}.", 87 e.getKey(), Long.toString(osmPrimitive. id), 255, e.getValue().length()86 e.getKey(), Long.toString(osmPrimitive.getId()), 255, e.getValue().length() 88 87 ), 89 88 tr("Precondition Violation"), … … 103 102 tr("{0} nodes in way {1} exceed the max. allowed number of nodes {2}", 104 103 ((Way)osmPrimitive).getNodesCount(), 105 Long.toString(osmPrimitive. id),104 Long.toString(osmPrimitive.getId()), 106 105 maxNodes 107 106 ), -
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r2017 r2025 90 90 HashSet<Relation> relationsUsingWays = new HashSet<Relation>(); 91 91 for (Relation r : getCurrentDataSet().relations) { 92 if (r. deleted|| r.incomplete) {92 if (r.isDeleted() || r.incomplete) { 93 93 continue; 94 94 } … … 177 177 for (Way w : selectedWays) { 178 178 modifyWay = w; 179 if (w. id!= 0) {179 if (w.getId() != 0) { 180 180 break; 181 181 } -
trunk/src/org/openstreetmap/josm/actions/ExitAction.java
r1677 r2025 21 21 public ExitAction() { 22 22 super(tr("Exit"), "exit", tr("Exit the application."), 23 Shortcut.registerShortcut("system:menuexit", tr("Exit"), KeyEvent.VK_Q, Shortcut.GROUP_MENU), true);23 Shortcut.registerShortcut("system:menuexit", tr("Exit"), KeyEvent.VK_Q, Shortcut.GROUP_MENU), true); 24 24 } 25 25 26 26 public void actionPerformed(ActionEvent e) { 27 if ( !Main.breakBecauseUnsavedChanges()) {27 if (Main.saveUnsavedModifications()) { 28 28 Main.saveGuiGeometry(); 29 29 System.exit(0); -
trunk/src/org/openstreetmap/josm/actions/HistoryInfoAction.java
r1697 r2025 21 21 @Override 22 22 protected String createInfoUrl(OsmPrimitive primitive) { 23 return getBaseURL() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive. id+ "/history";23 return getBaseURL() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive.getId() + "/history"; 24 24 } 25 25 } -
trunk/src/org/openstreetmap/josm/actions/InfoAction.java
r1697 r2025 21 21 @Override 22 22 protected String createInfoUrl(OsmPrimitive primitive) { 23 return getBaseURL() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive. id;23 return getBaseURL() + "/" + OsmPrimitiveType.from(primitive).getAPIName() + "/" + primitive.getId(); 24 24 } 25 25 } -
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r2017 r2025 95 95 Node useNode = null; 96 96 for (Node n: selectedNodes) { 97 if (n. id> 0) {97 if (n.getId() > 0) { 98 98 useNode = n; 99 99 break; … … 127 127 HashSet<Relation> relationsUsingNodes = new HashSet<Relation>(); 128 128 for (Relation r : getCurrentDataSet().relations) { 129 if (r. deleted|| r.incomplete) {129 if (r.isDeleted() || r.incomplete) { 130 130 continue; 131 131 } … … 217 217 218 218 for (Way w : getCurrentDataSet().ways) { 219 if (w. deleted|| w.incomplete || w.getNodesCount() < 1) {219 if (w.isDeleted() || w.incomplete || w.getNodesCount() < 1) { 220 220 continue; 221 221 } -
trunk/src/org/openstreetmap/josm/actions/PasteTagsAction.java
r2008 r2025 126 126 protected Map<OsmPrimitiveType, Integer> getSourceStatistics() { 127 127 HashMap<OsmPrimitiveType, Integer> ret = new HashMap<OsmPrimitiveType, Integer>(); 128 for (Class type: new Class[] {Node.class, Way.class, Relation.class}) {128 for (Class<? extends OsmPrimitive> type: new Class[] {Node.class, Way.class, Relation.class}) { 129 129 if (!getSourceTagsByType(type).isEmpty()) { 130 130 ret.put(OsmPrimitiveType.from(type), getSourcePrimitivesByType(type).size()); … … 136 136 protected Map<OsmPrimitiveType, Integer> getTargetStatistics() { 137 137 HashMap<OsmPrimitiveType, Integer> ret = new HashMap<OsmPrimitiveType, Integer>(); 138 for (Class type: new Class[] {Node.class, Way.class, Relation.class}) {138 for (Class<? extends OsmPrimitive> type: new Class[] {Node.class, Way.class, Relation.class}) { 139 139 int count = getSubcollectionByType(getEditLayer().data.getSelected(), type).size(); 140 140 if (count > 0) { … … 156 156 protected void pasteFromHomogeneousSource(Collection<? extends OsmPrimitive> targets) { 157 157 TagCollection tc = null; 158 Class sourceType = null; 159 for (Class type : new Class[] {Node.class, Way.class, Relation.class}) { 158 for (Class<? extends OsmPrimitive> type : new Class[] {Node.class, Way.class, Relation.class}) { 160 159 TagCollection tc1 = getSourceTagsByType(type); 161 160 if (!tc1.isEmpty()) { 162 161 tc = tc1; 163 sourceType = type;164 162 } 165 163 } -
trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java
r2017 r2025 72 72 layer.setName(file.getName()); 73 73 layer.setAssociatedFile(file); 74 if (layer instanceof OsmDataLayer) { 75 ((OsmDataLayer) layer).onPostSaveToFile(); 76 } 74 77 Main.parent.repaint(); 75 78 } catch (IOException e) { … … 88 91 */ 89 92 public boolean checkSaveConditions(Layer layer) { 90 if (layer == null) {91 JOptionPane.showMessageDialog(92 Main.parent,93 tr("Internal Error: cannot check conditions for no layer. Please report this as a bug."),94 tr("Error"),95 JOptionPane.ERROR_MESSAGE96 );97 return false;98 }99 if (Main.map == null) {100 JOptionPane.showMessageDialog(101 Main.parent,102 tr("No document open so nothing to save."),103 tr("Warning"),104 JOptionPane.WARNING_MESSAGE105 );106 return false;107 }108 109 93 if (layer instanceof OsmDataLayer && isDataSetEmpty((OsmDataLayer)layer) && 1 != new ExtendedDialog(Main.parent, tr("Empty document"), tr("The document contains no data."), new String[] {tr("Save anyway"), tr("Cancel")}, new String[] {"save.png", "cancel.png"}).getValue()) 110 94 return false; … … 144 128 private boolean isDataSetEmpty(OsmDataLayer layer) { 145 129 for (OsmPrimitive osm : layer.data.allNonDeletedPrimitives()) 146 if (!osm. deleted || osm.id> 0)130 if (!osm.isDeleted() || osm.getId() > 0) 147 131 return false; 148 132 return true; -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r2017 r2025 102 102 for (Node n : selectedNodes) { 103 103 for (Way w : getCurrentDataSet().ways) { 104 if (w. deleted|| w.incomplete) {104 if (w.isDeleted() || w.incomplete) { 105 105 continue; 106 106 } … … 293 293 294 294 for (Relation r : getCurrentDataSet().relations) { 295 if (r. deleted|| r.incomplete) {295 if (r.isDeleted() || r.incomplete) { 296 296 continue; 297 297 } -
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r2017 r2025 66 66 int count = 0; 67 67 for (Way w : getCurrentDataSet().ways) { 68 if (w. deleted|| w.incomplete || w.getNodesCount() < 1) {68 if (w.isDeleted() || w.incomplete || w.getNodesCount() < 1) { 69 69 continue; 70 70 } … … 91 91 int count = 0; 92 92 for (Way w : getCurrentDataSet().ways) { 93 if (w. deleted|| w.incomplete || w.getNodesCount() < 1) {93 if (w.isDeleted() || w.incomplete || w.getNodesCount() < 1) { 94 94 continue; 95 95 } … … 321 321 HashSet<String> rolesToReAdd = null; 322 322 for (Relation r : getCurrentDataSet().relations) { 323 if (r. deleted|| r.incomplete) {323 if (r.isDeleted() || r.incomplete) { 324 324 continue; 325 325 } … … 368 368 // modify all ways containing the nodes 369 369 for (Way w : getCurrentDataSet().ways) { 370 if (w. deleted|| w.incomplete || w.getNodesCount() < 1) {370 if (w.isDeleted() || w.incomplete || w.getNodesCount() < 1) { 371 371 continue; 372 372 } -
trunk/src/org/openstreetmap/josm/actions/UpdateDataAction.java
r1881 r2025 79 79 // bounds defined? => use the bbox downloader 80 80 // 81 new DownloadOsmTaskList().download(false, areas, new PleaseWaitProgressMonitor( ));81 new DownloadOsmTaskList().download(false, areas, new PleaseWaitProgressMonitor(tr("Updating data"))); 82 82 } 83 83 } -
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r2017 r2025 166 166 protected void initMultiFetchReaderWithNodes(MultiFetchServerObjectReader reader) { 167 167 for (OsmPrimitive primitive : toUpdate) { 168 if (primitive instanceof Node && primitive. id> 0) {168 if (primitive instanceof Node && primitive.getId() > 0) { 169 169 reader.append((Node)primitive); 170 170 } else if (primitive instanceof Way) { 171 171 Way way = (Way)primitive; 172 172 for (Node node: way.getNodes()) { 173 if (node. id> 0) {173 if (node.getId() > 0) { 174 174 reader.append(node); 175 175 } … … 181 181 protected void initMultiFetchReaderWithWays(MultiFetchServerObjectReader reader) { 182 182 for (OsmPrimitive primitive : toUpdate) { 183 if (primitive instanceof Way && primitive. id> 0) {183 if (primitive instanceof Way && primitive.getId() > 0) { 184 184 reader.append((Way)primitive); 185 185 } … … 189 189 protected void initMultiFetchReaderWithRelations(MultiFetchServerObjectReader reader) { 190 190 for (OsmPrimitive primitive : toUpdate) { 191 if (primitive instanceof Relation && primitive. id> 0) {191 if (primitive instanceof Relation && primitive.getId() > 0) { 192 192 reader.append((Relation)primitive); 193 193 } -
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r2005 r2025 26 26 27 27 import org.openstreetmap.josm.Main; 28 import org.openstreetmap.josm.data.APIDataSet; 28 29 import org.openstreetmap.josm.data.conflict.ConflictCollection; 29 30 import org.openstreetmap.josm.data.osm.DataSet; … … 34 35 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 35 36 import org.openstreetmap.josm.gui.historycombobox.SuggestingJHistoryComboBox; 37 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 36 38 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 37 39 import org.openstreetmap.josm.io.OsmApi; … … 108 110 } 109 111 112 public boolean checkPreUploadConditions(OsmDataLayer layer) { 113 return checkPreUploadConditions(layer, new APIDataSet(layer.data)); 114 } 115 116 public boolean checkPreUploadConditions(OsmDataLayer layer, APIDataSet apiData) { 117 ConflictCollection conflicts = layer.getConflicts(); 118 if (conflicts !=null && !conflicts.isEmpty()) { 119 JOptionPane.showMessageDialog( 120 Main.parent, 121 tr("<html>There are unresolved conflicts in layer ''{0}''.<br>" 122 + "You have to resolve them first.<html>", layer.getName()), 123 tr("Warning"), 124 JOptionPane.WARNING_MESSAGE 125 ); 126 return false; 127 } 128 // Call all upload hooks in sequence. The upload confirmation dialog 129 // is one of these. 130 for(UploadHook hook : uploadHooks) 131 if(!hook.checkUpload(apiData.getPrimitivesToAdd(), apiData.getPrimitivesToUpdate(), apiData.getPrimitivesToDelete())) 132 return false; 133 134 return true; 135 } 136 110 137 public void actionPerformed(ActionEvent e) { 111 138 if (!isEnabled()) … … 121 148 } 122 149 123 ConflictCollection conflicts = Main.map.mapView.getEditLayer().getConflicts(); 124 if (conflicts !=null && !conflicts.isEmpty()) { 125 JOptionPane.showMessageDialog( 126 Main.parent, 127 tr("There are unresolved conflicts. You have to resolve these first."), 128 tr("Warning"), 129 JOptionPane.WARNING_MESSAGE 130 ); 131 Main.map.conflictDialog.showDialog(); 132 return; 133 } 134 135 final LinkedList<OsmPrimitive> add = new LinkedList<OsmPrimitive>(); 136 final LinkedList<OsmPrimitive> update = new LinkedList<OsmPrimitive>(); 137 final LinkedList<OsmPrimitive> delete = new LinkedList<OsmPrimitive>(); 138 for (OsmPrimitive osm : getCurrentDataSet().allPrimitives()) { 139 if (osm.get("josm/ignore") != null) { 140 continue; 141 } 142 if (osm.id == 0 && !osm.deleted) { 143 add.addLast(osm); 144 } else if (osm.modified && !osm.deleted) { 145 update.addLast(osm); 146 } else if (osm.deleted && osm.id != 0) { 147 delete.addFirst(osm); 148 } 149 } 150 151 if (add.isEmpty() && update.isEmpty() && delete.isEmpty()) { 150 APIDataSet apiData = new APIDataSet(Main.main.getCurrentDataSet()); 151 if (apiData.isEmpty()) { 152 152 JOptionPane.showMessageDialog( 153 153 Main.parent, 154 154 tr("No changes to upload."), 155 155 tr("Warning"), 156 JOptionPane. WARNING_MESSAGE156 JOptionPane.INFORMATION_MESSAGE 157 157 ); 158 158 return; 159 159 } 160 161 // Call all upload hooks in sequence. The upload confirmation dialog 162 // is one of these. 163 for(UploadHook hook : uploadHooks) 164 if(!hook.checkUpload(add, update, delete)) 165 return; 166 167 final Collection<OsmPrimitive> all = new LinkedList<OsmPrimitive>(); 168 all.addAll(add); 169 all.addAll(update); 170 all.addAll(delete); 171 172 Main.worker.execute(new UploadDiffTask(all)); 160 if (!checkPreUploadConditions(Main.map.mapView.getEditLayer(), apiData)) 161 return; 162 Main.worker.execute(createUploadTask(Main.map.mapView.getEditLayer(), apiData.getPrimitives())); 173 163 } 174 164 … … 235 225 ); 236 226 switch(ret) { 237 case JOptionPane.CLOSED_OPTION: return;238 case JOptionPane.CANCEL_OPTION: return;239 case 0: synchronizePrimitive(id); break;240 case 1: synchronizeDataSet(); break;241 default:242 // should not happen243 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret));227 case JOptionPane.CLOSED_OPTION: return; 228 case JOptionPane.CANCEL_OPTION: return; 229 case 0: synchronizePrimitive(id); break; 230 case 1: synchronizeDataSet(); break; 231 default: 232 // should not happen 233 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret)); 244 234 } 245 235 } … … 275 265 ); 276 266 switch(ret) { 277 case JOptionPane.CLOSED_OPTION: return;278 case 1: return;279 case 0: synchronizeDataSet(); break;280 default:281 // should not happen282 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret));267 case JOptionPane.CLOSED_OPTION: return; 268 case 1: return; 269 case 0: synchronizeDataSet(); break; 270 default: 271 // should not happen 272 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret)); 283 273 } 284 274 } … … 522 512 } 523 513 524 525 class UploadDiffTask extends PleaseWaitRunnable { 514 public UploadDiffTask createUploadTask(OsmDataLayer layer, Collection<OsmPrimitive> toUpload) { 515 return new UploadDiffTask(layer, toUpload); 516 } 517 518 public class UploadDiffTask extends PleaseWaitRunnable { 526 519 private boolean uploadCancelled = false; 527 520 private Exception lastException = null; 528 521 private Collection <OsmPrimitive> toUpload; 529 522 private OsmServerWriter writer; 530 531 public UploadDiffTask(Collection <OsmPrimitive> toUpload) { 532 super(tr("Uploading"),false /* don't ignore exceptions */); 523 private OsmDataLayer layer; 524 525 private UploadDiffTask(OsmDataLayer layer, Collection <OsmPrimitive> toUpload) { 526 super(tr("Uploading data for layer ''{0}''", layer.getName()),false /* don't ignore exceptions */); 533 527 this.toUpload = toUpload; 528 this.layer = layer; 534 529 } 535 530 … … 537 532 writer = new OsmServerWriter(); 538 533 try { 539 writer.uploadOsm(getCurrentDataSet().version, toUpload, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)); 534 ProgressMonitor monitor = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false); 535 writer.uploadOsm(layer.data.version, toUpload, monitor); 540 536 } catch (Exception sxe) { 541 537 if (uploadCancelled) { … … 554 550 // partially uploaded 555 551 // 556 getEditLayer().cleanupAfterUpload(writer.getProcessedPrimitives());557 DataSet.fireSelectionChanged( getEditLayer().data.getSelected());558 getEditLayer().fireDataChange();552 layer.cleanupAfterUpload(writer.getProcessedPrimitives()); 553 DataSet.fireSelectionChanged(layer.data.getSelected()); 554 layer.fireDataChange(); 559 555 if (lastException != null) { 560 556 handleFailedUpload(lastException); 557 } else { 558 layer.onPostUploadToServer(); 561 559 } 562 560 } … … 568 566 } 569 567 } 568 569 public boolean isSuccessful() { 570 return !isCancelled() && !isFailed(); 571 } 572 573 public boolean isCancelled() { 574 return uploadCancelled; 575 } 576 577 public boolean isFailed() { 578 return lastException != null; 579 } 570 580 } 571 581 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r2009 r2025 765 765 Way way = null; 766 766 for (Way w : getCurrentDataSet().ways) { 767 if (w. deleted|| w.incomplete || w.getNodesCount() < 1) {767 if (w.isDeleted() || w.incomplete || w.getNodesCount() < 1) { 768 768 continue; 769 769 } -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r1938 r2025 227 227 228 228 switch (mode) { 229 case NONE: 230 return false; 231 case MISSING_KEY: 232 return osm.get(key) == null; 233 case ANY: 234 return true; 235 case ANY_VALUE: 236 return osm.get(key) != null; 237 case ANY_KEY: 238 for (String v:osm.getKeys().values()) { 239 if (v.equals(value)) 240 return true; 241 } 242 return false; 243 case EXACT: 244 return value.equals(osm.get(key)); 245 case ANY_KEY_REGEXP: 246 for (String v:osm.getKeys().values()) { 247 if (valuePattern.matcher(v).matches()) 248 return true; 249 } 250 return false; 251 case ANY_VALUE_REGEXP: 252 case EXACT_REGEXP: 253 for (Entry<String, String> entry:osm.entrySet()) { 254 if (keyPattern.matcher(entry.getKey()).matches()) { 255 if (mode == Mode.ANY_VALUE_REGEXP 256 || valuePattern.matcher(entry.getValue()).matches()) 229 case NONE: 230 return false; 231 case MISSING_KEY: 232 return osm.get(key) == null; 233 case ANY: 234 return true; 235 case ANY_VALUE: 236 return osm.get(key) != null; 237 case ANY_KEY: 238 for (String v:osm.getKeys().values()) { 239 if (v.equals(value)) 257 240 return true; 258 241 } 259 } 260 return false; 261 case MISSING_KEY_REGEXP: 262 for (String k:osm.keySet()) { 263 if (keyPattern.matcher(k).matches()) 264 return false; 265 } 266 return true; 242 return false; 243 case EXACT: 244 return value.equals(osm.get(key)); 245 case ANY_KEY_REGEXP: 246 for (String v:osm.getKeys().values()) { 247 if (valuePattern.matcher(v).matches()) 248 return true; 249 } 250 return false; 251 case ANY_VALUE_REGEXP: 252 case EXACT_REGEXP: 253 for (Entry<String, String> entry:osm.entrySet()) { 254 if (keyPattern.matcher(entry.getKey()).matches()) { 255 if (mode == Mode.ANY_VALUE_REGEXP 256 || valuePattern.matcher(entry.getValue()).matches()) 257 return true; 258 } 259 } 260 return false; 261 case MISSING_KEY_REGEXP: 262 for (String k:osm.keySet()) { 263 if (keyPattern.matcher(k).matches()) 264 return false; 265 } 266 return true; 267 267 } 268 268 throw new AssertionError("Missed state"); … … 402 402 private static class Modified extends Match { 403 403 @Override public boolean match(OsmPrimitive osm) { 404 return osm. modified || osm.id== 0;404 return osm.isModified() || osm.getId() == 0; 405 405 } 406 406 @Override public String toString() {return "modified";} -
trunk/src/org/openstreetmap/josm/actions/search/SelectionWebsiteLoader.java
r2017 r2025 48 48 Map<Long, String> ids = idReader.parseIds(in); 49 49 for (OsmPrimitive osm : Main.main.getCurrentDataSet().allNonDeletedPrimitives()) { 50 if (ids.containsKey(osm. id) && osm.getClass().getName().toLowerCase().endsWith(ids.get(osm.id))) {50 if (ids.containsKey(osm.getId()) && osm.getClass().getName().toLowerCase().endsWith(ids.get(osm.getId()))) { 51 51 if (mode == SearchAction.SearchMode.remove) { 52 52 sel.remove(osm); -
trunk/src/org/openstreetmap/josm/command/ChangeCommand.java
r1990 r2025 36 36 super.executeCommand(); 37 37 osm.cloneFrom(newOsm); 38 osm. modified = true;38 osm.setModified(true); 39 39 return true; 40 40 } … … 47 47 String msg = ""; 48 48 switch(OsmPrimitiveType.from(osm)) { 49 case NODE: msg = marktr("Change node {0}"); break;50 case WAY: msg = marktr("Change way {0}"); break;51 case RELATION: msg = marktr("Change relation {0}"); break;49 case NODE: msg = marktr("Change node {0}"); break; 50 case WAY: msg = marktr("Change way {0}"); break; 51 case RELATION: msg = marktr("Change relation {0}"); break; 52 52 } 53 53 return new DefaultMutableTreeNode( -
trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java
r2008 r2025 77 77 if (value == null) { 78 78 for (OsmPrimitive osm : objects) { 79 osm. modified = true;79 osm.setModified(true); 80 80 osm.remove(key); 81 81 } 82 82 } else { 83 83 for (OsmPrimitive osm : objects) { 84 osm. modified = true;84 osm.setModified(true); 85 85 osm.put(key, value); 86 86 } -
trunk/src/org/openstreetmap/josm/command/ChangeRelationMemberRoleCommand.java
r1990 r2025 51 51 relation.getMember(position).role = newRole; 52 52 53 oldModified = relation. modified;54 relation. modified = true;53 oldModified = relation.isModified(); 54 relation.setModified(true); 55 55 return true; 56 56 } … … 58 58 @Override public void undoCommand() { 59 59 relation.getMember(position).role = oldRole; 60 relation. modified = oldModified;60 relation.setModified(oldModified); 61 61 } 62 62 -
trunk/src/org/openstreetmap/josm/command/Command.java
r1894 r2025 89 89 e.getKey().cloneFrom(e.getValue()); 90 90 } 91 getLayer().setModified(true);92 91 } 93 92 … … 114 113 if (o != null) 115 114 return o; 116 Main.debug("unable to find osm with id: " + osm. id+ " hashCode: " + osm.hashCode());115 Main.debug("unable to find osm with id: " + osm.getId() + " hashCode: " + osm.hashCode()); 117 116 for (OsmPrimitive t : cloneMap.keySet()) { 118 117 OsmPrimitive to = cloneMap.get(t); 119 Main.debug("now: " + t. id+ " hashCode: " + t.hashCode());120 Main.debug("orig: " + to. id+ " hashCode: " + to.hashCode());118 Main.debug("now: " + t.getId() + " hashCode: " + t.hashCode()); 119 Main.debug("orig: " + to.getId() + " hashCode: " + to.hashCode()); 121 120 } 122 121 return o; -
trunk/src/org/openstreetmap/josm/command/CoordinateConflictResolveCommand.java
r1954 r2025 45 45 return new DefaultMutableTreeNode( 46 46 new JLabel( 47 tr("Resolve conflicts in coordinates in {0}",conflict.getMy(). id),47 tr("Resolve conflicts in coordinates in {0}",conflict.getMy().getId()), 48 48 ImageProvider.get("data", "object"), 49 49 JLabel.HORIZONTAL -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r1990 r2025 110 110 String msg = ""; 111 111 switch(OsmPrimitiveType.from(primitive)) { 112 case NODE: msg = "Delete node {0}"; break;113 case WAY: msg = "Delete way {0}"; break;114 case RELATION:msg = "Delete relation {0}"; break;112 case NODE: msg = "Delete node {0}"; break; 113 case WAY: msg = "Delete way {0}"; break; 114 case RELATION:msg = "Delete relation {0}"; break; 115 115 } 116 116 … … 131 131 apiname = t.getAPIName(); 132 132 switch(t) { 133 case NODE: msg = trn("Delete {0} node", "Delete {0} nodes", toDelete.size(), toDelete.size()); break;134 case WAY: msg = trn("Delete {0} way", "Delete {0} ways", toDelete.size(), toDelete.size()); break;135 case RELATION: msg = trn("Delete {0} relation", "Delete {0} relations", toDelete.size(), toDelete.size()); break;133 case NODE: msg = trn("Delete {0} node", "Delete {0} nodes", toDelete.size(), toDelete.size()); break; 134 case WAY: msg = trn("Delete {0} way", "Delete {0} ways", toDelete.size(), toDelete.size()); break; 135 case RELATION: msg = trn("Delete {0} relation", "Delete {0} relations", toDelete.size(), toDelete.size()); break; 136 136 } 137 137 } … … 355 355 } 356 356 Way w = (Way) primitive; 357 if (w. id== 0) { // new ways with id == 0 are fine,357 if (w.getId() == 0) { // new ways with id == 0 are fine, 358 358 continue; // process existing ways only 359 359 } … … 363 363 // nodes ... 364 364 for (Node n : wnew.getNodes()) { 365 if (n. id!= 0 || !primitivesToDelete.contains(n)) {365 if (n.getId() != 0 || !primitivesToDelete.contains(n)) { 366 366 nodesToKeep.add(n); 367 367 } … … 426 426 if (a != null) { 427 427 for (OsmPrimitive osm : primitivesToDelete) { 428 if (osm instanceof Node && osm. id!= 0) {428 if (osm instanceof Node && osm.getId() != 0) { 429 429 Node n = (Node) osm; 430 430 if (!a.contains(n.getCoor())) { -
trunk/src/org/openstreetmap/josm/command/DeletedStateConflictResolveCommand.java
r1954 r2025 45 45 return new DefaultMutableTreeNode( 46 46 new JLabel( 47 tr("Resolve conflicts in deleted state in {0}",conflict.getMy(). id),47 tr("Resolve conflicts in deleted state in {0}",conflict.getMy().getId()), 48 48 ImageProvider.get("data", "object"), 49 49 JLabel.HORIZONTAL … … 62 62 63 63 if (decision.equals(MergeDecisionType.KEEP_MINE)) { 64 if (conflict.getMy(). deleted) {64 if (conflict.getMy().isDeleted()) { 65 65 // because my was involved in a conflict it my still be referred 66 66 // to from a way or a relation. Fix this now. -
trunk/src/org/openstreetmap/josm/command/MoveCommand.java
r2017 r2025 69 69 OldState os = new OldState(); 70 70 os.latlon = new LatLon(n.getCoor()); 71 os.modified = n. modified;71 os.modified = n.isModified(); 72 72 oldState.add(os); 73 73 } … … 93 93 for (Node n : nodes) { 94 94 n.setEastNorth(n.getEastNorth().add(x, y)); 95 n. modified = true;95 n.setModified(true); 96 96 } 97 97 return true; … … 103 103 OldState os = it.next(); 104 104 n.setCoor(os.latlon); 105 n. modified = os.modified;105 n.setModified(os.modified); 106 106 } 107 107 } -
trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java
r1894 r2025 42 42 if (Main.map != null && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) { 43 43 OsmDataLayer data = (OsmDataLayer)Main.map.mapView.getActiveLayer(); 44 data.setModified(true);45 44 data.fireDataChange(); 46 45 } … … 62 61 if (Main.map != null && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) { 63 62 OsmDataLayer data = (OsmDataLayer)Main.map.mapView.getActiveLayer(); 64 data.setModified(data.uploadedModified || !commands.isEmpty());65 63 data.fireDataChange(); 66 64 } … … 81 79 if (Main.map != null && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) { 82 80 OsmDataLayer data = (OsmDataLayer)Main.map.mapView.getActiveLayer(); 83 data.setModified(true);84 81 data.fireDataChange(); 85 82 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r1997 r2025 83 83 Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>(); 84 84 for (OsmPrimitive osm : allPrimitives()) 85 if (osm. visible && !osm.deleted) {85 if (osm.isVisible() && !osm.isDeleted()) { 86 86 o.add(osm); 87 87 } … … 92 92 Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>(); 93 93 for (OsmPrimitive osm : allPrimitives()) 94 if (osm. visible && !osm.deleted&& !osm.incomplete) {94 if (osm.isVisible() && !osm.isDeleted() && !osm.incomplete) { 95 95 o.add(osm); 96 96 } … … 101 101 Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>(); 102 102 for (OsmPrimitive osm : allPrimitives()) 103 if (osm. visible && !osm.deleted&& !osm.incomplete && !(osm instanceof Relation)) {103 if (osm.isVisible() && !osm.isDeleted() && !osm.incomplete && !(osm instanceof Relation)) { 104 104 o.add(osm); 105 105 } … … 230 230 return sel; 231 231 for (OsmPrimitive osm : list) 232 if (osm.isSelected() && !osm. deleted) {232 if (osm.isSelected() && !osm.isDeleted()) { 233 233 sel.add(osm); 234 234 } … … 290 290 String as = h.get(a); 291 291 if (as == null) { 292 as = a.getName() != null ? a.getName() : Long.toString(a. id);292 as = a.getName() != null ? a.getName() : Long.toString(a.getId()); 293 293 h.put(a, as); 294 294 } 295 295 String bs = h.get(b); 296 296 if (bs == null) { 297 bs = b.getName() != null ? b.getName() : Long.toString(b. id);297 bs = b.getName() != null ? b.getName() : Long.toString(b.getId()); 298 298 h.put(b, bs); 299 299 } … … 320 320 throw new IllegalArgumentException(tr("parameter {0} > 0 required. Got {1}.", "id", id)); 321 321 for (OsmPrimitive primitive : nodes) { 322 if (primitive. id== id) return primitive;322 if (primitive.getId() == id) return primitive; 323 323 } 324 324 for (OsmPrimitive primitive : ways) { 325 if (primitive. id== id) return primitive;325 if (primitive.getId() == id) return primitive; 326 326 } 327 327 for (OsmPrimitive primitive : relations) { 328 if (primitive. id== id) return primitive;328 if (primitive.getId() == id) return primitive; 329 329 } 330 330 return null; … … 334 334 HashSet<Long> ret = new HashSet<Long>(); 335 335 for (OsmPrimitive primitive : nodes) { 336 ret.add(primitive. id);336 ret.add(primitive.getId()); 337 337 } 338 338 for (OsmPrimitive primitive : ways) { 339 ret.add(primitive. id);339 ret.add(primitive.getId()); 340 340 } 341 341 for (OsmPrimitive primitive : relations) { 342 ret.add(primitive. id);342 ret.add(primitive.getId()); 343 343 } 344 344 return ret; … … 346 346 347 347 /** 348 * Replies the set of ids of all complete primitiv ies (i.e. those with348 * Replies the set of ids of all complete primitives (i.e. those with 349 349 * ! primitive.incomplete) 350 350 * 351 * @return the set of ids of all complete primitiv ies351 * @return the set of ids of all complete primitives 352 352 */ 353 353 public Set<Long> getCompletePrimitiveIds() { … … 355 355 for (OsmPrimitive primitive : nodes) { 356 356 if (!primitive.incomplete) { 357 ret.add(primitive. id);357 ret.add(primitive.getId()); 358 358 } 359 359 } 360 360 for (OsmPrimitive primitive : ways) { 361 361 if (! primitive.incomplete) { 362 ret.add(primitive. id);362 ret.add(primitive.getId()); 363 363 } 364 364 } 365 365 for (OsmPrimitive primitive : relations) { 366 366 if (! primitive.incomplete) { 367 ret.add(primitive. id);367 ret.add(primitive.getId()); 368 368 } 369 369 } … … 451 451 return parents; 452 452 } 453 454 /** 455 * Replies true if there is at least one primitive in this dataset with 456 * {@see OsmPrimitive#isModified()} == <code>true</code>. 457 * 458 * @return true if there is at least one primitive in this dataset with 459 * {@see OsmPrimitive#isModified()} == <code>true</code>. 460 */ 461 public boolean isModified() { 462 for (Node n: nodes) { 463 if (n.isModified()) return true; 464 } 465 for (Way w: ways) { 466 if (w.isModified()) return true; 467 } 468 for (Relation r: relations) { 469 if (r.isModified()) return true; 470 } 471 return false; 472 } 453 473 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r2017 r2025 69 69 * new to the server! To create a new object, call the default constructor of 70 70 * the respective class. 71 */ 71 * 72 * @deprecated use {@see #getId()}. Don't assign an id, create a primitive with 73 * the respective constructors. 74 */ 75 @Deprecated 72 76 public long id = 0; 73 77 … … 77 81 * Deleted objects are deleted from the server. If the objects are added (id=0), 78 82 * the modified is ignored and the object is added to the server. 79 */ 83 * 84 * @deprecated Please use {@see #setModified()} and {@see #getModified()} 85 */ 86 @Deprecated 80 87 public boolean modified = false; 81 88 82 89 /** 83 90 * <code>true</code>, if the object has been deleted. 84 */ 91 * 92 * @deprecated use {@see #delete()} and {@see #isDeleted()} 93 */ 94 @Deprecated 85 95 public boolean deleted = false; 86 96 … … 89 99 * introduced with the 0.4 API to be able to communicate deleted objects 90 100 * (they will have visible=false). 91 */ 101 * 102 * @deprecated use {@see #isVisible()} and {@see #setVisible(boolean)} 103 */ 104 @Deprecated 92 105 public boolean visible = true; 93 106 … … 100 113 /** 101 114 * If set to true, this object is currently selected. 115 * 116 * @deprecated use {@see #isSelected()} and {@see #setSelected(boolean)} 102 117 */ 103 118 @Deprecated … … 121 136 public boolean isSelected() { 122 137 return selected; 138 } 139 140 /** 141 * Marks this primitive as being modified. 142 * 143 * @param modified true, if this primitive is to be modified 144 */ 145 public void setModified(boolean modified) { 146 this.modified = modified; 147 } 148 149 /** 150 * Replies <code>true</code> if the object has been modified since it was loaded from 151 * the server. In this case, on next upload, this object will be updated. 152 * 153 * @return <code>true</code> if the object has been modified since it was loaded from 154 * the server 155 */ 156 public boolean isModified() { 157 return modified; 158 } 159 160 /** 161 * Replies <code>true</code>, if the object has been deleted. 162 * 163 * @return <code>true</code>, if the object has been deleted. 164 * @see #delete(boolean) 165 */ 166 public boolean isDeleted() { 167 return deleted; 168 } 169 170 /** 171 * Replies true if this primitive is either unknown to the server (i.e. its id 172 * is 0) or it is known to the server and it hasn't be deleted on the server. 173 * Replies false, if this primitive is known on the server and has been deleted 174 * on the server. 175 * 176 * @see #setVisible(boolean) 177 */ 178 public boolean isVisible() { 179 return visible; 180 } 181 182 /** 183 * Sets whether this primitive is visible, i.e. whether it is known on the server 184 * and not deleted on the server. 185 * 186 * @see #isVisible() 187 * @throws IllegalStateException thrown if visible is set to false on an primitive with 188 * id==0 189 */ 190 public void setVisible(boolean visible) throws IllegalStateException{ 191 if (id == 0 && visible == false) 192 throw new IllegalStateException(tr("a primitive with id=0 can't be invisible")); 193 this.visible = visible; 194 } 195 196 /** 197 * Replies the id of this primitive. 198 * 199 * @return the id of this primitive. 200 */ 201 public long getId() { 202 return id; 123 203 } 124 204 … … 502 582 */ 503 583 public abstract String getDisplayName(NameFormatter formatter); 584 504 585 } 586 587 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/CreateOsmChangeVisitor.java
r1677 r2025 47 47 48 48 public void visit(Node n) { 49 if (n. deleted) {49 if (n.isDeleted()) { 50 50 switchMode("delete"); 51 51 osmwriter.setWithBody(false); 52 52 osmwriter.visit(n); 53 53 } else { 54 switchMode((n. id== 0) ? "create" : "modify");54 switchMode((n.getId() == 0) ? "create" : "modify"); 55 55 osmwriter.setWithBody(true); 56 56 osmwriter.visit(n); … … 58 58 } 59 59 public void visit(Way w) { 60 if (w. deleted) {60 if (w.isDeleted()) { 61 61 switchMode("delete"); 62 62 osmwriter.setWithBody(false); 63 63 osmwriter.visit(w); 64 64 } else { 65 switchMode((w. id== 0) ? "create" : "modify");65 switchMode((w.getId() == 0) ? "create" : "modify"); 66 66 osmwriter.setWithBody(true); 67 67 osmwriter.visit(w); … … 69 69 } 70 70 public void visit(Relation r) { 71 if (r. deleted) {71 if (r.isDeleted()) { 72 72 switchMode("delete"); 73 73 osmwriter.setWithBody(false); 74 74 osmwriter.visit(r); 75 75 } else { 76 switchMode((r. id== 0) ? "create" : "modify");76 switchMode((r.getId() == 0) ? "create" : "modify"); 77 77 osmwriter.setWithBody(true); 78 78 osmwriter.visit(r); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r1990 r2025 529 529 for (RelationMember m : r.getMembers()) 530 530 { 531 if (m.isNode() && !m.getMember().incomplete && !m.getMember(). deleted)531 if (m.isNode() && !m.getMember().incomplete && !m.getMember().isDeleted()) 532 532 { 533 533 drawSelectedMember(m.getMember(), styles != null ? getPrimitiveStyle(m.getMember()) : null, true, true); … … 550 550 for (RelationMember m : r.getMembers()) 551 551 { 552 if (m.isWay() && !m.getMember().incomplete && !m.getMember(). deleted) /* nodes drawn on second call */552 if (m.isWay() && !m.getMember().incomplete && !m.getMember().isDeleted()) /* nodes drawn on second call */ 553 553 { 554 554 drawSelectedMember(m.getMember(), styles != null ? getPrimitiveStyle(m.getMember()) … … 580 580 // TODO Nullable member will not be allowed after RelationMember.member is encalupsed 581 581 r.putError(tr("Empty member in relation."), true); 582 } else if(m.getMember(). deleted) {582 } else if(m.getMember().isDeleted()) { 583 583 r.putError(tr("Deleted member ''{0}'' in relation.", 584 584 m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); … … 834 834 //TODO Remove useless nullcheck when RelationMember.member is encalupsed 835 835 r.putError(tr("Empty member in relation."), true); 836 } else if(m.getMember(). deleted) {836 } else if(m.getMember().isDeleted()) { 837 837 r.putError(tr("Deleted member ''{0}'' in relation.", 838 838 m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); … … 1379 1379 for (final Relation osm : data.relations) 1380 1380 { 1381 if(!osm. deleted&& !osm.incomplete && osm.mappaintVisibleCode != viewid)1381 if(!osm.isDeleted() && !osm.incomplete && osm.mappaintVisibleCode != viewid) 1382 1382 { 1383 1383 osm.visit(this); … … 1396 1396 for (final Way osm : data.ways) 1397 1397 { 1398 if (!osm.incomplete && !osm. deleted1398 if (!osm.incomplete && !osm.isDeleted() 1399 1399 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 1400 1400 { … … 1437 1437 // profilerN = 0; 1438 1438 for (final OsmPrimitive osm : data.ways) 1439 if (!osm.incomplete && !osm. deleted&& !osm.isSelected()1439 if (!osm.incomplete && !osm.isDeleted() && !osm.isSelected() 1440 1440 && osm.mappaintVisibleCode != viewid ) 1441 1441 { … … 1456 1456 //profilerN = 0; 1457 1457 for (final OsmPrimitive osm : data.getSelected()) { 1458 if (!osm.incomplete && !osm. deleted&& !(osm instanceof Node)1458 if (!osm.incomplete && !osm.isDeleted() && !(osm instanceof Node) 1459 1459 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 1460 1460 { … … 1476 1476 //profilerN = 0; 1477 1477 for (final OsmPrimitive osm : data.nodes) 1478 if (!osm.incomplete && !osm. deleted1478 if (!osm.incomplete && !osm.isDeleted() 1479 1479 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 1480 1480 { … … 1496 1496 currentColor = nodeColor; 1497 1497 for (final OsmPrimitive osm : data.ways) 1498 if (!osm.incomplete && !osm. deleted1498 if (!osm.incomplete && !osm.isDeleted() 1499 1499 && osm.mappaintVisibleCode != viewid ) 1500 1500 { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitor.java
r1951 r2025 94 94 for (RelationMember member: r.getMembers()) { 95 95 newMembers.add( 96 new RelationMember(member.getRole(), mappedPrimitives.get(member.getMember())));96 new RelationMember(member.getRole(), mappedPrimitives.get(member.getMember()))); 97 97 98 98 } … … 117 117 OsmPrimitive clone = null; 118 118 if (primitive instanceof Node) { 119 clone = new Node(primitive. id);119 clone = new Node(primitive.getId()); 120 120 } else if (primitive instanceof Way) { 121 clone = new Way(primitive. id);121 clone = new Way(primitive.getId()); 122 122 } else if (primitive instanceof Relation) { 123 clone = new Relation(primitive. id);123 clone = new Relation(primitive.getId()); 124 124 } 125 125 clone.incomplete = true; … … 176 176 177 177 protected boolean isNew(OsmPrimitive primitive) { 178 return primitive. id== 0;178 return primitive.getId() == 0; 179 179 } 180 180 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r1948 r2025 62 62 this.theirDataSet = theirDataSet; 63 63 64 for (Node n : myDataSet.nodes) if (n. id!= 0) {65 nodeshash.put(n. id, n);66 } 67 for (Way w : myDataSet.ways) if (w. id!= 0) {68 wayshash.put(w. id, w);69 } 70 for (Relation r : myDataSet.relations) if (r. id!= 0) {71 relshash.put(r. id, r);64 for (Node n : myDataSet.nodes) if (n.getId() != 0) { 65 nodeshash.put(n.getId(), n); 66 } 67 for (Way w : myDataSet.ways) if (w.getId() != 0) { 68 wayshash.put(w.getId(), w); 69 } 70 for (Relation r : myDataSet.relations) if (r.getId() != 0) { 71 relshash.put(r.getId(), r); 72 72 } 73 73 conflicts = new ConflictCollection(); … … 98 98 HashMap<Long, P> primitivesWithDefinedIds) { 99 99 100 if (other. id> 0 ) {100 if (other.getId() > 0 ) { 101 101 // try to merge onto a matching primitive with the same 102 102 // defined id … … 109 109 // 110 110 for (P my : myPrimitives) { 111 if (my. id>0 ) {111 if (my.getId() >0 ) { 112 112 continue; 113 113 } 114 114 if (my.hasEqualSemanticAttributes(other)) { 115 if (my. deleted != other.deleted) {115 if (my.isDeleted() != other.isDeleted()) { 116 116 // differences in deleted state have to be merged manually 117 117 // … … 120 120 // copy the technical attributes from other 121 121 // version 122 my. visible = other.visible;122 my.setVisible(other.isVisible()); 123 123 my.user = other.user; 124 124 my.setTimestamp(other.getTimestamp()); 125 my. modified = other.modified;125 my.setModified(other.isModified()); 126 126 merged.put(other, my); 127 127 } … … 186 186 Node mergedNode = (Node) merged.get(myNode); 187 187 if (mergedNode != null) { 188 if (!mergedNode. deleted) {188 if (!mergedNode.isDeleted()) { 189 189 newNodes.add(mergedNode); 190 190 } … … 207 207 newMembers.add(myMember); 208 208 } else { 209 if (! mergedMember. deleted) {209 if (! mergedMember.isDeleted()) { 210 210 RelationMember newMember = new RelationMember(myMember.getRole(), mergedMember); 211 211 newMembers.add(newMember); … … 234 234 // merge other into an existing primitive with the same id, if possible 235 235 // 236 if (myPrimitivesWithDefinedIds.containsKey(other. id)) {237 P my = myPrimitivesWithDefinedIds.get(other. id);236 if (myPrimitivesWithDefinedIds.containsKey(other.getId())) { 237 P my = myPrimitivesWithDefinedIds.get(other.getId()); 238 238 if (my.version <= other.version) { 239 if (! my. visible && other.visible) {239 if (! my.isVisible() && other.isVisible()) { 240 240 // should not happen 241 241 // … … 243 243 + "their primitive with lower version {2} is not visible. " 244 244 + "Can't deal with this inconsistency. Keeping my primitive. ", 245 Long.toString(my. id),Long.toString(my.version), Long.toString(other.version)245 Long.toString(my.getId()),Long.toString(my.version), Long.toString(other.version) 246 246 )); 247 247 merged.put(other, my); 248 } else if (my. visible && ! other.visible) {248 } else if (my.isVisible() && ! other.isVisible()) { 249 249 // this is always a conflict because the user has to decide whether 250 250 // he wants to create a clone of its local primitive or whether he … … 270 270 // 271 271 merged.put(other, my); 272 } else if (my. deleted && ! other.deleted&& my.version == other.version) {272 } else if (my.isDeleted() && ! other.isDeleted() && my.version == other.version) { 273 273 // same version, but my is deleted. Assume mine takes precedence 274 274 // otherwise too many conflicts when refreshing from the server 275 275 merged.put(other, my); 276 } else if (my. deleted != other.deleted) {276 } else if (my.isDeleted() != other.isDeleted()) { 277 277 // differences in deleted state have to be resolved manually 278 278 // 279 279 conflicts.add(my,other); 280 } else if (! my. modified && other.modified) {280 } else if (! my.isModified() && other.isModified()) { 281 281 // my not modified. We can assume that other is the most recent version. 282 282 // clone it onto my. But check first, whether other is deleted. if so, 283 283 // make sure that my is not references anymore in myDataSet. 284 284 // 285 if (other. deleted) {285 if (other.isDeleted()) { 286 286 myDataSet.unlinkReferencesToPrimitive(my); 287 287 } 288 288 my.cloneFrom(other); 289 289 merged.put(other, my); 290 } else if (! my. modified && !other.modified&& my.version == other.version) {290 } else if (! my.isModified() && !other.isModified() && my.version == other.version) { 291 291 // both not modified. Keep mine 292 292 // 293 293 merged.put(other,my); 294 } else if (! my. modified && !other.modified&& my.version < other.version) {294 } else if (! my.isModified() && !other.isModified() && my.version < other.version) { 295 295 // my not modified but other is newer. clone other onto mine. 296 296 // 297 297 my.cloneFrom(other); 298 298 merged.put(other,my); 299 } else if (my. modified && ! other.modified&& my.version == other.version) {299 } else if (my.isModified() && ! other.isModified() && my.version == other.version) { 300 300 // my is same as other but mine is modified 301 301 // => keep mine … … 312 312 // 313 313 my.cloneFrom(other); 314 my. modified = true;314 my.setModified(true); 315 315 merged.put(other, my); 316 316 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r1938 r2025 56 56 /** 57 57 * Preferences 58 */58 */ 59 59 protected Color inactiveColor; 60 60 protected Color selectedColor; … … 124 124 125 125 ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, 126 Main.pref.getBoolean("mappaint.use-antialiasing", false) ?127 RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);126 Main.pref.getBoolean("mappaint.use-antialiasing", false) ? 127 RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); 128 128 } 129 129 … … 149 149 //profilerN = 0; 150 150 for (final OsmPrimitive osm : data.relations) 151 if (!osm. deleted&& !osm.isSelected())151 if (!osm.isDeleted() && !osm.isSelected()) 152 152 { 153 153 osm.visit(this); 154 // profilerN++;154 // profilerN++; 155 155 } 156 156 … … 163 163 //profilerN = 0; 164 164 for (final OsmPrimitive osm : data.ways) 165 if (!osm. deleted&& !osm.isSelected() && osm.isTagged())165 if (!osm.isDeleted() && !osm.isSelected() && osm.isTagged()) 166 166 { 167 167 osm.visit(this); 168 // profilerN++;168 // profilerN++; 169 169 } 170 170 displaySegments(); 171 171 172 172 for (final OsmPrimitive osm : data.ways) 173 if (!osm. deleted&& !osm.isSelected() && !osm.isTagged())173 if (!osm.isDeleted() && !osm.isSelected() && !osm.isTagged()) 174 174 { 175 175 osm.visit(this); 176 // profilerN++;176 // profilerN++; 177 177 } 178 178 displaySegments(); … … 187 187 //profilerN = 0; 188 188 for (final OsmPrimitive osm : data.getSelected()) 189 if (!osm. deleted)189 if (!osm.isDeleted()) 190 190 { 191 191 osm.visit(this); 192 // profilerN++;192 // profilerN++; 193 193 } 194 194 displaySegments(); … … 202 202 //profilerN = 0; 203 203 for (final OsmPrimitive osm : data.nodes) 204 if (!osm. deleted&& !osm.isSelected())204 if (!osm.isDeleted() && !osm.isSelected()) 205 205 { 206 206 osm.visit(this); 207 // profilerN++;207 // profilerN++; 208 208 } 209 209 … … 217 217 if(virtualNodeSize != 0) 218 218 { 219 // profilerN = 0;219 // profilerN = 0; 220 220 currentColor = nodeColor; 221 221 for (final OsmPrimitive osm : data.ways) 222 if (!osm. deleted)223 224 225 // profilerN++;226 222 if (!osm.isDeleted()) 223 { 224 visitVirtual((Way)osm); 225 // profilerN++; 226 } 227 227 displaySegments(); 228 228 229 // if(profiler)230 // {231 // System.out.format("Virtual : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);232 // profilerLast = java.lang.System.currentTimeMillis();233 // }229 // if(profiler) 230 // { 231 // System.out.format("Virtual : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 232 // profilerLast = java.lang.System.currentTimeMillis(); 233 // } 234 234 } 235 235 … … 249 249 if (n.incomplete) return; 250 250 251 if (inactive) 251 if (inactive) { 252 252 drawNode(n, inactiveColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); 253 else if (n.highlighted)253 } else if (n.highlighted) { 254 254 drawNode(n, highlightColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 255 else if (n.isSelected())255 } else if (n.isSelected()) { 256 256 drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 257 else if(n.isTagged())257 } else if(n.isTagged()) { 258 258 drawNode(n, nodeColor, taggedNodeSize, taggedNodeRadius, fillUnselectedNode); 259 else259 } else { 260 260 drawNode(n, nodeColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); 261 } 261 262 } 262 263 263 264 public static Boolean isLargeSegment(Point p1, Point p2, int space) 264 265 { 265 int xd = p1.x-p2.x; if(xd < 0) xd = -xd; 266 int yd = p1.y-p2.y; if(yd < 0) yd = -yd; 266 int xd = p1.x-p2.x; if(xd < 0) { 267 xd = -xd; 268 } 269 int yd = p1.y-p2.y; if(yd < 0) { 270 yd = -yd; 271 } 267 272 return (xd+yd > space); 268 273 } … … 325 330 Point p = nc.getPoint(it.next()); 326 331 drawSegment(lastP, p, wayColor, 327 showOnlyHeadArrowOnly ? !it.hasNext() : showThisDirectionArrow);328 if (showOrderNumber) 332 showOnlyHeadArrowOnly ? !it.hasNext() : showThisDirectionArrow); 333 if (showOrderNumber) { 329 334 drawOrderNumber(lastP, p, orderNumber); 335 } 330 336 lastP = p; 331 337 } … … 334 340 335 341 private Stroke relatedWayStroke = new BasicStroke( 336 4, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL);342 4, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL); 337 343 public void visit(Relation r) { 338 344 if (r.incomplete) return; … … 349 355 350 356 for (RelationMember m : r.getMembers()) { 351 if (m.getMember().incomplete || m.getMember().deleted) continue; 357 if (m.getMember().incomplete || m.getMember().isDeleted()) { 358 continue; 359 } 352 360 353 361 if (m.isNode()) { 354 362 Point p = nc.getPoint(m.getNode()); 355 363 if (p.x < 0 || p.y < 0 356 || p.x > nc.getWidth() || p.y > nc.getHeight()) continue; 364 || p.x > nc.getWidth() || p.y > nc.getHeight()) { 365 continue; 366 } 357 367 358 368 g.drawOval(p.x-3, p.y-3, 6, 6); … … 362 372 boolean first = true; 363 373 for (Node n : m.getWay().getNodes()) { 364 if (n.incomplete || n.deleted) continue; 374 if (n.incomplete || n.isDeleted()) { 375 continue; 376 } 365 377 Point p = nc.getPoint(n); 366 378 if (first) { … … 418 430 g.fillRect(p.x - radius, p.y - radius, size, size); 419 431 g.drawRect(p.x - radius, p.y - radius, size, size); 420 } else 432 } else { 421 433 g.drawRect(p.x - radius, p.y - radius, size, size); 434 } 422 435 } 423 436 } … … 427 440 */ 428 441 protected void drawSegment(Point p1, Point p2, Color col, boolean showDirection) { 429 if (col != currentColor) displaySegments(col); 442 if (col != currentColor) { 443 displaySegments(col); 444 } 430 445 431 446 if (isSegmentVisible(p1, p2)) { -
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r2003 r2025 3 3 import java.awt.Component; 4 4 import java.awt.Dimension; 5 import java.awt.Frame; 5 6 import java.awt.GridBagLayout; 6 7 import java.awt.Toolkit; … … 202 203 super.setVisible(visible); 203 204 if (visible) { 204 toFront();205 repaint(); 205 206 } 206 207 } -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r2017 r2025 47 47 mainFrame.addWindowListener(new WindowAdapter(){ 48 48 @Override public void windowClosing(final WindowEvent arg0) { 49 if ( Main.breakBecauseUnsavedChanges())49 if (!Main.saveUnsavedModifications()) 50 50 return; 51 51 Main.saveGuiGeometry(); … … 73 73 final Map<String, Collection<String>> args = new HashMap<String, Collection<String>>(); 74 74 for (String arg : argArray) { 75 if (!arg.startsWith("--")) 75 if (!arg.startsWith("--")) { 76 76 arg = "--download="+arg; 77 } 77 78 int i = arg.indexOf('='); 78 79 String key = i == -1 ? arg.substring(2) : arg.substring(2,i); 79 80 String value = i == -1 ? "" : arg.substring(i+1); 80 81 Collection<String> v = args.get(key); 81 if (v == null) 82 if (v == null) { 82 83 v = new LinkedList<String>(); 84 } 83 85 v.add(value); 84 86 args.put(key, v); … … 88 90 89 91 // Check if passed as parameter 90 if (args.containsKey("language")) 92 if (args.containsKey("language")) { 91 93 I18n.set((String)(args.get("language").toArray()[0])); 92 else94 } else { 93 95 I18n.set(Main.pref.get("language", null)); 96 } 94 97 95 98 if (argList.contains("--help") || argList.contains("-?") || argList.contains("-h")) { … … 143 146 144 147 if (((!args.containsKey("no-maximize") && !args.containsKey("geometry") 145 && Main.pref.get("gui.geometry").length() == 0) || args.containsKey("maximize"))146 && Toolkit.getDefaultToolkit().isFrameStateSupported(JFrame.MAXIMIZED_BOTH))148 && Main.pref.get("gui.geometry").length() == 0) || args.containsKey("maximize")) 149 && Toolkit.getDefaultToolkit().isFrameStateSupported(JFrame.MAXIMIZED_BOTH)) { 147 150 mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); 151 } 148 152 149 153 EventQueue.invokeLater(new Runnable() { … … 161 165 public static void removeObsoletePreferences() { 162 166 String[] obsolete = { 163 "sample.preference.that.does.not.exist", // sample comment, expiry date should go here164 "osm-server.version", // remove this around 10/2009165 "osm-server.additional-versions", // remove this around 10/2009166 null167 "sample.preference.that.does.not.exist", // sample comment, expiry date should go here 168 "osm-server.version", // remove this around 10/2009 169 "osm-server.additional-versions", // remove this around 10/2009 170 null 167 171 }; 168 172 for (String i : obsolete) { 169 if (i == null) continue; 173 if (i == null) { 174 continue; 175 } 170 176 if (Main.pref.hasKey(i)) { 171 177 Main.pref.removeFromCollection(i, Main.pref.get(i)); -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r1990 r2025 194 194 final StringBuilder text = new StringBuilder(); 195 195 String name = osm.getDisplayName(DefaultNameFormatter.getInstance()); 196 if (osm. id == 0 || osm.modified) {196 if (osm.getId() == 0 || osm.isModified()) { 197 197 name = "<i><b>"+ osm.getDisplayName(DefaultNameFormatter.getInstance())+"*</b></i>"; 198 198 } 199 199 text.append(name); 200 if (osm. id!= 0) {201 text.append("<br>id="+osm. id);200 if (osm.getId() != 0) { 201 text.append("<br>id="+osm.getId()); 202 202 } 203 203 for (Entry<String, String> e : osm.entrySet()) { -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r1952 r2025 44 44 import org.openstreetmap.josm.gui.layer.MapViewPaintable; 45 45 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 46 import org.openstreetmap.josm.gui.layer.OsmDataLayer.ModifiedChangedListener;47 46 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 48 47 import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker; … … 152 151 */ 153 152 public void addLayer(Layer layer) { 154 if (layer instanceof OsmDataLayer) {155 OsmDataLayer editLayer = (OsmDataLayer)layer;156 editLayer.listenerModified.add(new ModifiedChangedListener(){157 public void modifiedChanged(boolean value, OsmDataLayer source) {158 JOptionPane.getFrameForComponent(Main.parent).setTitle((value?"*":"")159 +tr("Java OpenStreetMap Editor"));160 }161 });162 }163 153 if (layer instanceof MarkerLayer && playHeadMarker == null) { 164 154 playHeadMarker = PlayHeadMarker.create(); … … 510 500 } 511 501 } 502 if (layer instanceof OsmDataLayer) { 503 refreshTitle((OsmDataLayer)layer); 504 } 512 505 513 506 /* This only makes the buttons look disabled. Disabling the actions as well requires … … 600 593 if (evt.getPropertyName().equals(Layer.VISIBLE_PROP)) { 601 594 repaint(); 595 } else if (evt.getPropertyName().equals(OsmDataLayer.REQUIRES_SAVE_TO_DISK_PROP) 596 || evt.getPropertyName().equals(OsmDataLayer.REQUIRES_UPLOAD_TO_SERVER_PROP)) { 597 OsmDataLayer layer = (OsmDataLayer)evt.getSource(); 598 if (layer == getEditLayer()) { 599 refreshTitle(layer); 600 } 601 } 602 } 603 604 protected void refreshTitle(OsmDataLayer layer) { 605 boolean dirty = layer.requiresSaveToFile() || layer.requiresUploadToServer(); 606 if (dirty) { 607 JOptionPane.getFrameForComponent(Main.parent).setTitle("* " + tr("Java OpenStreetMap Editor")); 608 } else { 609 JOptionPane.getFrameForComponent(Main.parent).setTitle(tr("Java OpenStreetMap Editor")); 602 610 } 603 611 } -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r1941 r2025 74 74 double dist = getDist100Pixel(); 75 75 return dist >= 2000 ? Math.round(dist/100)/10 +" km" : (dist >= 1 76 ? Math.round(dist*10)/10 +" m" : "< 1 m");76 ? Math.round(dist*10)/10 +" m" : "< 1 m"); 77 77 } 78 78 … … 112 112 center.east() - getWidth()/2.0*scale, 113 113 center.north() - getHeight()/2.0*scale), 114 new EastNorth(115 center.east() + getWidth()/2.0*scale,116 center.north() + getHeight()/2.0*scale));114 new EastNorth( 115 center.east() + getWidth()/2.0*scale, 116 center.north() + getHeight()/2.0*scale)); 117 117 }; 118 118 … … 121 121 Bounds b = getProjection().getWorldBoundsLatLon(); 122 122 return new ProjectionBounds(getProjection().latlon2eastNorth(b.min), 123 getProjection().latlon2eastNorth(b.max));123 getProjection().latlon2eastNorth(b.max)); 124 124 }; 125 125 … … 130 130 center.east() - getWidth()/2.0*scale, 131 131 center.north() - getHeight()/2.0*scale)), 132 getProjection().eastNorth2latlon(new EastNorth(133 center.east() + getWidth()/2.0*scale,134 center.north() + getHeight()/2.0*scale)));132 getProjection().eastNorth2latlon(new EastNorth( 133 center.east() + getWidth()/2.0*scale, 134 center.north() + getHeight()/2.0*scale))); 135 135 }; 136 136 … … 189 189 if(lon < b.min.lon()) {changed = true; lon = b.min.lon(); } 190 190 else if(lon > b.max.lon()) {changed = true; lon = b.max.lon(); } 191 if(changed) 192 newCenter = new CachedLatLon(lat, lon).getEastNorth(); 191 if(changed) { 192 newCenter = new CachedLatLon(lat, lon).getEastNorth(); 193 } 193 194 if (!newCenter.equals(center)) { 194 195 EastNorth oldCenter = center; … … 211 212 e2 = getProjection().latlon2eastNorth(new LatLon(lat, b.max.lon())); 212 213 d = e2.east() - e1.east(); 213 if(d < width*newScale) 214 if(d < width*newScale) { 214 215 newScale = Math.max(newScaleH, d/width); 216 } 215 217 } 216 218 else 217 219 { 218 220 d = d/(l1.greatCircleDistance(l2)*height*10); 219 if(newScale < d) 221 if(newScale < d) { 220 222 newScale = d; 223 } 221 224 } 222 225 if (scale != newScale) { … … 296 299 return null; 297 300 for (Node n : ds.nodes) { 298 if (n. deleted|| n.incomplete) {301 if (n.isDeleted() || n.incomplete) { 299 302 continue; 300 303 } … … 307 310 // when multiple nodes on one point, prefer new or selected nodes 308 311 else if(dist == minDistanceSq && minPrimitive != null 309 && ((n. id== 0 && n.isSelected())310 || (!minPrimitive.isSelected() && (n.isSelected() || n. id== 0)))) {312 && ((n.getId() == 0 && n.isSelected()) 313 || (!minPrimitive.isSelected() && (n.isSelected() || n.getId() == 0)))) { 311 314 minPrimitive = n; 312 315 } … … 327 330 return null; 328 331 for (Way w : ds.ways) { 329 if (w. deleted|| w.incomplete) {332 if (w.isDeleted() || w.incomplete) { 330 333 continue; 331 334 } … … 334 337 for (Node n : w.getNodes()) { 335 338 i++; 336 if (n. deleted|| n.incomplete) {339 if (n.isDeleted() || n.incomplete) { 337 340 continue; 338 341 } … … 451 454 return null; 452 455 for (Way w : ds.ways) { 453 if (w. deleted|| w.incomplete) {456 if (w.isDeleted() || w.incomplete) { 454 457 continue; 455 458 } 456 459 Node lastN = null; 457 460 for (Node n : w.getNodes()) { 458 if (n. deleted|| n.incomplete) {461 if (n.isDeleted() || n.incomplete) { 459 462 continue; 460 463 } … … 477 480 } 478 481 for (Node n : ds.nodes) { 479 if (!n. deleted&& !n.incomplete482 if (!n.isDeleted() && !n.incomplete 480 483 && getPoint(n).distanceSq(p) < snapDistance) { 481 484 nearest.add(n); … … 499 502 return null; 500 503 for (Node n : ds.nodes) { 501 if (!n. deleted&& !n.incomplete504 if (!n.isDeleted() && !n.incomplete 502 505 && getPoint(n).distanceSq(p) < snapDistance) { 503 506 nearest.add(n); -
trunk/src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java
r1811 r2025 45 45 */ 46 46 public PleaseWaitRunnable(String title, boolean ignoreException) { 47 this(title, new PleaseWaitProgressMonitor( ), ignoreException);47 this(title, new PleaseWaitProgressMonitor(title), ignoreException); 48 48 } 49 49 50 50 public PleaseWaitRunnable(String title, ProgressMonitor progressMonitor, boolean ignoreException) { 51 51 this.title = title; 52 this.progressMonitor = progressMonitor == null?new PleaseWaitProgressMonitor( ):progressMonitor;52 this.progressMonitor = progressMonitor == null?new PleaseWaitProgressMonitor(title):progressMonitor; 53 53 this.ignoreException = ignoreException; 54 54 this.progressMonitor.addCancelListener(this); -
trunk/src/org/openstreetmap/josm/gui/SelectionManager.java
r1911 r2025 286 286 // nodes 287 287 for (Node n : nc.getCurrentDataSet().nodes) { 288 if (!n. deleted&& !n.incomplete && r.contains(nc.getPoint(n))) {288 if (!n.isDeleted() && !n.incomplete && r.contains(nc.getPoint(n))) { 289 289 selection.add(n); 290 290 } … … 293 293 // ways 294 294 for (Way w : nc.getCurrentDataSet().ways) { 295 if (w. deleted|| w.getNodesCount() == 0 || w.incomplete) {295 if (w.isDeleted() || w.getNodesCount() == 0 || w.incomplete) { 296 296 continue; 297 297 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r1954 r2025 47 47 import org.openstreetmap.josm.gui.MapView; 48 48 import org.openstreetmap.josm.gui.SideButton; 49 import org.openstreetmap.josm.gui.io.SaveLayersDialog; 49 50 import org.openstreetmap.josm.gui.layer.Layer; 50 51 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 299 300 } 300 301 301 protected boolean confirmSkipSaving(OsmDataLayer layer) { 302 int result = new ExtendedDialog(Main.parent, 303 tr("Unsaved Changes"), 304 tr("There are unsaved changes in the layer''{0}''. Delete the layer anwyay?",layer.getName()), 305 new String[] {tr("Delete Layer"), tr("Cancel")}, 306 new String[] {"dialogs/delete.png", "cancel.png"}).getValue(); 307 308 return result == 1; 309 } 310 311 protected boolean confirmDeleteLayer(Layer layer) { 312 return ConditionalOptionPaneUtil.showConfirmationDialog( 313 "delete_layer", 314 Main.parent, 315 tr("Do you really want to delete layer ''{0}''?", layer.getName()), 316 tr("Confirmation"), 317 JOptionPane.YES_NO_OPTION, 318 JOptionPane.QUESTION_MESSAGE, 319 JOptionPane.YES_OPTION); 320 } 321 322 protected DeleteDecision confirmDeleteMultipleLayer(Layer layer, int idx, int numLayers) { 323 String options[] = new String[] { 324 tr("Yes"), 325 tr("No"), 326 tr("Delete all"), 327 tr("Cancel") 328 }; 329 int ret = ConditionalOptionPaneUtil.showOptionDialog( 330 "delete_layer", 331 Main.parent, 332 tr("Do you really want to delete layer ''{0}''?", layer.getName()), 333 tr("Deleting layer {0} of {1}", idx+1, numLayers), 334 JOptionPane.DEFAULT_OPTION, 335 JOptionPane.QUESTION_MESSAGE, 336 options, 337 options[0] 338 ); 339 switch(ret) { 340 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return DeleteDecision.deleteAll; 341 case JOptionPane.CLOSED_OPTION: return DeleteDecision.cancel; 342 case 0: return DeleteDecision.deleteCurrent; 343 case 1: return DeleteDecision.dontDeleteCurrent; 344 case 2: return DeleteDecision.deleteAll; 345 case 3: return DeleteDecision.cancel; 346 default: 347 // shouldn't happen. This is the safest option. 348 return DeleteDecision.cancel; 349 } 350 } 351 352 353 public void deleteSingleLayer(Layer layer) { 354 if (layer == null) 302 protected boolean enforceUploadOrSaveModifiedData(List<Layer> selectedLayers) { 303 SaveLayersDialog dialog = new SaveLayersDialog(Main.parent); 304 List<OsmDataLayer> layersWithUnmodifiedChanges = new ArrayList<OsmDataLayer>(); 305 for (Layer l: selectedLayers) { 306 if (! (l instanceof OsmDataLayer)) { 307 continue; 308 } 309 OsmDataLayer odl = (OsmDataLayer)l; 310 if (odl.requiresSaveToFile() || odl.requiresUploadToServer()) { 311 layersWithUnmodifiedChanges.add(odl); 312 } 313 } 314 dialog.prepareForSavingAndUpdatingLayersBeforeDelete(); 315 if (!layersWithUnmodifiedChanges.isEmpty()) { 316 dialog.getModel().populate(layersWithUnmodifiedChanges); 317 dialog.setVisible(true); 318 switch(dialog.getUserAction()) { 319 case CANCEL: return false; 320 case PROCEED: return true; 321 default: return false; 322 } 323 } 324 return true; 325 } 326 327 public void actionPerformed(ActionEvent e) { 328 List<Layer> selectedLayers; 329 if (this.layer == null) { 330 selectedLayers = getModel().getSelectedLayers(); 331 } else { 332 selectedLayers = Collections.singletonList(this.layer); 333 } 334 if (selectedLayers.isEmpty()) 355 335 return; 356 if (layer instanceof OsmDataLayer) { 357 OsmDataLayer dataLayer = (OsmDataLayer)layer; 358 if (dataLayer.isModified()) { 359 if (! confirmSkipSaving(dataLayer)) 360 return; 361 } 362 else if (!confirmDeleteLayer(dataLayer)) 363 return; 364 } else { 365 if (!confirmDeleteLayer(layer)) 366 return; 367 } 368 // model and view are going to be updated via LayerChangeListener 369 // 370 Main.main.removeLayer(layer); 371 } 372 373 public void deleteMultipleLayers(List<Layer> layers) { 374 boolean doAskConfirmation = true; 375 for (int i=0; i < layers.size(); i++) { 376 Layer layer = layers.get(i); 377 if (layer instanceof OsmDataLayer) { 378 OsmDataLayer dataLayer = (OsmDataLayer)layer; 379 if (dataLayer.isModified() && ! confirmSkipSaving(dataLayer)) { 380 continue; 381 } 382 } 383 if (doAskConfirmation) { 384 DeleteDecision decision = confirmDeleteMultipleLayer(layer, i, layers.size()); 385 switch(decision) { 386 case deleteCurrent: /* do nothing */ break; 387 case deleteAll: doAskConfirmation = false; break; 388 case dontDeleteCurrent: continue; 389 case cancel: return; 390 } 391 } 392 // model and view are going to be updated via LayerChangeListener 393 // 394 Main.main.removeLayer(layer); 395 } 396 } 397 398 public void actionPerformed(ActionEvent e) { 399 if (this.layer == null) { 400 List<Layer> selectedLayers = getModel().getSelectedLayers(); 401 if (selectedLayers.isEmpty()) 402 return; 403 if (selectedLayers.size() == 1) { 404 deleteSingleLayer(selectedLayers.get(0)); 405 } else { 406 deleteMultipleLayers(selectedLayers); 407 } 408 } else { 409 deleteSingleLayer(this.layer); 336 if (! enforceUploadOrSaveModifiedData(selectedLayers)) 337 return; 338 for(Layer l: selectedLayers) { 339 Main.main.removeLayer(l); 410 340 } 411 341 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r2005 r2025 135 135 int i = 0; 136 136 for (OsmPrimitive e : DataSet.sort(Main.main.getCurrentDataSet().relations)) { 137 if (!e. deleted&& !e.incomplete) {137 if (!e.isDeleted() && !e.incomplete) { 138 138 list.setElementAt(e, i++); 139 139 } … … 381 381 Relation copy = new Relation(); 382 382 copy.cloneFrom(original); 383 // FIXME: id is going to be hidden. How to reset a primitive? 384 // 383 385 copy.id = 0; 384 copy. modified = true;386 copy.setModified(true); 385 387 RelationEditor editor = RelationEditor.getEditor( 386 388 Main.main.getEditLayer(), -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ReferringRelationsBrowser.java
r2017 r2025 107 107 getLayer(), 108 108 full, 109 new PleaseWaitProgressMonitor( )109 new PleaseWaitProgressMonitor(tr("Loading parent relations")) 110 110 ); 111 111 task.setContinuation( -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r2017 r2025 895 895 } 896 896 } 897 new DownloadOsmTaskList().download(false, toDownload, new PleaseWaitProgressMonitor( ));897 new DownloadOsmTaskList().download(false, toDownload, new PleaseWaitProgressMonitor(tr("Download data"))); 898 898 } 899 899 } -
trunk/src/org/openstreetmap/josm/gui/layer/Layer.java
r2017 r2025 45 45 46 46 /** keeps track of property change listeners */ 47 pr ivatePropertyChangeSupport propertyChangeSupport;47 protected PropertyChangeSupport propertyChangeSupport; 48 48 49 49 /** -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r2017 r2025 71 71 */ 72 72 public class OsmDataLayer extends Layer { 73 static public final String REQUIRES_SAVE_TO_DISK_PROP = OsmDataLayer.class.getName() + ".requiresSaveToDisk"; 74 static public final String REQUIRES_UPLOAD_TO_SERVER_PROP = OsmDataLayer.class.getName() + ".requiresUploadToServer"; 75 76 private boolean requiresSaveToFile = false; 77 private boolean requiresUploadToServer = false; 78 79 protected void setRequiresSaveToFile(boolean newValue) { 80 boolean oldValue = requiresSaveToFile; 81 requiresSaveToFile = newValue; 82 if (oldValue != newValue) { 83 propertyChangeSupport.firePropertyChange(REQUIRES_SAVE_TO_DISK_PROP, oldValue, newValue); 84 } 85 } 86 87 protected void setRequiresUploadToServer(boolean newValue) { 88 boolean oldValue = requiresUploadToServer; 89 requiresUploadToServer = newValue; 90 if (oldValue != newValue) { 91 propertyChangeSupport.firePropertyChange(REQUIRES_UPLOAD_TO_SERVER_PROP, oldValue, newValue); 92 } 93 } 73 94 74 95 /** the global counter for created data layers */ … … 96 117 private void inc(final OsmPrimitive osm, final int i) { 97 118 normal[i]++; 98 if (osm. deleted) {119 if (osm.isDeleted()) { 99 120 deleted[i]++; 100 121 } … … 113 134 } 114 135 115 public interface ModifiedChangedListener {116 void modifiedChanged(boolean value, OsmDataLayer source);117 }118 136 public interface CommandQueueListener { 119 137 void commandChanged(int queueSize, int redoSize); … … 130 148 private ConflictCollection conflicts; 131 149 132 /**133 * Whether the data of this layer was modified during the session.134 */135 private boolean modified = false;136 /**137 * Whether the data was modified due an upload of the data to the server.138 */139 public boolean uploadedModified = false;140 141 public final LinkedList<ModifiedChangedListener> listenerModified = new LinkedList<ModifiedChangedListener>();142 150 public final LinkedList<DataChangeListener> listenerDataChanged = new LinkedList<DataChangeListener>(); 143 151 … … 310 318 @Override public void visitBoundingBox(final BoundingXYVisitor v) { 311 319 for (final Node n : data.nodes) 312 if (!n. deleted&& !n.incomplete) {320 if (!n.isDeleted() && !n.incomplete) { 313 321 v.visit(n); 314 322 } 315 }316 317 /**318 * Cleanup the layer after save to disk. Just marks the layer as unmodified.319 * Leaves the undo/redo stack unchanged.320 *321 */322 public void cleanupAfterSaveToDisk() {323 setModified(false);324 323 } 325 324 … … 333 332 */ 334 333 public void cleanupAfterUpload(final Collection<OsmPrimitive> processed) { 335 336 334 // return immediately if an upload attempt failed 337 335 if (processed == null || processed.isEmpty()) … … 351 349 cleanIterator(it, processedSet); 352 350 } 353 354 setModified(true);355 351 } 356 352 … … 367 363 if (!processed.remove(osm)) 368 364 return; 369 osm. modified = false;370 if (osm. deleted) {365 osm.setModified(false); 366 if (osm.isDeleted()) { 371 367 it.remove(); 372 }373 }374 375 public boolean isModified() {376 return modified;377 }378 379 public void setModified(final boolean modified) {380 if (modified == this.modified)381 return;382 this.modified = modified;383 for (final ModifiedChangedListener l : listenerModified) {384 l.modifiedChanged(modified, this);385 368 } 386 369 } … … 392 375 int size = 0; 393 376 for (final OsmPrimitive osm : list) 394 if (!osm. deleted) {377 if (!osm.isDeleted()) { 395 378 size++; 396 379 } … … 446 429 447 430 public void fireDataChange() { 431 setRequiresSaveToFile(true); 432 setRequiresUploadToServer(true); 448 433 for (DataChangeListener dcl : listenerDataChanged) { 449 434 dcl.dataChanged(this); … … 456 441 HashSet<Node> doneNodes = new HashSet<Node>(); 457 442 for (Way w : data.ways) { 458 if (w.incomplete || w. deleted) {443 if (w.incomplete || w.isDeleted()) { 459 444 continue; 460 445 } … … 468 453 ArrayList<WayPoint> trkseg = null; 469 454 for (Node n : w.getNodes()) { 470 if (n.incomplete || n. deleted) {455 if (n.incomplete || n.isDeleted()) { 471 456 trkseg = null; 472 457 continue; … … 492 477 // records them? 493 478 for (Node n : data.nodes) { 494 if (n.incomplete || n. deleted|| doneNodes.contains(n)) {479 if (n.incomplete || n.isDeleted() || doneNodes.contains(n)) { 495 480 continue; 496 481 } … … 546 531 return conflicts; 547 532 } 533 534 /** 535 * Replies true if the data managed by this layer needs to be uploaded to 536 * the server because it contains at least one modified primitive. 537 * 538 * @return true if the data managed by this layer needs to be uploaded to 539 * the server because it contains at least one modified primitive; false, 540 * otherwise 541 */ 542 public boolean requiresUploadToServer() { 543 return requiresUploadToServer; 544 } 545 546 /** 547 * Replies true if the data managed by this layer needs to be saved to 548 * a file. Only replies true if a file is assigned to this layer and 549 * if the data managed by this layer has been modified since the last 550 * save operation to the file. 551 * 552 * @return true if the data managed by this layer needs to be saved to 553 * a file 554 */ 555 public boolean requiresSaveToFile() { 556 return getAssociatedFile() != null && requiresSaveToFile; 557 } 558 559 /** 560 * Initializes the layer after a successful load of OSM data from a file 561 * 562 */ 563 public void onPostLoadFromFile() { 564 setRequiresSaveToFile(false); 565 setRequiresUploadToServer(data.isModified()); 566 } 567 568 /** 569 * Initializes the layer after a successful save of OSM data to a file 570 * 571 */ 572 public void onPostSaveToFile() { 573 setRequiresSaveToFile(false); 574 setRequiresUploadToServer(data.isModified()); 575 } 576 577 /** 578 * Initializes the layer after a successful upload to the server 579 * 580 */ 581 public void onPostUploadToServer() { 582 setRequiresUploadToServer(false); 583 // keep requiresSaveToDisk unchanged 584 } 548 585 } -
trunk/src/org/openstreetmap/josm/gui/progress/PleaseWaitProgressMonitor.java
r2017 r2025 28 28 29 29 private PleaseWaitDialog dialog; 30 private String windowTitle; 30 31 31 public PleaseWaitProgressMonitor( ) {32 public PleaseWaitProgressMonitor(String windowTitle) { 32 33 this(JOptionPane.getFrameForComponent(Main.map)); 34 this.windowTitle = windowTitle; 33 35 } 34 36 … … 86 88 throw new ProgressException("PleaseWaitDialog parent must be either Frame or Dialog"); 87 89 90 if (windowTitle != null) { 91 dialog.setTitle(windowTitle); 92 } 88 93 dialog.cancel.setEnabled(true); 89 94 dialog.setCustomText(""); -
trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
r2000 r2025 168 168 public MultiFetchServerObjectReader append(Node node) { 169 169 if (node == null) return this; 170 if (node. id== 0) return this;171 remember(node. id, OsmPrimitiveType.NODE);170 if (node.getId() == 0) return this; 171 remember(node.getId(), OsmPrimitiveType.NODE); 172 172 return this; 173 173 } … … 182 182 public MultiFetchServerObjectReader append(Way way) { 183 183 if (way == null) return this; 184 if (way. id== 0) return this;184 if (way.getId() == 0) return this; 185 185 for (Node node: way.getNodes()) { 186 if (node. id> 0) {187 remember(node. id, OsmPrimitiveType.NODE);188 } 189 } 190 remember(way. id, OsmPrimitiveType.WAY);186 if (node.getId() > 0) { 187 remember(node.getId(), OsmPrimitiveType.NODE); 188 } 189 } 190 remember(way.getId(), OsmPrimitiveType.WAY); 191 191 return this; 192 192 } … … 201 201 public MultiFetchServerObjectReader append(Relation relation) { 202 202 if (relation == null) return this; 203 if (relation. id== 0) return this;204 remember(relation. id, OsmPrimitiveType.RELATION);203 if (relation.getId() == 0) return this; 204 remember(relation.getId(), OsmPrimitiveType.RELATION); 205 205 for (RelationMember member : relation.getMembers()) { 206 206 if (OsmPrimitiveType.from(member.member).equals(OsmPrimitiveType.RELATION)) { 207 207 // avoid infinite recursion in case of cyclic dependencies in relations 208 208 // 209 if (relations.contains(member.member. id)) {209 if (relations.contains(member.member.getId())) { 210 210 continue; 211 211 } … … 373 373 String msg = ""; 374 374 switch(type) { 375 case NODE: msg = tr("Fetching node with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break;376 case WAY: msg = tr("Fetching way with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break;377 case RELATION: msg = tr("Fetching relation with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break;375 case NODE: msg = tr("Fetching node with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break; 376 case WAY: msg = tr("Fetching way with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break; 377 case RELATION: msg = tr("Fetching relation with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break; 378 378 } 379 379 progressMonitor.setCustomText(msg); … … 411 411 String msg = ""; 412 412 switch(type) { 413 case NODE: msg = tr("Fetching a package of nodes from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break;414 case WAY: msg = tr("Fetching a package of ways from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break;415 case RELATION: msg = tr("Fetching a package of relations from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break;413 case NODE: msg = tr("Fetching a package of nodes from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break; 414 case WAY: msg = tr("Fetching a package of ways from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break; 415 case RELATION: msg = tr("Fetching a package of relations from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break; 416 416 } 417 417 progressMonitor.setCustomText(msg); -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r1894 r2025 251 251 if (version.equals("0.5")) { 252 252 // legacy mode does not return the new object version. 253 sendRequest("PUT", OsmPrimitiveType.from(osm).getAPIName()+"/" + osm. id, toXml(osm, true));253 sendRequest("PUT", OsmPrimitiveType.from(osm).getAPIName()+"/" + osm.getId(), toXml(osm, true)); 254 254 } else { 255 255 String ret = null; 256 256 // normal mode (0.6 and up) returns new object version. 257 257 try { 258 ret = sendRequest("PUT", OsmPrimitiveType.from(osm).getAPIName()+"/" + osm. id, toXml(osm, true));258 ret = sendRequest("PUT", OsmPrimitiveType.from(osm).getAPIName()+"/" + osm.getId(), toXml(osm, true)); 259 259 osm.version = Integer.parseInt(ret.trim()); 260 260 } catch(NumberFormatException e) { 261 throw new OsmTransferException(tr("unexpected format of new version of modified primitive ''{0}'', got ''{1}''", osm. id, ret));261 throw new OsmTransferException(tr("unexpected format of new version of modified primitive ''{0}'', got ''{1}''", osm.getId(), ret)); 262 262 } 263 263 } … … 303 303 */ 304 304 public void stopChangeset(ProgressMonitor progressMonitor) throws OsmTransferException { 305 progressMonitor.beginTask(tr("Closing changeset ..."));305 progressMonitor.beginTask(tr("Closing changeset {0}...", changeset.getId())); 306 306 try { 307 307 initialize(); 308 sendRequest("PUT", "changeset" + "/" + changeset. id+ "/close", null);308 sendRequest("PUT", "changeset" + "/" + changeset.getId() + "/close", null); 309 309 changeset = null; 310 310 } finally { … … 341 341 String diff = duv.getDocument(); 342 342 try { 343 String diffresult = sendRequest("POST", "changeset/" + changeset. id+ "/upload", diff);343 String diffresult = sendRequest("POST", "changeset/" + changeset.getId() + "/upload", diff); 344 344 DiffResultReader.parseDiffResult(diffresult, list, processed, duv.getNewIdMap(), 345 345 progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)); -
trunk/src/org/openstreetmap/josm/io/OsmExporter.java
r2017 r2025 76 76 tmpFile.delete(); 77 77 } 78 layer. cleanupAfterSaveToDisk();78 layer.onPostSaveToFile(); 79 79 } catch (IOException e) { 80 80 e.printStackTrace(); -
trunk/src/org/openstreetmap/josm/io/OsmImporter.java
r1811 r2025 50 50 Main.main.addLayer(layer); 51 51 layer.fireDataChange(); 52 layer.onPostLoadFromFile(); 52 53 } 53 54 } -
trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r2004 r2025 95 95 String msg = ""; 96 96 switch(OsmPrimitiveType.from(osm)) { 97 case NODE: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading node ''{4}'' (id: {5})"); break;98 case WAY: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading way ''{4}'' (id: {5})"); break;99 case RELATION: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading relation ''{4}'' (id: {5})"); break;97 case NODE: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading node ''{4}'' (id: {5})"); break; 98 case WAY: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading way ''{4}'' (id: {5})"); break; 99 case RELATION: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading relation ''{4}'' (id: {5})"); break; 100 100 } 101 101 progressMonitor.subTask( … … 105 105 primitives.size(), 106 106 time_left_str, 107 osm.getName() == null ? osm. id: osm.getName(),108 osm. id));107 osm.getName() == null ? osm.getId() : osm.getName(), 108 osm.getId())); 109 109 makeApiRequest(osm,progressMonitor); 110 110 processed.add(osm); … … 117 117 } finally { 118 118 try { 119 api.stopChangeset(progressMonitor.createSubTaskMonitor(0, false)); 119 // starting the changeset may have failed, for instance because the user 120 // cancelled the upload task. Only close the changeset if we currently have 121 // an open changeset 122 123 if (api.getCurrentChangeset() != null && api.getCurrentChangeset().getId() > 0) { 124 api.stopChangeset(progressMonitor.createSubTaskMonitor(0, false)); 125 } 120 126 } catch(Exception e) { 121 127 Changeset changeset = api.getCurrentChangeset(); 122 String changesetId = (changeset == null ? tr("unknown") : Long.toString(changeset. id));128 String changesetId = (changeset == null ? tr("unknown") : Long.toString(changeset.getId())); 123 129 logger.warning(tr("Failed to close changeset {0}, will be closed by server after timeout. Exception was: {1}", 124 130 changesetId, e.toString())); … … 149 155 } catch (Exception ee) { 150 156 Changeset changeset = api.getCurrentChangeset(); 151 String changesetId = (changeset == null ? tr("unknown") : Long.toString(changeset. id));157 String changesetId = (changeset == null ? tr("unknown") : Long.toString(changeset.getId())); 152 158 logger.warning(tr("Failed to close changeset {0}, will be closed by server after timeout. Exception was: {1}", 153 159 changesetId, ee.toString())); … … 166 172 167 173 api.initialize(); 168 169 progressMonitor.beginTask("");170 174 171 175 try { … … 180 184 181 185 if (useChangeset) { 186 progressMonitor.beginTask(tr("Starting to upload in one request ...")); 182 187 uploadChangesAsDiffUpload(primitives, progressMonitor); 183 188 } else { 189 progressMonitor.beginTask(tr("Starting to upload with one request per primitive ...")); 184 190 uploadChangesIndividually(primitives, progressMonitor); 185 191 } … … 190 196 191 197 void makeApiRequest(OsmPrimitive osm, ProgressMonitor progressMonitor) throws OsmTransferException { 192 if (osm. deleted) {198 if (osm.isDeleted()) { 193 199 api.deletePrimitive(osm, progressMonitor); 194 } else if (osm. id== 0) {200 } else if (osm.getId() == 0) { 195 201 api.createPrimitive(osm); 196 202 } else { -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r1938 r2025 85 85 86 86 private boolean shouldWrite(OsmPrimitive osm) { 87 return osm. id != 0 || !osm.deleted;87 return osm.getId() != 0 || !osm.isDeleted(); 88 88 } 89 89 … … 155 155 */ 156 156 private long getUsedId(OsmPrimitive osm) { 157 if (osm. id!= 0)158 return osm. id;157 if (osm.getId() != 0) 158 return osm.getId(); 159 159 if (usedNewIds.containsKey(osm)) 160 160 return usedNewIds.get(osm); … … 169 169 } 170 170 for (Entry<String, String> e : osm.entrySet()) { 171 if ((osm instanceof Changeset) || !("created_by".equals(e.getKey()))) 171 if ((osm instanceof Changeset) || !("created_by".equals(e.getKey()))) { 172 172 out.println(" <tag k='"+ XmlWriter.encode(e.getKey()) + 173 173 "' v='"+XmlWriter.encode(e.getValue())+ "' />"); 174 } 174 175 } 175 176 out.println(" </" + tagname + ">"); … … 193 194 if (!osmConform) { 194 195 String action = null; 195 if (osm. deleted) {196 if (osm.isDeleted()) { 196 197 action = "delete"; 197 } else if (osm. modified) {198 } else if (osm.isModified()) { 198 199 action = "modify"; 199 200 } … … 209 210 out.print(" user='"+XmlWriter.encode(osm.user.name)+"'"); 210 211 } 211 out.print(" visible='"+osm. visible+"'");212 out.print(" visible='"+osm.isVisible()+"'"); 212 213 if (osm.version != -1) { 213 214 out.print(" version='"+osm.version+"'"); 214 215 } 215 if (this.changeset != null && this.changeset. id!= 0) {216 out.print(" changeset='"+this.changeset. id+"'" );216 if (this.changeset != null && this.changeset.getId() != 0) { 217 out.print(" changeset='"+this.changeset.getId()+"'" ); 217 218 } 218 219 } -
trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
r2017 r2025 48 48 //System.out.println("Going to handle method "+method+" (short: "+method.getName()+") with event "+args[0]); 49 49 if (method.getName().equals("handleQuit")) { 50 handled = !Main.breakBecauseUnsavedChanges();50 handled = Main.saveUnsavedModifications(); 51 51 } else if (method.getName().equals("handleAbout")) { 52 52 Main.main.menu.about.actionPerformed(null);
Note:
See TracChangeset
for help on using the changeset viewer.