Changeset 15476 in josm


Ignore:
Timestamp:
2019-10-26T14:58:45+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #18259 - disable delete action for already deleted relations

Location:
trunk/src/org/openstreetmap/josm/actions/relation
Files:
3 edited

Legend:

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

    r14397 r15476  
    1212import org.openstreetmap.josm.data.osm.IRelation;
    1313import org.openstreetmap.josm.data.osm.OsmData;
     14import org.openstreetmap.josm.data.osm.OsmUtils;
     15import org.openstreetmap.josm.data.osm.Relation;
    1416import org.openstreetmap.josm.io.NetworkManager;
    1517import org.openstreetmap.josm.io.OnlineResource;
    1618import org.openstreetmap.josm.tools.SubclassFilteredCollection;
     19import org.openstreetmap.josm.tools.Utils;
    1720
    1821/**
     
    5255    }
    5356
     57    protected final boolean canModify() {
     58        SubclassFilteredCollection<IRelation<?>, Relation> filteredRelations = Utils.filteredCollection(relations, Relation.class);
     59        return OsmUtils.isOsmCollectionEditable(filteredRelations) && filteredRelations.parallelStream().anyMatch(r -> !r.isDeleted());
     60    }
     61
    5462    protected final boolean canDownload() {
    5563        if (relations.isEmpty()) {
     
    6068            && ds != null && !ds.isLocked() && DownloadPolicy.BLOCKED != ds.getDownloadPolicy();
    6169    }
    62    
     70
    6371    protected void setHelpId(String helpId) {
    6472        putValue("help", helpId);
  • trunk/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java

    r13957 r15476  
    88
    99import org.openstreetmap.josm.actions.mapmode.DeleteAction;
    10 import org.openstreetmap.josm.data.osm.OsmUtils;
    1110import org.openstreetmap.josm.data.osm.Relation;
    1211import org.openstreetmap.josm.gui.MainApplication;
     
    5251    @Override
    5352    protected void updateEnabledState() {
    54         setEnabled(OsmUtils.isOsmCollectionEditable(relations));
     53        setEnabled(canModify());
    5554    }
    5655}
  • trunk/src/org/openstreetmap/josm/actions/relation/EditRelationAction.java

    r15152 r15476  
    1515import org.openstreetmap.josm.data.osm.IRelation;
    1616import org.openstreetmap.josm.data.osm.OsmPrimitive;
    17 import org.openstreetmap.josm.data.osm.OsmUtils;
    1817import org.openstreetmap.josm.data.osm.Relation;
    1918import org.openstreetmap.josm.data.osm.RelationMember;
     
    8786    @Override
    8887    protected void updateEnabledState() {
    89         boolean enabled = false;
    90         SubclassFilteredCollection<IRelation<?>, Relation> filteredRelations = Utils.filteredCollection(relations, Relation.class);
    91         if (OsmUtils.isOsmCollectionEditable(filteredRelations)) {
    92             for (Relation r : filteredRelations) {
    93                 if (!r.isDeleted()) {
    94                     enabled = true;
    95                     break;
    96                 }
    97             }
    98         }
    99         setEnabled(enabled);
     88        setEnabled(canModify());
    10089    }
    10190}
Note: See TracChangeset for help on using the changeset viewer.