Changeset 13497 in josm for trunk/src


Ignore:
Timestamp:
2018-03-04T15:18:05+01:00 (21 months ago)
Author:
Don-vip
Message:

fix #16051, see #8039, see #10456 - more fixes for download/upload policies and locked status (merge of layers)

Location:
trunk/src/org/openstreetmap/josm
Files:
5 edited

Legend:

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

    r10382 r13497  
    1111import org.openstreetmap.josm.Main;
    1212import org.openstreetmap.josm.data.osm.DataSet;
     13import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
    1314import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1415import org.openstreetmap.josm.io.OnlineResource;
     
    4647    @Override
    4748    protected void updateEnabledState() {
    48         setEnabled(getLayerManager().getEditDataSet() != null && !Main.isOffline(OnlineResource.OSM_API));
     49        DataSet ds = getLayerManager().getEditDataSet();
     50        setEnabled(ds != null && !DownloadPolicy.BLOCKED.equals(ds.getDownloadPolicy())
     51                && !Main.isOffline(OnlineResource.OSM_API));
    4952    }
    5053
  • trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java

    r13434 r13497  
    6464    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
    6565        updateEnabledStateOnModifiableSelection(selection);
     66        OsmDataLayer editLayer = getLayerManager().getEditLayer();
     67        if (editLayer != null && !editLayer.isUploadable()) {
     68            setEnabled(false);
     69        }
    6670    }
    6771
     
    8993    public void actionPerformed(ActionEvent e) {
    9094        OsmDataLayer editLayer = getLayerManager().getEditLayer();
    91         if (!isEnabled())
     95        if (!isEnabled() || !editLayer.isUploadable())
    9296            return;
    9397        if (editLayer.isUploadDiscouraged() && UploadAction.warnUploadDiscouraged(editLayer)) {
     
    203207                hull.add(w);
    204208                for (Node n: w.getNodes()) {
    205                     // we upload modified nodes even if they aren't in the current
    206                     // selection.
     209                    // we upload modified nodes even if they aren't in the current selection.
    207210                    n.accept(this);
    208211                }
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r13453 r13497  
    329329            version = copyFrom.version;
    330330            uploadPolicy = copyFrom.uploadPolicy;
     331            downloadPolicy = copyFrom.downloadPolicy;
    331332            isReadOnly.set(copyFrom.isReadOnly.get());
    332333        } finally {
  • trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java

    r11374 r13497  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.geom.Area;
    67import java.util.ArrayList;
    78import java.util.Collection;
     
    1415import java.util.Set;
    1516
     17import org.openstreetmap.josm.data.DataSource;
    1618import org.openstreetmap.josm.data.conflict.Conflict;
    1719import org.openstreetmap.josm.data.conflict.ConflictCollection;
     
    432434            candidates.clear();
    433435            fixReferences();
     436
     437            Area a = targetDataSet.getDataSourceArea();
     438
     439            // copy the merged layer's data source info.
     440            // only add source rectangles if they are not contained in the layer already.
     441            for (DataSource src : sourceDataSet.getDataSources()) {
     442                if (a == null || !a.contains(src.bounds.asRect())) {
     443                    targetDataSet.addDataSource(src);
     444                }
     445            }
     446
     447            // copy the merged layer's API version
     448            if (targetDataSet.getVersion() == null) {
     449                targetDataSet.setVersion(sourceDataSet.getVersion());
     450            }
     451
     452            // copy the merged layer's policies and locked status
     453            if (sourceDataSet.getUploadPolicy() != null && (targetDataSet.getUploadPolicy() == null
     454                    || sourceDataSet.getUploadPolicy().compareTo(targetDataSet.getUploadPolicy()) > 0)) {
     455                targetDataSet.setUploadPolicy(sourceDataSet.getUploadPolicy());
     456            }
     457            if (sourceDataSet.getDownloadPolicy() != null && (targetDataSet.getDownloadPolicy() == null
     458                    || sourceDataSet.getDownloadPolicy().compareTo(targetDataSet.getDownloadPolicy()) > 0)) {
     459                targetDataSet.setDownloadPolicy(sourceDataSet.getDownloadPolicy());
     460            }
     461            if (sourceDataSet.isLocked() && !targetDataSet.isLocked()) {
     462                targetDataSet.lock();
     463            }
    434464        } finally {
    435465            targetDataSet.endUpdate();
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r13462 r13497  
    552552        }
    553553
    554         Area a = data.getDataSourceArea();
    555 
    556         // copy the merged layer's data source info.
    557         // only add source rectangles if they are not contained in the layer already.
    558         for (DataSource src : from.getDataSources()) {
    559             if (a == null || !a.contains(src.bounds.asRect())) {
    560                 data.addDataSource(src);
    561             }
    562         }
    563 
    564         // copy the merged layer's API version
    565         if (data.getVersion() == null) {
    566             data.setVersion(from.getVersion());
    567         }
    568 
    569554        int numNewConflicts = 0;
    570555        for (Conflict<?> c : visitor.getConflicts()) {
Note: See TracChangeset for help on using the changeset viewer.