Changeset 5958 in josm for trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java
- Timestamp:
- 2013-05-13T03:10:05+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java
r5266 r5958 29 29 import org.openstreetmap.josm.data.osm.history.HistoryDataSet; 30 30 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 31 import org.openstreetmap.josm.gui.util.GuiHelper; 32 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; 31 33 import org.openstreetmap.josm.tools.ImageProvider; 32 34 … … 66 68 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 67 69 selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel()); 68 table.addMouseListener(new PopupMenuLauncher(table));70 table.addMouseListener(new InternalPopupMenuLauncher()); 69 71 table.addMouseListener(new DoubleClickAdapter(table)); 70 72 return table; … … 79 81 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 80 82 selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel()); 81 table.addMouseListener(new PopupMenuLauncher(table));83 table.addMouseListener(new InternalPopupMenuLauncher()); 82 84 table.addMouseListener(new DoubleClickAdapter(table)); 83 85 return table; … … 115 117 selectionSynchronizer = new SelectionSynchronizer(); 116 118 119 popupMenu = new NodeListPopupMenu(); 120 117 121 // --------------------------- 118 122 gc.gridx = 0; … … 135 139 gc.anchor = GridBagConstraints.NORTHWEST; 136 140 add(embeddInScrollPane(buildCurrentNodeListTable()),gc); 137 138 popupMenu = new NodeListPopupMenu();139 141 } 140 142 … … 172 174 173 175 static class NodeListPopupMenu extends JPopupMenu { 174 private ZoomToNodeAction zoomToNodeAction;175 private ShowHistoryAction showHistoryAction;176 private final ZoomToNodeAction zoomToNodeAction; 177 private final ShowHistoryAction showHistoryAction; 176 178 177 179 public NodeListPopupMenu() { … … 262 264 Runnable r = new Runnable() { 263 265 public void run() { 264 History h = HistoryDataSet.getInstance().getHistory(primitiveId);266 final History h = HistoryDataSet.getInstance().getHistory(primitiveId); 265 267 if (h == null) 266 268 return; 267 HistoryBrowserDialogManager.getInstance().show(h); 269 GuiHelper.runInEDT(new Runnable() { 270 @Override public void run() { 271 HistoryBrowserDialogManager.getInstance().show(h); 272 } 273 }); 268 274 } 269 275 }; … … 283 289 } 284 290 285 class PopupMenuLauncher extends MouseAdapter { 286 private JTable table; 287 288 public PopupMenuLauncher(JTable table) { 289 this.table = table; 290 } 291 292 @Override 293 public void mousePressed(MouseEvent e) { 294 showPopup(e); 295 } 296 297 @Override 298 public void mouseReleased(MouseEvent e) { 299 showPopup(e); 300 } 301 302 private void showPopup(MouseEvent e) { 303 if (!e.isPopupTrigger()) return; 304 Point p = e.getPoint(); 305 int row = table.rowAtPoint(p); 306 307 PrimitiveId pid = primitiveIdAtRow(table.getModel(), row); 308 if (pid == null) 309 return; 310 popupMenu.prepare(pid); 311 popupMenu.show(e.getComponent(), e.getX(), e.getY()); 291 class InternalPopupMenuLauncher extends PopupMenuLauncher { 292 public InternalPopupMenuLauncher() { 293 super(popupMenu); 294 } 295 296 @Override protected int checkTableSelection(JTable table, Point p) { 297 int row = super.checkTableSelection(table, p); 298 popupMenu.prepare(primitiveIdAtRow(table.getModel(), row)); 299 return row; 312 300 } 313 301 }
Note:
See TracChangeset
for help on using the changeset viewer.