Ignore:
Timestamp:
2018-02-24T18:58:28+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #8039, fix #10456: final fixes for the read-only/locked layers:

  • rename "read-only" to "locked" (in XML and Java classes/interfaces)
  • add a new download policy (true/never) to allow private layers forbidding only to download data, but allowing everything else

This leads to:

  • normal layers: download allowed, modifications allowed, upload allowed
  • private layers: download allowed or not (download=true/never), modifications allowed, upload allowed or not (upload=true/discouraged/never)
  • locked layers: nothing allowed, the data cannot be modified in any way
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r13435 r13453  
    6464import org.openstreetmap.josm.data.osm.DataSelectionListener;
    6565import org.openstreetmap.josm.data.osm.DataSet;
     66import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
    6667import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy;
    6768import org.openstreetmap.josm.data.osm.DataSetMerger;
     
    421422    public Icon getIcon() {
    422423        ImageProvider base = getBaseIconProvider().setMaxSize(ImageSizes.LAYER);
    423         if (isUploadDiscouraged() || data.getUploadPolicy() == UploadPolicy.BLOCKED) {
     424        if (data.getDownloadPolicy() != null && data.getDownloadPolicy() != DownloadPolicy.NORMAL) {
     425            base.addOverlay(new ImageOverlay(new ImageProvider("warning-small"), 0.5, 0.0, 1.0, 0.5));
     426        }
     427        if (data.getUploadPolicy() != null && data.getUploadPolicy() != UploadPolicy.NORMAL) {
    424428            base.addOverlay(new ImageOverlay(new ImageProvider("warning-small"), 0.5, 0.5, 1.0, 1.0));
    425429        }
     
    428432            // If the layer is being uploaded then change the default icon to a clock
    429433            base = new ImageProvider("clock").setMaxSize(ImageSizes.LAYER);
    430         } else if (isReadOnly()) {
     434        } else if (isLocked()) {
    431435            // If the layer is read only then change the default icon to a lock
    432436            base = new ImageProvider("lock").setMaxSize(ImageSizes.LAYER);
     
    940944
    941945    @Override
     946    public boolean isDownloadable() {
     947        return data.getDownloadPolicy() != DownloadPolicy.BLOCKED && !isLocked();
     948    }
     949
     950    @Override
    942951    public boolean isUploadable() {
    943         return data.getUploadPolicy() != UploadPolicy.BLOCKED;
     952        return data.getUploadPolicy() != UploadPolicy.BLOCKED && !isLocked();
    944953    }
    945954
     
    10311040    }
    10321041
    1033     /**
    1034      * Determines if upload is being discouraged.
    1035      * (i.e. this dataset contains private data which should not be uploaded)
    1036      * @return {@code true} if upload is being discouraged, {@code false} otherwise
    1037      */
    10381042    @Override
    10391043    public final boolean isUploadDiscouraged() {
     
    11741178
    11751179    @Override
    1176     public void setReadOnly() {
    1177         data.setReadOnly();
    1178     }
    1179 
    1180     @Override
    1181     public void unsetReadOnly() {
    1182         data.unsetReadOnly();
    1183     }
    1184 
    1185     @Override
    1186     public boolean isReadOnly() {
    1187         return data.isReadOnly();
     1180    public void lock() {
     1181        data.lock();
     1182    }
     1183
     1184    @Override
     1185    public void unlock() {
     1186        data.unlock();
     1187    }
     1188
     1189    @Override
     1190    public boolean isLocked() {
     1191        return data.isLocked();
    11881192    }
    11891193
Note: See TracChangeset for help on using the changeset viewer.