001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.conflict.tags;
003
004import static org.openstreetmap.josm.tools.I18n.tr;
005
006import javax.swing.JTable;
007import javax.swing.ListSelectionModel;
008
009import org.openstreetmap.josm.gui.tagging.TagTableColumnModelBuilder;
010import org.openstreetmap.josm.gui.widgets.JosmComboBox;
011import org.openstreetmap.josm.gui.widgets.JosmTable;
012
013/**
014 * This table presents the tags that are conflicting to the user.
015 */
016public class TagConflictResolverTable extends JosmTable implements MultiValueCellEditor.NavigationListener {
017
018    /**
019     * Constructs a new {@code TagConflictResolverTable}.
020     * @param model table model
021     */
022    public TagConflictResolverTable(TagConflictResolverModel model) {
023        super(model, new TagTableColumnModelBuilder(new MultiValueCellRenderer(), "", tr("Key"), tr("Value"))
024                .setWidth(20, 0).setPreferredWidth(20, 0).setMaxWidth(30, 0)
025                .setCellEditor(new MultiValueCellEditor(), 2).build());
026
027        setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
028        setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
029        putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
030
031        installCustomNavigation(2);
032
033        ((MultiValueCellEditor) getColumnModel().getColumn(2).getCellEditor()).addNavigationListener(this);
034
035        setRowHeight((int) new JosmComboBox<String>().getPreferredSize().getHeight());
036    }
037
038    @Override
039    public void gotoNextDecision() {
040        selectNextColumnCellAction.actionPerformed(null);
041    }
042
043    @Override
044    public void gotoPreviousDecision() {
045        selectPreviousColumnCellAction.actionPerformed(null);
046    }
047}