From 946593fd8ea35eecc3611db33f4d77c15af4da8b Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Thu, 14 Jan 2021 07:26:05 -0700 Subject: [PATCH] Fix JOSM-20388, attempting to duplicate a MapWithAI layer Signed-off-by: Taylor Smock --- .../josm/plugins/mapwithai/backend/MapWithAILayer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAILayer.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAILayer.java index 94e8745d..0921f2f3 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAILayer.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAILayer.java @@ -37,6 +37,7 @@ import org.openstreetmap.josm.data.osm.Way; import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.gui.Notification; +import org.openstreetmap.josm.gui.dialogs.layer.DuplicateAction; import org.openstreetmap.josm.gui.layer.Layer; import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; @@ -131,8 +132,11 @@ public Object getInfoComponent() { @Override public Action[] getMenuEntries() { + Collection> forbiddenActions = Arrays.asList(LayerSaveAction.class, + LayerSaveAsAction.class, DuplicateAction.class, LayerGpxExportAction.class, + ConvertToGpxLayerAction.class); final List actions = Arrays.asList(super.getMenuEntries()).stream() - .filter(action -> !(action instanceof LayerSaveAction) && !(action instanceof LayerSaveAsAction)) + .filter(action -> forbiddenActions.stream().noneMatch(clazz -> clazz.isInstance(action))) .collect(Collectors.toCollection(ArrayList::new)); if (actions.isEmpty()) { actions.add(new ContinuousDownloadAction(this));