kopia lustrzana https://github.com/JOSM/MapWithAI
Only enable add action when in RapiDLayer and a Primitive is selected
Signed-off-by: Taylor Smock <smocktaylor@gmail.com>pull/1/head
rodzic
455edddab8
commit
a4c446d46a
|
@ -11,6 +11,7 @@ import org.openstreetmap.josm.actions.JosmAction;
|
|||
import org.openstreetmap.josm.data.UndoRedoHandler;
|
||||
import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
||||
import org.openstreetmap.josm.gui.MainApplication;
|
||||
import org.openstreetmap.josm.gui.layer.Layer;
|
||||
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||
import org.openstreetmap.josm.plugins.rapid.RapiDPlugin;
|
||||
import org.openstreetmap.josm.tools.Shortcut;
|
||||
|
@ -43,4 +44,28 @@ public class RapiDMoveAction extends JosmAction {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateEnabledState() {
|
||||
setEnabled(checkIfActionEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
|
||||
if (selection == null || selection.isEmpty()) {
|
||||
setEnabled(false);
|
||||
} else {
|
||||
setEnabled(checkIfActionEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkIfActionEnabled() {
|
||||
Layer active = getLayerManager().getActiveLayer();
|
||||
if (active instanceof RapiDLayer) {
|
||||
RapiDLayer rapid = (RapiDLayer) active;
|
||||
Collection<OsmPrimitive> selection = rapid.getDataSet().getAllSelected();
|
||||
return (selection != null && !selection.isEmpty());
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue