Ignore:
Timestamp:
2018-02-18T05:02:23+01:00 (6 years ago)
Author:
Don-vip
Message:

see #8039, see #10456 - support read-only data layers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmReader.java

    r13196 r13434  
    141141        String upload = parser.getAttributeValue(null, "upload");
    142142        if (upload != null) {
    143             for (UploadPolicy policy : UploadPolicy.values()) {
    144                 if (policy.getXmlFlag().equalsIgnoreCase(upload)) {
    145                     ds.setUploadPolicy(policy);
    146                     break;
    147                 }
    148             }
     143            try {
     144                ds.setUploadPolicy(UploadPolicy.of(upload));
     145            } catch (IllegalArgumentException e) {
     146                throwException(MessageFormat.format("Illegal value for attribute ''upload''. Got ''{0}''.", upload), e);
     147            }
     148        }
     149        if ("true".equalsIgnoreCase(parser.getAttributeValue(null, "read-only"))) {
     150            ds.setReadOnly();
    149151        }
    150152        String generator = parser.getAttributeValue(null, "generator");
     
    181183                    parseUnknown();
    182184                }
    183             } else if (event == XMLStreamConstants.END_ELEMENT)
     185            } else if (event == XMLStreamConstants.END_ELEMENT) {
    184186                return;
     187            }
    185188        }
    186189    }
     
    618621            progressMonitor.worked(1);
    619622
     623            boolean readOnly = getDataSet().isReadOnly();
     624
    620625            progressMonitor.indeterminateSubTask(tr("Preparing data set..."));
     626            if (readOnly) {
     627                getDataSet().unsetReadOnly();
     628            }
    621629            prepareDataSet();
     630            if (readOnly) {
     631                getDataSet().setReadOnly();
     632            }
    622633            progressMonitor.worked(1);
    623634
     
    628639                    pp.postprocessDataSet(getDataSet(), progressMonitor);
    629640                }
     641            }
     642            // Make sure postprocessors did not change the read-only state
     643            if (readOnly && !getDataSet().isReadOnly()) {
     644                getDataSet().setReadOnly();
    630645            }
    631646            return getDataSet();
Note: See TracChangeset for help on using the changeset viewer.