Changeset 13486 in josm for trunk/src/org
- Timestamp:
- 2018-03-03T17:59:48+01:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
r13067 r13486 41 41 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 42 42 import org.openstreetmap.josm.gui.dialogs.relation.sort.RelationSorter; 43 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 43 44 import org.openstreetmap.josm.gui.util.GuiHelper; 44 45 import org.openstreetmap.josm.spi.preferences.Config; … … 160 161 161 162 // download incomplete relation or incomplete members if necessary 162 if (multipolygonRelation != null) { 163 OsmDataLayer editLayer = getLayerManager().getEditLayer(); 164 if (multipolygonRelation != null && editLayer != null && editLayer.isDownloadable()) { 163 165 if (!multipolygonRelation.isNew() && multipolygonRelation.isIncomplete()) { 164 166 MainApplication.worker.submit( 165 new DownloadRelationTask(Collections.singleton(multipolygonRelation), getLayerManager().getEditLayer()));167 new DownloadRelationTask(Collections.singleton(multipolygonRelation), editLayer)); 166 168 } else if (multipolygonRelation.hasIncompleteMembers()) { 167 169 MainApplication.worker.submit(new DownloadRelationMemberTask(multipolygonRelation, 168 170 DownloadSelectedIncompleteMembersAction.buildSetOfIncompleteMembers(Collections.singleton(multipolygonRelation)), 169 getLayerManager().getEditLayer()));171 editLayer)); 170 172 } 171 173 } -
trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java
r13434 r13486 10 10 11 11 import org.openstreetmap.josm.actions.downloadtasks.DownloadReferrersTask; 12 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy; 12 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 14 import org.openstreetmap.josm.gui.MainApplication; … … 67 68 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 68 69 updateEnabledStateOnModifiableSelection(selection); 70 if (isEnabled() && selection != null && !selection.isEmpty() 71 && DownloadPolicy.BLOCKED.equals(selection.iterator().next().getDataSet().getDownloadPolicy())) { 72 setEnabled(false); 73 } 69 74 } 70 75 } -
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r13453 r13486 359 359 /** 360 360 * Updates enabled state according to selected primitives, if any. 361 * Enables action if the collec iton is not empty and references primitives in a modifiable data layer.361 * Enables action if the collection is not empty and references primitives in a modifiable data layer. 362 362 * Can be called in {@link #updateEnabledState(Collection)} implementations. 363 363 * @param selection the collection of selected primitives -
trunk/src/org/openstreetmap/josm/actions/UpdateDataAction.java
r12675 r13486 47 47 @Override 48 48 protected void updateEnabledState() { 49 setEnabled(getLayerManager().getEditLayer() != null && !Main.isOffline(OnlineResource.OSM_API)); 49 OsmDataLayer editLayer = getLayerManager().getEditLayer(); 50 setEnabled(editLayer != null && editLayer.isDownloadable() && !Main.isOffline(OnlineResource.OSM_API)); 50 51 } 51 52 … … 53 54 public void actionPerformed(ActionEvent e) { 54 55 OsmDataLayer editLayer = getLayerManager().getEditLayer(); 55 if (!isEnabled() || editLayer == null )56 if (!isEnabled() || editLayer == null || !editLayer.isDownloadable()) 56 57 return; 57 58 -
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r12636 r13486 16 16 import org.openstreetmap.josm.Main; 17 17 import org.openstreetmap.josm.data.osm.DataSet; 18 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy; 18 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 20 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 119 120 @Override 120 121 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 121 setEnabled(selection != null && !selection.isEmpty() && !Main.isOffline(OnlineResource.OSM_API)); 122 if (selection == null || selection.isEmpty()) { 123 setEnabled(false); 124 } else { 125 DataSet ds = selection.iterator().next().getDataSet(); 126 setEnabled(!ds.isLocked() && !DownloadPolicy.BLOCKED.equals(ds.getDownloadPolicy()) 127 && !Main.isOffline(OnlineResource.OSM_API)); 128 } 122 129 } 123 130 -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r13464 r13486 11 11 import java.util.Collections; 12 12 import java.util.HashSet; 13 import java.util.Optional;14 13 import java.util.Set; 15 14 import java.util.concurrent.Future; … … 294 293 OsmDataLayer layer = addNewLayerIfRequired(newLayerName); 295 294 if (layer == null) { 296 layer = Optional.ofNullable(getEditLayer()).orElseGet(this::getFirstModifiableDataLayer); 295 layer = getEditLayer(); 296 if (layer == null || !layer.isDownloadable()) { 297 layer = getFirstModifiableDataLayer(); 298 } 297 299 Collection<OsmPrimitive> primitivesToUpdate = searchPrimitivesToUpdate(bounds, layer.data); 298 300 layer.mergeFrom(dataSet); -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java
r12630 r13486 62 62 super("Download referrers", false /* don't ignore exception*/); 63 63 CheckParameterUtil.ensureParameterNotNull(targetLayer, "targetLayer"); 64 if (!targetLayer.isDownloadable()) { 65 throw new IllegalArgumentException("Non-downloadable layer: " + targetLayer); 66 } 64 67 canceled = false; 65 68 this.children = new HashMap<>(); -
trunk/src/org/openstreetmap/josm/actions/relation/AbstractRelationAction.java
r11922 r13486 7 7 import javax.swing.AbstractAction; 8 8 9 import org.openstreetmap.josm.Main; 9 10 import org.openstreetmap.josm.actions.OsmPrimitiveAction; 11 import org.openstreetmap.josm.data.osm.DataSet; 12 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy; 10 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 14 import org.openstreetmap.josm.data.osm.Relation; 15 import org.openstreetmap.josm.io.OnlineResource; 12 16 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 13 17 … … 46 50 setEnabled(!relations.isEmpty()); 47 51 } 52 53 protected final boolean canDownload() { 54 if (relations.isEmpty()) { 55 return false; 56 } 57 DataSet ds = relations.iterator().next().getDataSet(); 58 return !Main.isOffline(OnlineResource.OSM_API) 59 && ds != null && !ds.isLocked() && !DownloadPolicy.BLOCKED.equals(ds.getDownloadPolicy()); 60 } 48 61 } -
trunk/src/org/openstreetmap/josm/actions/relation/DownloadMembersAction.java
r13453 r13486 8 8 import java.util.Collection; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 11 import org.openstreetmap.josm.gui.MainApplication; 13 12 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationTask; 14 import org.openstreetmap.josm.io.OnlineResource;15 13 import org.openstreetmap.josm.tools.ImageProvider; 16 14 import org.openstreetmap.josm.tools.SubclassFilteredCollection; … … 47 45 @Override 48 46 protected void updateEnabledState() { 49 setEnabled(!relations.isEmpty() && !Main.isOffline(OnlineResource.OSM_API) 50 && !relations.iterator().next().getDataSet().isLocked()); 47 setEnabled(canDownload()); 51 48 } 52 49 } -
trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java
r13453 r13486 9 9 import java.util.Set; 10 10 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 12 import org.openstreetmap.josm.data.osm.Relation; 14 13 import org.openstreetmap.josm.gui.MainApplication; 15 14 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask; 16 import org.openstreetmap.josm.io.OnlineResource;17 15 import org.openstreetmap.josm.tools.ImageProvider; 18 16 import org.openstreetmap.josm.tools.SubclassFilteredCollection; … … 67 65 @Override 68 66 protected void updateEnabledState() { 69 setEnabled(!relations.isEmpty() && !incompleteMembers.isEmpty() && !Main.isOffline(OnlineResource.OSM_API) 70 && !relations.iterator().next().getDataSet().isLocked()); 67 setEnabled(!incompleteMembers.isEmpty() && canDownload()); 71 68 } 72 69 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationMemberTask.java
r12675 r13486 9 9 import java.util.Collection; 10 10 import java.util.HashSet; 11 import java.util.Objects; 11 12 import java.util.Set; 12 13 … … 30 31 /** 31 32 * The asynchronous task for downloading relation members. 32 * 33 * @since 2563 33 34 */ 34 35 public class DownloadRelationMemberTask extends PleaseWaitRunnable { … … 44 45 if (parent != null) 45 46 this.parents.add(parent); 46 this.children = children; 47 this.curLayer = curLayer; 47 this.children = Objects.requireNonNull(children); 48 this.curLayer = Objects.requireNonNull(curLayer); 49 checkLayer(); 48 50 } 49 51 … … 52 54 if (parent != null) 53 55 this.parents.add(parent); 54 this.children = children; 55 this.curLayer = curLayer; 56 this.children = Objects.requireNonNull(children); 57 this.curLayer = Objects.requireNonNull(curLayer); 58 checkLayer(); 56 59 } 57 60 … … 67 70 super(tr("Download relation members"), false /* don't ignore exception */); 68 71 this.parents.addAll(parents); 69 this.children = children; 70 this.curLayer = curLayer; 72 this.children = Objects.requireNonNull(children); 73 this.curLayer = Objects.requireNonNull(curLayer); 74 checkLayer(); 75 } 76 77 private void checkLayer() { 78 if (!curLayer.isDownloadable()) { 79 throw new IllegalArgumentException("Non-downloadable layer: " + curLayer); 80 } 71 81 } 72 82 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationTask.java
r12663 r13486 27 27 * The asynchronous task for fully downloading a collection of relations. Does a full download 28 28 * for each relations and merges the relation into an {@link OsmDataLayer} 29 * 29 * @since 2563 30 30 */ 31 31 public class DownloadRelationTask extends PleaseWaitRunnable { … … 50 50 this.relations = relations; 51 51 this.layer = layer; 52 if (!layer.isDownloadable()) { 53 throw new IllegalArgumentException("Non-downloadable layer: " + layer); 54 } 52 55 } 53 56 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java
r12713 r13486 78 78 CheckParameterUtil.ensure(child, "child", "id > 0", ch -> ch.getUniqueId() > 0); 79 79 CheckParameterUtil.ensureParameterNotNull(layer, "layer"); 80 if (!layer.isDownloadable()) { 81 throw new IllegalArgumentException("Non-downloadable layer: " + layer); 82 } 80 83 referrers = null; 81 84 this.layer = layer; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ReferringRelationsBrowserModel.java
r12657 r13486 8 8 9 9 import org.openstreetmap.josm.data.osm.DataSet; 10 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy; 10 11 import org.openstreetmap.josm.data.osm.Relation; 11 12 import org.openstreetmap.josm.data.osm.RelationMember; … … 35 36 } 36 37 38 /** 39 * Sets the relation. 40 * @param relation the relation 41 */ 37 42 public void setRelation(Relation relation) { 38 43 this.relation = relation; … … 62 67 } 63 68 69 /** 70 * Populates the model with parent referrers. 71 * @param parents parent referrers 72 */ 64 73 public void populate(List<Relation> parents) { 65 74 referrers.clear(); … … 93 102 } 94 103 104 /** 105 * Determines if reloading the relation is possible/authorized. 106 * @return {@code true} if reloading the relation is possible/authorized 107 */ 95 108 public boolean canReload() { 96 return relation != null && !relation.isNew(); 109 return relation != null && !relation.isNew() 110 && !relation.getDataSet().isLocked() 111 && !DownloadPolicy.BLOCKED.equals(relation.getDataSet().getDownloadPolicy()); 97 112 } 98 113 114 /** 115 * Returns the relation. 116 * @return the relation 117 */ 99 118 public Relation getRelation() { 100 119 return relation; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/AbstractRelationEditorAction.java
r12933 r13486 8 8 import javax.swing.event.TableModelListener; 9 9 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.osm.DataSet; 12 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy; 10 13 import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor; 11 14 import org.openstreetmap.josm.gui.dialogs.relation.MemberTable; 12 15 import org.openstreetmap.josm.gui.dialogs.relation.MemberTableModel; 13 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 17 import org.openstreetmap.josm.io.OnlineResource; 14 18 15 19 /** … … 49 53 50 54 protected abstract void updateEnabledState(); 55 56 protected final boolean canDownload() { 57 DataSet ds = editor.getRelation().getDataSet(); 58 return !Main.isOffline(OnlineResource.OSM_API) 59 && ds != null && !ds.isLocked() && !DownloadPolicy.BLOCKED.equals(ds.getDownloadPolicy()); 60 } 51 61 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/DownloadIncompleteMembersAction.java
r13130 r13486 15 15 import org.openstreetmap.josm.gui.dialogs.relation.MemberTableModel; 16 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 17 import org.openstreetmap.josm.io.OnlineResource;18 17 import org.openstreetmap.josm.tools.ImageProvider; 19 18 import org.openstreetmap.josm.tools.Shortcut; … … 59 58 @Override 60 59 protected void updateEnabledState() { 61 setEnabled(memberTableModel.hasIncompleteMembers() && !Main.isOffline(OnlineResource.OSM_API));60 setEnabled(memberTableModel.hasIncompleteMembers() && canDownload()); 62 61 } 63 62 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/DownloadSelectedIncompleteMembersAction.java
r13130 r13486 7 7 import java.awt.event.ActionEvent; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.gui.MainApplication; 11 10 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask; … … 14 13 import org.openstreetmap.josm.gui.dialogs.relation.MemberTableModel; 15 14 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 16 import org.openstreetmap.josm.io.OnlineResource;17 15 import org.openstreetmap.josm.tools.ImageProvider; 18 16 … … 54 52 @Override 55 53 protected void updateEnabledState() { 56 setEnabled(memberTableModel.hasIncompleteSelectedMembers() && !Main.isOffline(OnlineResource.OSM_API));54 setEnabled(memberTableModel.hasIncompleteSelectedMembers() && canDownload()); 57 55 } 58 56 } -
trunk/src/org/openstreetmap/josm/gui/io/AbstractPrimitiveTask.java
r12675 r13486 53 53 ensureParameterNotNull(layer, "layer"); 54 54 this.layer = layer; 55 if (!layer.isDownloadable()) { 56 throw new IllegalArgumentException("Non-downloadable layer: " + layer); 57 } 55 58 } 56 59 -
trunk/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesWithReferrersTask.java
r12636 r13486 131 131 // Append downloaded data to JOSM 132 132 OsmDataLayer layer = MainApplication.getLayerManager().getEditLayer(); 133 if (layer == null || this.newLayer )133 if (layer == null || this.newLayer || !layer.isDownloadable()) 134 134 MainApplication.getLayerManager().addLayer(tmpLayer); 135 135 else
Note:
See TracChangeset
for help on using the changeset viewer.