diff --git a/src/org/openstreetmap/josm/gui/dialogs/LayerListPopup.java b/src/org/openstreetmap/josm/gui/dialogs/LayerListPopup.java
index 68d3b77a8..a9a38a30c 100644
|
a
|
b
|
import java.util.ArrayList;
|
| 11 | 11 | import java.util.Arrays; |
| 12 | 12 | import java.util.Collections; |
| 13 | 13 | import java.util.List; |
| | 14 | import java.util.stream.Collectors; |
| | 15 | import java.util.stream.Stream; |
| 14 | 16 | |
| 15 | 17 | import javax.swing.AbstractAction; |
| 16 | 18 | import javax.swing.Action; |
| … |
… |
public class LayerListPopup extends JPopupMenu {
|
| 81 | 83 | List<Action> actions; |
| 82 | 84 | if (selectedLayers.size() == 1) { |
| 83 | 85 | Action[] entries = selectedLayers.get(0).getMenuEntries(); |
| 84 | | actions = entries != null ? Arrays.asList(entries) : Collections.emptyList(); |
| | 86 | // Since we may add to the array later, we cannot use Arrays.asList -- it prohibits the use of `add` or `remove`. |
| | 87 | actions = entries != null ? Stream.of(entries).collect(Collectors.toCollection(ArrayList::new)) : Collections.emptyList(); |
| 85 | 88 | } else { |
| 86 | 89 | // Very simple algorithm - first selected layer has actions order as in getMenuEntries, actions from other layers go to the end |
| 87 | 90 | actions = new ArrayList<>(); |