Attempt to fix an issue where an empty selection is attempted to be changed

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2020-04-06 18:32:25 -06:00
rodzic 34fc6c35f3
commit 6677610a8f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
1 zmienionych plików z 19 dodań i 13 usunięć

Wyświetl plik

@ -110,19 +110,25 @@ public class MovePrimitiveDataSetCommand extends Command {
List<Command> removeKeyCommand = new ArrayList<>();
Set<OsmPrimitive> fullSelection = new HashSet<>();
MapWithAIDataUtils.addPrimitivesToCollection(fullSelection, selection);
CreateConnectionsCommand.getConflationCommands().forEach(clazz -> {
try {
removeKeyCommand.add(new ChangePropertyCommand(fullSelection,
clazz.getConstructor(DataSet.class).newInstance(from).getKey(), null));
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
Logging.error(e);
}
});
SequenceCommand sequence = new SequenceCommand("Temporary Command", removeKeyCommand);
sequence.executeCommand(); // This *must* be executed for the delete command to get everything.
commands.add(DeleteCommand.delete(selection, true, true));
sequence.undoCommand();
if (!fullSelection.isEmpty()) {
CreateConnectionsCommand.getConflationCommands().forEach(clazz -> {
try {
removeKeyCommand.add(new ChangePropertyCommand(fullSelection,
clazz.getConstructor(DataSet.class).newInstance(from).getKey(), null));
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
Logging.error(e);
}
});
}
if (!removeKeyCommand.isEmpty()) {
SequenceCommand sequence = new SequenceCommand("Temporary Command", removeKeyCommand);
sequence.executeCommand(); // This *must* be executed for the delete command to get everything.
commands.add(DeleteCommand.delete(selection, true, true));
sequence.undoCommand();
} else {
commands.add(DeleteCommand.delete(selection, true, true));
}
return new SequenceCommand(trn("Move {0} OSM Primitive between data sets",
"Move {0} OSM Primitives between data sets", selection.size(), selection.size()), commands);