Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.history;
|
---|
3 |
|
---|
4 | import java.util.ArrayList;
|
---|
5 | import java.util.List;
|
---|
6 |
|
---|
7 | import javax.swing.table.AbstractTableModel;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.gui.history.TwoColumnDiff.Item.DiffItemType;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * Simple model storing "diff cells" in a list. Could probably have
|
---|
13 | * used a {@link javax.swing.table.DefaultTableModel} instead.
|
---|
14 | */
|
---|
15 | class DiffTableModel extends AbstractTableModel {
|
---|
16 | private List<TwoColumnDiff.Item> rows;
|
---|
17 |
|
---|
18 | public void setRows(List<TwoColumnDiff.Item> rows) {
|
---|
19 | this.rows = rows;
|
---|
20 | }
|
---|
21 |
|
---|
22 | public DiffTableModel(List<TwoColumnDiff.Item> rows) {
|
---|
23 | this.rows = rows;
|
---|
24 | }
|
---|
25 | public DiffTableModel() {
|
---|
26 | this.rows = new ArrayList<>();
|
---|
27 | }
|
---|
28 | @Override
|
---|
29 | public int getRowCount() {
|
---|
30 | return rows.size();
|
---|
31 | }
|
---|
32 |
|
---|
33 | @Override
|
---|
34 | public int getColumnCount() {
|
---|
35 | return 1;
|
---|
36 | }
|
---|
37 |
|
---|
38 | @Override
|
---|
39 | public TwoColumnDiff.Item getValueAt(int rowIndex, int columnIndex) {
|
---|
40 | return rows.get(rowIndex);
|
---|
41 | }
|
---|
42 |
|
---|
43 | public int getFirstChange() {
|
---|
44 | for (int i=0; i<rows.size(); i++) {
|
---|
45 | if (rows.get(i).state != DiffItemType.SAME)
|
---|
46 | return i;
|
---|
47 | }
|
---|
48 | return -1;
|
---|
49 | }
|
---|
50 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.