001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.correction;
003
004import static org.openstreetmap.josm.tools.I18n.tr;
005
006import java.util.List;
007
008import org.openstreetmap.josm.data.correction.TagCorrection;
009
010/**
011 * Tag correction table model.
012 * @since 729
013 */
014public class TagCorrectionTableModel extends CorrectionTableModel<TagCorrection> {
015
016    /**
017     * Constructs a new {@code TagCorrectionTableModel}.
018     * @param tagCorrections list of tag corrections
019     */
020    public TagCorrectionTableModel(List<TagCorrection> tagCorrections) {
021        super(tagCorrections);
022    }
023
024    @Override
025    public int getColumnCount() {
026        return 5;
027    }
028
029    @Override
030    public String getCorrectionColumnName(int colIndex) {
031        switch (colIndex) {
032        case 0:
033            return tr("Old key");
034        case 1:
035            return tr("Old value");
036        case 2:
037            return tr("New key");
038        case 3:
039            return tr("New value");
040        default:
041            return null;
042        }
043    }
044
045    @Override
046    public Object getCorrectionValueAt(int rowIndex, int colIndex) {
047        TagCorrection tagCorrection = getCorrections().get(rowIndex);
048
049        switch (colIndex) {
050        case 0:
051            return tagCorrection.oldKey;
052        case 1:
053            return tagCorrection.oldValue;
054        case 2:
055            return tagCorrection.newKey;
056        case 3:
057            return tagCorrection.newValue;
058        default:
059            return null;
060        }
061    }
062
063    @Override
064    protected boolean isBoldCell(int row, int column) {
065        TagCorrection tagCorrection = getCorrections().get(row);
066        return (column == 2 && tagCorrection.isKeyChanged())
067            || (column == 3 && tagCorrection.isValueChanged());
068    }
069}