Changeset 2273 in josm
- Timestamp:
- 2009-10-11T16:37:08+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AbstractInfoAction.java
r2256 r2273 108 108 Iterator<OsmPrimitive> it = primitivesToShow.iterator(); 109 109 while(it.hasNext()) { 110 if (it.next(). getId() == 0) {110 if (it.next().isNew()) { 111 111 it.remove(); 112 112 } -
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r2256 r2273 81 81 for (Way w : combinedWays) { 82 82 targetWay = w; 83 if ( w.getId() != 0) {83 if (!w.isNew()) { 84 84 break; 85 85 } -
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r2256 r2273 89 89 Node targetNode = null; 90 90 for (Node n: candidates) { 91 if ( n.getId() > 0) {91 if (!n.isNew()) { 92 92 targetNode = n; 93 93 break; -
trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java
r2070 r2273 36 36 public boolean doSave() { 37 37 Layer layer = null; 38 if ( layer == null &&Main.map != null && (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer38 if (Main.map != null && (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer 39 39 || Main.map.mapView.getActiveLayer() instanceof GpxLayer)) { 40 40 layer = Main.map.mapView.getActiveLayer(); … … 140 140 private boolean isDataSetEmpty(OsmDataLayer layer) { 141 141 for (OsmPrimitive osm : layer.data.allNonDeletedPrimitives()) 142 if (!osm.isDeleted() || osm.getId() > 0)142 if (!osm.isDeleted() || !osm.isNew()) 143 143 return false; 144 144 return true; -
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r2256 r2273 134 134 * 135 135 */ 136 class UpdatePrimitivesTask extends PleaseWaitRunnable {136 static class UpdatePrimitivesTask extends PleaseWaitRunnable { 137 137 private DataSet ds; 138 138 private boolean canceled; … … 170 170 protected void initMultiFetchReaderWithNodes(MultiFetchServerObjectReader reader) { 171 171 for (OsmPrimitive primitive : toUpdate) { 172 if (primitive instanceof Node && primitive.getId() > 0) {172 if (primitive instanceof Node && !primitive.isNew()) { 173 173 reader.append((Node)primitive); 174 174 } else if (primitive instanceof Way) { 175 175 Way way = (Way)primitive; 176 176 for (Node node: way.getNodes()) { 177 if ( node.getId() > 0) {177 if (!node.isNew()) { 178 178 reader.append(node); 179 179 } … … 185 185 protected void initMultiFetchReaderWithWays(MultiFetchServerObjectReader reader) { 186 186 for (OsmPrimitive primitive : toUpdate) { 187 if (primitive instanceof Way && primitive.getId() > 0) {187 if (primitive instanceof Way && !primitive.isNew()) { 188 188 reader.append((Way)primitive); 189 189 } … … 193 193 protected void initMultiFetchReaderWithRelations(MultiFetchServerObjectReader reader) { 194 194 for (OsmPrimitive primitive : toUpdate) { 195 if (primitive instanceof Relation && primitive.getId() > 0) {195 if (primitive instanceof Relation && !primitive.isNew()) { 196 196 reader.append((Relation)primitive); 197 197 } -
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r2255 r2273 5 5 6 6 import java.awt.event.ActionEvent; 7 import java.awt.event.ActionListener;8 7 import java.awt.event.KeyEvent; 9 8 import java.io.IOException; … … 18 17 import java.util.regex.Pattern; 19 18 20 import javax.swing.JButton;21 import javax.swing.JDialog;22 19 import javax.swing.JOptionPane; 23 20 … … 38 35 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 39 36 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 40 import org.openstreetmap.josm.gui.help.HelpBrowser;41 import org.openstreetmap.josm.gui.help.HelpBuilder;42 37 import org.openstreetmap.josm.gui.io.UploadDialog; 43 38 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 53 48 import org.openstreetmap.josm.tools.ImageProvider; 54 49 import org.openstreetmap.josm.tools.Shortcut; 55 import org.openstreetmap.josm.tools.WindowGeometry;56 50 import org.xml.sax.SAXException; 57 51 … … 234 228 String lbl = ""; 235 229 switch(primitiveType) { 236 237 238 230 case NODE: lbl = tr("Synchronize node {0} only", id); break; 231 case WAY: lbl = tr("Synchronize way {0} only", id); break; 232 case RELATION: lbl = tr("Synchronize relation {0} only", id); break; 239 233 } 240 234 ButtonSpec[] spec = new ButtonSpec[] { … … 280 274 ); 281 275 switch(ret) { 282 283 284 276 case 0: synchronizePrimitive(primitiveType, id); break; 277 case 1: synchronizeDataSet(); break; 278 default: return; 285 279 } 286 280 } -
trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java
r2256 r2273 68 68 HashSet<OsmPrimitive> ret = new HashSet<OsmPrimitive>(); 69 69 for (OsmPrimitive p : ds.nodes) { 70 if (p.isDeleted() && p.getId() > 0&& p.isVisible() && p.isModified()) {70 if (p.isDeleted() && !p.isNew() && p.isVisible() && p.isModified()) { 71 71 ret.add(p); 72 72 } 73 73 } 74 74 for (OsmPrimitive p : ds.ways) { 75 if (p.isDeleted() && p.getId() > 0&& p.isVisible() && p.isModified()) {75 if (p.isDeleted() && !p.isNew() && p.isVisible() && p.isModified()) { 76 76 ret.add(p); 77 77 } 78 78 } 79 79 for (OsmPrimitive p : ds.relations) { 80 if (p.isDeleted() && p.getId() > 0&& p.isVisible() && p.isModified()) {80 if (p.isDeleted() && !p.isNew() && p.isVisible() && p.isModified()) { 81 81 ret.add(p); 82 82 } … … 88 88 HashSet<OsmPrimitive> ret = new HashSet<OsmPrimitive>(); 89 89 for (OsmPrimitive p: primitives) { 90 if (p. getId() == 0) {90 if (p.isNew()) { 91 91 ret.add(p); 92 92 } else if (p.isVisible() && p.isModified() && !p.incomplete) { … … 135 135 protected boolean hasPrimitivesToDelete(Collection<OsmPrimitive> primitives) { 136 136 for (OsmPrimitive p: primitives) 137 if (p.isDeleted() && p.isModified() && p.getId() > 0)137 if (p.isDeleted() && p.isModified() && !p.isNew()) 138 138 return true; 139 139 return false; … … 188 188 189 189 public void visit(Node n) { 190 if (n. getId() == 0|| ((n.isModified() || n.isDeleted()) && n.isVisible())) {190 if (n.isNew() || ((n.isModified() || n.isDeleted()) && n.isVisible())) { 191 191 // upload new nodes as well as modified and deleted ones 192 192 hull.add(n); … … 195 195 196 196 public void visit(Way w) { 197 if (w. getId() == 0|| ((w.isModified() || w.isDeleted()) && w.isVisible())) {197 if (w.isNew() || ((w.isModified() || w.isDeleted()) && w.isVisible())) { 198 198 // upload new ways as well as modified and deleted ones 199 199 hull.add(w); … … 207 207 208 208 public void visit(Relation r) { 209 if (r. getId() == 0|| ((r.isModified() || r.isDeleted()) && r.isVisible())) {209 if (r.isNew() || ((r.isModified() || r.isDeleted()) && r.isVisible())) { 210 210 hull.add(r); 211 211 for (OsmPrimitive p : r.getMemberPrimitives()) { … … 214 214 // so wont check here for deleted primitives here 215 215 // 216 if (p. getId() == 0) {216 if (p.isNew()) { 217 217 p.visit(this); 218 218 } … … 297 297 HashSet<OsmPrimitive> ret = new HashSet<OsmPrimitive>(); 298 298 for (OsmPrimitive p: toUpload) { 299 if (p.isDeleted() && p.getId() >0) {299 if (p.isDeleted() && !p.isNew()) { 300 300 ret.add(p); 301 301 } -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java
r2253 r2273 155 155 HashSet<OsmPrimitive> ret = new HashSet<OsmPrimitive>(); 156 156 for (OsmPrimitive primitive : ds.nodes) { 157 if (!primitive.incomplete && primitive. getId() == 0) {157 if (!primitive.incomplete && primitive.isNew()) { 158 158 ret.add(primitive); 159 159 } 160 160 } 161 161 for (OsmPrimitive primitive : ds.ways) { 162 if (! primitive.incomplete && primitive. getId() == 0) {162 if (! primitive.incomplete && primitive.isNew()) { 163 163 ret.add(primitive); 164 164 } 165 165 } 166 166 for (OsmPrimitive primitive : ds.relations) { 167 if (! primitive.incomplete && primitive. getId() == 0) {167 if (! primitive.incomplete && primitive.isNew()) { 168 168 ret.add(primitive); 169 169 } -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r2264 r2273 33 33 private String rxErrorMsg = marktr("The regex \"{0}\" had a parse error at offset {1}, full error:\n\n{2}"); 34 34 private PushbackTokenizer tokenizer; 35 private staticCollectBackReferencesVisitor childBackRefs;35 private CollectBackReferencesVisitor childBackRefs; 36 36 37 37 public SearchCompiler(boolean caseSensitive, boolean regexSearch, PushbackTokenizer tokenizer) { … … 230 230 231 231 switch (mode) { 232 case NONE: 233 return false; 234 case MISSING_KEY: 235 return osm.get(key) == null; 236 case ANY: 237 return true; 238 case ANY_VALUE: 239 return osm.get(key) != null; 240 case ANY_KEY: 241 for (String v:osm.getKeys().values()) { 242 if (v.equals(value)) 232 case NONE: 233 return false; 234 case MISSING_KEY: 235 return osm.get(key) == null; 236 case ANY: 237 return true; 238 case ANY_VALUE: 239 return osm.get(key) != null; 240 case ANY_KEY: 241 for (String v:osm.getKeys().values()) { 242 if (v.equals(value)) 243 return true; 244 } 245 return false; 246 case EXACT: 247 return value.equals(osm.get(key)); 248 case ANY_KEY_REGEXP: 249 for (String v:osm.getKeys().values()) { 250 if (valuePattern.matcher(v).matches()) 251 return true; 252 } 253 return false; 254 case ANY_VALUE_REGEXP: 255 case EXACT_REGEXP: 256 for (Entry<String, String> entry:osm.entrySet()) { 257 if (keyPattern.matcher(entry.getKey()).matches()) { 258 if (mode == Mode.ANY_VALUE_REGEXP 259 || valuePattern.matcher(entry.getValue()).matches()) 243 260 return true; 244 261 } 245 return false; 246 case EXACT: 247 return value.equals(osm.get(key)); 248 case ANY_KEY_REGEXP: 249 for (String v:osm.getKeys().values()) { 250 if (valuePattern.matcher(v).matches()) 251 return true; 252 } 253 return false; 254 case ANY_VALUE_REGEXP: 255 case EXACT_REGEXP: 256 for (Entry<String, String> entry:osm.entrySet()) { 257 if (keyPattern.matcher(entry.getKey()).matches()) { 258 if (mode == Mode.ANY_VALUE_REGEXP 259 || valuePattern.matcher(entry.getValue()).matches()) 260 return true; 261 } 262 } 263 return false; 264 case MISSING_KEY_REGEXP: 265 for (String k:osm.keySet()) { 266 if (keyPattern.matcher(k).matches()) 267 return false; 268 } 269 return true; 262 } 263 return false; 264 case MISSING_KEY_REGEXP: 265 for (String k:osm.keySet()) { 266 if (keyPattern.matcher(k).matches()) 267 return false; 268 } 269 return true; 270 270 } 271 271 throw new AssertionError("Missed state"); … … 417 417 private static class Modified extends Match { 418 418 @Override public boolean match(OsmPrimitive osm) { 419 return osm.isModified() || osm. getId() == 0;419 return osm.isModified() || osm.isNew(); 420 420 } 421 421 @Override public String toString() {return "modified";} … … 473 473 474 474 private static class Child extends Match { 475 private Match parent; 476 public Child(Match m) { parent = m; } 477 @Override public boolean match(OsmPrimitive osm) throws ParseError { 475 private final Match parent; 476 private final CollectBackReferencesVisitor childBackRefs; 477 478 public Child(Match m, CollectBackReferencesVisitor childBackRefs) { 478 479 // "child" (null) should mean the same as "child()" 479 480 // (Always). I.e. match everything 480 if ( parent== null) {481 if (m == null) { 481 482 parent = new Always(); 482 } 483 483 } else { 484 parent = m; 485 } 486 this.childBackRefs = childBackRefs; 487 } 488 489 @Override public boolean match(OsmPrimitive osm) throws ParseError { 484 490 boolean isChild = false; 485 491 childBackRefs.initialize(); … … 592 598 return new Selected(); 593 599 else if (tok.equals("child")) 594 return new Child(parseParens() );600 return new Child(parseParens(), childBackRefs); 595 601 else if (tok.equals("parent")) 596 602 return new Parent(parseParens()); -
trunk/src/org/openstreetmap/josm/actions/upload/CyclicUploadDependencyException.java
r2168 r2273 22 22 if (r.getName() != null) { 23 23 sb.append("'").append(r.getName()).append("'"); 24 } else if ( r.getId() > 0) {24 } else if (!r.isNew()) { 25 25 sb.append(r.getId()); 26 26 } else { -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r2173 r2273 109 109 String msg = ""; 110 110 switch(OsmPrimitiveType.from(primitive)) { 111 112 113 111 case NODE: msg = "Delete node {0}"; break; 112 case WAY: msg = "Delete way {0}"; break; 113 case RELATION:msg = "Delete relation {0}"; break; 114 114 } 115 115 … … 130 130 apiname = t.getAPIName(); 131 131 switch(t) { 132 133 134 132 case NODE: msg = trn("Delete {0} node", "Delete {0} nodes", toDelete.size(), toDelete.size()); break; 133 case WAY: msg = trn("Delete {0} way", "Delete {0} ways", toDelete.size(), toDelete.size()); break; 134 case RELATION: msg = trn("Delete {0} relation", "Delete {0} relations", toDelete.size(), toDelete.size()); break; 135 135 } 136 136 } … … 185 185 return 1; 186 186 187 String role = new String();187 String role = ""; 188 188 for (RelationMember m : ref.getMembers()) { 189 189 if (m.getMember() == osm) { … … 399 399 } 400 400 Way w = (Way) primitive; 401 if (w. getId() == 0) { // new ways with id == 0 are fine,401 if (w.isNew()) { // new ways with id == 0 are fine, 402 402 continue; // process existing ways only 403 403 } … … 407 407 // nodes ... 408 408 for (Node n : wnew.getNodes()) { 409 if ( n.getId() != 0|| !primitivesToDelete.contains(n)) {409 if (!n.isNew() || !primitivesToDelete.contains(n)) { 410 410 nodesToKeep.add(n); 411 411 } … … 470 470 if (a != null) { 471 471 for (OsmPrimitive osm : primitivesToDelete) { 472 if (osm instanceof Node && osm.getId() != 0) {472 if (osm instanceof Node && !osm.isNew()) { 473 473 Node n = (Node) osm; 474 474 if (!a.contains(n.getCoor())) { -
trunk/src/org/openstreetmap/josm/data/APIDataSet.java
r2250 r2273 58 58 continue; 59 59 } 60 if (osm. getId() == 0&& !osm.isDeleted()) {60 if (osm.isNew() && !osm.isDeleted()) { 61 61 toAdd.addLast(osm); 62 62 } else if (osm.isModified() && !osm.isDeleted()) { 63 63 toUpdate.addLast(osm); 64 } else if (osm.isDeleted() && osm.getId() != 0&& osm.isModified()) {64 } else if (osm.isDeleted() && !osm.isNew() && osm.isModified()) { 65 65 toDelete.addFirst(osm); 66 66 } … … 119 119 toDelete.clear(); 120 120 for (OsmPrimitive osm: primitives) { 121 if (osm. getId() == 0&& !osm.isDeleted()) {121 if (osm.isNew() && !osm.isDeleted()) { 122 122 toAdd.addLast(osm); 123 123 } else if (osm.isModified() && !osm.isDeleted()) { 124 124 toUpdate.addLast(osm); 125 } else if (osm.isDeleted() && osm.getId() != 0&& osm.isModified()) {125 } else if (osm.isDeleted() && !osm.isNew() && osm.isModified()) { 126 126 toDelete.addFirst(osm); 127 127 } … … 216 216 boolean refersToNewRelation = false; 217 217 for (RelationMember m : relation.getMembers()) { 218 if (m.isRelation() && m.getMember(). getId() <= 0) {218 if (m.isRelation() && m.getMember().isNew()) { 219 219 refersToNewRelation = true; 220 220 break; … … 253 253 this.relations = new HashSet<Relation>(); 254 254 for(Relation relation: relations) { 255 if ( relation.getId() > 0) {255 if (!relation.isNew() ) { 256 256 continue; 257 257 } 258 258 this.relations.add(relation); 259 259 for (RelationMember m: relation.getMembers()) { 260 if (m.isRelation() && m.getMember(). getId() == 0) {260 if (m.isRelation() && m.getMember().isNew()) { 261 261 addDependency(relation, (Relation)m.getMember()); 262 262 } … … 306 306 new Comparator<Relation>() { 307 307 public int compare(Relation o1, Relation o2) { 308 return new Integer(uploadOrder.indexOf(o1)).compareTo(uploadOrder.indexOf(o2));308 return Integer.valueOf(uploadOrder.indexOf(o1)).compareTo(uploadOrder.indexOf(o2)); 309 309 } 310 310 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r2264 r2273 332 332 public long getId() { 333 333 return id; 334 } 335 336 /** 337 * 338 * @return True if primitive is new (not yet uploaded the server, id <= 0) 339 */ 340 public boolean isNew() { 341 return id <= 0; 334 342 } 335 343 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/CreateOsmChangeVisitor.java
r2025 r2273 52 52 osmwriter.visit(n); 53 53 } else { 54 switchMode( (n.getId() == 0) ? "create" : "modify");54 switchMode(n.isNew() ? "create" : "modify"); 55 55 osmwriter.setWithBody(true); 56 56 osmwriter.visit(n); … … 63 63 osmwriter.visit(w); 64 64 } else { 65 switchMode( (w.getId() == 0) ? "create" : "modify");65 switchMode(w.isNew() ? "create" : "modify"); 66 66 osmwriter.setWithBody(true); 67 67 osmwriter.visit(w); … … 74 74 osmwriter.visit(r); 75 75 } else { 76 switchMode( (r.getId() == 0) ? "create" : "modify");76 switchMode(r.isNew() ? "create" : "modify"); 77 77 osmwriter.setWithBody(true); 78 78 osmwriter.visit(r); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitor.java
r2181 r2273 123 123 clone = new Relation(primitive.getId()); 124 124 } 125 clone.incomplete = true;126 125 mappedPrimitives.put(primitive, clone); 127 126 } … … 173 172 // ... and the way itself 174 173 rememberWay(w); 175 }176 177 protected boolean isNew(OsmPrimitive primitive) {178 return primitive.getId() == 0;179 174 } 180 175 … … 202 197 if (isInSelectionBase(node)) { 203 198 rememberNode(node); 204 } else if ( isNew(node)) {199 } else if (node.isNew()) { 205 200 rememberNode(node); 206 201 } else { … … 211 206 if (isInSelectionBase(way)) { 212 207 way.visit(this); 213 } else if ( isNew(way)) {208 } else if (way.isNew()) { 214 209 way.visit(this); 215 210 } else { … … 220 215 if (isInSelectionBase(member.getMember())) { 221 216 relation.visit(this); 222 } else if ( isNew(relation)) {217 } else if (relation.isNew()) { 223 218 relation.visit(this); 224 219 } else { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r2070 r2273 62 62 this.theirDataSet = theirDataSet; 63 63 64 for (Node n : myDataSet.nodes) if ( n.getId() != 0) {64 for (Node n : myDataSet.nodes) if (!n.isNew()) { 65 65 nodeshash.put(n.getId(), n); 66 66 } 67 for (Way w : myDataSet.ways) if ( w.getId() != 0) {67 for (Way w : myDataSet.ways) if (!w.isNew()) { 68 68 wayshash.put(w.getId(), w); 69 69 } 70 for (Relation r : myDataSet.relations) if ( r.getId() != 0) {70 for (Relation r : myDataSet.relations) if (!r.isNew()) { 71 71 relshash.put(r.getId(), r); 72 72 } … … 98 98 HashMap<Long, P> primitivesWithDefinedIds) { 99 99 100 if ( other.getId() > 0) {100 if (!other.isNew() ) { 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.getId() >0) {111 if (!my.isNew()) { 112 112 continue; 113 113 } -
trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java
r2136 r2273 97 97 } 98 98 if (name == null) { 99 name = node. getId() == 0? tr("node") : ""+ node.getId();99 name = node.isNew() ? tr("node") : ""+ node.getId(); 100 100 } 101 101 name += " (" + node.getCoor().latToString(CoordinateFormat.getDefaultFormat()) + ", " + node.getCoor().lonToString(CoordinateFormat.getDefaultFormat()) + ")"; -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r2264 r2273 320 320 // pressed. Cannot use "setSelected()" because it will cause a 321 321 // fireSelectionChanged event which is unnecessary at this point. 322 if((mods & MouseEvent.SHIFT_DOWN_MASK) == 0) 322 if((mods & MouseEvent.SHIFT_DOWN_MASK) == 0) { 323 323 ds.clearSelection(); 324 } 324 325 325 326 // This will cycle through the available items. … … 415 416 final StringBuilder text = new StringBuilder(); 416 417 String name = osm.getDisplayName(DefaultNameFormatter.getInstance()); 417 if (osm. getId() == 0|| osm.isModified()) {418 if (osm.isNew() || osm.isModified()) { 418 419 name = "<i><b>"+ name + "*</b></i>"; 419 420 } 420 421 text.append(name); 421 422 422 if ( osm.getId() != 0) {423 if (!osm.isNew()) { 423 424 text.append(" [id="+osm.getId()+"]"); 424 425 } -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r2264 r2273 318 318 // when multiple nodes on one point, prefer new or selected nodes 319 319 else if(dist == minDistanceSq && minPrimitive != null 320 && ((n. getId() == 0&& ds.isSelected(n))321 || (!ds.isSelected(minPrimitive) && (ds.isSelected(n) || n. getId() == 0)))) {320 && ((n.isNew() && ds.isSelected(n)) 321 || (!ds.isSelected(minPrimitive) && (ds.isSelected(n) || n.isNew())))) { 322 322 minPrimitive = n; 323 323 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModel.java
r2181 r2273 76 76 @Override 77 77 public boolean isEqualEntry(Node e1, Node e2) { 78 if ( e1.getId() > 0)78 if (!e1.isNew()) 79 79 return e1.getId() == e2.getId(); 80 80 else -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergeModel.java
r2181 r2273 212 212 public LatLon getMergedCoords() { 213 213 switch(coordMergeDecision) { 214 215 216 214 case KEEP_MINE: return myCoords; 215 case KEEP_THEIR: return theirCoords; 216 case UNDECIDED: return null; 217 217 } 218 218 // should not happen … … 246 246 public Boolean getMergedDeletedState() { 247 247 switch(deletedMergeDecision) { 248 249 250 248 case KEEP_MINE: return myDeletedState; 249 case KEEP_THEIR: return theirDeletedState; 250 case UNDECIDED: return null; 251 251 } 252 252 // should not happen … … 279 279 public Boolean getMergedVisibleState() { 280 280 switch(visibleMergeDecision) { 281 282 283 281 case KEEP_MINE: return myVisibleState; 282 case KEEP_THEIR: return theirVisibleState; 283 case UNDECIDED: return null; 284 284 } 285 285 // should not happen … … 484 484 485 485 switch(ret) { 486 487 488 486 case JOptionPane.CLOSED_OPTION: return false; 487 case JOptionPane.YES_OPTION: return true; 488 case JOptionPane.NO_OPTION: return false; 489 489 } 490 490 return false; … … 513 513 514 514 switch(ret) { 515 516 517 515 case JOptionPane.CLOSED_OPTION: return false; 516 case JOptionPane.YES_OPTION: return true; 517 case JOptionPane.NO_OPTION: return false; 518 518 } 519 519 return false; … … 535 535 HashMap<Long,OsmPrimitive> candidates = new HashMap<Long,OsmPrimitive>(); 536 536 for (Node n : way.getNodes()) { 537 if ( n.getId() > 0 && !candidates.values().contains(n)) {537 if (!n.isNew() && !candidates.values().contains(n)) { 538 538 candidates.put(n.getId(), n); 539 539 } … … 572 572 HashMap<Long,OsmPrimitive> candidates = new HashMap<Long, OsmPrimitive>(); 573 573 for (RelationMember m : r.getMembers()) { 574 if ( m.getMember().getId() > 0&& !candidates.values().contains(m.getMember())) {574 if (!m.getMember().isNew() && !candidates.values().contains(m.getMember())) { 575 575 candidates.put(m.getMember().getId(), m.getMember()); 576 576 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberListMergeModel.java
r2181 r2273 25 25 public boolean isEqualEntry(RelationMember e1, RelationMember e2) { 26 26 boolean ret = e1.getRole().equals(e2.getRole()); 27 if ( e1.getMember().getId() > 0) {27 if (!e1.getMember().isNew() ) { 28 28 ret = ret && (e1.getMember().getId() == e2.getMember().getId()); 29 29 } else { -
trunk/src/org/openstreetmap/josm/gui/dialogs/HistoryDialog.java
r2243 r2273 144 144 * 145 145 */ 146 class HistoryItemTableModel extends DefaultTableModel implements SelectionChangedListener{146 static class HistoryItemTableModel extends DefaultTableModel implements SelectionChangedListener{ 147 147 private ArrayList<OsmPrimitive> data; 148 148 private DefaultListSelectionModel selectionModel; … … 196 196 return; 197 197 for (OsmPrimitive primitive: Main.main.getCurrentDataSet().getSelected()) { 198 if (primitive. getId() == 0) {198 if (primitive.isNew()) { 199 199 continue; 200 200 } … … 226 226 * The column model 227 227 */ 228 class HistoryTableColumnModel extends DefaultTableColumnModel {228 static class HistoryTableColumnModel extends DefaultTableColumnModel { 229 229 protected void createColumns() { 230 230 TableColumn col = null; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java
r2181 r2273 365 365 if (member.isRelation()) { 366 366 Relation child = member.getRelation(); 367 if (!downloadedRelationIds.contains(child )) {367 if (!downloadedRelationIds.contains(child.getId())) { 368 368 relationsToDownload.push(child); 369 369 } … … 403 403 while(! relationsToDownload.isEmpty() && !cancelled) { 404 404 Relation r = relationsToDownload.pop(); 405 if (r. getId() == 0) {405 if (r.isNew()) { 406 406 continue; 407 407 } … … 514 514 while(it.hasNext() && !cancelled) { 515 515 Relation r = it.next(); 516 if (r. getId() == 0) {516 if (r.isNew()) { 517 517 continue; 518 518 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r2163 r2273 592 592 ); 593 593 switch(ret) { 594 595 596 597 598 599 594 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return; 595 case JOptionPane.CLOSED_OPTION: return; 596 case JOptionPane.NO_OPTION: return; 597 case JOptionPane.YES_OPTION: 598 memberTableModel.removeMembersReferringTo(toCheck); 599 break; 600 600 } 601 601 } … … 628 628 ); 629 629 switch(ret) { 630 631 632 633 634 630 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION : return true; 631 case JOptionPane.YES_OPTION: return true; 632 case JOptionPane.NO_OPTION: return false; 633 case JOptionPane.CLOSED_OPTION: return false; 634 case JOptionPane.CANCEL_OPTION: throw new AddAbortException(); 635 635 } 636 636 // should not happen … … 1064 1064 ); 1065 1065 switch(ret) { 1066 1067 1068 1066 case JOptionPane.CANCEL_OPTION: return false; 1067 case JOptionPane.YES_OPTION: return true; 1068 case JOptionPane.NO_OPTION: return false; 1069 1069 } 1070 1070 return false; … … 1200 1200 1201 1201 protected void updateEnabledState() { 1202 setEnabled(getRelation() != null && getRelation().getId() > 0);1202 setEnabled(getRelation() != null && !getRelation().isNew()); 1203 1203 } 1204 1204 } … … 1240 1240 ); 1241 1241 switch(ret) { 1242 1243 1244 1245 1242 case JOptionPane.YES_OPTION: return true; 1243 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return true; 1244 default: 1245 return false; 1246 1246 } 1247 1247 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r2083 r2273 202 202 for (int i=0; i< members.size();i++) { 203 203 RelationMember member = members.get(i); 204 if (member.getMember(). getId() == 0) {204 if (member.getMember().isNew()) { 205 205 continue; 206 206 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java
r2181 r2273 79 79 if (layer == null) 80 80 throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "layer")); 81 if (child. getId() == 0)81 if (child.isNew()) 82 82 throw new IllegalArgumentException(tr("Value of child.getId() > 0 expected. Got {1}.", child.getId())); 83 83 referrers = null; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ReferringRelationsBrowserModel.java
r2070 r2273 89 89 90 90 public boolean canReload() { 91 return relation != null && relation.getId() > 0;91 return relation != null && !relation.isNew(); 92 92 } 93 93 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java
r2181 r2273 117 117 if (getRelation() == null) { 118 118 setTitle(tr("Create new relation in layer ''{0}''", layer.getName())); 119 } else if (getRelation(). getId() == 0) {119 } else if (getRelation().isNew()) { 120 120 setTitle(tr("Edit new relation in layer ''{0}''", layer.getName())); 121 121 } else { -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationTree.java
r2070 r2273 91 91 TreePath path = event.getPath(); 92 92 Relation parent = (Relation)event.getPath().getLastPathComponent(); 93 if (! parent.incomplete || parent. getId() == 0)93 if (! parent.incomplete || parent.isNew()) 94 94 // we don't load complete or new relations 95 95 return; -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r2241 r2273 362 362 protected String getUploadComment() { 363 363 switch(southTabbedPane.getSelectedIndex()) { 364 365 366 367 368 364 case 0: 365 return pnlChangesetSelection.getUploadComment(); 366 case 1: 367 TagModel tm = tagEditorPanel.getModel().get("comment"); 368 return tm == null? "" : tm.getValue(); 369 369 } 370 370 return ""; -
trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
r2181 r2273 155 155 public MultiFetchServerObjectReader append(Node node) { 156 156 if (node == null) return this; 157 if (node. getId() == 0) return this;157 if (node.isNew()) return this; 158 158 remember(node.getId(), OsmPrimitiveType.NODE); 159 159 return this; … … 169 169 public MultiFetchServerObjectReader append(Way way) { 170 170 if (way == null) return this; 171 if (way. getId() == 0) return this;171 if (way.isNew()) return this; 172 172 for (Node node: way.getNodes()) { 173 if ( node.getId() > 0) {173 if (!node.isNew()) { 174 174 remember(node.getId(), OsmPrimitiveType.NODE); 175 175 } … … 188 188 public MultiFetchServerObjectReader append(Relation relation) { 189 189 if (relation == null) return this; 190 if (relation. getId() == 0) return this;190 if (relation.isNew()) return this; 191 191 remember(relation.getId(), OsmPrimitiveType.RELATION); 192 192 for (RelationMember member : relation.getMembers()) { -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r2222 r2273 555 555 String errorBody = responseBody == null ? null : responseBody.toString().trim(); 556 556 switch(retCode) { 557 558 559 560 561 562 557 case HttpURLConnection.HTTP_OK: 558 break; // do nothing 559 case HttpURLConnection.HTTP_GONE: 560 throw new OsmApiPrimitiveGoneException(errorHeader, errorBody); 561 default: 562 throw new OsmApiException(retCode, errorHeader, errorBody); 563 563 564 564 } -
trunk/src/org/openstreetmap/josm/io/OsmServerBackreferenceReader.java
r2181 r2273 51 51 if (primitive == null) 52 52 throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "primitive")); 53 if (primitive. getId() == 0)53 if (primitive.isNew()) 54 54 throw new IllegalArgumentException(tr("ID parameter ''{0}'' > 0 expected. Got ''{1}''.", "primitive", primitive.getId())); 55 55 this.id = primitive.getId(); … … 222 222 if (isReadFull() ||primitiveType.equals(OsmPrimitiveType.NODE)) { 223 223 for (Way way: waysToCheck) { 224 if ( way.getId() > 0&& way.incomplete) {224 if (!way.isNew() && way.incomplete) { 225 225 OsmServerObjectReader reader = new OsmServerObjectReader(way.getId(), OsmPrimitiveType.from(way), true /* read full */); 226 226 DataSet wayDs = reader.parseOsm(progressMonitor.createSubTaskMonitor(1, false)); … … 233 233 Collection<Relation> relationsToCheck = new ArrayList<Relation>(ds.relations); 234 234 for (Relation relation: relationsToCheck) { 235 if ( relation.getId() > 0&& relation.incomplete) {235 if (!relation.isNew() && relation.incomplete) { 236 236 OsmServerObjectReader reader = new OsmServerObjectReader(relation.getId(), OsmPrimitiveType.from(relation), true /* read full */); 237 237 DataSet wayDs = reader.parseOsm(progressMonitor.createSubTaskMonitor(1, false)); -
trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r2198 r2273 79 79 String msg = ""; 80 80 switch(OsmPrimitiveType.from(osm)) { 81 82 83 81 case NODE: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading node ''{4}'' (id: {5})"); break; 82 case WAY: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading way ''{4}'' (id: {5})"); break; 83 case RELATION: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading relation ''{4}'' (id: {5})"); break; 84 84 } 85 85 progressMonitor.subTask( … … 178 178 if (osm.isDeleted()) { 179 179 api.deletePrimitive(osm, progressMonitor); 180 } else if (osm. getId() == 0) {180 } else if (osm.isNew()) { 181 181 api.createPrimitive(osm, progressMonitor); 182 182 } else { -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r2115 r2273 87 87 88 88 private boolean shouldWrite(OsmPrimitive osm) { 89 return osm.getId() != 0|| !osm.isDeleted();89 return !osm.isNew() || !osm.isDeleted(); 90 90 } 91 91 … … 173 173 */ 174 174 private long getUsedId(OsmPrimitive osm) { 175 if ( osm.getId() != 0)175 if (!osm.isNew()) 176 176 return osm.getId(); 177 177 if (usedNewIds.containsKey(osm))
Note:
See TracChangeset
for help on using the changeset viewer.