Changeset 9881 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java
r8510 r9881 7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.KeyEvent; 9 import java.text.MessageFormat;10 9 import java.util.Collection; 11 import java.util.Map;12 10 13 11 import org.openstreetmap.josm.Main; 14 12 import org.openstreetmap.josm.actions.downloadtasks.DownloadReferrersTask; 15 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;17 14 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 18 import org.openstreetmap.josm.tools.CheckParameterUtil;19 15 import org.openstreetmap.josm.tools.Shortcut; 20 16 … … 47 43 */ 48 44 public static void downloadReferrers(OsmDataLayer targetLayer, Collection<OsmPrimitive> children) { 49 if (children == null || children.isEmpty()) return; 45 if (children == null || children.isEmpty()) 46 return; 50 47 Main.worker.submit(new DownloadReferrersTask(targetLayer, children)); 51 }52 53 /**54 * Downloads the primitives referring to the primitives in <code>primitives</code>55 * into the target layer <code>targetLayer</code>.56 * Does nothing if primitives is null or empty.57 *58 * @param targetLayer the target layer. Must not be null.59 * @param children the collection of primitives, given as map of ids and types60 * @throws IllegalArgumentException if targetLayer is null61 */62 public static void downloadReferrers(OsmDataLayer targetLayer, Map<Long, OsmPrimitiveType> children) {63 if (children == null || children.isEmpty()) return;64 Main.worker.submit(new DownloadReferrersTask(targetLayer, children));65 }66 67 /**68 * Downloads the primitives referring to the primitive given by <code>id</code> and <code>type</code>.69 *70 * @param targetLayer the target layer. Must not be null.71 * @param id the primitive id. id > 0 required.72 * @param type the primitive type. type != null required73 * @throws IllegalArgumentException if targetLayer is null74 * @throws IllegalArgumentException if id <= 075 * @throws IllegalArgumentException if type == null76 */77 public static void downloadReferrers(OsmDataLayer targetLayer, long id, OsmPrimitiveType type) {78 if (id <= 0)79 throw new IllegalArgumentException(MessageFormat.format("Id > 0 required, got {0}", id));80 CheckParameterUtil.ensureParameterNotNull(type, "type");81 Main.worker.submit(new DownloadReferrersTask(targetLayer, id, type));82 48 } 83 49 -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java
r9241 r9881 71 71 this.targetLayer = targetLayer; 72 72 parents = new DataSet(); 73 }74 75 /**76 * constructor77 *78 * @param targetLayer the target layer for the downloaded primitives. Must not be null.79 * @param children the collection of children for which parents are to be downloaded. Children80 * are specified by their id and their type.81 */82 public DownloadReferrersTask(OsmDataLayer targetLayer, Map<Long, OsmPrimitiveType> children) {83 super("Download referrers", false /* don't ignore exception*/);84 CheckParameterUtil.ensureParameterNotNull(targetLayer, "targetLayer");85 canceled = false;86 this.children = new HashMap<>();87 if (children != null) {88 for (Entry<Long, OsmPrimitiveType> entry : children.entrySet()) {89 if (entry.getKey() > 0 && entry.getValue() != null) {90 children.put(entry.getKey(), entry.getValue());91 }92 }93 }94 this.targetLayer = targetLayer;95 parents = new DataSet();96 }97 98 /**99 * constructor100 *101 * @param targetLayer the target layer. Must not be null.102 * @param id the primitive id. id > 0 required.103 * @param type the primitive type. type != null required104 * @throws IllegalArgumentException if id <= 0105 * @throws IllegalArgumentException if type == null106 * @throws IllegalArgumentException if targetLayer == null107 */108 public DownloadReferrersTask(OsmDataLayer targetLayer, long id, OsmPrimitiveType type) {109 super("Download referrers", false /* don't ignore exception*/);110 CheckParameterUtil.ensureParameterNotNull(targetLayer, "targetLayer");111 if (id <= 0)112 throw new IllegalArgumentException(MessageFormat.format("Id > 0 required, got {0}", id));113 CheckParameterUtil.ensureParameterNotNull(type, "type");114 canceled = false;115 this.children = new HashMap<>();116 this.children.put(id, type);117 this.targetLayer = targetLayer;118 parents = new DataSet();119 }120 121 /**122 * constructor123 *124 * @param targetLayer the target layer. Must not be null.125 * @param primitiveId a PrimitiveId object.126 * @throws IllegalArgumentException if id <= 0127 * @throws IllegalArgumentException if targetLayer == null128 */129 public DownloadReferrersTask(OsmDataLayer targetLayer, PrimitiveId primitiveId) {130 this(targetLayer, primitiveId, null);131 73 } 132 74
Note:
See TracChangeset
for help on using the changeset viewer.