1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.conflict.pair;
|
---|
3 |
|
---|
4 | import javax.swing.JTable;
|
---|
5 | import javax.swing.ListSelectionModel;
|
---|
6 | import javax.swing.table.TableColumnModel;
|
---|
7 |
|
---|
8 | import org.openstreetmap.josm.command.conflict.ConflictResolveCommand;
|
---|
9 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
10 | import org.openstreetmap.josm.data.osm.PrimitiveId;
|
---|
11 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
12 | import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTable;
|
---|
13 | import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTableModel;
|
---|
14 |
|
---|
15 | public abstract class PairTable extends OsmPrimitivesTable {
|
---|
16 |
|
---|
17 | private final transient ListMergeModel<? extends PrimitiveId, ? extends ConflictResolveCommand> model;
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Constructs a new {@code PairTable}.
|
---|
21 | * @param name table name
|
---|
22 | * @param model merge model
|
---|
23 | * @param dm table model
|
---|
24 | * @param cm column model
|
---|
25 | * @param sm selection model
|
---|
26 | */
|
---|
27 | public PairTable(String name, ListMergeModel<? extends PrimitiveId, ? extends ConflictResolveCommand> model,
|
---|
28 | OsmPrimitivesTableModel dm, TableColumnModel cm, ListSelectionModel sm) {
|
---|
29 | super(dm, cm, sm);
|
---|
30 | this.model = model;
|
---|
31 | setName(name);
|
---|
32 | setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | public OsmPrimitive getPrimitiveInLayer(int row, OsmDataLayer layer) {
|
---|
37 | OsmPrimitive result = super.getPrimitiveInLayer(row, layer);
|
---|
38 | if (model != null && result != null && layer != null && result.getDataSet() != layer.data) {
|
---|
39 | result = model.getMyPrimitiveById(result);
|
---|
40 | }
|
---|
41 | return result;
|
---|
42 | }
|
---|
43 | }
|
---|