source: josm/trunk/src/org/openstreetmap/josm/gui/history/DiffTableModel.java@ 7005

Last change on this file since 7005 was 7005, checked in by Don-vip, 10 years ago

see #8465 - use diamond operator where applicable

File size: 1.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.history;
3
4import java.util.ArrayList;
5import java.util.List;
6
7import javax.swing.table.AbstractTableModel;
8
9import 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 */
15class 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.