Ignore:
Timestamp:
2018-02-24T18:58:28+01:00 (22 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/actions
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java

    r13435 r13453  
    251251    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
    252252        int numWays = 0;
    253         if (selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isReadOnly)) {
     253        if (selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isLocked)) {
    254254            for (OsmPrimitive osm : selection) {
    255255                if (osm instanceof Way && !osm.isIncomplete() && ++numWays >= 2) {
  • trunk/src/org/openstreetmap/josm/actions/JosmAction.java

    r13434 r13453  
    350350    protected final void updateEnabledStateOnCurrentSelection(boolean allowReadOnly) {
    351351        DataSet ds = getLayerManager().getActiveDataSet();
    352         if (ds != null && (allowReadOnly || !ds.isReadOnly())) {
     352        if (ds != null && (allowReadOnly || !ds.isLocked())) {
    353353            updateEnabledState(ds.getSelected());
    354354        } else {
     
    366366    protected final void updateEnabledStateOnModifiableSelection(Collection<? extends OsmPrimitive> selection) {
    367367        setEnabled(selection != null && !selection.isEmpty()
    368                 && selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isReadOnly));
     368                && selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isLocked));
    369369    }
    370370
  • trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java

    r13434 r13453  
    366366    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
    367367        if (selection == null || selection.isEmpty()
    368                 || selection.stream().map(OsmPrimitive::getDataSet).anyMatch(DataSet::isReadOnly)) {
     368                || selection.stream().map(OsmPrimitive::getDataSet).anyMatch(DataSet::isLocked)) {
    369369            setEnabled(false);
    370370            return;
  • trunk/src/org/openstreetmap/josm/actions/MoveNodeAction.java

    r13434 r13453  
    6363    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
    6464        if (selection == null || selection.isEmpty()
    65                 || selection.stream().map(OsmPrimitive::getDataSet).anyMatch(DataSet::isReadOnly)) {
     65                || selection.stream().map(OsmPrimitive::getDataSet).anyMatch(DataSet::isLocked)) {
    6666            setEnabled(false);
    6767            return;
  • trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java

    r13434 r13453  
    169169    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
    170170        setEnabled(selection.stream().anyMatch(
    171                 o -> o instanceof Way && !o.isIncomplete() && !o.getDataSet().isReadOnly()));
     171                o -> o instanceof Way && !o.isIncomplete() && !o.getDataSet().isLocked()));
    172172    }
    173173}
  • trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java

    r13434 r13453  
    297297        // Selection still can be wrong, but let SplitWayAction process and tell user what's wrong
    298298        setEnabled(selection != null && !selection.isEmpty()
    299                 && selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isReadOnly)
     299                && selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isLocked)
    300300                && selection.stream().anyMatch(o -> o instanceof Node && !o.isIncomplete()));
    301301    }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r13435 r13453  
    238238        private static Stream<OsmDataLayer> getModifiableDataLayers() {
    239239            return MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class)
    240                     .stream().filter(l -> !l.isReadOnly());
     240                    .stream().filter(OsmDataLayer::isDownloadable);
    241241        }
    242242
  • trunk/src/org/openstreetmap/josm/actions/mapmode/MapMode.java

    r13434 r13453  
    250250     */
    251251    protected boolean isEditableDataLayer(Layer l) {
    252         return l instanceof OsmDataLayer && !((OsmDataLayer) l).isReadOnly();
     252        return l instanceof OsmDataLayer && !((OsmDataLayer) l).isLocked();
    253253    }
    254254}
  • trunk/src/org/openstreetmap/josm/actions/relation/AddSelectionToRelations.java

    r13434 r13453  
    7171    public void selectionChanged(final Collection<? extends OsmPrimitive> newSelection) {
    7272        GuiHelper.runInEDT(() -> setEnabled(newSelection != null && !newSelection.isEmpty() && !relations.isEmpty()
    73                 && relations.stream().map(Relation::getDataSet).noneMatch(DataSet::isReadOnly)));
     73                && relations.stream().map(Relation::getDataSet).noneMatch(DataSet::isLocked)));
    7474    }
    7575}
  • trunk/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java

    r13434 r13453  
    5151    @Override
    5252    protected void updateEnabledState() {
    53         setEnabled(!relations.isEmpty() && relations.stream().map(Relation::getDataSet).noneMatch(DataSet::isReadOnly));
     53        setEnabled(!relations.isEmpty() && relations.stream().map(Relation::getDataSet).noneMatch(DataSet::isLocked));
    5454    }
    5555}
  • trunk/src/org/openstreetmap/josm/actions/relation/DownloadMembersAction.java

    r13446 r13453  
    4848    protected void updateEnabledState() {
    4949        setEnabled(!relations.isEmpty() && !Main.isOffline(OnlineResource.OSM_API)
    50                 && !relations.iterator().next().getDataSet().isReadOnly());
     50                && !relations.iterator().next().getDataSet().isLocked());
    5151    }
    5252}
  • trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java

    r13446 r13453  
    6868    protected void updateEnabledState() {
    6969        setEnabled(!relations.isEmpty() && !incompleteMembers.isEmpty() && !Main.isOffline(OnlineResource.OSM_API)
    70                 && !relations.iterator().next().getDataSet().isReadOnly());
     70                && !relations.iterator().next().getDataSet().isLocked());
    7171    }
    7272}
  • trunk/src/org/openstreetmap/josm/actions/relation/DuplicateRelationAction.java

    r13434 r13453  
    5252    protected void updateEnabledState() {
    5353        // only one selected relation can be edited
    54         setEnabled(relations.size() == 1 && !relations.iterator().next().getDataSet().isReadOnly());
     54        setEnabled(relations.size() == 1 && !relations.iterator().next().getDataSet().isLocked());
    5555    }
    5656}
  • trunk/src/org/openstreetmap/josm/actions/relation/EditRelationAction.java

    r13435 r13453  
    8989    protected void updateEnabledState() {
    9090        boolean enabled = false;
    91         if (relations.stream().map(Relation::getDataSet).noneMatch(DataSet::isReadOnly)) {
     91        if (relations.stream().map(Relation::getDataSet).noneMatch(DataSet::isLocked)) {
    9292            for (Relation r : relations) {
    9393                if (!r.isDeleted()) {
Note: See TracChangeset for help on using the changeset viewer.