Changeset 17998 in josm for trunk/src/org


Ignore:
Timestamp:
2021-07-11T04:31:05+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #20950 - UnsupportedOperationException when right-clicking on an MVT Layer in non-expert mode (patch by taylor.smock)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListPopup.java

    r14153 r17998  
    22package org.openstreetmap.josm.gui.dialogs;
    33
     4import static java.util.Collections.emptyList;
     5import static java.util.stream.Collectors.toCollection;
    46import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    57import static org.openstreetmap.josm.tools.I18n.tr;
     
    911import java.awt.event.ActionEvent;
    1012import java.util.ArrayList;
    11 import java.util.Arrays;
    12 import java.util.Collections;
    1313import java.util.List;
     14import java.util.stream.Stream;
    1415
    1516import javax.swing.AbstractAction;
     
    8283        if (selectedLayers.size() == 1) {
    8384            Action[] entries = selectedLayers.get(0).getMenuEntries();
    84             actions = entries != null ? Arrays.asList(entries) : Collections.emptyList();
     85            // Since we may add to the array later, we cannot use Arrays.asList -- it prohibits the use of `add` or `remove`.
     86            actions = entries != null ? Stream.of(entries).collect(toCollection(ArrayList::new)) : emptyList();
    8587        } else {
    8688            // Very simple algorithm - first selected layer has actions order as in getMenuEntries, actions from other layers go to the end
Note: See TracChangeset for help on using the changeset viewer.