private TableColumnModel createColumnModel(ColumnDisplayDefinition[] colDefs) { // _colDefs = hdgs; TableColumnModel cm = new DefaultTableColumnModel(); _rntc = new RowNumberTableColumn(); for (int i = 0; i < colDefs.length; ++i) { ColumnDisplayDefinition colDef = colDefs[i]; int colWidth; if (null == colDef.getAbsoluteWidth()) { colWidth = colDef.getDisplayWidth() * _multiplier; if (colWidth > MAX_COLUMN_WIDTH * _multiplier) { colWidth = MAX_COLUMN_WIDTH * _multiplier; } else if (colWidth < MIN_COLUMN_WIDTH * _multiplier) { colWidth = MIN_COLUMN_WIDTH * _multiplier; } } else { colWidth = colDef.getAbsoluteWidth(); } ExtTableColumn col = new ExtTableColumn( i, colWidth, CellComponentFactory.getTableCellRenderer(colDefs[i]), null); String headerValue = colDef.getColumnHeading(); col.setHeaderValue(headerValue); col.setColumnDisplayDefinition(colDef); cm.addColumn(col); } return cm; }
@Override public void switchColumnHeader(ColumnHeaderDisplay columnHeaderDisplay) { for (Enumeration e = _table.getColumnModel().getColumns(); e.hasMoreElements(); ) { ExtTableColumn col = (ExtTableColumn) e.nextElement(); if (ColumnHeaderDisplay.COLUMN_NAME == columnHeaderDisplay) { col.setHeaderValue(col.getColumnDisplayDefinition().getColumnName()); } else if (ColumnHeaderDisplay.COLUMN_LABEL == columnHeaderDisplay) { col.setHeaderValue(col.getColumnDisplayDefinition().getLabel()); } } _table.getTableHeader().repaint(); }