kopia lustrzana https://github.com/JOSM/MapWithAI
Add dialog for when someone tries to add too many objects
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head v0.1.10
rodzic
f0898f5a5d
commit
d62089662c
|
@ -8,12 +8,15 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import org.openstreetmap.josm.actions.JosmAction;
|
||||
import org.openstreetmap.josm.data.UndoRedoHandler;
|
||||
import org.openstreetmap.josm.data.osm.DataSet;
|
||||
import org.openstreetmap.josm.data.osm.Node;
|
||||
import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
||||
import org.openstreetmap.josm.gui.MainApplication;
|
||||
import org.openstreetmap.josm.gui.Notification;
|
||||
import org.openstreetmap.josm.gui.layer.Layer;
|
||||
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||
|
@ -44,6 +47,9 @@ public class MapWithAIMoveAction extends JosmAction {
|
|||
.collect(Collectors.toList());
|
||||
ds.clearSelection(nodes);
|
||||
nodes.stream().map(Node::getReferrers).forEach(ds::addSelected);
|
||||
if (ds.getSelected().size() > maxAddition) {
|
||||
createMaxAddedDialog(maxAddition, ds.getSelected().size());
|
||||
}
|
||||
final Collection<OsmPrimitive> selected = maxAddition > 0
|
||||
? ds.getSelected().stream().limit(maxAddition).collect(Collectors.toList())
|
||||
: ds.getSelected();
|
||||
|
@ -64,6 +70,20 @@ public class MapWithAIMoveAction extends JosmAction {
|
|||
}
|
||||
}
|
||||
|
||||
private void createMaxAddedDialog(int maxAddition, int triedToAdd) {
|
||||
final Notification notification = new Notification();
|
||||
final StringBuilder message = new StringBuilder();
|
||||
message.append(MapWithAIPlugin.NAME);
|
||||
message.append(": ");
|
||||
message.append(tr("maximum additions per action are ")).append(maxAddition).append(", ");
|
||||
message.append(tr("tried to add ")).append(triedToAdd).append(".");
|
||||
notification.setContent(message.toString());
|
||||
notification.setDuration(Notification.TIME_LONG);
|
||||
notification.setIcon(JOptionPane.INFORMATION_MESSAGE);
|
||||
notification.show();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateEnabledState() {
|
||||
setEnabled(checkIfActionEnabled());
|
||||
|
|
Ładowanie…
Reference in New Issue