diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/CreateConnectionsCommand.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/CreateConnectionsCommand.java index e1a9d6a..e56f058 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/CreateConnectionsCommand.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/CreateConnectionsCommand.java @@ -124,19 +124,10 @@ public class CreateConnectionsCommand extends Command { } } - Command permanentCommand = null; - if (permanent.size() == 1) { - permanentCommand = permanent.get(0); - } else if (!permanent.isEmpty()) { - permanentCommand = new SequenceCommand(getRealDescriptionText(), permanent); - } - - Command undoCommand = null; - if (undoable.size() == 1) { - undoCommand = undoable.get(0); - } else if (!undoable.isEmpty()) { - undoCommand = new SequenceCommand(getRealDescriptionText(), undoable); - } + Command permanentCommand = permanent.isEmpty() ? null + : SequenceCommand.wrapIfNeeded(getRealDescriptionText(), permanent); + Command undoCommand = undoable.isEmpty() ? null + : SequenceCommand.wrapIfNeeded(getRealDescriptionText(), undoable); return Arrays.asList(permanentCommand, undoCommand); } diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddCommand.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddCommand.java index e2882ad..d7e6b79 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddCommand.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddCommand.java @@ -99,7 +99,7 @@ public class MapWithAIAddCommand extends Command implements Runnable { final Command movePrimitivesCommand = new MovePrimitiveDataSetCommand(editable, mapWithAI, primitives, primitiveData); final Command createConnectionsCommand = createConnections(editable, primitiveData); - command = new SequenceCommand(getDescriptionText(), movePrimitivesCommand, + command = SequenceCommand.wrapIfNeeded(getDescriptionText(), movePrimitivesCommand, createConnectionsCommand); } GuiHelper.runInEDTAndWait(command::executeCommand);