Changeset 14713 in josm for trunk/src/org
- Timestamp:
- 2019-01-20T21:35:58+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java
r14277 r14713 9 9 import java.awt.Dialog; 10 10 import java.awt.FlowLayout; 11 import java.awt.Point; 11 12 import java.awt.event.ActionEvent; 12 import java.awt.event.MouseAdapter;13 13 import java.awt.event.MouseEvent; 14 14 import java.io.IOException; 15 15 import java.net.HttpURLConnection; 16 import java.util.Arrays; 16 17 import java.util.HashSet; 17 18 import java.util.Iterator; … … 19 20 import java.util.Set; 20 21 import java.util.Stack; 22 import java.util.stream.Collectors; 21 23 22 24 import javax.swing.AbstractAction; … … 24 26 import javax.swing.JOptionPane; 25 27 import javax.swing.JPanel; 28 import javax.swing.JPopupMenu; 26 29 import javax.swing.JScrollPane; 30 import javax.swing.JTree; 27 31 import javax.swing.SwingUtilities; 28 32 import javax.swing.event.TreeSelectionEvent; … … 33 37 import org.openstreetmap.josm.data.osm.DataSetMerger; 34 38 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 39 import org.openstreetmap.josm.data.osm.OsmPrimitive; 35 40 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 36 41 import org.openstreetmap.josm.data.osm.Relation; … … 39 44 import org.openstreetmap.josm.gui.MainApplication; 40 45 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 46 import org.openstreetmap.josm.gui.PopupMenuHandler; 41 47 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 42 48 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 43 49 import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor; 50 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; 44 51 import org.openstreetmap.josm.io.OsmApi; 45 52 import org.openstreetmap.josm.io.OsmApiException; … … 88 95 add(pane, BorderLayout.CENTER); 89 96 97 final JPopupMenu popupMenu = new JPopupMenu(); 98 final PopupMenuHandler popupMenuHandler = new PopupMenuHandler(popupMenu); 99 RelationPopupMenus.setupHandler(popupMenuHandler); 100 90 101 add(buildButtonPanel(), BorderLayout.SOUTH); 91 102 childTree.setToggleClickCount(0); 92 childTree.addMouseListener(new MouseAdapter() {103 childTree.addMouseListener(new PopupMenuLauncher(popupMenu) { 93 104 @Override 94 105 public void mouseClicked(MouseEvent e) { … … 103 114 } 104 115 } 116 } 117 118 @Override 119 protected TreePath checkTreeSelection(JTree tree, Point p) { 120 final TreePath treeSelection = super.checkTreeSelection(tree, p); 121 final TreePath[] selectionPaths = tree.getSelectionPaths(); 122 if (selectionPaths == null) { 123 return treeSelection; 124 } 125 final List<OsmPrimitive> relations = Arrays.stream(selectionPaths) 126 .map(TreePath::getLastPathComponent) 127 .map(OsmPrimitive.class::cast) 128 .collect(Collectors.toList()); 129 popupMenuHandler.setPrimitives(relations); 130 return treeSelection; 105 131 } 106 132 });
Note:
See TracChangeset
for help on using the changeset viewer.