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

Relation list: delete selected relations at once

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified 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    }
Note: See TracChangeset for help on using the changeset viewer.