Ignore:
Timestamp:
2020-06-11T22:48:46+02:00 (4 years ago)
Author:
simon04
Message:

fix #19330 - History browser: Add semantic check to select equivalent nodes/members on opposite sides

File:
1 edited

Legend:

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

    r16473 r16609  
    55import java.awt.Insets;
    66import java.awt.event.ActionEvent;
     7import java.util.function.BiPredicate;
     8import java.util.stream.IntStream;
    79
    810import javax.swing.AbstractAction;
     
    1012import javax.swing.JScrollPane;
    1113import javax.swing.JTable;
     14import javax.swing.ListSelectionModel;
    1215
    1316import org.openstreetmap.josm.actions.AutoScaleAction;
     
    9497    }
    9598
     99    /**
     100     * Enables semantic highlighting for the {@link org.openstreetmap.josm.data.StructUtils.SerializeOptions}
     101     * @param thisSelectionModel selection model
     102     * @param thisModel table model (corresponding to the selection model)
     103     * @param otherModel table model for the other point in time
     104     * @param isSemanticallyEquivalent predicate to determine whether the items should be highlighted
     105     */
     106    protected void enableSemanticSelectionSynchronization(ListSelectionModel thisSelectionModel,
     107                                                          DiffTableModel thisModel, DiffTableModel otherModel,
     108                                                          BiPredicate<TwoColumnDiff.Item, TwoColumnDiff.Item> isSemanticallyEquivalent) {
     109        selectionSynchronizer.setSelectionIndexMapper((selection, sourceSelectionModel) -> {
     110            DiffTableModel sourceModel = sourceSelectionModel == thisSelectionModel ? thisModel : otherModel;
     111            DiffTableModel destinationModel = sourceSelectionModel == thisSelectionModel ? otherModel : thisModel;
     112            return IntStream.range(0, destinationModel.getRowCount())
     113                    .filter(i -> isSemanticallyEquivalent.test(sourceModel.getValueAt(selection, 0), destinationModel.getValueAt(i, 0)));
     114        });
     115    }
     116
    96117    static class ListPopupMenu extends JPopupMenu {
    97118        private final ZoomToObjectAction zoomToObjectAction;
Note: See TracChangeset for help on using the changeset viewer.