Changeset 5622 in josm


Ignore:
Timestamp:
2012-12-16T21:08:54+01:00 (7 years ago)
Author:
jttt
Message:

Compare selected version with previous after click on date on user in history dialog

Location:
trunk/src/org/openstreetmap/josm/gui/history
Files:
2 edited

Legend:

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

    r5495 r5622  
    3939public class VersionTable extends JTable implements Observer{
    4040    private VersionTablePopupMenu popupMenu;
     41    private final HistoryBrowserModel model;
    4142
    4243    protected void build() {
     
    4950        putClientProperty("terminateEditOnFocusLost", true);
    5051        popupMenu = new VersionTablePopupMenu();
    51         addMouseListener(new PopupMenuTrigger());
     52        addMouseListener(new MouseListener());
    5253        getModel().addTableModelListener(new TableModelListener() {
    5354            @Override
     
    6667        model.addObserver(this);
    6768        build();
     69        this.model = model;
    6870    }
    6971
     
    9395    }
    9496
    95     class PopupMenuTrigger extends MouseAdapter {
     97    class MouseListener extends MouseAdapter {
    9698        @Override
    9799        public void mousePressed(MouseEvent e) {
    98             showPopup(e);
     100            if (!showPopup(e) && e.getButton() == MouseEvent.BUTTON1) {
     101                int row = rowAtPoint(e.getPoint());
     102                int col = columnAtPoint(e.getPoint());
     103                if (row > 0 && (col == VersionTableColumnModel.COL_DATE || col == VersionTableColumnModel.COL_USER)) {
     104                    model.getVersionTableModel().setCurrentPointInTime(row);
     105                    model.getVersionTableModel().setReferencePointInTime(row - 1);
     106                }
     107            }
    99108        }
    100109        @Override
     
    102111            showPopup(e);
    103112        }
    104         private void showPopup(MouseEvent e) {
     113        private boolean showPopup(MouseEvent e) {
    105114            if (e.isPopupTrigger()) {
    106115                showPopupMenu(e);
     116                return true;
    107117            }
     118            return false;
    108119        }
    109120    }
     
    177188        }
    178189
     190        @Override
    179191        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    180192            if (value == null) return null;
     
    185197        }
    186198
     199        @Override
    187200        public Object getCellEditorValue() {
    188201            btn.removeItemListener(this);
     
    192205        public void itemStateChanged(ItemEvent e) {
    193206            fireEditingStopped();
    194         }
    195     }
    196 
    197     public static class LabelRenderer implements TableCellRenderer {
    198         public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) {
    199             return (Component) value;
    200207        }
    201208    }
  • trunk/src/org/openstreetmap/josm/gui/history/VersionTableColumnModel.java

    r5495 r5622  
    1414 */
    1515public class VersionTableColumnModel extends DefaultTableColumnModel {
     16
     17    public static final int COL_VERSION = 0;
     18    public static final int COL_REFERENCE = 1;
     19    public static final int COL_CURRENT = 2;
     20    public static final int COL_DATE = 3;
     21    public static final int COL_USER = 4;
     22
    1623    protected void createColumns() {
    1724        TableColumn col = null;
Note: See TracChangeset for help on using the changeset viewer.