Changeset 13497 in josm
- Timestamp:
- 2018-03-04T15:18:05+01:00 (7 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UpdateModifiedAction.java
r10382 r13497 11 11 import org.openstreetmap.josm.Main; 12 12 import org.openstreetmap.josm.data.osm.DataSet; 13 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy; 13 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 15 import org.openstreetmap.josm.io.OnlineResource; … … 46 47 @Override 47 48 protected void updateEnabledState() { 48 setEnabled(getLayerManager().getEditDataSet() != null && !Main.isOffline(OnlineResource.OSM_API)); 49 DataSet ds = getLayerManager().getEditDataSet(); 50 setEnabled(ds != null && !DownloadPolicy.BLOCKED.equals(ds.getDownloadPolicy()) 51 && !Main.isOffline(OnlineResource.OSM_API)); 49 52 } 50 53 -
trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java
r13434 r13497 64 64 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 65 65 updateEnabledStateOnModifiableSelection(selection); 66 OsmDataLayer editLayer = getLayerManager().getEditLayer(); 67 if (editLayer != null && !editLayer.isUploadable()) { 68 setEnabled(false); 69 } 66 70 } 67 71 … … 89 93 public void actionPerformed(ActionEvent e) { 90 94 OsmDataLayer editLayer = getLayerManager().getEditLayer(); 91 if (!isEnabled() )95 if (!isEnabled() || !editLayer.isUploadable()) 92 96 return; 93 97 if (editLayer.isUploadDiscouraged() && UploadAction.warnUploadDiscouraged(editLayer)) { … … 203 207 hull.add(w); 204 208 for (Node n: w.getNodes()) { 205 // we upload modified nodes even if they aren't in the current 206 // selection. 209 // we upload modified nodes even if they aren't in the current selection. 207 210 n.accept(this); 208 211 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r13453 r13497 329 329 version = copyFrom.version; 330 330 uploadPolicy = copyFrom.uploadPolicy; 331 downloadPolicy = copyFrom.downloadPolicy; 331 332 isReadOnly.set(copyFrom.isReadOnly.get()); 332 333 } finally { -
trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
r11374 r13497 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.geom.Area; 6 7 import java.util.ArrayList; 7 8 import java.util.Collection; … … 14 15 import java.util.Set; 15 16 17 import org.openstreetmap.josm.data.DataSource; 16 18 import org.openstreetmap.josm.data.conflict.Conflict; 17 19 import org.openstreetmap.josm.data.conflict.ConflictCollection; … … 432 434 candidates.clear(); 433 435 fixReferences(); 436 437 Area a = targetDataSet.getDataSourceArea(); 438 439 // copy the merged layer's data source info. 440 // only add source rectangles if they are not contained in the layer already. 441 for (DataSource src : sourceDataSet.getDataSources()) { 442 if (a == null || !a.contains(src.bounds.asRect())) { 443 targetDataSet.addDataSource(src); 444 } 445 } 446 447 // copy the merged layer's API version 448 if (targetDataSet.getVersion() == null) { 449 targetDataSet.setVersion(sourceDataSet.getVersion()); 450 } 451 452 // copy the merged layer's policies and locked status 453 if (sourceDataSet.getUploadPolicy() != null && (targetDataSet.getUploadPolicy() == null 454 || sourceDataSet.getUploadPolicy().compareTo(targetDataSet.getUploadPolicy()) > 0)) { 455 targetDataSet.setUploadPolicy(sourceDataSet.getUploadPolicy()); 456 } 457 if (sourceDataSet.getDownloadPolicy() != null && (targetDataSet.getDownloadPolicy() == null 458 || sourceDataSet.getDownloadPolicy().compareTo(targetDataSet.getDownloadPolicy()) > 0)) { 459 targetDataSet.setDownloadPolicy(sourceDataSet.getDownloadPolicy()); 460 } 461 if (sourceDataSet.isLocked() && !targetDataSet.isLocked()) { 462 targetDataSet.lock(); 463 } 434 464 } finally { 435 465 targetDataSet.endUpdate(); -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r13462 r13497 552 552 } 553 553 554 Area a = data.getDataSourceArea();555 556 // copy the merged layer's data source info.557 // only add source rectangles if they are not contained in the layer already.558 for (DataSource src : from.getDataSources()) {559 if (a == null || !a.contains(src.bounds.asRect())) {560 data.addDataSource(src);561 }562 }563 564 // copy the merged layer's API version565 if (data.getVersion() == null) {566 data.setVersion(from.getVersion());567 }568 569 554 int numNewConflicts = 0; 570 555 for (Conflict<?> c : visitor.getConflicts()) { -
trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetTest.java
r12479 r13497 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 5 6 import static org.junit.Assert.assertTrue; 6 7 … … 14 15 import org.junit.Test; 15 16 import org.openstreetmap.josm.data.coor.LatLon; 17 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy; 16 18 import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy; 17 19 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 194 196 } 195 197 198 /** 199 * Unit test for {@link DataSet#mergeFrom} - Policies. 200 */ 201 @Test 202 public void testMergePolicies() { 203 DataSet ds1 = new DataSet(); 204 DataSet ds2 = new DataSet(); 205 206 ds1.setUploadPolicy(UploadPolicy.BLOCKED); 207 ds2.setUploadPolicy(UploadPolicy.NORMAL); 208 ds1.mergeFrom(ds2); 209 assertEquals(UploadPolicy.BLOCKED, ds1.getUploadPolicy()); 210 211 ds1.setUploadPolicy(UploadPolicy.NORMAL); 212 ds2.setUploadPolicy(UploadPolicy.BLOCKED); 213 ds1.mergeFrom(ds2); 214 assertEquals(UploadPolicy.BLOCKED, ds1.getUploadPolicy()); 215 216 ds1.setDownloadPolicy(DownloadPolicy.BLOCKED); 217 ds2.setDownloadPolicy(DownloadPolicy.NORMAL); 218 ds1.mergeFrom(ds2); 219 assertEquals(DownloadPolicy.BLOCKED, ds1.getDownloadPolicy()); 220 221 ds1.setDownloadPolicy(DownloadPolicy.NORMAL); 222 ds2.setDownloadPolicy(DownloadPolicy.BLOCKED); 223 ds1.mergeFrom(ds2); 224 assertEquals(DownloadPolicy.BLOCKED, ds1.getDownloadPolicy()); 225 226 ds2.lock(); 227 assertFalse(ds1.isLocked()); 228 assertTrue(ds2.isLocked()); 229 ds1.mergeFrom(ds2); 230 assertTrue(ds1.isLocked()); 231 } 232 196 233 private static void assertEqualsDataSet(DataSet ds1, DataSet ds2) { 197 234 assertEquals(new ArrayList<>(ds1.getNodes()), new ArrayList<>(ds2.getNodes())); … … 202 239 assertEquals(ds1.getVersion(), ds2.getVersion()); 203 240 } 241 242 /** 243 * Checks that enum values are defined in the correct order. 244 */ 245 @Test 246 public void testEnumOrder() { 247 assertTrue(DownloadPolicy.BLOCKED.compareTo(DownloadPolicy.NORMAL) > 0); 248 assertTrue(UploadPolicy.BLOCKED.compareTo(UploadPolicy.NORMAL) > 0); 249 assertTrue(UploadPolicy.BLOCKED.compareTo(UploadPolicy.DISCOURAGED) > 0); 250 assertTrue(UploadPolicy.DISCOURAGED.compareTo(UploadPolicy.NORMAL) > 0); 251 } 204 252 }
Note:
See TracChangeset
for help on using the changeset viewer.