Changeset 16456 in josm for trunk/src


Ignore:
Timestamp:
2020-05-17T22:19:47+02:00 (5 years ago)
Author:
simon04
Message:

fix #19161 - History/RelationMemberListViewer: show reversed diff indicator

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

Legend:

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

    r15772 r16456  
    1313import javax.swing.JTable;
    1414import javax.swing.ListSelectionModel;
    15 import javax.swing.event.TableModelEvent;
    16 import javax.swing.event.TableModelListener;
    1715
    1816import org.openstreetmap.josm.actions.AutoScaleAction;
     
    5654        final NodeListTableColumnModel columnModel = new NodeListTableColumnModel();
    5755        final JTable table = new JTable(tableModel, columnModel);
    58         tableModel.addTableModelListener(new ReversedChangeListener(table, columnModel));
     56        tableModel.addTableModelListener(new ReversedChangeListener(table, columnModel, tr("The nodes of this way are in reverse order")));
    5957        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    6058        selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel());
     
    6260        table.addMouseListener(new DoubleClickAdapter(table));
    6361        return table;
    64     }
    65 
    66     static final class ReversedChangeListener implements TableModelListener {
    67         private final NodeListTableColumnModel columnModel;
    68         private final JTable table;
    69         private Boolean reversed;
    70         private final String nonReversedText;
    71         private final String reversedText;
    72 
    73         ReversedChangeListener(JTable table, NodeListTableColumnModel columnModel) {
    74             this.columnModel = columnModel;
    75             this.table = table;
    76             nonReversedText = tr("Nodes") + (table.getFont().canDisplay('\u25bc') ? " \u25bc" : " (1-n)");
    77             reversedText = tr("Nodes") + (table.getFont().canDisplay('\u25b2') ? " \u25b2" : " (n-1)");
    78         }
    79 
    80         @Override
    81         public void tableChanged(TableModelEvent e) {
    82             if (e.getSource() instanceof DiffTableModel) {
    83                 final DiffTableModel mod = (DiffTableModel) e.getSource();
    84                 if (reversed == null || reversed != mod.isReversed()) {
    85                     reversed = mod.isReversed();
    86                     columnModel.getColumn(0).setHeaderValue(reversed ? reversedText : nonReversedText);
    87                     table.getTableHeader().setToolTipText(
    88                             reversed ? tr("The nodes of this way are in reverse order") : null);
    89                     table.getTableHeader().repaint();
    90                 }
    91             }
    92         }
    9362    }
    9463
  • trunk/src/org/openstreetmap/josm/gui/history/RelationMemberListViewer.java

    r15774 r16456  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.history;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    35
    46import java.awt.Rectangle;
     
    2123    @Override
    2224    protected JTable buildTable(PointInTimeType pointInTimeType) {
    23         JTable table = new JTable(
    24                 model.getRelationMemberTableModel(pointInTimeType),
    25                 new RelationMemberTableColumnModel());
     25        DiffTableModel tableModel = model.getRelationMemberTableModel(pointInTimeType);
     26        RelationMemberTableColumnModel columnModel = new RelationMemberTableColumnModel();
     27        JTable table = new JTable(tableModel, columnModel);
     28        tableModel.addTableModelListener(new ReversedChangeListener(
     29                table, columnModel, tr("The members of this relation are in reverse order")));
    2630        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    2731        selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel());
Note: See TracChangeset for help on using the changeset viewer.