public int convertColumnIndexToModel(int viewColumnIndex) { if (viewColumnIndex < 0) { return viewColumnIndex; } return getColumnModel().getColumn(viewColumnIndex).getModelIndex(); }
private static int columnInView(STable table, int column) { int viewColumn = 0; for (int i=0; i < column; i++) { STableColumn tableColumn = table.getColumnModel().getColumn(i); if (!tableColumn.isHidden()) viewColumn++; } return viewColumn; } }
private int columnInView(STable table, int column) { int viewColumn = 0; for (int i = 0; i < column; i++) { STableColumn tableColumn = table.getColumnModel().getColumn(i); if (!tableColumn.isHidden()) viewColumn++; } return viewColumn; }
/** * Prepares and returns the renderer to render the column header * @param col Column number to render. Starts with <code>0</code>. May be <code>-1</code> for row selection column. * @return The renderer to render the column header */ public SComponent prepareHeaderRenderer(STableCellRenderer headerRenderer, int col) { Object headerValue; if (col < 0) { headerValue = null; } else if (getColumnModel() != null && getColumnModel().getColumn(col) != null) { headerValue = getColumnModel().getColumn(col).getHeaderValue(); } else { headerValue = model.getColumnName(col); } return headerRenderer.getTableCellRendererComponent(this, headerValue, false, -1, col); }
/** * Returns the header renderer for the given header cell. * @param col Table column * @return The header renderer for the given header cell. */ public STableCellRenderer getHeaderRenderer( int col ) { STableColumnModel columnModel = getColumnModel(); if ( columnModel != null) { STableColumn column = columnModel.getColumn(col); if (column != null) { STableCellRenderer renderer = column.getHeaderRenderer(); if (renderer != null) return renderer; } } return headerRenderer; }
/** * Maps the index of the column in the table model at * <code>modelColumnIndex</code> to the index of the column * in the view. Returns the index of the * corresponding column in the view; returns -1 if this column is not * being displayed. If <code>modelColumnIndex</code> is less than zero, * returns <code>modelColumnIndex</code>. * * @param modelColumnIndex the index of the column in the model * @return the index of the corresponding column in the view * * @see #convertColumnIndexToModel */ public int convertColumnIndexToView(int modelColumnIndex) { if (modelColumnIndex < 0) { return modelColumnIndex; } STableColumnModel cm = getColumnModel(); int count = cm.getColumnCount(); for (int column = 0; column < count; column++) { if (cm.getColumn(column).getModelIndex() == modelColumnIndex) { return column; } } return -1; }
/** * Returns the cell renderer for the given table cell. * @param row Table row * @param col Table column * @return The cell renderer for the given table cell. */ public STableCellRenderer getCellRenderer( int row, int col ) { STableColumnModel columnModel = getColumnModel(); if (columnModel != null) { STableColumn column = columnModel.getColumn(col); if (column != null) { STableCellRenderer renderer = column.getCellRenderer(); if (renderer != null) return renderer; } } return getDefaultRenderer(getColumnClass(col)); }
/** * Return an appropriate editor for the cell specified by this row and * column. If the TableColumn for this column has a non-null editor, return that. * If not, find the class of the data in this column (using getColumnClass()) * and return the default editor for this type of data. * * @param row the row of the cell to edit, where 0 is the first * @param col the column of the cell to edit, where 0 is the first */ public STableCellEditor getCellEditor( int row, int col ) { STableColumnModel columnModel = getColumnModel(); if (columnModel != null) { STableColumn column = columnModel.getColumn(col); if (column != null) { STableCellEditor editor = column.getCellEditor(); if (editor != null) return editor; } } return getDefaultEditor(getColumnClass(col)); }
/** * Creates the default columns of the table from the table model. */ public void createDefaultColumnsFromModel() { TableModel tm = model; if (tm != null) { STableColumnModel columnModel = getColumnModel(); while (columnModel.getColumnCount() > 0) columnModel.removeColumn(columnModel.getColumn(0)); for ( int i = 0; i < tm.getColumnCount(); i++ ) { STableColumn column = new STableColumn( i ); String columnName = tm.getColumnName( i ); column.setHeaderValue( columnName ); this.columnModel.addColumn( column ); } } }
protected void writeBody(Device device, STable table, int startX, int endX, int startY, int endY, int emptyIndex) throws IOException { final SListSelectionModel selectionModel = table.getSelectionModel(); StringBuilder selectedArea = Utils.inlineStyles(table .getDynamicStyle(STable.SELECTOR_SELECTED)); StringBuilder evenArea = Utils.inlineStyles(table .getDynamicStyle(STable.SELECTOR_EVEN_ROWS)); StringBuilder oddArea = Utils.inlineStyles(table .getDynamicStyle(STable.SELECTOR_ODD_ROWS)); final SCellRendererPane rendererPane = table.getCellRendererPane(); STableColumnModel columnModel = table.getColumnModel(); for (int r = startY; r < endY; ++r) { writeTableRow(device, table, columnModel, selectionModel, rendererPane, r, startX, endX, emptyIndex, selectedArea, oddArea, evenArea); } }
private void writeColumnWidths(Device device, STable table, int startX, int endX) throws IOException { STableColumnModel columnModel = table.getColumnModel(); // IE-6 crashes if there is a colgroup element but the table body is empty. // That's why, we're writing the colgroup element only if the header is visible OR the model contains at least // one row if (columnModel != null && atLeastOneColumnWidthIsNotNull(columnModel) && (table.isHeaderVisible() || table.getModel().getRowCount() > 0)) { device.print("<colgroup>"); if (isSelectionColumnVisible(table)) writeCol(device, selectionColumnWidth); for (int i = startX; i < endX; ++i) { STableColumn column = columnModel.getColumn(i); if (!column.isHidden()) writeCol(device, column.getWidth()); else ++endX; } device.print("</colgroup>"); Utils.printNewline(device, table); } }
private void writeColumnWidths(Device device, STable table, int startX, int endX) throws IOException { STableColumnModel columnModel = table.getColumnModel(); if (columnModel != null && atLeastOneColumnWidthIsNotNull(columnModel)) { device.print("<colgroup>"); if (isSelectionColumnVisible(table)) writeCol(device, selectionColumnWidth); for (int i = startX; i < endX; ++i) { STableColumn column = columnModel.getColumn(i); if (!column.isHidden()) writeCol(device, column.getWidth()); else ++endX; } device.print("</colgroup>"); Utils.printNewline(device, table); } }
protected void writeBody(Device device, STable table, int startX, int endX, int startY, int endY, int emptyIndex) throws IOException { final SListSelectionModel selectionModel = table.getSelectionModel(); String selectedAreaStyle = table.getStyle(STable.SELECTOR_SELECTED); String evenAreaStyle = table.getStyle(STable.SELECTOR_EVEN_ROWS); String oddAreaStyle = table.getStyle(STable.SELECTOR_ODD_ROWS); StringBuilder selectedAreaInline = Utils.inlineStyles(table.getDynamicStyle(STable.SELECTOR_SELECTED)); StringBuilder evenAreaInline = Utils.inlineStyles(table.getDynamicStyle(STable.SELECTOR_EVEN_ROWS)); StringBuilder oddAreaInline = Utils.inlineStyles(table.getDynamicStyle(STable.SELECTOR_ODD_ROWS)); final SCellRendererPane rendererPane = table.getCellRendererPane(); STableColumnModel columnModel = table.getColumnModel(); for (int r = startY; r < endY; ++r) { writeTableRow(device, table, columnModel, selectionModel, rendererPane, r, startX, endX, emptyIndex, selectedAreaInline, oddAreaInline, evenAreaInline, selectedAreaStyle, oddAreaStyle, evenAreaStyle); } }
private void writeHeader(Device device, STable table, int startX, int endX) throws IOException { if (!table.isHeaderVisible()) return; final SCellRendererPane rendererPane = table.getCellRendererPane(); STableColumnModel columnModel = table.getColumnModel(); StringBuilder headerArea = Utils.inlineStyles(table .getDynamicStyle(STable.SELECTOR_HEADER)); device.print("<tr class=\"header\""); Utils.optAttribute(device, "style", headerArea); device.print(">"); Utils.printNewline(device, table, 1); writeSelectionHeader(device, table); for (int i = startX; i < endX; ++i) { STableColumn column = columnModel.getColumn(i); if (!column.isHidden()) writeHeaderCell(device, table, rendererPane, i); else ++endX; } device.print("</tr>"); Utils.printNewline(device, table); }
String propertyName = columnViewDescriptor.getName(); if (!forbiddenColumns.contains(propertyName)) { STableColumn column = viewComponent.getColumnModel().getColumn( columnIndex++); column.setIdentifier(propertyName);
protected void writeHeader(Device device, STable table, int startX, int endX) throws IOException { if (!table.isHeaderVisible()) return; final SCellRendererPane rendererPane = table.getCellRendererPane(); STableColumnModel columnModel = table.getColumnModel(); String headerAreaStyle = table.getStyle(STable.SELECTOR_HEADER); if (headerAreaStyle != null) device.print("<tr class=\"" + headerAreaStyle + '"'); else device.print("<tr class=\"header\""); StringBuilder headerAreaInline = Utils.inlineStyles(table.getDynamicStyle(STable.SELECTOR_HEADER)); Utils.optAttribute(device, "style", headerAreaInline); device.print(">"); Utils.printNewline(device, table, 1); writeSelectionHeader(device, table); for (int i = startX; i < endX; ++i) { STableColumn column = columnModel.getColumn(i); if (!column.isHidden()) writeHeaderCell(device, table, rendererPane, i); else ++endX; } device.print("</tr>"); Utils.printNewline(device, table); }