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 013public class TagConflictResolverTable extends JosmTable implements MultiValueCellEditor.NavigationListener { 014 015 /** 016 * Constructs a new {@code TagConflictResolverTable}. 017 * @param model table model 018 */ 019 public TagConflictResolverTable(TagConflictResolverModel model) { 020 super(model, new TagTableColumnModelBuilder(new MultiValueCellRenderer(), "", tr("Key"), tr("Value")) 021 .setWidth(20, 0).setPreferredWidth(20, 0).setMaxWidth(30, 0) 022 .setCellEditor(new MultiValueCellEditor(), 2).build()); 023 024 setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); 025 setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 026 putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); 027 028 installCustomNavigation(2); 029 030 ((MultiValueCellEditor) getColumnModel().getColumn(2).getCellEditor()).addNavigationListener(this); 031 032 setRowHeight((int) new JosmComboBox<String>().getPreferredSize().getHeight()); 033 } 034 035 @Override 036 public void gotoNextDecision() { 037 selectNextColumnCellAction.actionPerformed(null); 038 } 039 040 @Override 041 public void gotoPreviousDecision() { 042 selectPreviousColumnCellAction.actionPerformed(null); 043 } 044}