kopia lustrzana https://github.com/JOSM/MapWithAI
rodzic
3c6e69c631
commit
a181a4d446
|
@ -15,6 +15,7 @@ import org.openstreetmap.josm.data.osm.Way;
|
|||
import org.openstreetmap.josm.gui.MainApplication;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.commands.MergeDuplicateWays;
|
||||
import org.openstreetmap.josm.tools.Logging;
|
||||
import org.openstreetmap.josm.tools.Shortcut;
|
||||
|
||||
/**
|
||||
|
@ -37,16 +38,21 @@ public class MergeDuplicateWaysAction extends JosmAction {
|
|||
public void actionPerformed(ActionEvent e) {
|
||||
final List<Way> ways = new ArrayList<>(MainApplication.getLayerManager().getActiveDataSet().getSelectedWays());
|
||||
Command command = null;
|
||||
if (ways.size() == 2) {
|
||||
command = new MergeDuplicateWays(ways.get(0), ways.get(1));
|
||||
} else if (ways.size() == 1) {
|
||||
command = new MergeDuplicateWays(ways.get(0));
|
||||
} else if (ways.isEmpty()) {
|
||||
command = new MergeDuplicateWays(MainApplication.getLayerManager().getActiveDataSet());
|
||||
}
|
||||
if (command != null) {
|
||||
UndoRedoHandler.getInstance().add(command);
|
||||
}
|
||||
int i = 0;
|
||||
do {
|
||||
if (ways.size() == 2) {
|
||||
command = new MergeDuplicateWays(ways.get(0), ways.get(1));
|
||||
} else if (ways.size() == 1) {
|
||||
command = new MergeDuplicateWays(ways.get(0));
|
||||
} else if (ways.isEmpty()) {
|
||||
command = new MergeDuplicateWays(MainApplication.getLayerManager().getActiveDataSet());
|
||||
}
|
||||
if (command != null) {
|
||||
UndoRedoHandler.getInstance().add(command);
|
||||
i++;
|
||||
Logging.error(Integer.toString(i));
|
||||
}
|
||||
} while (command != null && i < 10);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.Set;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import org.openstreetmap.josm.command.ChangeCommand;
|
||||
import org.openstreetmap.josm.command.ChangePropertyCommand;
|
||||
import org.openstreetmap.josm.command.Command;
|
||||
import org.openstreetmap.josm.command.DeleteCommand;
|
||||
import org.openstreetmap.josm.command.SequenceCommand;
|
||||
|
@ -86,9 +85,7 @@ public class MergeDuplicateWays extends Command {
|
|||
|
||||
@Override
|
||||
public void undoCommand() {
|
||||
List<Command> reversedCommands = new ArrayList<>(commands);
|
||||
Collections.reverse(reversedCommands);
|
||||
for (final Command tCommand : reversedCommands) {
|
||||
for (final Command tCommand : commands) {
|
||||
tCommand.undoCommand();
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +209,6 @@ public class MergeDuplicateWays extends Command {
|
|||
if (newWay.getNodesCount() > 0) {
|
||||
commands.add(new DeleteCommand(way2));
|
||||
commands.add(new ChangeCommand(way1, newWay));
|
||||
commands.add(new ChangePropertyCommand(way1.getDataSet(), Collections.singleton(newWay), way2.getKeys()));
|
||||
}
|
||||
if (commands.contains(null)) {
|
||||
commands = commands.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
||||
|
|
Ładowanie…
Reference in New Issue