Ignore:
Timestamp:
2017-09-04T00:50:22+02:00 (3 years ago)
Author:
Don-vip
Message:

see #13036 - see #15229 - see #15182 - make Commands depends only on a DataSet, not a Layer. This removes a lot of GUI dependencies

Location:
trunk/src/org/openstreetmap/josm/command
Files:
10 edited

Legend:

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

    r12663 r12718  
    4545     * @param layer The data layer. Must not be {@code null}
    4646     * @param osm The primitive to add
     47     * @deprecated to be removed end of 2017. Use {@link #AddCommand(DataSet, OsmPrimitive)} instead
    4748     */
     49    @Deprecated
    4850    public AddCommand(OsmDataLayer layer, OsmPrimitive osm) {
    4951        super(layer);
  • trunk/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java

    r11609 r12718  
    5959     * @param toSelect The OSM primitives to select at the end. Can be {@code null}
    6060     * @param layer The target data layer. Must not be {@code null}
    61      */
     61     * @deprecated to be removed end of 2017. Use {@link #AddPrimitivesCommand(List, List, DataSet)} instead
     62     */
     63    @Deprecated
    6264    public AddPrimitivesCommand(List<PrimitiveData> data, List<PrimitiveData> toSelect, OsmDataLayer layer) {
    6365        super(layer);
     66        init(data, toSelect);
     67    }
     68
     69    /**
     70     * Constructs a new {@code AddPrimitivesCommand} to add data to the given data set.
     71     * @param data The OSM primitives data to add. Must not be {@code null}
     72     * @param toSelect The OSM primitives to select at the end. Can be {@code null}
     73     * @param ds The target data set. Must not be {@code null}
     74     * @since 12718
     75     */
     76    public AddPrimitivesCommand(List<PrimitiveData> data, List<PrimitiveData> toSelect, DataSet ds) {
     77        super(ds);
    6478        init(data, toSelect);
    6579    }
  • trunk/src/org/openstreetmap/josm/command/ChangeCommand.java

    r12663 r12718  
    4545     * @param osm The existing primitive to modify
    4646     * @param newOsm The new primitive
     47     * @deprecated to be removed end of 2017. Use {@link #ChangeCommand(DataSet, OsmPrimitive, OsmPrimitive)} instead
    4748     */
     49    @Deprecated
    4850    public ChangeCommand(OsmDataLayer layer, OsmPrimitive osm, OsmPrimitive newOsm) {
    4951        super(layer);
  • trunk/src/org/openstreetmap/josm/command/Command.java

    r12636 r12718  
    3535 * one atomic action on a specific dataset, such as move or delete.
    3636 *
    37  * The command remembers the {@link OsmDataLayer} it is operating on.
     37 * The command remembers the {@link DataSet} it is operating on.
    3838 *
    3939 * @author imi
     
    135135    private Map<OsmPrimitive, PrimitiveData> cloneMap = new HashMap<>();
    136136
    137     /** the layer which this command is applied to */
     137    /**
     138     * the layer which this command is applied to
     139     * @deprecated to be removed end of 2017. Use {@link #data} instead
     140     */
     141    @Deprecated
    138142    private final OsmDataLayer layer;
    139143
     
    146150    public Command() {
    147151        this.layer = MainApplication.getLayerManager().getEditLayer();
    148         this.data = layer != null ? layer.data : null;
     152        this.data = layer != null ? layer.data : Main.main.getEditDataSet();
    149153    }
    150154
     
    154158     * @param layer the data layer. Must not be null.
    155159     * @throws IllegalArgumentException if layer is null
    156      */
     160     * @deprecated to be removed end of 2017. Use {@link #Command(DataSet)} instead
     161     */
     162    @Deprecated
    157163    public Command(OsmDataLayer layer) {
    158164        CheckParameterUtil.ensureParameterNotNull(layer, "layer");
     
    216222     * @param oldLayer the old layer that was removed
    217223     * @return true if this command is invalid after that layer is removed.
    218      */
     224     * @deprecated to be removed end of 2017.
     225     */
     226    @Deprecated
    219227    public boolean invalidBecauselayerRemoved(Layer oldLayer) {
    220228        return layer == oldLayer;
     
    234242     * Replies the layer this command is (or was) applied to.
    235243     * @return the layer this command is (or was) applied to
    236      */
     244     * @deprecated to be removed end of 2017. Use {@link #getAffectedDataSet} instead
     245     */
     246    @Deprecated
    237247    protected OsmDataLayer getLayer() {
    238248        return layer;
     
    371381     * Invalidate all layers that were affected by this command.
    372382     * @see Layer#invalidate()
    373      */
     383     * @deprecated to be removed end of 2017.
     384     */
     385    @Deprecated
    374386    public void invalidateAffectedLayers() {
    375387        OsmDataLayer layer = getLayer();
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r12663 r12718  
    108108
    109109    /**
    110      * Constructor for a single data item. Use the collection constructor to delete multiple
    111      * objects.
     110     * Constructor for a single data item. Use the collection constructor to delete multiple objects.
    112111     *
    113112     * @param layer the layer context for deleting this primitive. Must not be null.
     
    115114     * @throws IllegalArgumentException if data is null
    116115     * @throws IllegalArgumentException if layer is null
    117      */
     116     * @deprecated to be removed end of 2017. Use {@link #DeleteCommand(DataSet, OsmPrimitive)} instead
     117     */
     118    @Deprecated
    118119    public DeleteCommand(OsmDataLayer layer, OsmPrimitive data) {
    119120        this(layer, Collections.singleton(data));
     
    121122
    122123    /**
    123      * Constructor for a collection of data to be deleted in the context of
    124      * a specific layer
     124     * Constructor for a single data item. Use the collection constructor to delete multiple objects.
     125     *
     126     * @param dataset the data set context for deleting this primitive. Must not be null.
     127     * @param data the primitive to delete. Must not be null.
     128     * @throws IllegalArgumentException if data is null
     129     * @throws IllegalArgumentException if layer is null
     130     * @since 12718
     131     */
     132    public DeleteCommand(DataSet dataset, OsmPrimitive data) {
     133        this(dataset, Collections.singleton(data));
     134    }
     135
     136    /**
     137     * Constructor for a collection of data to be deleted in the context of a specific layer
    125138     *
    126139     * @param layer the layer context for deleting these primitives. Must not be null.
     
    128141     * @throws IllegalArgumentException if layer is null
    129142     * @throws IllegalArgumentException if data is null or empty
    130      */
     143     * @deprecated to be removed end of 2017. Use {@link #DeleteCommand(DataSet, Collection)} instead
     144     */
     145    @Deprecated
    131146    public DeleteCommand(OsmDataLayer layer, Collection<? extends OsmPrimitive> data) {
    132147        super(layer);
     
    137152
    138153    /**
    139      * Constructor for a collection of data to be deleted in the context of
    140      * a specific data set
     154     * Constructor for a collection of data to be deleted in the context of a specific data set
    141155     *
    142156     * @param dataset the dataset context for deleting these primitives. Must not be null.
     
    286300     * @return command A command to perform the deletions, or null of there is nothing to delete.
    287301     * @throws IllegalArgumentException if layer is null
    288      */
     302     * @deprecated to be removed end of 2017. Use {@link #deleteWithReferences(Collection, boolean)} instead
     303     */
     304    @Deprecated
    289305    public static Command deleteWithReferences(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection, boolean silent) {
    290         CheckParameterUtil.ensureParameterNotNull(layer, "layer");
     306        return deleteWithReferences(selection, silent);
     307    }
     308
     309    /**
     310     * Delete the primitives and everything they reference.
     311     *
     312     * If a node is deleted, the node and all ways and relations the node is part of are deleted as well.
     313     * If a way is deleted, all relations the way is member of are also deleted.
     314     * If a way is deleted, only the way and no nodes are deleted.
     315     *
     316     * @param selection The list of all object to be deleted.
     317     * @param silent  Set to true if the user should not be bugged with additional dialogs
     318     * @return command A command to perform the deletions, or null of there is nothing to delete.
     319     * @throws IllegalArgumentException if layer is null
     320     * @since 12718
     321     */
     322    public static Command deleteWithReferences(Collection<? extends OsmPrimitive> selection, boolean silent) {
    291323        if (selection == null || selection.isEmpty()) return null;
    292324        Set<OsmPrimitive> parents = OsmPrimitive.getReferrer(selection);
     
    297329        if (!silent && !checkAndConfirmOutlyingDelete(parents, null))
    298330            return null;
    299         return new DeleteCommand(layer, parents);
     331        return new DeleteCommand(parents.iterator().next().getDataSet(), parents);
    300332    }
    301333
     
    307339     * If a way is deleted, only the way and no nodes are deleted.
    308340     *
    309      * @param layer the {@link OsmDataLayer} in whose context primitives are deleted. Must not be null.
     341     * @param layer unused
    310342     * @param selection The list of all object to be deleted.
    311343     * @return command A command to perform the deletions, or null of there is nothing to delete.
    312344     * @throws IllegalArgumentException if layer is null
    313      */
     345     * @deprecated to be removed end of 2017. Use {@link #deleteWithReferences(Collection)} instead
     346     */
     347    @Deprecated
    314348    public static Command deleteWithReferences(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection) {
    315         return deleteWithReferences(layer, selection, false);
     349        return deleteWithReferences(selection);
     350    }
     351
     352    /**
     353     * Delete the primitives and everything they reference.
     354     *
     355     * If a node is deleted, the node and all ways and relations the node is part of are deleted as well.
     356     * If a way is deleted, all relations the way is member of are also deleted.
     357     * If a way is deleted, only the way and no nodes are deleted.
     358     *
     359     * @param selection The list of all object to be deleted.
     360     * @return command A command to perform the deletions, or null of there is nothing to delete.
     361     * @throws IllegalArgumentException if layer is null
     362     * @since 12718
     363     */
     364    public static Command deleteWithReferences(Collection<? extends OsmPrimitive> selection) {
     365        return deleteWithReferences(selection, false);
    316366    }
    317367
     
    325375     * they are part of a relation, inform the user and do not delete.
    326376     *
    327      * @param layer the {@link OsmDataLayer} in whose context the primitives are deleted
     377     * @param layer unused
    328378     * @param selection the objects to delete.
    329379     * @return command a command to perform the deletions, or null if there is nothing to delete.
    330      */
     380     * @deprecated to be removed end of 2017. Use {@link #delete(Collection)} instead
     381     */
     382    @Deprecated
    331383    public static Command delete(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection) {
    332         return delete(layer, selection, true, false);
     384        return delete(selection);
     385    }
     386
     387    /**
     388     * Try to delete all given primitives.
     389     *
     390     * If a node is used by a way, it's removed from that way. If a node or a way is used by a
     391     * relation, inform the user and do not delete.
     392     *
     393     * If this would cause ways with less than 2 nodes to be created, delete these ways instead. If
     394     * they are part of a relation, inform the user and do not delete.
     395     *
     396     * @param selection the objects to delete.
     397     * @return command a command to perform the deletions, or null if there is nothing to delete.
     398     * @since 12718
     399     */
     400    public static Command delete(Collection<? extends OsmPrimitive> selection) {
     401        return delete(selection, true, false);
    333402    }
    334403
     
    376445     * they are part of a relation, inform the user and do not delete.
    377446     *
    378      * @param layer the {@link OsmDataLayer} in whose context the primitives are deleted
     447     * @param layer unused
    379448     * @param selection the objects to delete.
    380449     * @param alsoDeleteNodesInWay <code>true</code> if nodes should be deleted as well
    381450     * @return command a command to perform the deletions, or null if there is nothing to delete.
    382      */
     451     * @deprecated to be removed end of 2017. Use {@link #delete(Collection, boolean)} instead
     452     */
     453    @Deprecated
    383454    public static Command delete(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection,
    384455            boolean alsoDeleteNodesInWay) {
    385         return delete(layer, selection, alsoDeleteNodesInWay, false /* not silent */);
     456        return delete(selection, alsoDeleteNodesInWay);
    386457    }
    387458
     
    395466     * they are part of a relation, inform the user and do not delete.
    396467     *
    397      * @param layer the {@link OsmDataLayer} in whose context the primitives are deleted
     468     * @param selection the objects to delete.
     469     * @param alsoDeleteNodesInWay <code>true</code> if nodes should be deleted as well
     470     * @return command a command to perform the deletions, or null if there is nothing to delete.
     471     * @since 12718
     472     */
     473    public static Command delete(Collection<? extends OsmPrimitive> selection, boolean alsoDeleteNodesInWay) {
     474        return delete(selection, alsoDeleteNodesInWay, false /* not silent */);
     475    }
     476
     477    /**
     478     * Try to delete all given primitives.
     479     *
     480     * If a node is used by a way, it's removed from that way. If a node or a way is used by a
     481     * relation, inform the user and do not delete.
     482     *
     483     * If this would cause ways with less than 2 nodes to be created, delete these ways instead. If
     484     * they are part of a relation, inform the user and do not delete.
     485     *
     486     * @param layer unused
    398487     * @param selection the objects to delete.
    399488     * @param alsoDeleteNodesInWay <code>true</code> if nodes should be deleted as well
    400489     * @param silent set to true if the user should not be bugged with additional questions
    401490     * @return command a command to perform the deletions, or null if there is nothing to delete.
    402      */
     491     * @deprecated to be removed end of 2017. Use {@link #delete(Collection, boolean, boolean)} instead
     492     */
     493    @Deprecated
    403494    public static Command delete(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection,
    404495            boolean alsoDeleteNodesInWay, boolean silent) {
     496        return delete(selection, alsoDeleteNodesInWay, silent);
     497    }
     498
     499    /**
     500     * Try to delete all given primitives.
     501     *
     502     * If a node is used by a way, it's removed from that way. If a node or a way is used by a
     503     * relation, inform the user and do not delete.
     504     *
     505     * If this would cause ways with less than 2 nodes to be created, delete these ways instead. If
     506     * they are part of a relation, inform the user and do not delete.
     507     *
     508     * @param selection the objects to delete.
     509     * @param alsoDeleteNodesInWay <code>true</code> if nodes should be deleted as well
     510     * @param silent set to true if the user should not be bugged with additional questions
     511     * @return command a command to perform the deletions, or null if there is nothing to delete.
     512     * @since 12718
     513     */
     514    public static Command delete(Collection<? extends OsmPrimitive> selection, boolean alsoDeleteNodesInWay, boolean silent) {
    405515        if (selection == null || selection.isEmpty())
    406516            return null;
     
    460570        //
    461571        if (!primitivesToDelete.isEmpty()) {
    462             cmds.add(layer != null ? new DeleteCommand(layer, primitivesToDelete) :
    463                 new DeleteCommand(primitivesToDelete.iterator().next().getDataSet(), primitivesToDelete));
     572            cmds.add(new DeleteCommand(primitivesToDelete.iterator().next().getDataSet(), primitivesToDelete));
    464573        }
    465574
     
    469578    /**
    470579     * Create a command that deletes a single way segment. The way may be split by this.
    471      * @param layer The layer the segment is in.
     580     * @param layer unused
    472581     * @param ws The way segment that should be deleted
    473582     * @return A matching command to safely delete that segment.
    474      */
     583     * @deprecated to be removed end of 2017. Use {@link #deleteWaySegment(WaySegment)} instead
     584     */
     585    @Deprecated
    475586    public static Command deleteWaySegment(OsmDataLayer layer, WaySegment ws) {
     587        return deleteWaySegment(ws);
     588    }
     589
     590    /**
     591     * Create a command that deletes a single way segment. The way may be split by this.
     592     * @param ws The way segment that should be deleted
     593     * @return A matching command to safely delete that segment.
     594     * @since 12718
     595     */
     596    public static Command deleteWaySegment(WaySegment ws) {
    476597        if (ws.way.getNodesCount() < 3)
    477             return delete(layer, Collections.singleton(ws.way), false);
     598            return delete(Collections.singleton(ws.way), false);
    478599
    479600        if (ws.way.isClosed()) {
     
    506627            return new ChangeCommand(ws.way, wnew);
    507628        } else {
    508             SplitWayResult split = SplitWayAction.splitWay(layer, ws.way, Arrays.asList(n1, n2), Collections.<OsmPrimitive>emptyList());
     629            SplitWayResult split = SplitWayAction.splitWay(ws.way, Arrays.asList(n1, n2), Collections.<OsmPrimitive>emptyList());
    509630            return split != null ? split.getCommand() : null;
    510631        }
  • trunk/src/org/openstreetmap/josm/command/PurgeCommand.java

    r12688 r12718  
    5454     * @param toPurge primitives to purge
    5555     * @param makeIncomplete primitives to make incomplete
     56     * @deprecated to be removed end of 2017. Use {@link #PurgeCommand(DataSet, Collection, Collection)} instead
    5657     */
     58    @Deprecated
    5759    public PurgeCommand(OsmDataLayer layer, Collection<OsmPrimitive> toPurge, Collection<OsmPrimitive> makeIncomplete) {
    5860        super(layer);
     
    319321     * @return command to purge selected OSM primitives
    320322     * @since 12688
     323     * @deprecated to be removed end of 2017. Use {@link #build(Collection, List)} instead
    321324     */
     325    @Deprecated
    322326    public static PurgeCommand build(OsmDataLayer layer, Collection<OsmPrimitive> sel, List<OsmPrimitive> toPurgeAdditionally) {
     327        return build(sel, toPurgeAdditionally);
     328    }
     329
     330    /**
     331     * Creates a new {@code PurgeCommand} to purge selected OSM primitives.
     332     * @param sel selected OSM primitives
     333     * @param toPurgeAdditionally optional list that will be filled with primitives to be purged that have not been in the selection
     334     * @return command to purge selected OSM primitives
     335     * @since 12718
     336     */
     337    public static PurgeCommand build(Collection<OsmPrimitive> sel, List<OsmPrimitive> toPurgeAdditionally) {
    323338        Set<OsmPrimitive> toPurge = new HashSet<>(sel);
    324339        // finally, contains all objects that are purged
     
    423438        }
    424439
    425         return layer != null ? new PurgeCommand(layer, toPurgeChecked, makeIncomplete)
    426                 : new PurgeCommand(toPurgeChecked.iterator().next().getDataSet(), toPurgeChecked, makeIncomplete);
     440        return new PurgeCommand(toPurgeChecked.iterator().next().getDataSet(), toPurgeChecked, makeIncomplete);
    427441    }
    428442
  • trunk/src/org/openstreetmap/josm/command/SequenceCommand.java

    r11874 r12718  
    1212
    1313import org.openstreetmap.josm.data.osm.OsmPrimitive;
     14import org.openstreetmap.josm.gui.layer.Layer;
    1415import org.openstreetmap.josm.tools.ImageProvider;
    1516import org.openstreetmap.josm.tools.Utils;
     
    136137    }
    137138
     139    /**
     140     * Invalidate all layers that were affected by this command.
     141     * @see Layer#invalidate()
     142     * @deprecated to be removed end of 2017.
     143     */
    138144    @Override
     145    @Deprecated
    139146    public void invalidateAffectedLayers() {
    140147        super.invalidateAffectedLayers();
  • trunk/src/org/openstreetmap/josm/command/conflict/ConflictAddCommand.java

    r12672 r12718  
    1616import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
    1717import org.openstreetmap.josm.data.osm.OsmPrimitive;
    18 import org.openstreetmap.josm.gui.MainApplication;
    1918import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2019import org.openstreetmap.josm.tools.ImageProvider;
     
    3332     * @param layer the data layer. Must not be null.
    3433     * @param conflict the conflict to add
     34     * @deprecated to be removed end of 2017. Use {@link #ConflictAddCommand(DataSet, Conflict)} instead
    3535     */
     36    @Deprecated
    3637    public ConflictAddCommand(OsmDataLayer layer, Conflict<? extends OsmPrimitive> conflict) {
    3738        super(layer);
     
    5657                        + "''{1}''.<br>"
    5758                        + "This conflict cannot be added.</html>",
    58                         Utils.escapeReservedCharactersHTML(getLayer().getName()),
     59                        Utils.escapeReservedCharactersHTML(getAffectedDataSet().getName()),
    5960                        Utils.escapeReservedCharactersHTML(conflict.getMy().getDisplayName(DefaultNameFormatter.getInstance()))
    6061                ),
     
    7778    @Override
    7879    public void undoCommand() {
    79         if (MainApplication.isDisplayingMapView() && !MainApplication.getLayerManager().containsLayer(getLayer())) {
     80        DataSet ds = getAffectedDataSet();
     81        if (!Main.main.containsDataSet(ds)) {
    8082            Logging.warn(tr("Layer ''{0}'' does not exist any more. Cannot remove conflict for object ''{1}''.",
    81                     getLayer().getName(),
     83                    ds.getName(),
    8284                    conflict.getMy().getDisplayName(DefaultNameFormatter.getInstance())
    8385            ));
    8486            return;
    8587        }
    86         getAffectedDataSet().getConflicts().remove(conflict);
     88        ds.getConflicts().remove(conflict);
    8789    }
    8890
  • trunk/src/org/openstreetmap/josm/command/conflict/ConflictResolveCommand.java

    r12672 r12718  
    66import java.util.Objects;
    77
     8import org.openstreetmap.josm.Main;
    89import org.openstreetmap.josm.command.Command;
    910import org.openstreetmap.josm.data.conflict.Conflict;
    1011import org.openstreetmap.josm.data.conflict.ConflictCollection;
    1112import org.openstreetmap.josm.data.osm.DataSet;
    12 import org.openstreetmap.josm.gui.MainApplication;
    1313import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1414import org.openstreetmap.josm.tools.Logging;
     
    2424public abstract class ConflictResolveCommand extends Command {
    2525    /** the list of resolved conflicts */
    26     private final ConflictCollection resolvedConflicts;
     26    private final ConflictCollection resolvedConflicts = new ConflictCollection();
    2727
    2828    /**
     
    3030     */
    3131    public ConflictResolveCommand() {
    32         super();
    33         resolvedConflicts = new ConflictCollection();
     32        // Do nothing
    3433    }
    3534
     
    3736     * Constructs a new {@code ConflictResolveCommand} in the context of a given data layer.
    3837     * @param layer the data layer. Must not be null.
     38     * @deprecated to be removed end of 2017. Use {@link #ConflictResolveCommand(DataSet)} instead
    3939     */
     40    @Deprecated
    4041    public ConflictResolveCommand(OsmDataLayer layer) {
    4142        super(layer);
    42         resolvedConflicts = new ConflictCollection();
     43    }
     44
     45    /**
     46     * Constructs a new {@code ConflictResolveCommand} in the context of a given data set.
     47     * @param ds the data set. Must not be null.
     48     */
     49    public ConflictResolveCommand(DataSet ds) {
     50        super(ds);
    4351    }
    4452
     
    5664    /**
    5765     * reconstitutes all remembered conflicts. Add the remembered conflicts to the
    58      * set of conflicts of the {@link OsmDataLayer} this command was applied to.
     66     * set of conflicts of the {@link DataSet} this command was applied to.
    5967     *
    6068     */
     
    7280        super.undoCommand();
    7381
    74         if (MainApplication.isDisplayingMapView()) {
    75             if (!MainApplication.getLayerManager().containsLayer(getLayer())) {
    76                 Logging.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more",
    77                         this.toString(),
    78                         getLayer().toString()
    79                 ));
    80                 return;
    81             }
     82        DataSet ds = getAffectedDataSet();
     83        if (!Main.main.containsDataSet(ds)) {
     84            Logging.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more",
     85                    this.toString(),
     86                    ds.getName()
     87            ));
     88            return;
     89        }
    8290
    83             MainApplication.getLayerManager().setActiveLayer(getLayer());
    84         }
     91        Main.main.setEditDataSet(ds);
    8592        reconstituteConflicts();
    8693    }
  • trunk/src/org/openstreetmap/josm/command/conflict/RelationMemberConflictResolverCommand.java

    r12672 r12718  
    1010import javax.swing.Icon;
    1111
     12import org.openstreetmap.josm.Main;
    1213import org.openstreetmap.josm.data.conflict.Conflict;
    1314import org.openstreetmap.josm.data.osm.DataSet;
     
    1516import org.openstreetmap.josm.data.osm.Relation;
    1617import org.openstreetmap.josm.data.osm.RelationMember;
    17 import org.openstreetmap.josm.gui.MainApplication;
    18 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1918import org.openstreetmap.josm.tools.ImageProvider;
    2019import org.openstreetmap.josm.tools.Logging;
     
    7271    @Override
    7372    public void undoCommand() {
    74         OsmDataLayer layer = getLayer();
    75         if (!MainApplication.getLayerManager().containsLayer(layer)) {
     73        DataSet editDs = getAffectedDataSet();
     74        if (!Main.main.containsDataSet(editDs)) {
    7675            Logging.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more",
    7776                    this.toString(),
    78                     layer.toString()
     77                    editDs.getName()
    7978            ));
    8079            return;
    8180        }
    8281
    83         MainApplication.getLayerManager().setActiveLayer(layer);
    84         DataSet editDs = MainApplication.getLayerManager().getEditDataSet();
     82        Main.main.setEditDataSet(editDs);
    8583
    8684        // restore the former state
Note: See TracChangeset for help on using the changeset viewer.