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.RoleCorrection; 009import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 010 011/** 012 * Role correction table model. 013 * @since 1001 014 */ 015public class RoleCorrectionTableModel extends CorrectionTableModel<RoleCorrection> { 016 017 /** 018 * Constructs a new {@code RoleCorrectionTableModel}. 019 * @param roleCorrections list of role corrections 020 */ 021 public RoleCorrectionTableModel(List<RoleCorrection> roleCorrections) { 022 super(roleCorrections); 023 } 024 025 @Override 026 public int getColumnCount() { 027 return 4; 028 } 029 030 @Override 031 public String getCorrectionColumnName(int colIndex) { 032 switch (colIndex) { 033 case 0: 034 return tr("Relation"); 035 case 1: 036 return tr("Old role"); 037 case 2: 038 return tr("New role"); 039 default: 040 return null; 041 } 042 } 043 044 @Override 045 public Object getCorrectionValueAt(int rowIndex, int colIndex) { 046 RoleCorrection roleCorrection = getCorrections().get(rowIndex); 047 048 switch (colIndex) { 049 case 0: 050 return roleCorrection.relation.getDisplayName(DefaultNameFormatter.getInstance()); 051 case 1: 052 return roleCorrection.member.getRole(); 053 case 2: 054 return roleCorrection.newRole; 055 default: 056 return null; 057 } 058 } 059 060 @Override 061 protected boolean isBoldCell(int row, int column) { 062 return column == 2; 063 } 064}