/** * Configure column properties from TableModel. This implementation * sets the column's <code>headerValue</code> property from the * model's <code>columnName</code>. * <p> * * The factory's initial column configuration is passed through this method, so * subclasses can override to customize. * <p> * * @param model the TableModel to read configuration properties from * @param columnExt the TableColumnExt to configure. * @throws NullPointerException if model or column == null * @throws IllegalStateException if column does not have valid modelIndex * (in coordinate space of the tablemodel) * * @see #createAndConfigureTableColumn(TableModel, int) */ public void configureTableColumn(TableModel model, TableColumnExt columnExt) { if ((columnExt.getModelIndex() < 0) || (columnExt.getModelIndex() >= model.getColumnCount())) throw new IllegalStateException("column must have valid modelIndex"); columnExt.setHeaderValue(model.getColumnName(columnExt.getModelIndex())); }
/** * Configure column properties from TableModel. This implementation * sets the column's <code>headerValue</code> property from the * model's <code>columnName</code>. * <p> * * The factory's initial column configuration is passed through this method, so * subclasses can override to customize. * <p> * * @param model the TableModel to read configuration properties from * @param columnExt the TableColumnExt to configure. * @throws NullPointerException if model or column == null * @throws IllegalStateException if column does not have valid modelIndex * (in coordinate space of the tablemodel) * * @see #createAndConfigureTableColumn(TableModel, int) */ public void configureTableColumn(TableModel model, TableColumnExt columnExt) { if ((columnExt.getModelIndex() < 0) || (columnExt.getModelIndex() >= model.getColumnCount())) throw new IllegalStateException("column must have valid modelIndex"); columnExt.setHeaderValue(model.getColumnName(columnExt.getModelIndex())); }
/** * Configure column properties from TableModel. This implementation * sets the column's <code>headerValue</code> property from the * model's <code>columnName</code>. * <p> * * The factory's initial column configuration is passed through this method, so * subclasses can override to customize. * <p> * * @param model the TableModel to read configuration properties from * @param columnExt the TableColumnExt to configure. * @throws NullPointerException if model or column == null * @throws IllegalStateException if column does not have valid modelIndex * (in coordinate space of the tablemodel) * * @see #createAndConfigureTableColumn(TableModel, int) */ public void configureTableColumn(TableModel model, TableColumnExt columnExt) { if ((columnExt.getModelIndex() < 0) || (columnExt.getModelIndex() >= model.getColumnCount())) throw new IllegalStateException("column must have valid modelIndex"); columnExt.setHeaderValue(model.getColumnName(columnExt.getModelIndex())); }
/** * Configure column properties from TableModel. This implementation * sets the column's <code>headerValue</code> property from the * model's <code>columnName</code>. * <p> * * The factory's initial column configuration is passed through this method, so * subclasses can override to customize. * <p> * * @param model the TableModel to read configuration properties from * @param columnExt the TableColumnExt to configure. * @throws NullPointerException if model or column == null * @throws IllegalStateException if column does not have valid modelIndex * (in coordinate space of the tablemodel) * * @see #createAndConfigureTableColumn(TableModel, int) */ public void configureTableColumn(TableModel model, TableColumnExt columnExt) { if ((columnExt.getModelIndex() < 0) || (columnExt.getModelIndex() >= model.getColumnCount())) throw new IllegalStateException("column must have valid modelIndex"); columnExt.setHeaderValue(model.getColumnName(columnExt.getModelIndex())); }
/** * Configure column properties from TableModel. This implementation * sets the column's <code>headerValue</code> property from the * model's <code>columnName</code>. * <p> * * The factory's initial column configuration is passed through this method, so * subclasses can override to customize. * <p> * * @param model the TableModel to read configuration properties from * @param columnExt the TableColumnExt to configure. * @throws NullPointerException if model or column == null * @throws IllegalStateException if column does not have valid modelIndex * (in coordinate space of the tablemodel) * * @see #createAndConfigureTableColumn(TableModel, int) */ public void configureTableColumn(TableModel model, TableColumnExt columnExt) { if ((columnExt.getModelIndex() < 0) || (columnExt.getModelIndex() >= model.getColumnCount())) throw new IllegalStateException("column must have valid modelIndex"); columnExt.setHeaderValue(model.getColumnName(columnExt.getModelIndex())); }
ColumnFactory factory = new ColumnFactory() { @Override protected void configureTableColumn(TableModel model, TableColumnExt columnExt) { super(...); columnExt.setPrototypeValue(myPrototype[columnExt.getModelIndex()]; } } table.setColumnFactory(factory); table.setModel(myModel);
/** * {@inheritDoc} * * Listens to column property changes. * */ public void columnPropertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals("editable")) { updateEditingAfterColumnChanged((TableColumn) event.getSource(), (Boolean) event.getNewValue()); } else if (event.getPropertyName().equals("sortable")) { updateSortingAfterColumnChanged((TableColumn) event.getSource(), (Boolean) event.getNewValue()); } else if (event.getPropertyName().startsWith("highlighter")) { if (event.getSource() instanceof TableColumnExt && getRowCount() > 0) { TableColumnExt column = (TableColumnExt) event.getSource(); Rectangle r = getCellRect(0, convertColumnIndexToView(column .getModelIndex()), true); r.height = getHeight(); repaint(r); } else { repaint(); } } }
.getModelIndex()), true); r.height = getHeight(); repaint(r);
/** * Instantiates a new table view column with all properties copied from the * given original. * * @param columnExt the column to copy properties from * @see #copyFrom(TableColumnExt) */ public TableColumnExt(TableColumnExt columnExt) { this(columnExt.getModelIndex(), columnExt.getWidth(), columnExt .getCellRenderer(), columnExt.getCellEditor()); copyFrom(columnExt); }
/** * Instantiates a new table view column with all properties copied from the * given original. * * @param columnExt the column to copy properties from * @see #copyFrom(TableColumnExt) */ public TableColumnExt(TableColumnExt columnExt) { this(columnExt.getModelIndex(), columnExt.getWidth(), columnExt .getCellRenderer(), columnExt.getCellEditor()); copyFrom(columnExt); }
/** * Instantiates a new table view column with all properties copied from the * given original. * * @param columnExt the column to copy properties from * @see #copyFrom(TableColumnExt) */ public TableColumnExt(TableColumnExt columnExt) { this(columnExt.getModelIndex(), columnExt.getWidth(), columnExt .getCellRenderer(), columnExt.getCellEditor()); copyFrom(columnExt); }
/** * Instantiates a new table view column with all properties copied from the * given original. * * @param columnExt the column to copy properties from * @see #copyFrom(TableColumnExt) */ public TableColumnExt(TableColumnExt columnExt) { this(columnExt.getModelIndex(), columnExt.getWidth(), columnExt .getCellRenderer(), columnExt.getCellEditor()); copyFrom(columnExt); }
/** * Instantiates a new table view column with all properties copied from the * given original. * * @param columnExt the column to copy properties from * @see #copyFrom(TableColumnExt) */ public TableColumnExt(TableColumnExt columnExt) { this(columnExt.getModelIndex(), columnExt.getWidth(), columnExt .getCellRenderer(), columnExt.getCellEditor()); copyFrom(columnExt); }
/** * Returns the cell renderer to use for measuring. Delegates to * JXTable for visible columns, duplicates table logic for hidden * columns. <p> * * @param table the table which provides the renderer * @param columnExt the TableColumn to configure * * @return returns a cell renderer for measuring. */ protected TableCellRenderer getCellRenderer(JXTable table, TableColumnExt columnExt) { int viewIndex = table.convertColumnIndexToView(columnExt .getModelIndex()); if (viewIndex >= 0) { // JW: ok to not guard against rowCount < 0? // technically, the index should be a valid coordinate return table.getCellRenderer(0, viewIndex); } // hidden column - need api on JXTable to access renderer for hidden? // here we duplicate JXTable api ... maybe by-passing the strategy // implemented there TableCellRenderer renderer = columnExt.getCellRenderer(); if (renderer == null) { renderer = table.getDefaultRenderer(table.getModel().getColumnClass(columnExt.getModelIndex())); } return renderer; }
/** * Returns the cell renderer to use for measuring. Delegates to * JXTable for visible columns, duplicates table logic for hidden * columns. <p> * * @param table the table which provides the renderer * @param columnExt the TableColumn to configure * * @return returns a cell renderer for measuring. */ protected TableCellRenderer getCellRenderer(JXTable table, TableColumnExt columnExt) { int viewIndex = table.convertColumnIndexToView(columnExt .getModelIndex()); if (viewIndex >= 0) { // JW: ok to not guard against rowCount < 0? // technically, the index should be a valid coordinate return table.getCellRenderer(0, viewIndex); } // hidden column - need api on JXTable to access renderer for hidden? // here we duplicate JXTable api ... maybe by-passing the strategy // implemented there TableCellRenderer renderer = columnExt.getCellRenderer(); if (renderer == null) { renderer = table.getDefaultRenderer(table.getModel().getColumnClass(columnExt.getModelIndex())); } return renderer; }
/** * Returns the cell renderer to use for measuring. Delegates to * JXTable for visible columns, duplicates table logic for hidden * columns. <p> * * @param table the table which provides the renderer * @param columnExt the TableColumn to configure * * @return returns a cell renderer for measuring. */ protected TableCellRenderer getCellRenderer(JXTable table, TableColumnExt columnExt) { int viewIndex = table.convertColumnIndexToView(columnExt .getModelIndex()); if (viewIndex >= 0) { // JW: ok to not guard against rowCount < 0? // technically, the index should be a valid coordinate return table.getCellRenderer(0, viewIndex); } // hidden column - need api on JXTable to access renderer for hidden? // here we duplicate JXTable api ... maybe by-passing the strategy // implemented there TableCellRenderer renderer = columnExt.getCellRenderer(); if (renderer == null) { renderer = table.getDefaultRenderer(table.getModel().getColumnClass(columnExt.getModelIndex())); } return renderer; }
/** * Returns the cell renderer to use for measuring. Delegates to * JXTable for visible columns, duplicates table logic for hidden * columns. <p> * * @param table the table which provides the renderer * @param columnExt the TableColumn to configure * * @return returns a cell renderer for measuring. */ protected TableCellRenderer getCellRenderer(JXTable table, TableColumnExt columnExt) { int viewIndex = table.convertColumnIndexToView(columnExt .getModelIndex()); if (viewIndex >= 0) { // JW: ok to not guard against rowCount < 0? // technically, the index should be a valid coordinate return table.getCellRenderer(0, viewIndex); } // hidden column - need api on JXTable to access renderer for hidden? // here we duplicate JXTable api ... maybe by-passing the strategy // implemented there TableCellRenderer renderer = columnExt.getCellRenderer(); if (renderer == null) { renderer = table.getDefaultRenderer(table.getModel().getColumnClass(columnExt.getModelIndex())); } return renderer; }
/** * Returns the cell renderer to use for measuring. Delegates to * JXTable for visible columns, duplicates table logic for hidden * columns. <p> * * @param table the table which provides the renderer * @param columnExt the TableColumn to configure * * @return returns a cell renderer for measuring. */ protected TableCellRenderer getCellRenderer(JXTable table, TableColumnExt columnExt) { int viewIndex = table.convertColumnIndexToView(columnExt .getModelIndex()); if (viewIndex >= 0) { // JW: ok to not guard against rowCount < 0? // technically, the index should be a valid coordinate return table.getCellRenderer(0, viewIndex); } // hidden column - need api on JXTable to access renderer for hidden? // here we duplicate JXTable api ... maybe by-passing the strategy // implemented there TableCellRenderer renderer = columnExt.getCellRenderer(); if (renderer == null) { renderer = table.getDefaultRenderer(table.getModel().getColumnClass(columnExt.getModelIndex())); } return renderer; }
protected void installSizeBytesRenderer(TableColumnExt columnExt, int columnIndex, TableModel model) { if (columnIndex != -1) { if (columnExt.getModelIndex() == columnIndex && SizeBytesStringValue.isTargetClass(model.getColumnClass(columnIndex))) { columnExt.setCellRenderer(new DefaultTableRenderer(getSizeBytesStringValue())); } } }
/** * Returns the SortOrder of the given column. * * PENDING: JW - define the behaviour if the identifier is not found. This * can happen if either there's no column at all with the identifier or if * there's no column of type TableColumnExt. Currently returns * SortOrder.UNSORTED. * * @param identifier the column's identifier. * @return the interactive sorter's SortOrder if matches the column or * SortOrder.UNSORTED */ public SortOrder getSortOrder(Object identifier) { SortController sortController = getSortController(); if (sortController == null) return SortOrder.UNSORTED; TableColumnExt columnExt = getColumnExt(identifier); if (columnExt == null) return SortOrder.UNSORTED; int modelIndex = columnExt.getModelIndex(); SortKey sortKey = SortKey.getFirstSortKeyForColumn(sortController .getSortKeys(), modelIndex); return sortKey != null ? sortKey.getSortOrder() : SortOrder.UNSORTED; }