Coverage Report - de.glossmaker.gui.bibtex.NavigatableTable
 
Classes in this File Line Coverage Branch Coverage Complexity
NavigatableTable
0%
0/19
0%
0/12
3
 
 1  
 package de.glossmaker.gui.bibtex;
 2  
 
 3  
 import java.awt.Component;
 4  
 
 5  
 import javax.swing.JTable;
 6  
 import javax.swing.JTextField;
 7  
 import javax.swing.table.TableModel;
 8  
 
 9  
 @SuppressWarnings("serial")
 10  
 public class NavigatableTable extends JTable {
 11  0
         private int mOldRow = -1;
 12  
         
 13  
         public NavigatableTable() {
 14  0
                 super();
 15  0
         }
 16  
 
 17  
         public NavigatableTable(TableModel tableModel) {
 18  0
                 super(tableModel);
 19  0
         }
 20  
         
 21  
 
 22  
         @Override
 23  
         public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
 24  0
                 int row = rowIndex;
 25  0
                 int col = columnIndex;
 26  
                 while (isCellEditable(row, col) == false && 
 27  
                                 row < getModel().getRowCount() &&
 28  0
                                 row > 1) {
 29  0
                         if (mOldRow > rowIndex) {
 30  0
                                 row--;
 31  
                         } else {
 32  0
                                 row++;
 33  
                         }
 34  
                 }
 35  0
                 super.changeSelection(row, col, toggle, extend);
 36  
                 
 37  0
                 if (editCellAt(row, col)) {
 38  0
                         Component component = getEditorComponent();
 39  0
                         component.requestFocusInWindow();
 40  
                         
 41  0
                         if (component instanceof JTextField) {
 42  0
                                 ((JTextField)component).selectAll();
 43  
                         } 
 44  
             }
 45  0
                 mOldRow = row;
 46  0
         }
 47  
         
 48  
         
 49  
 }