001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.dialogs.relation;
003
004import static org.openstreetmap.josm.tools.I18n.tr;
005
006import javax.swing.table.DefaultTableColumnModel;
007import javax.swing.table.TableColumn;
008
009import org.openstreetmap.josm.data.osm.DataSet;
010import org.openstreetmap.josm.data.osm.Relation;
011
012/**
013 * This is the column model for the {@link MemberTable}
014 */
015public class MemberTableColumnModel extends DefaultTableColumnModel {
016
017    /**
018     * Constructs a new {@code MemberTableColumnModel}.
019     * @param ds the data set. Must not be null
020     * @param relation the relation. Can be null
021     */
022    public MemberTableColumnModel(DataSet ds, Relation relation) {
023        TableColumn col = null;
024
025        // column 0 - the member role
026        col = new TableColumn(0);
027        col.setHeaderValue(tr("Role"));
028        col.setResizable(true);
029        col.setPreferredWidth(100);
030        col.setCellRenderer(new MemberTableRoleCellRenderer());
031        col.setCellEditor(new MemberRoleCellEditor(ds, relation));
032        addColumn(col);
033
034        // column 1 - the member
035        col = new TableColumn(1);
036        col.setHeaderValue(tr("Refers to"));
037        col.setResizable(true);
038        col.setPreferredWidth(300);
039        col.setCellRenderer(new MemberTableMemberCellRenderer());
040        addColumn(col);
041
042        // column 2 -
043        col = new TableColumn(2);
044        col.setHeaderValue("");
045        col.setResizable(false);
046        col.setPreferredWidth(20);
047        col.setCellRenderer(new MemberTableLinkedCellRenderer());
048        addColumn(col);
049    }
050}