Changeset 9472 in josm for trunk


Ignore:
Timestamp:
2016-01-15T22:00:20+01:00 (9 years ago)
Author:
simon04
Message:

Relation list: delete selected relations at once

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
2 edited

Legend:

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

    r9230 r9472  
    99import java.awt.event.KeyEvent;
    1010import java.awt.event.MouseEvent;
     11import java.util.Collection;
    1112import java.util.Collections;
    1213import java.util.HashSet;
     
    318319     *
    319320     * @param layer the layer in whose context the relation is deleted. Must not be null.
    320      * @param toDelete  the relation to be deleted. Must  not be null.
     321     * @param toDelete  the relation to be deleted. Must not be null.
    321322     * @throws IllegalArgumentException if layer is null
    322      * @throws IllegalArgumentException if toDelete is nul
     323     * @throws IllegalArgumentException if toDelete is null
    323324     */
    324325    public static void deleteRelation(OsmDataLayer layer, Relation toDelete) {
     326        deleteRelations(layer, Collections.singleton(toDelete));
     327    }
     328
     329    /**
     330     * Deletes the relations in the context of the given layer.
     331     *
     332     * @param layer the layer in whose context the relations are deleted. Must not be null.
     333     * @param toDelete  the relations to be deleted. Must not be null.
     334     * @throws IllegalArgumentException if layer is null
     335     * @throws IllegalArgumentException if toDelete is null
     336     */
     337    public static void deleteRelations(OsmDataLayer layer, Collection<Relation> toDelete) {
    325338        CheckParameterUtil.ensureParameterNotNull(layer, "layer");
    326339        CheckParameterUtil.ensureParameterNotNull(toDelete, "toDelete");
    327340
    328         Command cmd = DeleteCommand.delete(layer, Collections.singleton(toDelete));
     341        final Command cmd = DeleteCommand.delete(layer, toDelete);
    329342        if (cmd != null) {
    330343            // cmd can be null if the user cancels dialogs DialogCommand displays
    331344            Main.main.undoRedo.add(cmd);
    332             if (getCurrentDataSet().getSelectedRelations().contains(toDelete)) {
    333                 getCurrentDataSet().toggleSelected(toDelete);
     345            for (Relation relation : toDelete) {
     346                if (getCurrentDataSet().getSelectedRelations().contains(relation)) {
     347                    getCurrentDataSet().toggleSelected(relation);
     348                }
     349                RelationDialogManager.getRelationDialogManager().close(layer, relation);
    334350            }
    335             RelationDialogManager.getRelationDialogManager().close(layer, toDelete);
    336351        }
    337352    }
  • trunk/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java

    r8510 r9472  
    55
    66import java.awt.event.ActionEvent;
     7import java.util.Collection;
    78
    89import org.openstreetmap.josm.Main;
     10import org.openstreetmap.josm.actions.mapmode.DeleteAction;
    911import org.openstreetmap.josm.data.osm.Relation;
    1012import org.openstreetmap.josm.tools.ImageProvider;
     
    1517 */
    1618public class DeleteRelationsAction extends AbstractRelationAction {
    17     static class AbortException extends Exception {}
    1819
    1920    /**
     
    2627    }
    2728
    28     protected void deleteRelation(Relation toDelete) {
     29    protected void deleteRelation(Collection<Relation> toDelete) {
    2930        if (toDelete == null)
    3031            return;
    31         org.openstreetmap.josm.actions.mapmode.DeleteAction
    32                 .deleteRelation(Main.main.getEditLayer(), toDelete);
     32        DeleteAction.deleteRelations(Main.main.getEditLayer(), toDelete);
    3333        // clear selection after deletion
    3434        if (Main.map.relationListDialog != null)
     
    4040        if (!isEnabled() || !Main.main.hasEditLayer())
    4141            return;
    42         for (Relation r : relations) {
    43             deleteRelation(r);
    44         }
     42        deleteRelation(relations);
    4543    }
    4644}
    47 
Note: See TracChangeset for help on using the changeset viewer.