Ignore:
Timestamp:
2009-09-02T21:37:18+02:00 (15 years ago)
Author:
Gubaer
Message:

applied #2163: patch by xeen: for delete-command mouse-icons

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r2025 r2026  
    4343 */
    4444public class DeleteCommand extends Command {
    45 
    4645    /**
    4746     * The primitives that get deleted.
     
    157156     * If a way is deleted, only the way and no nodes are deleted.
    158157     *
     158     * @param layer
    159159     * @param selection The list of all object to be deleted.
     160     * @param simulate  Set to true if the user should not be bugged with additional dialogs
    160161     * @return command A command to perform the deletions, or null of there is nothing to delete.
    161162     */
    162     public static Command deleteWithReferences(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection) {
     163    public static Command deleteWithReferences(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection, boolean simulate) {
    163164        CollectBackReferencesVisitor v = new CollectBackReferencesVisitor(layer.data);
    164165        for (OsmPrimitive osm : selection) {
     
    168169        if (v.data.isEmpty())
    169170            return null;
    170         if (!checkAndConfirmOutlyingDeletes(layer,v.data))
     171        if (!checkAndConfirmOutlyingDeletes(layer,v.data) && !simulate)
    171172            return null;
    172173        return new DeleteCommand(layer,v.data);
    173174    }
    174175
    175     private static int testRelation(Relation ref, OsmPrimitive osm) {
     176    public static Command deleteWithReferences(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection) {
     177        return deleteWithReferences(layer, selection, false);
     178    }
     179
     180    private static int testRelation(Relation ref, OsmPrimitive osm, boolean simulate) {
     181        // If this delete action is simulated, do not bug the user with dialogs
     182        // and assume the relations should be deleted
     183        if(simulate)
     184            return 1;
     185
    176186        String role = new String();
    177187        for (RelationMember m : ref.getMembers()) {
     
    195205
    196206    public static Command delete(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection) {
    197         return delete(layer, selection, true);
     207        return delete(layer, selection, true, false);
    198208    }
    199209
     
    243253     * @param selection The objects to delete.
    244254     * @param alsoDeleteNodesInWay <code>true</code> if nodes should be deleted as well
     255     * @param simulate Set to true if the user should not be bugged with additional questions
    245256     * @return command a command to perform the deletions, or null if there is nothing to delete.
    246257     */
    247     public static Command delete(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection, boolean alsoDeleteNodesInWay) {
     258    public static Command delete(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection,
     259            boolean alsoDeleteNodesInWay) {
     260        return delete(layer, selection, alsoDeleteNodesInWay, false);
     261    }
     262
     263    public static Command delete(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection,
     264            boolean alsoDeleteNodesInWay, boolean simulate) {
    248265        if (selection.isEmpty())
    249266            return null;
     
    260277        }
    261278
    262         if (!checkAndConfirmOutlyingDeletes(layer,primitivesToDelete))
     279        if (!checkAndConfirmOutlyingDeletes(layer,primitivesToDelete) && !simulate)
    263280            return null;
    264281
     
    273290                    waysToBeChanged.add((Way) ref);
    274291                } else if (ref instanceof Relation) {
    275                     if (testRelation((Relation) ref, osm) == 1) {
     292                    if (testRelation((Relation) ref, osm, simulate) == 1) {
    276293                        Collection<OsmPrimitive> relset = relationsToBeChanged.get(ref);
    277294                        if (relset == null) {
     
    314331                        }
    315332                        if (!found) {
    316                             if (testRelation((Relation) ref, w) == 1) {
     333                            if (testRelation((Relation) ref, w, simulate) == 1) {
    317334                                relset.add(w);
    318335                                relationsToBeChanged.put(ref, relset);
Note: See TracChangeset for help on using the changeset viewer.