kopia lustrzana https://github.com/JOSM/MapWithAI
Add methods to prevent mass additions
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
f96693e05a
commit
1568ee4ead
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Ładowanie…
Reference in New Issue