source: josm/trunk/src/org/openstreetmap/josm/corrector/CorrectionTableModel.java@ 6388

Last change on this file since 6388 was 6084, checked in by bastiK, 11 years ago

see #8902 - add missing @Override annotations (patch by shinigami)

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.corrector;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.Arrays;
7import java.util.List;
8
9import javax.swing.table.AbstractTableModel;
10
11public abstract class CorrectionTableModel<C extends Correction> extends
12 AbstractTableModel {
13
14 private List<C> corrections;
15 private boolean[] apply;
16 private int applyColumn;
17
18 public CorrectionTableModel(List<C> corrections) {
19 super();
20 this.corrections = corrections;
21 apply = new boolean[this.corrections.size()];
22 Arrays.fill(apply, true);
23 applyColumn = getColumnCount() - 1;
24 }
25
26 @Override
27 abstract public int getColumnCount();
28
29 abstract protected boolean isBoldCell(int row, int column);
30 abstract public String getCorrectionColumnName(int colIndex);
31 abstract public Object getCorrectionValueAt(int rowIndex, int colIndex);
32
33 public List<C> getCorrections() {
34 return corrections;
35 }
36
37 public int getApplyColumn() {
38 return applyColumn;
39 }
40
41 public boolean getApply(int i) {
42 return apply[i];
43 }
44
45 @Override
46 public int getRowCount() {
47 return corrections.size();
48 }
49
50 @Override
51 public Class<?> getColumnClass(int columnIndex) {
52 if (columnIndex == applyColumn)
53 return Boolean.class;
54 return String.class;
55 }
56
57 @Override
58 public String getColumnName(int columnIndex) {
59 if (columnIndex == applyColumn)
60 return tr("Apply?");
61
62 return getCorrectionColumnName(columnIndex);
63 }
64
65 @Override
66 public boolean isCellEditable(int rowIndex, int columnIndex) {
67 return columnIndex == applyColumn;
68 }
69
70 @Override
71 public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
72 if (columnIndex == applyColumn && aValue instanceof Boolean)
73 apply[rowIndex] = (Boolean)aValue;
74 }
75
76 @Override
77 public Object getValueAt(int rowIndex, int colIndex) {
78 if (colIndex == applyColumn)
79 return apply[rowIndex];
80
81 return getCorrectionValueAt(rowIndex, colIndex);
82 }
83}
Note: See TracBrowser for help on using the repository browser.