Changeset 2273 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2009-10-11T16:37:08+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 10 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 {
Note:
See TracChangeset
for help on using the changeset viewer.