Add methods to prevent mass additions

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2019-12-30 08:27:06 -07:00
rodzic f96693e05a
commit 1568ee4ead
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
2 zmienionych plików z 13 dodań i 1 usunięć

Wyświetl plik

@ -16,6 +16,7 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import org.openstreetmap.josm.actions.ExpertToggleAction;
import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.DownloadPolicy;
@ -187,4 +188,15 @@ public class MapWithAILayer extends OsmDataLayer implements ActiveLayerChangeLis
super.onPostDownloadFromServer();
GetDataRunnable.cleanup(getDataSet(), bounds);
}
@Override
public void selectionChanged(SelectionChangeEvent event) {
final int maximumAdditionSelection = MapWithAIPreferenceHelper.getMaximumAddition();
if (maximumAdditionSelection < event.getSelection().size()
&& (MapWithAIPreferenceHelper.getMaximumAddition() != 0 || !ExpertToggleAction.isExpert())) {
getDataSet().setSelected(event.getSelection().stream().distinct().limit(maximumAdditionSelection)
.collect(Collectors.toList()));
}
super.selectionChanged(event);
}
}

Wyświetl plik

@ -113,7 +113,7 @@ public final class MapWithAIPreferenceHelper {
if ((mapWithAILayer != null) && (mapWithAILayer.getMaximumAddition() != null)) {
defaultReturn = mapWithAILayer.getMaximumAddition();
}
return defaultReturn;
return defaultReturn > DEFAULT_MAXIMUM_ADDITION * 10 ? DEFAULT_MAXIMUM_ADDITION * 10 : defaultReturn;
}
/**