Changeset 11709 in josm
- Timestamp:
- 2017-03-09T22:49:28+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ToggleUploadDiscouragedLayerAction.java
r11708 r11709 32 32 super(tr("Discourage upload"), ImageProvider.get("no_upload")); 33 33 this.layer = layer; 34 setEnabled(layer.isUploadable()); 34 35 } 35 36 … … 43 44 public Component createMenuComponent() { 44 45 JCheckBoxMenuItem item = new JCheckBoxMenuItem(this); 45 item.setSelected(layer.isUploadDiscouraged() );46 item.setSelected(layer.isUploadDiscouraged() || !layer.isUploadable()); 46 47 return item; 47 48 } -
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r11385 r11709 141 141 @Override 142 142 protected void updateEnabledState() { 143 setEnabled(getLayerManager().getEditLayer() != null); 143 OsmDataLayer editLayer = getLayerManager().getEditLayer(); 144 setEnabled(editLayer != null && editLayer.isUploadable()); 144 145 } 145 146 -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r11632 r11709 100 100 101 101 /** 102 * Upload policy. 103 * 104 * Determines if upload to the OSM server is intended, discouraged, or 105 * disabled / blocked. 106 */ 107 public enum UploadPolicy { 108 /** 109 * Normal dataset, upload intended. 110 */ 111 NORMAL("true"), 112 /** 113 * Upload discouraged, for example when using or distributing a private dataset. 114 */ 115 DISCOURAGED("false"), 116 /** 117 * Upload blocked. 118 * Upload options completely disabled. Intended for special cases 119 * where a warning dialog is not enough, see #12731. 120 * 121 * For the user, it shouldn't be too easy to disable this flag. 122 */ 123 BLOCKED("never"); 124 125 String xml_flag; 126 127 private UploadPolicy(String xml_flag) { 128 this.xml_flag = xml_flag; 129 } 130 131 /** 132 * Get the corresponding value of the <code>upload='...'</code> XML-attribute 133 * in the .osm file. 134 * @return value of the <code>upload</code> attribute 135 */ 136 public String getXmlFlag() { 137 return xml_flag; 138 } 139 }; 140 141 /** 102 142 * Maximum number of events that can be fired between beginUpdate/endUpdate to be send as single events (ie without DatasetChangedEvent) 103 143 */ … … 124 164 private int highlightUpdateCount; 125 165 126 private boolean uploadDiscouraged;166 private UploadPolicy uploadPolicy; 127 167 128 168 private final ReadWriteLock lock = new ReentrantReadWriteLock(); … … 300 340 301 341 /** 302 * Determines if upload is being discouraged (i.e. this dataset contains private data which should not be uploaded) 342 * Determines if upload is being discouraged. 343 * (i.e. this dataset contains private data which should not be uploaded) 303 344 * @return {@code true} if upload is being discouraged, {@code false} otherwise 304 345 * @see #setUploadDiscouraged 305 */ 346 * @deprecated use {@link #getUploadPolicy()} 347 */ 348 @Deprecated 306 349 public boolean isUploadDiscouraged() { 307 return upload Discouraged;350 return uploadPolicy == UploadPolicy.DISCOURAGED || uploadPolicy == UploadPolicy.BLOCKED; 308 351 } 309 352 … … 312 355 * @param uploadDiscouraged {@code true} if this dataset contains private data which should not be uploaded 313 356 * @see #isUploadDiscouraged 314 */ 357 * @deprecated use {@link #setUploadPolicy(UploadPolicy)} 358 */ 359 @Deprecated 315 360 public void setUploadDiscouraged(boolean uploadDiscouraged) { 316 this.uploadDiscouraged = uploadDiscouraged; 361 if (uploadPolicy != UploadPolicy.BLOCKED) { 362 this.uploadPolicy = uploadDiscouraged ? UploadPolicy.DISCOURAGED : UploadPolicy.NORMAL; 363 } 364 } 365 366 /** 367 * Get the upload policy. 368 * @return the upload policy 369 * @see #setUploadPolicy(UploadPolicy) 370 */ 371 public UploadPolicy getUploadPolicy() { 372 return this.uploadPolicy; 373 } 374 375 /** 376 * Sets the upload policy. 377 * @param uploadPolicy the upload policy 378 * @see #getUploadPolicy() 379 */ 380 public void setUploadPolicy(UploadPolicy uploadPolicy) { 381 this.uploadPolicy = uploadPolicy; 317 382 } 318 383 -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r11649 r11709 63 63 import org.openstreetmap.josm.data.osm.DataIntegrityProblemException; 64 64 import org.openstreetmap.josm.data.osm.DataSet; 65 import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy; 65 66 import org.openstreetmap.josm.data.osm.DataSetMerger; 66 67 import org.openstreetmap.josm.data.osm.DatasetConsistencyTest; … … 387 388 public Icon getIcon() { 388 389 ImageProvider base = getBaseIconProvider().setMaxSize(ImageSizes.LAYER); 389 if (isUploadDiscouraged() ) {390 if (isUploadDiscouraged() || data.getUploadPolicy() == UploadPolicy.BLOCKED) { 390 391 base.addOverlay(new ImageOverlay(new ImageProvider("warning-small"), 0.5, 0.5, 1.0, 1.0)); 391 392 } … … 603 604 if (isUploadDiscouraged()) { 604 605 p.add(new JLabel(tr("Upload is discouraged")), GBC.eop().insets(15, 0, 0, 0)); 606 } 607 if (data.getUploadPolicy() == UploadPolicy.BLOCKED) { 608 p.add(new JLabel(tr("Upload is blocked")), GBC.eop().insets(15, 0, 0, 0)); 605 609 } 606 610 … … 874 878 @Override 875 879 public boolean isUploadable() { 876 return true;880 return data.getUploadPolicy() != UploadPolicy.BLOCKED; 877 881 } 878 882 879 883 @Override 880 884 public boolean requiresUploadToServer() { 881 return requiresUploadToServer;885 return isUploadable() && requiresUploadToServer; 882 886 } 883 887 … … 968 972 } 969 973 974 /** 975 * Determines if upload is being discouraged. 976 * (i.e. this dataset contains private data which should not be uploaded) 977 * @return {@code true} if upload is being discouraged, {@code false} otherwise 978 */ 970 979 @Override 971 980 public final boolean isUploadDiscouraged() { 972 return data. isUploadDiscouraged();981 return data.getUploadPolicy() == UploadPolicy.DISCOURAGED; 973 982 } 974 983 … … 979 988 */ 980 989 public final void setUploadDiscouraged(boolean uploadDiscouraged) { 981 if (uploadDiscouraged ^ isUploadDiscouraged()) { 982 data.setUploadDiscouraged(uploadDiscouraged); 990 if (data.getUploadPolicy() != UploadPolicy.BLOCKED && 991 uploadDiscouraged ^ isUploadDiscouraged()) { 992 data.setUploadPolicy(uploadDiscouraged ? UploadPolicy.DISCOURAGED : UploadPolicy.NORMAL); 983 993 for (LayerStateChangeListener l : layerStateChangeListeners) { 984 994 l.uploadDiscouragedChanged(this, uploadDiscouraged); -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r11627 r11709 28 28 import org.openstreetmap.josm.data.osm.Changeset; 29 29 import org.openstreetmap.josm.data.osm.DataSet; 30 import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy; 30 31 import org.openstreetmap.josm.data.osm.Node; 31 32 import org.openstreetmap.josm.data.osm.NodeData; … … 139 140 String upload = parser.getAttributeValue(null, "upload"); 140 141 if (upload != null) { 141 ds.setUploadDiscouraged(!Boolean.parseBoolean(upload)); 142 for (UploadPolicy policy : UploadPolicy.values()) { 143 if (policy.getXmlFlag().equalsIgnoreCase(upload)) { 144 ds.setUploadPolicy(policy); 145 break; 146 } 147 } 142 148 } 143 149 String generator = parser.getAttributeValue(null, "generator"); -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r11627 r11709 17 17 import org.openstreetmap.josm.data.osm.Changeset; 18 18 import org.openstreetmap.josm.data.osm.DataSet; 19 import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy; 19 20 import org.openstreetmap.josm.data.osm.INode; 20 21 import org.openstreetmap.josm.data.osm.IPrimitive; … … 75 76 76 77 public void header() { 77 header( null);78 } 79 80 public void header( Booleanupload) {78 header(UploadPolicy.NORMAL); 79 } 80 81 public void header(UploadPolicy upload) { 81 82 out.println("<?xml version='1.0' encoding='UTF-8'?>"); 82 83 out.print("<osm version='"); 83 84 out.print(version); 84 if (upload != null ) {85 if (upload != null && upload != UploadPolicy.NORMAL) { 85 86 out.print("' upload='"); 86 out.print(upload );87 out.print(upload.getXmlFlag()); 87 88 } 88 89 out.println("' generator='JOSM'>"); … … 114 115 115 116 public void writeLayer(OsmDataLayer layer) { 116 header( !layer.isUploadDiscouraged());117 header(layer.data.getUploadPolicy()); 117 118 writeDataSources(layer.data); 118 119 writeContent(layer.data); -
trunk/src/org/openstreetmap/josm/tools/RightAndLefthandTraffic.java
r11611 r11709 157 157 OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, ds.getVersion()) 158 158 ) { 159 w.header( Boolean.FALSE);159 w.header(DataSet.UploadPolicy.DISCOURAGED); 160 160 w.writeContent(ds); 161 161 w.footer();
Note:
See TracChangeset
for help on using the changeset viewer.