Ignore:
Timestamp:
2013-05-13T03:10:05+02:00 (12 years ago)
Author:
Don-vip
Message:
  • Improve PopupMenuLauncher to automatically select JTable/JList/JTree line under cursor
  • Simplify all popup menus with this new feature
  • Remove custom popup menus in BoundingBoxSelection and BoundingBoxSelection to use default text field popup menus recently introduced
  • Fix EDT violations in changeset window
  • Make Autoscale actions publicly available in MainMenu
  • Add a new "Zoom to problem" mode in AutoScaleAction
  • Make "Zoom to problem" menu item in validator dialog use this new feature
  • Update enabled state of "Zoom to Conflict" and "Zoom to problem" against selection of conflict/validator dialog
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java

    r5622 r5958  
    66import java.awt.Component;
    77import java.awt.Dimension;
     8import java.awt.Point;
    89import java.awt.Rectangle;
    910import java.awt.event.ActionEvent;
    1011import java.awt.event.ItemEvent;
    1112import java.awt.event.ItemListener;
    12 import java.awt.event.MouseAdapter;
    1313import java.awt.event.MouseEvent;
    1414import java.util.Observable;
     
    3030import org.openstreetmap.josm.actions.AbstractInfoAction;
    3131import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive;
     32import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    3233import org.openstreetmap.josm.tools.ImageProvider;
    3334
     
    8586    }
    8687
    87     protected void showPopupMenu(MouseEvent evt) {
    88         HistoryBrowserModel.VersionTableModel model = getVersionTableModel();
    89         int row = rowAtPoint(evt.getPoint());
    90         if (row > -1 && !model.isLatest(row)) {
    91             HistoryOsmPrimitive primitive = model.getPrimitive(row);
    92             popupMenu.prepare(primitive);
    93             popupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
    94         }
    95     }
    96 
    97     class MouseListener extends MouseAdapter {
     88    class MouseListener extends PopupMenuLauncher {
     89        public MouseListener() {
     90            super(popupMenu);
     91        }
    9892        @Override
    9993        public void mousePressed(MouseEvent e) {
    100             if (!showPopup(e) && e.getButton() == MouseEvent.BUTTON1) {
     94            super.mousePressed(e);
     95            if (!e.isPopupTrigger() && e.getButton() == MouseEvent.BUTTON1) {
    10196                int row = rowAtPoint(e.getPoint());
    10297                int col = columnAtPoint(e.getPoint());
     
    108103        }
    109104        @Override
    110         public void mouseReleased(MouseEvent e) {
    111             showPopup(e);
    112         }
    113         private boolean showPopup(MouseEvent e) {
    114             if (e.isPopupTrigger()) {
    115                 showPopupMenu(e);
    116                 return true;
     105        protected int checkTableSelection(JTable table, Point p) {
     106            HistoryBrowserModel.VersionTableModel model = getVersionTableModel();
     107            int row = rowAtPoint(p);
     108            if (row > -1 && !model.isLatest(row)) {
     109                popupMenu.prepare(model.getPrimitive(row));
    117110            }
    118             return false;
     111            return row;
    119112        }
    120113    }
Note: See TracChangeset for help on using the changeset viewer.