Changeset 2025 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2009-09-02T21:17:52+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.