Ignore:
Timestamp:
2018-02-24T18:58:28+01:00 (21 months 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
Location:
trunk/src/org/openstreetmap/josm/gui
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r13434 r13453  
    353353            DataSet ds = MainApplication.getLayerManager().getActiveDataSet();
    354354            if (ds != null && isDoubleClick(e)) {
    355                 if (e.isControlDown() && !ds.isReadOnly()) {
     355                if (e.isControlDown() && !ds.isLocked()) {
    356356                    editCurrentRelation();
    357357                } else {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PresetListPanel.java

    r13446 r13453  
    4141            int answer = t.showDialog(selection, false);
    4242
    43             if (answer == TaggingPreset.DIALOG_ANSWER_APPLY && !selection.iterator().next().getDataSet().isReadOnly()) {
     43            if (answer == TaggingPreset.DIALOG_ANSWER_APPLY && !selection.iterator().next().getDataSet().isLocked()) {
    4444                presetHandler.updateTags(t.getChangedTags());
    4545            }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r13446 r13453  
    490490        MainApplication.getMap().relationListDialog.selectRelation(relation);
    491491        OsmDataLayer layer = MainApplication.getLayerManager().getActiveDataLayer();
    492         if (!layer.isReadOnly()) {
     492        if (!layer.isLocked()) {
    493493            RelationEditor.getEditor(
    494494                    layer, relation, ((MemberInfo) membershipData.getValueAt(row, 1)).role).setVisible(true);
     
    647647
    648648        DataSet ds = Main.main.getActiveDataSet();
    649         boolean isReadOnly = ds != null && ds.isReadOnly();
     649        boolean isReadOnly = ds != null && ds.isLocked();
    650650        boolean hasSelection = !newSel.isEmpty();
    651651        boolean hasTags = hasSelection && tagData.getRowCount() > 0;
     
    10601060        protected final void updateEnabledState() {
    10611061            DataSet ds = Main.main.getActiveDataSet();
    1062             setEnabled(ds != null && !ds.isReadOnly() &&
     1062            setEnabled(ds != null && !ds.isLocked() &&
    10631063                    ((tagTable != null && tagTable.getSelectedRowCount() >= 1)
    10641064                    || (membershipTable != null && membershipTable.getSelectedRowCount() > 0)
     
    11161116        protected void updateEnabledState() {
    11171117            DataSet ds = Main.main.getActiveDataSet();
    1118             setEnabled(ds != null && !ds.isReadOnly() &&
     1118            setEnabled(ds != null && !ds.isLocked() &&
    11191119                    ((tagTable != null && tagTable.getSelectedRowCount() == 1)
    11201120                    ^ (membershipTable != null && membershipTable.getSelectedRowCount() == 1)
     
    12711271            Collection<OsmPrimitive> sel = Main.main.getInProgressSelection();
    12721272            String clipboard = ClipboardUtils.getClipboardStringContent();
    1273             if (sel.isEmpty() || clipboard == null || sel.iterator().next().getDataSet().isReadOnly())
     1273            if (sel.isEmpty() || clipboard == null || sel.iterator().next().getDataSet().isLocked())
    12741274                return;
    12751275            MainApplication.undoRedo.add(new ChangePropertyCommand(sel, key, Utils.strip(clipboard)));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java

    r13434 r13453  
    564564        public void setupDialog() {
    565565            super.setupDialog();
    566             buttons.get(0).setEnabled(!Main.main.getActiveDataSet().isReadOnly());
     566            buttons.get(0).setEnabled(!Main.main.getActiveDataSet().isLocked());
    567567            final Dimension size = getSize();
    568568            // Set resizable only in width
  • trunk/src/org/openstreetmap/josm/gui/io/UploadPrimitivesTask.java

    r13440 r13453  
    220220        // partially uploaded. Better run on EDT.
    221221        Runnable r = () -> {
    222             boolean readOnly = layer.isReadOnly();
     222            boolean readOnly = layer.isLocked();
    223223            if (readOnly) {
    224                 layer.unsetReadOnly();
     224                layer.unlock();
    225225            }
    226226            try {
     
    230230            } finally {
    231231                if (readOnly) {
    232                     layer.setReadOnly();
     232                    layer.lock();
    233233                }
    234234            }
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractModifiableLayer.java

    r13434 r13453  
    22package org.openstreetmap.josm.gui.layer;
    33
    4 import org.openstreetmap.josm.data.osm.ReadOnly;
     4import org.openstreetmap.josm.data.osm.Lockable;
    55import org.openstreetmap.josm.gui.io.AbstractIOTask;
    66import org.openstreetmap.josm.gui.io.AbstractUploadDialog;
     
    1111 * @since 7358
    1212 */
    13 public abstract class AbstractModifiableLayer extends Layer implements UploadToServer, SaveToFile, ReadOnly {
     13public abstract class AbstractModifiableLayer extends Layer implements DownloadFromServer, UploadToServer, SaveToFile, Lockable {
    1414
    1515    /**
     
    1919    public AbstractModifiableLayer(String name) {
    2020        super(name);
     21    }
     22
     23    @Override
     24    public boolean isDownloadable() {
     25        // Override if needed
     26        return false;
    2127    }
    2228
     
    8389
    8490    @Override
    85     public void setReadOnly() {
     91    public void lock() {
    8692        // Override if needed
    8793    }
    8894
    8995    @Override
    90     public void unsetReadOnly() {
     96    public void unlock() {
    9197        // Override if needed
    9298    }
    9399
    94100    @Override
    95     public boolean isReadOnly() {
     101    public boolean isLocked() {
    96102        // Override if needed
    97103        return false;
  • trunk/src/org/openstreetmap/josm/gui/layer/MainLayerManager.java

    r13437 r13453  
    376376     */
    377377    public synchronized OsmDataLayer getEditLayer() {
    378         if (dataLayer != null && !dataLayer.isReadOnly())
     378        if (dataLayer != null && !dataLayer.isLocked())
    379379            return dataLayer;
    380380        else
     
    402402     */
    403403    public synchronized DataSet getEditDataSet() {
    404         if (dataLayer != null && !dataLayer.isReadOnly()) {
     404        if (dataLayer != null && !dataLayer.isLocked()) {
    405405            return dataLayer.data;
    406406        } else {
     
    509509        GuiHelper.assertCallFromEdt();
    510510        layer.setUploadInProgress();
    511         layer.setReadOnly();
     511        layer.lock();
    512512
    513513        // Reset only the edit layer as empty
     
    528528    public synchronized void processLayerAfterUpload(OsmDataLayer layer) {
    529529        GuiHelper.assertCallFromEdt();
    530         layer.unsetReadOnly();
     530        layer.unlock();
    531531        layer.unsetUploadInProgress();
    532532
  • trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java

    r13437 r13453  
    134134
    135135    @Override
     136    public boolean isDownloadable() {
     137        return true;
     138    }
     139
     140    @Override
    136141    public boolean isUploadable() {
    137142        return true;
  • 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
  • trunk/src/org/openstreetmap/josm/gui/layer/UploadToServer.java

    r13434 r13453  
    88/**
    99 * Interface for layers that can upload data.
     10 * @see DownloadFromServer
    1011 * @since 9751
    1112 */
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

    r13446 r13453  
    493493
    494494            answer = new PresetDialog(p, title, preset_name_label ? null : (ImageIcon) getValue(Action.SMALL_ICON),
    495                     sel.isEmpty() || sel.iterator().next().getDataSet().isReadOnly(), showNewRelation).getValue();
     495                    sel.isEmpty() || sel.iterator().next().getDataSet().isLocked(), showNewRelation).getValue();
    496496        }
    497497        if (!showNewRelation && answer == 2)
Note: See TracChangeset for help on using the changeset viewer.