- Timestamp:
- 2018-02-24T18:58:28+01:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 31 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r13435 r13453 251 251 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 252 252 int numWays = 0; 253 if (selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::is ReadOnly)) {253 if (selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isLocked)) { 254 254 for (OsmPrimitive osm : selection) { 255 255 if (osm instanceof Way && !osm.isIncomplete() && ++numWays >= 2) { -
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r13434 r13453 350 350 protected final void updateEnabledStateOnCurrentSelection(boolean allowReadOnly) { 351 351 DataSet ds = getLayerManager().getActiveDataSet(); 352 if (ds != null && (allowReadOnly || !ds.is ReadOnly())) {352 if (ds != null && (allowReadOnly || !ds.isLocked())) { 353 353 updateEnabledState(ds.getSelected()); 354 354 } else { … … 366 366 protected final void updateEnabledStateOnModifiableSelection(Collection<? extends OsmPrimitive> selection) { 367 367 setEnabled(selection != null && !selection.isEmpty() 368 && selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::is ReadOnly));368 && selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isLocked)); 369 369 } 370 370 -
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r13434 r13453 366 366 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 367 367 if (selection == null || selection.isEmpty() 368 || selection.stream().map(OsmPrimitive::getDataSet).anyMatch(DataSet::is ReadOnly)) {368 || selection.stream().map(OsmPrimitive::getDataSet).anyMatch(DataSet::isLocked)) { 369 369 setEnabled(false); 370 370 return; -
trunk/src/org/openstreetmap/josm/actions/MoveNodeAction.java
r13434 r13453 63 63 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 64 64 if (selection == null || selection.isEmpty() 65 || selection.stream().map(OsmPrimitive::getDataSet).anyMatch(DataSet::is ReadOnly)) {65 || selection.stream().map(OsmPrimitive::getDataSet).anyMatch(DataSet::isLocked)) { 66 66 setEnabled(false); 67 67 return; -
trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java
r13434 r13453 169 169 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 170 170 setEnabled(selection.stream().anyMatch( 171 o -> o instanceof Way && !o.isIncomplete() && !o.getDataSet().is ReadOnly()));171 o -> o instanceof Way && !o.isIncomplete() && !o.getDataSet().isLocked())); 172 172 } 173 173 } -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r13434 r13453 297 297 // Selection still can be wrong, but let SplitWayAction process and tell user what's wrong 298 298 setEnabled(selection != null && !selection.isEmpty() 299 && selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::is ReadOnly)299 && selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isLocked) 300 300 && selection.stream().anyMatch(o -> o instanceof Node && !o.isIncomplete())); 301 301 } -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r13435 r13453 238 238 private static Stream<OsmDataLayer> getModifiableDataLayers() { 239 239 return MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class) 240 .stream().filter( l -> !l.isReadOnly());240 .stream().filter(OsmDataLayer::isDownloadable); 241 241 } 242 242 -
trunk/src/org/openstreetmap/josm/actions/mapmode/MapMode.java
r13434 r13453 250 250 */ 251 251 protected boolean isEditableDataLayer(Layer l) { 252 return l instanceof OsmDataLayer && !((OsmDataLayer) l).is ReadOnly();252 return l instanceof OsmDataLayer && !((OsmDataLayer) l).isLocked(); 253 253 } 254 254 } -
trunk/src/org/openstreetmap/josm/actions/relation/AddSelectionToRelations.java
r13434 r13453 71 71 public void selectionChanged(final Collection<? extends OsmPrimitive> newSelection) { 72 72 GuiHelper.runInEDT(() -> setEnabled(newSelection != null && !newSelection.isEmpty() && !relations.isEmpty() 73 && relations.stream().map(Relation::getDataSet).noneMatch(DataSet::is ReadOnly)));73 && relations.stream().map(Relation::getDataSet).noneMatch(DataSet::isLocked))); 74 74 } 75 75 } -
trunk/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java
r13434 r13453 51 51 @Override 52 52 protected void updateEnabledState() { 53 setEnabled(!relations.isEmpty() && relations.stream().map(Relation::getDataSet).noneMatch(DataSet::is ReadOnly));53 setEnabled(!relations.isEmpty() && relations.stream().map(Relation::getDataSet).noneMatch(DataSet::isLocked)); 54 54 } 55 55 } -
trunk/src/org/openstreetmap/josm/actions/relation/DownloadMembersAction.java
r13446 r13453 48 48 protected void updateEnabledState() { 49 49 setEnabled(!relations.isEmpty() && !Main.isOffline(OnlineResource.OSM_API) 50 && !relations.iterator().next().getDataSet().is ReadOnly());50 && !relations.iterator().next().getDataSet().isLocked()); 51 51 } 52 52 } -
trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java
r13446 r13453 68 68 protected void updateEnabledState() { 69 69 setEnabled(!relations.isEmpty() && !incompleteMembers.isEmpty() && !Main.isOffline(OnlineResource.OSM_API) 70 && !relations.iterator().next().getDataSet().is ReadOnly());70 && !relations.iterator().next().getDataSet().isLocked()); 71 71 } 72 72 } -
trunk/src/org/openstreetmap/josm/actions/relation/DuplicateRelationAction.java
r13434 r13453 52 52 protected void updateEnabledState() { 53 53 // only one selected relation can be edited 54 setEnabled(relations.size() == 1 && !relations.iterator().next().getDataSet().is ReadOnly());54 setEnabled(relations.size() == 1 && !relations.iterator().next().getDataSet().isLocked()); 55 55 } 56 56 } -
trunk/src/org/openstreetmap/josm/actions/relation/EditRelationAction.java
r13435 r13453 89 89 protected void updateEnabledState() { 90 90 boolean enabled = false; 91 if (relations.stream().map(Relation::getDataSet).noneMatch(DataSet::is ReadOnly)) {91 if (relations.stream().map(Relation::getDataSet).noneMatch(DataSet::isLocked)) { 92 92 for (Relation r : relations) { 93 93 if (!r.isDeleted()) { -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r13434 r13453 104 104 * @author imi 105 105 */ 106 public final class DataSet extends QuadBucketPrimitiveStore implements Data, ProjectionChangeListener, ReadOnly { 106 public final class DataSet extends QuadBucketPrimitiveStore implements Data, ProjectionChangeListener, Lockable { 107 108 /** 109 * Download policy. 110 * 111 * Determines if download from the OSM server is intended, discouraged, or disabled / blocked. 112 * @see UploadPolicy 113 * @since 13453 114 */ 115 public enum DownloadPolicy { 116 /** 117 * Normal dataset, download intended. 118 */ 119 NORMAL("true"), 120 /** 121 * Download blocked. 122 * Download options completely disabled. Intended for private layers, see #8039. 123 */ 124 BLOCKED("never"); 125 126 final String xmlFlag; 127 128 DownloadPolicy(String xmlFlag) { 129 this.xmlFlag = xmlFlag; 130 } 131 132 /** 133 * Get the corresponding value of the <code>upload='...'</code> XML-attribute 134 * in the .osm file. 135 * @return value of the <code>download</code> attribute 136 */ 137 public String getXmlFlag() { 138 return xmlFlag; 139 } 140 141 /** 142 * Returns the {@code DownloadPolicy} for the given <code>upload='...'</code> XML-attribute 143 * @param xmlFlag <code>download='...'</code> XML-attribute to convert 144 * @return {@code DownloadPolicy} value 145 * @throws IllegalArgumentException for invalid values 146 */ 147 public static DownloadPolicy of(String xmlFlag) { 148 for (DownloadPolicy policy : values()) { 149 if (policy.getXmlFlag().equalsIgnoreCase(xmlFlag)) { 150 return policy; 151 } 152 } 153 throw new IllegalArgumentException(xmlFlag); 154 } 155 } 107 156 108 157 /** 109 158 * Upload policy. 110 159 * 111 * Determines if upload to the OSM server is intended, discouraged, or 112 * disabled / blocked.160 * Determines if upload to the OSM server is intended, discouraged, or disabled / blocked. 161 * @see DownloadPolicy 113 162 */ 114 163 public enum UploadPolicy { … … 173 222 174 223 private final Storage<OsmPrimitive> allPrimitives = new Storage<>(new Storage.PrimitiveIdHash(), true); 175 private final Map<PrimitiveId, OsmPrimitive> primitivesMap = allPrimitives.foreignKey(new Storage.PrimitiveIdHash()); 224 private final Map<PrimitiveId, OsmPrimitive> primitivesMap = allPrimitives 225 .foreignKey(new Storage.PrimitiveIdHash()); 176 226 private final CopyOnWriteArrayList<DataSetListener> listeners = new CopyOnWriteArrayList<>(); 177 227 … … 187 237 188 238 private String name; 239 private DownloadPolicy downloadPolicy; 189 240 private UploadPolicy uploadPolicy; 190 241 /** Flag used to know if the dataset should not be editable */ … … 250 301 primMap.put(w, newWay); 251 302 List<Node> newNodes = new ArrayList<>(); 252 for (Node n : w.getNodes()) {303 for (Node n : w.getNodes()) { 253 304 newNodes.add((Node) primMap.get(n)); 254 305 } … … 268 319 Relation newRelation = (Relation) primMap.get(r); 269 320 List<RelationMember> newMembers = new ArrayList<>(); 270 for (RelationMember rm : r.getMembers()) {321 for (RelationMember rm : r.getMembers()) { 271 322 newMembers.add(new RelationMember(rm.getRole(), primMap.get(rm.getMember()))); 272 323 } … … 378 429 checkModifiable(); 379 430 this.version = version; 431 } 432 433 /** 434 * Get the download policy. 435 * @return the download policy 436 * @see #setDownloadPolicy(DownloadPolicy) 437 * @since 13453 438 */ 439 public DownloadPolicy getDownloadPolicy() { 440 return this.downloadPolicy; 441 } 442 443 /** 444 * Sets the download policy. 445 * @param downloadPolicy the download policy 446 * @see #getUploadPolicy() 447 * @since 13453 448 */ 449 public void setDownloadPolicy(DownloadPolicy downloadPolicy) { 450 this.downloadPolicy = downloadPolicy; 380 451 } 381 452 … … 529 600 */ 530 601 public Collection<OsmPrimitive> allNonDeletedPhysicalPrimitives() { 531 return getPrimitives(primitive -> !primitive.isDeleted() && !primitive.isIncomplete() && !(primitive instanceof Relation)); 602 return getPrimitives( 603 primitive -> !primitive.isDeleted() && !primitive.isIncomplete() && !(primitive instanceof Relation)); 532 604 } 533 605 … … 565 637 if (getPrimitiveById(primitive) != null) 566 638 throw new DataIntegrityProblemException( 567 tr("Unable to add primitive {0} to the dataset because it is already included", primitive.toString())); 639 tr("Unable to add primitive {0} to the dataset because it is already included", 640 primitive.toString())); 568 641 569 642 allPrimitives.add(primitive); … … 690 763 */ 691 764 public Collection<OsmPrimitive> getSelectedNodesAndWays() { 692 return new SubclassFilteredCollection<>(getSelected(), primitive -> primitive instanceof Node || primitive instanceof Way); 765 return new SubclassFilteredCollection<>(getSelected(), 766 primitive -> primitive instanceof Node || primitive instanceof Way); 693 767 } 694 768 … … 1006 1080 OsmPrimitive result = getPrimitiveById(primitiveId); 1007 1081 if (result == null && primitiveId != null) { 1008 Logging.warn(tr("JOSM expected to find primitive [{0} {1}] in dataset but it is not there. Please report this " 1009 + "at {2}. This is not a critical error, it should be safe to continue in your work.", 1082 Logging.warn(tr( 1083 "JOSM expected to find primitive [{0} {1}] in dataset but it is not there. Please report this " 1084 + "at {2}. This is not a critical error, it should be safe to continue in your work.", 1010 1085 primitiveId.getType(), Long.toString(primitiveId.getUniqueId()), Main.getJOSMWebsite())); 1011 1086 Logging.error(new Exception()); … … 1115 1190 */ 1116 1191 public boolean isModified() { 1117 for (OsmPrimitive p : allPrimitives) {1192 for (OsmPrimitive p : allPrimitives) { 1118 1193 if (p.isModified()) 1119 1194 return true; … … 1128 1203 */ 1129 1204 public boolean requiresUploadToServer() { 1130 for (OsmPrimitive p : allPrimitives) {1205 for (OsmPrimitive p : allPrimitives) { 1131 1206 if (APIOperation.of(p) != null) 1132 1207 return true; … … 1199 1274 try { 1200 1275 if (eventsToFire.size() < MAX_SINGLE_EVENTS) { 1201 for (AbstractDatasetChangedEvent event : eventsToFire) {1276 for (AbstractDatasetChangedEvent event : eventsToFire) { 1202 1277 fireEventToListeners(event); 1203 1278 } … … 1219 1294 1220 1295 private void fireEventToListeners(AbstractDatasetChangedEvent event) { 1221 for (DataSetListener listener : listeners) {1296 for (DataSetListener listener : listeners) { 1222 1297 event.fire(listener); 1223 1298 } … … 1260 1335 1261 1336 void fireChangesetIdChanged(OsmPrimitive primitive, int oldChangesetId, int newChangesetId) { 1262 fireEvent(new ChangesetIdChangedEvent(this, Collections.singletonList(primitive), oldChangesetId, newChangesetId)); 1337 fireEvent(new ChangesetIdChangedEvent(this, Collections.singletonList(primitive), oldChangesetId, 1338 newChangesetId)); 1263 1339 } 1264 1340 … … 1283 1359 */ 1284 1360 public void invalidateEastNorthCache() { 1285 if (Main.getProjection() == null) return; // sanity check 1361 if (Main.getProjection() == null) 1362 return; // sanity check 1286 1363 beginUpdate(); 1287 1364 try { 1288 for (Node n : getNodes()) {1365 for (Node n : getNodes()) { 1289 1366 n.invalidateEastNorthCache(); 1290 1367 } … … 1326 1403 try { 1327 1404 clearSelection(); 1328 for (OsmPrimitive primitive :allPrimitives) {1405 for (OsmPrimitive primitive : allPrimitives) { 1329 1406 primitive.setDataset(null); 1330 1407 } … … 1343 1420 public void deleteInvisible() { 1344 1421 checkModifiable(); 1345 for (OsmPrimitive primitive :allPrimitives) {1422 for (OsmPrimitive primitive : allPrimitives) { 1346 1423 if (!primitive.isVisible()) { 1347 1424 primitive.setDeleted(true); … … 1454 1531 1455 1532 @Override 1456 public void setReadOnly() {1533 public void lock() { 1457 1534 if (!isReadOnly.compareAndSet(false, true)) { 1458 1535 Logging.warn("Trying to set readOnly flag on a readOnly dataset ", getName()); … … 1461 1538 1462 1539 @Override 1463 public void un setReadOnly() {1540 public void unlock() { 1464 1541 if (!isReadOnly.compareAndSet(true, false)) { 1465 1542 Logging.warn("Trying to unset readOnly flag on a non-readOnly dataset ", getName()); … … 1468 1545 1469 1546 @Override 1470 public boolean is ReadOnly() {1547 public boolean isLocked() { 1471 1548 return isReadOnly.get(); 1472 1549 } … … 1477 1554 */ 1478 1555 private void checkModifiable() { 1479 if (is ReadOnly()) {1556 if (isLocked()) { 1480 1557 throw new IllegalStateException("DataSet is read-only"); 1481 1558 } -
trunk/src/org/openstreetmap/josm/data/osm/Lockable.java
r13452 r13453 3 3 4 4 /** 5 * To be implemented by modifiable objects to offer a "read-only " mode.6 * @since 134 345 * To be implemented by modifiable objects to offer a "read-only/locked" mode. 6 * @since 13453 7 7 */ 8 public interface ReadOnly{8 public interface Lockable { 9 9 10 10 /** 11 * Enables the read-only mode.11 * Enables the read-only/locked mode. 12 12 */ 13 void setReadOnly();13 void lock(); 14 14 15 15 /** 16 * Disables the read-only mode.16 * Disables the read-only/locked mode. 17 17 */ 18 void un setReadOnly();18 void unlock(); 19 19 20 20 /** 21 * Determines if this is read-only (thus it cannot be modified).22 * @return {@code true} if this is read-only 21 * Determines if this is read-only/locked (thus it cannot be modified). 22 * @return {@code true} if this is read-only/locked 23 23 */ 24 boolean is ReadOnly();24 boolean isLocked(); 25 25 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r13434 r13453 279 279 */ 280 280 protected final void checkDatasetNotReadOnly() { 281 if (dataSet != null && dataSet.is ReadOnly())281 if (dataSet != null && dataSet.isLocked()) 282 282 throw new DataIntegrityProblemException("Primitive cannot be modified in read-only dataset: " + toString()); 283 283 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRenderer.java
r13444 r13453 128 128 */ 129 129 public void drawVirtualNodes(DataSet data, BBox bbox) { 130 if (virtualNodeSize == 0 || data == null || bbox == null || data.is ReadOnly())130 if (virtualNodeSize == 0 || data == null || bbox == null || data.isLocked()) 131 131 return; 132 132 // print normal virtual nodes -
trunk/src/org/openstreetmap/josm/data/validation/TestError.java
r13434 r13453 360 360 public boolean isFixable() { 361 361 return (fixingCommand != null || ((tester != null) && tester.isFixable(this))) 362 && primitives.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::is ReadOnly);362 && primitives.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isLocked); 363 363 } 364 364 -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r13434 r13453 353 353 DataSet ds = MainApplication.getLayerManager().getActiveDataSet(); 354 354 if (ds != null && isDoubleClick(e)) { 355 if (e.isControlDown() && !ds.is ReadOnly()) {355 if (e.isControlDown() && !ds.isLocked()) { 356 356 editCurrentRelation(); 357 357 } else { -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PresetListPanel.java
r13446 r13453 41 41 int answer = t.showDialog(selection, false); 42 42 43 if (answer == TaggingPreset.DIALOG_ANSWER_APPLY && !selection.iterator().next().getDataSet().is ReadOnly()) {43 if (answer == TaggingPreset.DIALOG_ANSWER_APPLY && !selection.iterator().next().getDataSet().isLocked()) { 44 44 presetHandler.updateTags(t.getChangedTags()); 45 45 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r13446 r13453 490 490 MainApplication.getMap().relationListDialog.selectRelation(relation); 491 491 OsmDataLayer layer = MainApplication.getLayerManager().getActiveDataLayer(); 492 if (!layer.is ReadOnly()) {492 if (!layer.isLocked()) { 493 493 RelationEditor.getEditor( 494 494 layer, relation, ((MemberInfo) membershipData.getValueAt(row, 1)).role).setVisible(true); … … 647 647 648 648 DataSet ds = Main.main.getActiveDataSet(); 649 boolean isReadOnly = ds != null && ds.is ReadOnly();649 boolean isReadOnly = ds != null && ds.isLocked(); 650 650 boolean hasSelection = !newSel.isEmpty(); 651 651 boolean hasTags = hasSelection && tagData.getRowCount() > 0; … … 1060 1060 protected final void updateEnabledState() { 1061 1061 DataSet ds = Main.main.getActiveDataSet(); 1062 setEnabled(ds != null && !ds.is ReadOnly() &&1062 setEnabled(ds != null && !ds.isLocked() && 1063 1063 ((tagTable != null && tagTable.getSelectedRowCount() >= 1) 1064 1064 || (membershipTable != null && membershipTable.getSelectedRowCount() > 0) … … 1116 1116 protected void updateEnabledState() { 1117 1117 DataSet ds = Main.main.getActiveDataSet(); 1118 setEnabled(ds != null && !ds.is ReadOnly() &&1118 setEnabled(ds != null && !ds.isLocked() && 1119 1119 ((tagTable != null && tagTable.getSelectedRowCount() == 1) 1120 1120 ^ (membershipTable != null && membershipTable.getSelectedRowCount() == 1) … … 1271 1271 Collection<OsmPrimitive> sel = Main.main.getInProgressSelection(); 1272 1272 String clipboard = ClipboardUtils.getClipboardStringContent(); 1273 if (sel.isEmpty() || clipboard == null || sel.iterator().next().getDataSet().is ReadOnly())1273 if (sel.isEmpty() || clipboard == null || sel.iterator().next().getDataSet().isLocked()) 1274 1274 return; 1275 1275 MainApplication.undoRedo.add(new ChangePropertyCommand(sel, key, Utils.strip(clipboard))); -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r13434 r13453 564 564 public void setupDialog() { 565 565 super.setupDialog(); 566 buttons.get(0).setEnabled(!Main.main.getActiveDataSet().is ReadOnly());566 buttons.get(0).setEnabled(!Main.main.getActiveDataSet().isLocked()); 567 567 final Dimension size = getSize(); 568 568 // Set resizable only in width -
trunk/src/org/openstreetmap/josm/gui/io/UploadPrimitivesTask.java
r13440 r13453 220 220 // partially uploaded. Better run on EDT. 221 221 Runnable r = () -> { 222 boolean readOnly = layer.is ReadOnly();222 boolean readOnly = layer.isLocked(); 223 223 if (readOnly) { 224 layer.un setReadOnly();224 layer.unlock(); 225 225 } 226 226 try { … … 230 230 } finally { 231 231 if (readOnly) { 232 layer. setReadOnly();232 layer.lock(); 233 233 } 234 234 } -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractModifiableLayer.java
r13434 r13453 2 2 package org.openstreetmap.josm.gui.layer; 3 3 4 import org.openstreetmap.josm.data.osm. ReadOnly;4 import org.openstreetmap.josm.data.osm.Lockable; 5 5 import org.openstreetmap.josm.gui.io.AbstractIOTask; 6 6 import org.openstreetmap.josm.gui.io.AbstractUploadDialog; … … 11 11 * @since 7358 12 12 */ 13 public abstract class AbstractModifiableLayer extends Layer implements UploadToServer, SaveToFile, ReadOnly{13 public abstract class AbstractModifiableLayer extends Layer implements DownloadFromServer, UploadToServer, SaveToFile, Lockable { 14 14 15 15 /** … … 19 19 public AbstractModifiableLayer(String name) { 20 20 super(name); 21 } 22 23 @Override 24 public boolean isDownloadable() { 25 // Override if needed 26 return false; 21 27 } 22 28 … … 83 89 84 90 @Override 85 public void setReadOnly() {91 public void lock() { 86 92 // Override if needed 87 93 } 88 94 89 95 @Override 90 public void un setReadOnly() {96 public void unlock() { 91 97 // Override if needed 92 98 } 93 99 94 100 @Override 95 public boolean is ReadOnly() {101 public boolean isLocked() { 96 102 // Override if needed 97 103 return false; -
trunk/src/org/openstreetmap/josm/gui/layer/MainLayerManager.java
r13437 r13453 376 376 */ 377 377 public synchronized OsmDataLayer getEditLayer() { 378 if (dataLayer != null && !dataLayer.is ReadOnly())378 if (dataLayer != null && !dataLayer.isLocked()) 379 379 return dataLayer; 380 380 else … … 402 402 */ 403 403 public synchronized DataSet getEditDataSet() { 404 if (dataLayer != null && !dataLayer.is ReadOnly()) {404 if (dataLayer != null && !dataLayer.isLocked()) { 405 405 return dataLayer.data; 406 406 } else { … … 509 509 GuiHelper.assertCallFromEdt(); 510 510 layer.setUploadInProgress(); 511 layer. setReadOnly();511 layer.lock(); 512 512 513 513 // Reset only the edit layer as empty … … 528 528 public synchronized void processLayerAfterUpload(OsmDataLayer layer) { 529 529 GuiHelper.assertCallFromEdt(); 530 layer.un setReadOnly();530 layer.unlock(); 531 531 layer.unsetUploadInProgress(); 532 532 -
trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java
r13437 r13453 134 134 135 135 @Override 136 public boolean isDownloadable() { 137 return true; 138 } 139 140 @Override 136 141 public boolean isUploadable() { 137 142 return true; -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r13435 r13453 64 64 import org.openstreetmap.josm.data.osm.DataSelectionListener; 65 65 import org.openstreetmap.josm.data.osm.DataSet; 66 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy; 66 67 import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy; 67 68 import org.openstreetmap.josm.data.osm.DataSetMerger; … … 421 422 public Icon getIcon() { 422 423 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) { 424 428 base.addOverlay(new ImageOverlay(new ImageProvider("warning-small"), 0.5, 0.5, 1.0, 1.0)); 425 429 } … … 428 432 // If the layer is being uploaded then change the default icon to a clock 429 433 base = new ImageProvider("clock").setMaxSize(ImageSizes.LAYER); 430 } else if (is ReadOnly()) {434 } else if (isLocked()) { 431 435 // If the layer is read only then change the default icon to a lock 432 436 base = new ImageProvider("lock").setMaxSize(ImageSizes.LAYER); … … 940 944 941 945 @Override 946 public boolean isDownloadable() { 947 return data.getDownloadPolicy() != DownloadPolicy.BLOCKED && !isLocked(); 948 } 949 950 @Override 942 951 public boolean isUploadable() { 943 return data.getUploadPolicy() != UploadPolicy.BLOCKED ;952 return data.getUploadPolicy() != UploadPolicy.BLOCKED && !isLocked(); 944 953 } 945 954 … … 1031 1040 } 1032 1041 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} otherwise1037 */1038 1042 @Override 1039 1043 public final boolean isUploadDiscouraged() { … … 1174 1178 1175 1179 @Override 1176 public void setReadOnly() {1177 data. setReadOnly();1178 } 1179 1180 @Override 1181 public void un setReadOnly() {1182 data.un setReadOnly();1183 } 1184 1185 @Override 1186 public boolean is ReadOnly() {1187 return data.is ReadOnly();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(); 1188 1192 } 1189 1193 -
trunk/src/org/openstreetmap/josm/gui/layer/UploadToServer.java
r13434 r13453 8 8 /** 9 9 * Interface for layers that can upload data. 10 * @see DownloadFromServer 10 11 * @since 9751 11 12 */ -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r13446 r13453 493 493 494 494 answer = new PresetDialog(p, title, preset_name_label ? null : (ImageIcon) getValue(Action.SMALL_ICON), 495 sel.isEmpty() || sel.iterator().next().getDataSet().is ReadOnly(), showNewRelation).getValue();495 sel.isEmpty() || sel.iterator().next().getDataSet().isLocked(), showNewRelation).getValue(); 496 496 } 497 497 if (!showNewRelation && answer == 2) -
trunk/src/org/openstreetmap/josm/io/DiffResultProcessor.java
r13440 r13453 123 123 boolean readOnly = false; 124 124 if (ds != null) { 125 readOnly = ds.is ReadOnly();125 readOnly = ds.isLocked(); 126 126 if (readOnly) { 127 ds.un setReadOnly();127 ds.unlock(); 128 128 } 129 129 ds.beginUpdate(); … … 158 158 ds.endUpdate(); 159 159 if (readOnly) { 160 ds. setReadOnly();160 ds.lock(); 161 161 } 162 162 } -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r13434 r13453 12 12 import java.util.List; 13 13 import java.util.Objects; 14 import java.util.function.Consumer; 14 15 import java.util.regex.Matcher; 15 16 import java.util.regex.Pattern; … … 27 28 import org.openstreetmap.josm.data.osm.Changeset; 28 29 import org.openstreetmap.josm.data.osm.DataSet; 30 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy; 29 31 import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy; 30 32 import org.openstreetmap.josm.data.osm.Node; … … 139 141 } 140 142 ds.setVersion(v); 141 String upload = parser.getAttributeValue(null, "upload"); 142 if (upload != null) { 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(); 143 parsePolicy("download", policy -> ds.setDownloadPolicy(DownloadPolicy.of(policy))); 144 parsePolicy("upload", policy -> ds.setUploadPolicy(UploadPolicy.of(policy))); 145 if ("true".equalsIgnoreCase(parser.getAttributeValue(null, "locked"))) { 146 ds.lock(); 151 147 } 152 148 String generator = parser.getAttributeValue(null, "generator"); … … 185 181 } else if (event == XMLStreamConstants.END_ELEMENT) { 186 182 return; 183 } 184 } 185 } 186 187 private void parsePolicy(String key, Consumer<String> consumer) throws XMLStreamException { 188 String policy = parser.getAttributeValue(null, key); 189 if (policy != null) { 190 try { 191 consumer.accept(policy); 192 } catch (IllegalArgumentException e) { 193 throwException(MessageFormat.format("Illegal value for attribute ''{0}''. Got ''{1}''.", key, policy), e); 187 194 } 188 195 } … … 621 628 progressMonitor.worked(1); 622 629 623 boolean readOnly = getDataSet().is ReadOnly();630 boolean readOnly = getDataSet().isLocked(); 624 631 625 632 progressMonitor.indeterminateSubTask(tr("Preparing data set...")); 626 633 if (readOnly) { 627 getDataSet().un setReadOnly();634 getDataSet().unlock(); 628 635 } 629 636 prepareDataSet(); 630 637 if (readOnly) { 631 getDataSet(). setReadOnly();638 getDataSet().lock(); 632 639 } 633 640 progressMonitor.worked(1); … … 641 648 } 642 649 // Make sure postprocessors did not change the read-only state 643 if (readOnly && !getDataSet().is ReadOnly()) {644 getDataSet(). setReadOnly();650 if (readOnly && !getDataSet().isLocked()) { 651 getDataSet().lock(); 645 652 } 646 653 return getDataSet();
Note:
See TracChangeset
for help on using the changeset viewer.