1 13 14 package org.eclipse.jface.layout; 15 16 import org.eclipse.jface.viewers.ColumnLayoutData; 17 import org.eclipse.jface.viewers.ColumnPixelData; 18 import org.eclipse.swt.widgets.Composite; 19 import org.eclipse.swt.widgets.Layout; 20 import org.eclipse.swt.widgets.Scrollable; 21 import org.eclipse.swt.widgets.Table; 22 import org.eclipse.swt.widgets.TableColumn; 23 import org.eclipse.swt.widgets.Widget; 24 25 37 public class TableColumnLayout extends AbstractColumnLayout { 38 39 44 int getColumnCount(Scrollable tableTree) { 45 return ((Table) tableTree).getColumnCount(); 46 } 47 48 54 void setColumnWidths(Scrollable tableTree, int[] widths) { 55 TableColumn[] columns = ((Table) tableTree).getColumns(); 56 for (int i = 0; i < widths.length; i++) { 57 columns[i].setWidth(widths[i]); 58 } 59 } 60 61 66 ColumnLayoutData getLayoutData(Scrollable tableTree, int columnIndex) { 67 TableColumn column = ((Table) tableTree).getColumn(columnIndex); 68 return (ColumnLayoutData) column.getData(LAYOUT_DATA); 69 } 70 71 Composite getComposite(Widget column) { 72 return ((TableColumn) column).getParent().getParent(); 73 } 74 75 78 void updateColumnData(Widget column) { 79 TableColumn tColumn = (TableColumn) column; 80 Table t = tColumn.getParent(); 81 82 if( ! IS_GTK || t.getColumn(t.getColumnCount()-1) != tColumn ){ 83 tColumn.setData(LAYOUT_DATA,new ColumnPixelData(tColumn.getWidth())); 84 layout(t.getParent(), true); 85 } 86 } 87 } 88 | Popular Tags |