source: josm/trunk/src/org/openstreetmap/josm/corrector/TagCorrectionTableModel.java@ 732

Last change on this file since 732 was 732, checked in by framm, 16 years ago
  • fixed "override" bugs that made josm not compile
File size: 1.8 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 class TagCorrectionTableModel extends AbstractTableModel {
12
13 List<TagCorrection> tagCorrections;
14
15 private boolean[] apply;
16
17 public TagCorrectionTableModel(List<TagCorrection> tagCorrections) {
18 this.tagCorrections = tagCorrections;
19 apply = new boolean[this.tagCorrections.size()];
20 Arrays.fill(apply, true);
21 }
22
23 public int getColumnCount() {
24 return 5;
25 }
26
27 @Override public Class<?> getColumnClass(int columnIndex) {
28 if (columnIndex == 4)
29 return Boolean.class;
30 return String.class;
31 }
32
33 @Override public String getColumnName(int colIndex) {
34 switch (colIndex) {
35 case 0:
36 return tr("Old key");
37 case 1:
38 return tr("Old value");
39 case 2:
40 return tr("New key");
41 case 3:
42 return tr("New value");
43 case 4:
44 return tr("Apply?");
45 }
46 return null;
47 }
48
49 public int getRowCount() {
50 return tagCorrections.size();
51 }
52
53 public Object getValueAt(int rowIndex, int colIndex) {
54
55 TagCorrection tagCorrection = tagCorrections.get(rowIndex);
56
57 switch (colIndex) {
58 case 0:
59 return tagCorrection.oldKey;
60 case 1:
61 return tagCorrection.oldValue;
62 case 2:
63 return tagCorrection.newKey;
64 case 3:
65 return tagCorrection.newValue;
66 case 4:
67 return apply[rowIndex];
68 }
69 return null;
70 }
71
72 @Override public boolean isCellEditable(int rowIndex, int columnIndex) {
73 return columnIndex == 4;
74 }
75
76 @Override public void setValueAt(Object aValue, int rowIndex,
77 int columnIndex) {
78 if (columnIndex == 4 && aValue instanceof Boolean)
79 apply[rowIndex] = (Boolean)aValue;
80 }
81
82 public boolean getApply(int i) {
83 return apply[i];
84 }
85}
Note: See TracBrowser for help on using the repository browser.