Changeset 13161 in josm
- Timestamp:
- 2017-11-25T14:14:25+01:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/APIDataSet.java
r13018 r13161 26 26 import org.openstreetmap.josm.data.osm.RelationMember; 27 27 import org.openstreetmap.josm.data.osm.Way; 28 import org.openstreetmap.josm.tools.Logging; 28 29 import org.openstreetmap.josm.tools.Utils; 29 30 … … 40 41 41 42 /** 43 * The type of operation we can perform with OSM API on a primitive. 44 * @since 13161 45 */ 46 public enum APIOperation { 47 /** Add a new primitive */ 48 ADD, 49 /** Update an existing primitive */ 50 UPDATE, 51 /** Delete an existing primitive */ 52 DELETE; 53 54 /** 55 * Determines the API operation to perform on a primitive. 56 * @param osm OSM primitive 57 * @return the API operation to perform on {@code osm} 58 */ 59 public static APIOperation of(OsmPrimitive osm) { 60 if (osm.isNewOrUndeleted() && !osm.isDeleted()) { 61 return ADD; 62 } else if (osm.isModified() && !osm.isDeleted()) { 63 return UPDATE; 64 } else if (osm.isDeleted() && !osm.isNew() && osm.isModified() && osm.isVisible()) { 65 return DELETE; 66 } 67 return null; 68 } 69 } 70 71 /** 42 72 * creates a new empty data set 43 73 */ … … 69 99 70 100 for (OsmPrimitive osm :primitives) { 71 if (osm.isNewOrUndeleted() && !osm.isDeleted()) { 72 toAdd.add(osm); 73 } else if (osm.isModified() && !osm.isDeleted()) { 74 toUpdate.add(osm); 75 } else if (osm.isDeleted() && !osm.isNew() && osm.isModified() && osm.isVisible()) { 76 toDelete.add(osm); 101 switch (APIOperation.of(osm)) { 102 case ADD: toAdd.add(osm); break; 103 case UPDATE: toUpdate.add(osm); break; 104 case DELETE: toDelete.add(osm); break; 105 default: Logging.trace("Ignored primitive {0}", osm); 77 106 } 78 107 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r12970 r13161 25 25 26 26 import org.openstreetmap.josm.Main; 27 import org.openstreetmap.josm.data.APIDataSet.APIOperation; 27 28 import org.openstreetmap.josm.data.Bounds; 28 29 import org.openstreetmap.josm.data.Data; … … 1136 1137 1137 1138 /** 1139 * Replies true if there is at least one primitive in this dataset which requires to be uploaded to server. 1140 * @return true if there is at least one primitive in this dataset which requires to be uploaded to server 1141 * @since 13161 1142 */ 1143 public boolean requiresUploadToServer() { 1144 for (OsmPrimitive p: allPrimitives) { 1145 if (APIOperation.of(p) != null) 1146 return true; 1147 } 1148 return false; 1149 } 1150 1151 /** 1138 1152 * Adds a new data set listener. 1139 1153 * @param dsl The data set listener to add -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r13133 r13161 997 997 invalidate(); 998 998 setRequiresSaveToFile(true); 999 setRequiresUploadToServer( true);999 setRequiresUploadToServer(event.getDataset().requiresUploadToServer()); 1000 1000 } 1001 1001
Note:
See TracChangeset
for help on using the changeset viewer.