Lower maximum maxAdd and only allow 0 for infinite when expert

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2019-12-24 16:01:50 -07:00
rodzic f6f87bcea3
commit e24709a279
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
2 zmienionych plików z 7 dodań i 4 usunięć

Wyświetl plik

@ -54,7 +54,7 @@ public class MapWithAIPreferences implements SubPreferenceSetting {
public MapWithAIPreferences() { public MapWithAIPreferences() {
switchLayerCheckBox = new JCheckBox(); switchLayerCheckBox = new JCheckBox();
maximumAdditionSpinner = new JSpinner( maximumAdditionSpinner = new JSpinner(
new SpinnerNumberModel(MapWithAIPreferenceHelper.getMaximumAddition(), 0, 100, 1)); new SpinnerNumberModel(MapWithAIPreferenceHelper.getMaximumAddition(), 0, 50, 1));
mergeBuildingAddressCheckBox = new JCheckBox(); mergeBuildingAddressCheckBox = new JCheckBox();
replacementTableDisplayData = new ArrayList<>(); replacementTableDisplayData = new ArrayList<>();
fillReplacementTagDisplayData(replacementTableDisplayData); fillReplacementTagDisplayData(replacementTableDisplayData);

Wyświetl plik

@ -13,6 +13,7 @@ import java.util.stream.Collectors;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import org.openstreetmap.josm.actions.ExpertToggleAction;
import org.openstreetmap.josm.actions.JosmAction; import org.openstreetmap.josm.actions.JosmAction;
import org.openstreetmap.josm.data.UndoRedoHandler; import org.openstreetmap.josm.data.UndoRedoHandler;
import org.openstreetmap.josm.data.osm.DataSet; import org.openstreetmap.josm.data.osm.DataSet;
@ -46,7 +47,7 @@ public class MapWithAIMoveAction extends JosmAction {
int modifier = Shortcut.SHIFT; int modifier = Shortcut.SHIFT;
final String shortText = "data:mapwithaiadd"; final String shortText = "data:mapwithaiadd";
final Optional<Shortcut> shortCut = Shortcut.findShortcut(key, InputEvent.SHIFT_DOWN_MASK); // Shortcut.SHIFT final Optional<Shortcut> shortCut = Shortcut.findShortcut(key, InputEvent.SHIFT_DOWN_MASK); // Shortcut.SHIFT
// maps to // maps to
// KeyEvent.SHIFT_DOWN_MASK // KeyEvent.SHIFT_DOWN_MASK
if (shortCut.isPresent() && !shortText.equals(shortCut.get().getShortText())) { if (shortCut.isPresent() && !shortText.equals(shortCut.get().getShortText())) {
key = KeyEvent.VK_C; key = KeyEvent.VK_C;
@ -70,7 +71,7 @@ public class MapWithAIMoveAction extends JosmAction {
} }
final Collection<OsmPrimitive> selected = limitCollection(ds, maxAddition); final Collection<OsmPrimitive> selected = limitCollection(ds, maxAddition);
final OsmDataLayer editLayer = getOsmDataLayer(); final OsmDataLayer editLayer = getOsmDataLayer();
if (editLayer != null) { if (editLayer != null && !selected.isEmpty()) {
final MapWithAIAddCommand command = new MapWithAIAddCommand(mapWithAI, editLayer, selected); final MapWithAIAddCommand command = new MapWithAIAddCommand(mapWithAI, editLayer, selected);
UndoRedoHandler.getInstance().add(command); UndoRedoHandler.getInstance().add(command);
if (MapWithAIPreferenceHelper.isSwitchLayers()) { if (MapWithAIPreferenceHelper.isSwitchLayers()) {
@ -81,7 +82,9 @@ public class MapWithAIMoveAction extends JosmAction {
} }
private static Collection<OsmPrimitive> limitCollection(DataSet ds, int maxSize) { private static Collection<OsmPrimitive> limitCollection(DataSet ds, int maxSize) {
return maxSize > 0 ? ds.getSelected().stream().limit(maxSize).collect(Collectors.toList()) : ds.getSelected(); return (maxSize > 0 || !ExpertToggleAction.isExpert())
? ds.getSelected().stream().limit(maxSize).collect(Collectors.toList())
: ds.getSelected();
} }
private static OsmDataLayer getOsmDataLayer() { private static OsmDataLayer getOsmDataLayer() {