Coverage Report - de.glossmaker.gui.ColumnModelListener
 
Classes in this File Line Coverage Branch Coverage Complexity
ColumnModelListener
0%
0/21
0%
0/6
1,5
 
 1  
 package de.glossmaker.gui;
 2  
 
 3  
 import java.util.Enumeration;
 4  
 
 5  
 import javax.swing.event.ChangeEvent;
 6  
 import javax.swing.event.ListSelectionEvent;
 7  
 import javax.swing.event.TableColumnModelEvent;
 8  
 import javax.swing.event.TableColumnModelListener;
 9  
 import javax.swing.table.DefaultTableColumnModel;
 10  
 import javax.swing.table.TableColumn;
 11  
 
 12  
 import de.glossmaker.gloss.datastructure.gui.Config;
 13  
 
 14  
 /**
 15  
  * This class listens to resize of the columns and the movement of columns.
 16  
  * 
 17  
  * @author Markus Flingelli
 18  
  *
 19  
  */
 20  
 public class ColumnModelListener implements TableColumnModelListener {
 21  0
         private String mKey = null;
 22  
 
 23  
         
 24  0
         public ColumnModelListener(String key, int size)  {
 25  0
                 mKey = key;
 26  0
                 Config.getInstance().addTable(key, size);
 27  0
         }
 28  
 
 29  
         public void columnMarginChanged(ChangeEvent event) {
 30  0
                 if (event.getSource() instanceof DefaultTableColumnModel) {
 31  0
                         DefaultTableColumnModel model = (DefaultTableColumnModel)event.getSource();
 32  0
                         Enumeration<TableColumn> elements = model.getColumns();
 33  0
                         int i = 0;
 34  0
                         while(elements.hasMoreElements()) {
 35  0
                                 TableColumn column = elements.nextElement();
 36  0
                                 Config.getInstance().setTableWidth(mKey, i, column.getWidth());
 37  0
                                 i++;
 38  0
                         }
 39  
                 }
 40  0
         }
 41  
 
 42  
         public void columnMoved(TableColumnModelEvent event) {
 43  0
                 if (event.getFromIndex() != event.getToIndex()) {
 44  0
                         Config.getInstance().moveColumn(mKey, event.getFromIndex(), event.getToIndex());
 45  
                 }
 46  0
         }
 47  
 
 48  0
         public void columnRemoved(TableColumnModelEvent event) {}
 49  
 
 50  0
         public void columnSelectionChanged(ListSelectionEvent event) {}
 51  
 
 52  0
         public void columnAdded(TableColumnModelEvent event) {}
 53  
 
 54  
 }