Changeset 15673 in josm


Ignore:
Timestamp:
2020-01-10T00:07:24+01:00 (3 months ago)
Author:
simon04
Message:

see #13901 - Reimplement Tag2Link in core

The plugin tag2link has been created and maintained by Don-vip.

Location:
trunk
Files:
4 added
4 edited

Legend:

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

    r15355 r15673  
    7878import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
    7979import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
     80import org.openstreetmap.josm.gui.util.AbstractTag2LinkPopupListener;
    8081import org.openstreetmap.josm.gui.util.HighlightHelper;
    8182import org.openstreetmap.josm.gui.widgets.CompileSearchTextDecorator;
     
    662663            }
    663664        });
     665
     666        popupMenuHandler.addListener(new AbstractTag2LinkPopupListener() {
     667            @Override
     668            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
     669                final IRelation<?> selection = getSelected();
     670                if (selection != null) {
     671                    selection.visitKeys((primitive, key, value) -> addLinks(popupMenu, key, value));
     672                }
     673            }
     674        });
    664675    }
    665676
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r15356 r15673  
    3636import javax.swing.event.ListSelectionEvent;
    3737import javax.swing.event.ListSelectionListener;
     38import javax.swing.event.PopupMenuEvent;
    3839
    3940import org.openstreetmap.josm.actions.AbstractSelectAction;
     
    7475import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
    7576import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
     77import org.openstreetmap.josm.gui.util.AbstractTag2LinkPopupListener;
    7678import org.openstreetmap.josm.gui.util.GuiHelper;
    7779import org.openstreetmap.josm.gui.util.HighlightHelper;
     
    231233        handler.addAction(actZoomToListSelection);
    232234        handler.addSeparator();
     235        handler.addListener(new AbstractTag2LinkPopupListener() {
     236            @Override
     237            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
     238                final Collection<OsmPrimitive> selection = getSelectedPrimitives();
     239                if (!selection.isEmpty()) {
     240                    selection.iterator().next().visitKeys((primitive, key, value) -> addLinks(popupMenu, key, value));
     241                }
     242            }
     243        });
    233244        return RelationPopupMenus.setupHandler(handler);
    234245    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r15670 r15673  
    4141import javax.swing.event.ListSelectionEvent;
    4242import javax.swing.event.ListSelectionListener;
     43import javax.swing.event.PopupMenuEvent;
    4344import javax.swing.event.RowSorterEvent;
    4445import javax.swing.event.RowSorterListener;
     
    9798import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler;
    9899import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType;
     100import org.openstreetmap.josm.gui.util.AbstractTag2LinkPopupListener;
    99101import org.openstreetmap.josm.gui.util.HighlightHelper;
    100102import org.openstreetmap.josm.gui.util.TableHelper;
     
    391393        membershipMenu.add(taginfoAction);
    392394
     395        membershipMenu.addPopupMenuListener(new AbstractTag2LinkPopupListener() {
     396            @Override
     397            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
     398                final IRelation<?> relation = getSelectedMembershipRelation();
     399                if (relation != null) {
     400                    relation.visitKeys((primitive, key, value) -> addLinks(membershipMenu, key, value));
     401                }
     402            }
     403        });
     404
    393405        membershipTable.addMouseListener(new PopupMenuLauncher(membershipMenu) {
    394406            @Override
     
    442454        tagMenu.add(helpTagAction);
    443455        tagMenu.add(taginfoAction);
     456        tagMenu.addPopupMenuListener(new AbstractTag2LinkPopupListener() {
     457            @Override
     458            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
     459                final Tags tags = getSelectedProperties();
     460                if (tags != null) {
     461                    tags.getValues().forEach(value -> addLinks(tagMenu, tags.getKey(), value));
     462                }
     463            }
     464        });
     465
    444466        tagTable.addMouseListener(new PopupMenuLauncher(tagMenu));
    445467    }
  • trunk/src/org/openstreetmap/josm/gui/history/OpenChangesetPopupMenu.java

    r15208 r15673  
    66import java.awt.Container;
    77import java.awt.Rectangle;
    8 import java.awt.event.ActionEvent;
    98import java.text.MessageFormat;
    109import java.util.Arrays;
     
    1211import java.util.Objects;
    1312
    14 import javax.swing.AbstractAction;
    1513import javax.swing.Action;
    1614import javax.swing.JComponent;
     
    2018import org.openstreetmap.josm.data.StructUtils.StructEntry;
    2119import org.openstreetmap.josm.data.osm.PrimitiveId;
     20import org.openstreetmap.josm.gui.util.OpenBrowserAction;
    2221import org.openstreetmap.josm.spi.preferences.Config;
    23 import org.openstreetmap.josm.tools.ImageProvider;
    24 import org.openstreetmap.josm.tools.OpenBrowser;
    2522
    2623/**
     
    107104    }
    108105
    109     static class OpenBrowserAction extends AbstractAction {
    110         final String url;
    111 
    112         OpenBrowserAction(String name, String url) {
    113             super(name);
    114             putValue(SHORT_DESCRIPTION, tr("Open {0}", url));
    115             new ImageProvider("help/internet").getResource().attachImageIcon(this, true);
    116             this.url = url;
    117         }
    118 
    119         @Override
    120         public void actionPerformed(ActionEvent e) {
    121             OpenBrowser.displayUrl(url);
    122         }
    123     }
    124106}
Note: See TracChangeset for help on using the changeset viewer.