View Javadoc
1   package org.vaadin.extension.gridscroll;
2   
3   import com.vaadin.ui.CustomComponent;
4   import com.vaadin.ui.Grid;
5   import com.vaadin.ui.Grid.Column;
6   
7   /**
8    * The GridColumnsResizedEvent when Grid's columns are being resized
9    * 
10   * @since 2.2.0
11   * 
12   * @see GridScrollExtension#addGridColumnsResizedListener(org.vaadin.extension.gridscroll.GridScrollExtension.GridColumnsResizedListener)
13   *
14   * @param <T> Bean type of the Grid
15   * 
16   * @author Tatu Lund
17   */
18  @SuppressWarnings("serial")
19  public class GridColumnsResizedEvent<T> extends CustomComponent.Event {
20  	private int column;
21  	private Grid<T> grid;
22  	
23  	public GridColumnsResizedEvent(Grid<T> source, int column) {
24  		super(source);
25  		grid = source;
26  	}
27  
28  	/**
29  	 * Return the index of the column that was adjusted by the user
30  	 * 
31  	 * @since 2.3.5
32  	 * 
33  	 * @return Index of the column, -1 if there was no user originated resizing
34  	 */
35  	public int getColumn() {
36  		int colIndex = column;
37  		for (Column<T, ?> col : grid.getColumns()) {
38  			if (col.isHidden()) colIndex++;
39  		}
40  		return colIndex;
41  	}
42  
43  }