Switch to edit layer when adding a feature

Signed-off-by: Taylor Smock <smocktaylor@gmail.com>
pull/1/head
Taylor Smock 2019-09-21 11:25:13 -06:00
rodzic 6bb35a5b26
commit 455edddab8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 9FDE4FFEF1C4CCB7
2 zmienionych plików z 24 dodań i 8 usunięć

Wyświetl plik

@ -19,6 +19,8 @@ import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
import org.openstreetmap.josm.data.osm.PrimitiveData;
import org.openstreetmap.josm.data.osm.Way;
import org.openstreetmap.josm.data.osm.visitor.MergeSourceBuildingVisitor;
import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
import org.openstreetmap.josm.plugins.rapid.RapiDPlugin;
import org.openstreetmap.josm.tools.Logging;
import org.openstreetmap.josm.tools.Utils;
@ -30,6 +32,17 @@ public class RapiDAddCommand extends Command {
AddPrimitivesCommand addPrimitivesCommand;
Collection<OsmPrimitive> modifiedPrimitives;
OsmDataLayer editLayer = null;
public RapiDAddCommand(RapiDLayer rapidLayer, OsmDataLayer editLayer, Collection<OsmPrimitive> selection) {
super(rapidLayer.getDataSet());
this.rapid = rapidLayer.getDataSet();
this.editable = editLayer.getDataSet();
this.primitives = selection;
this.editLayer = editLayer;
modifiedPrimitives = null;
}
/**
* Add primitives from RapiD to the OSM data layer
*
@ -61,6 +74,11 @@ public class RapiDAddCommand extends Command {
RapiDDataUtils.removePrimitivesFromDataSet(primitives);
rapid.lock();
}
if (editLayer != null) {
MainApplication.getLayerManager().setActiveLayer(editLayer);
editable.setSelected(
editable.getSelected().stream().filter(OsmPrimitive::isTagged).collect(Collectors.toSet()));
}
return true;
}

Wyświetl plik

@ -9,7 +9,6 @@ import java.util.List;
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.OsmPrimitive;
import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
@ -27,20 +26,19 @@ public class RapiDMoveAction extends JosmAction {
@Override
public void actionPerformed(ActionEvent event) {
for (RapiDLayer layer : MainApplication.getLayerManager().getLayersOfType(RapiDLayer.class)) {
for (RapiDLayer rapid : MainApplication.getLayerManager().getLayersOfType(RapiDLayer.class)) {
List<OsmDataLayer> osmLayers = MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class);
DataSet editData = null;
DataSet rapid = layer.getDataSet();
Collection<OsmPrimitive> selected = rapid.getSelected();
OsmDataLayer editLayer = null;
Collection<OsmPrimitive> selected = rapid.getDataSet().getSelected();
for (OsmDataLayer osmLayer : osmLayers) {
if (!osmLayer.isLocked() && osmLayer.isVisible() && osmLayer.isUploadable()
&& osmLayer.getClass().equals(OsmDataLayer.class)) {
editData = osmLayer.getDataSet();
editLayer = osmLayer;
break;
}
}
if (editData != null) {
RapiDAddCommand command = new RapiDAddCommand(rapid, editData, selected);
if (editLayer != null) {
RapiDAddCommand command = new RapiDAddCommand(rapid, editLayer, selected);
UndoRedoHandler.getInstance().add(command);
}
}