Changeset 15687 in josm for trunk/src


Ignore:
Timestamp:
2020-01-11T21:02:08+01:00 (5 years ago)
Author:
simon04
Message:

see #13901 - Tag2Link: add popup menu separator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/util/AbstractTag2LinkPopupListener.java

    r15673 r15687  
    22package org.openstreetmap.josm.gui.util;
    33
     4import java.awt.Component;
    45import java.util.ArrayList;
    56import java.util.List;
    67
    7 import javax.swing.JMenuItem;
    88import javax.swing.JPopupMenu;
    99import javax.swing.event.PopupMenuEvent;
     
    1717public abstract class AbstractTag2LinkPopupListener implements PopupMenuListener {
    1818
    19     private final List<JMenuItem> itemList;
     19    private final List<Component> itemList;
    2020
    2121    protected AbstractTag2LinkPopupListener() {
     
    3535
    3636    protected void addLinks(JPopupMenu popup, String key, String value) {
    37         Tag2Link.getLinksForTag(key, value, (name, url) -> itemList.add(popup.add(new OpenBrowserAction(name, url))));
     37        Tag2Link.getLinksForTag(key, value, (name, url) -> {
     38            if (itemList.isEmpty()) {
     39                itemList.add(popup.add(new JPopupMenu.Separator()));
     40            }
     41
     42            itemList.add(popup.add(new OpenBrowserAction(name, url)));
     43        });
    3844    }
    3945}
Note: See TracChangeset for help on using the changeset viewer.