/** * {@inheritDoc} */ @Override public int convertColumnIndexToView(int columnIndex) { return table.convertColumnIndexToView(columnIndex); }
/** * {@inheritDoc} */ @Override public int convertColumnIndexToView(int columnIndex) { return table.convertColumnIndexToView(columnIndex); }
/** * {@inheritDoc} */ @Override public int modelToView(int columnIndex) { return table.convertColumnIndexToView(columnIndex); }
/** * {@inheritDoc} */ @Override public int convertColumnIndexToView(int columnIndex) { return table.convertColumnIndexToView(columnIndex); }
/** * {@inheritDoc} */ @Override public int convertColumnIndexToView(int columnIndex) { return table.convertColumnIndexToView(columnIndex); }
/** * {@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(); } } }
/** * Returns the view column index of the primary sort column. * * @return the view column index of the primary sort column or -1 if nothing * sorted or the primary sort column not visible. */ public int getSortedColumnIndex() { RowSorter<?> controller = getRowSorter(); if (controller != null) { SortKey sortKey = SortUtils.getFirstSortingKey(controller.getSortKeys()); if (sortKey != null) { return convertColumnIndexToView(sortKey.getColumn()); } } return -1; } /**
/** * Returns the view column index of the primary sort column. * * @return the view column index of the primary sort column or -1 if nothing * sorted or the primary sort column not visible. */ public int getSortedColumnIndex() { RowSorter<?> controller = getRowSorter(); if (controller != null) { SortKey sortKey = SortUtils.getFirstSortingKey(controller.getSortKeys()); if (sortKey != null) { return convertColumnIndexToView(sortKey.getColumn()); } } return -1; } /**
/** * Returns the view column index of the primary sort column. * * @return the view column index of the primary sort column or -1 if nothing * sorted or the primary sort column not visible. */ public int getSortedColumnIndex() { RowSorter<?> controller = getRowSorter(); if (controller != null) { SortKey sortKey = SortUtils.getFirstSortingKey(controller.getSortKeys()); if (sortKey != null) { return convertColumnIndexToView(sortKey.getColumn()); } } return -1; } /**
/** * Returns the view column index of the primary sort column. * * @return the view column index of the primary sort column or -1 if nothing * sorted or the primary sort column not visible. */ public int getSortedColumnIndex() { RowSorter<?> controller = getRowSorter(); if (controller != null) { SortKey sortKey = SortUtils.getFirstSortingKey(controller.getSortKeys()); if (sortKey != null) { return convertColumnIndexToView(sortKey.getColumn()); } } return -1; } /**
/** * Adjusts editing state after column's property change. Cancels ongoing * editing if the sending column is the editingColumn and the column's * editable changed to <code>false</code>, otherwise does nothing. * * @param column the <code>TableColumn</code> which sent the change * notifcation * @param editable the new value of the column's editable property */ private void updateEditingAfterColumnChanged(TableColumn column, boolean editable) { if (!isEditing()) return; int viewIndex = convertColumnIndexToView(column.getModelIndex()); if ((viewIndex < 0) || (viewIndex != getEditingColumn())) return; getCellEditor().cancelCellEditing(); }
/** * Adjusts editing state after column's property change. Cancels ongoing * editing if the sending column is the editingColumn and the column's * editable changed to <code>false</code>, otherwise does nothing. * * @param column the <code>TableColumn</code> which sent the change * notifcation * @param editable the new value of the column's editable property */ private void updateEditingAfterColumnChanged(TableColumn column, boolean editable) { if (!isEditing()) return; int viewIndex = convertColumnIndexToView(column.getModelIndex()); if ((viewIndex < 0) || (viewIndex != getEditingColumn())) return; getCellEditor().cancelCellEditing(); }
/** * Adjusts editing state after column's property change. Cancels ongoing * editing if the sending column is the editingColumn and the column's * editable changed to <code>false</code>, otherwise does nothing. * * @param column the <code>TableColumn</code> which sent the change * notifcation * @param editable the new value of the column's editable property */ private void updateEditingAfterColumnChanged(TableColumn column, boolean editable) { if (!isEditing()) return; int viewIndex = convertColumnIndexToView(column.getModelIndex()); if ((viewIndex < 0) || (viewIndex != getEditingColumn())) return; getCellEditor().cancelCellEditing(); }
/** * Adjusts editing state after column's property change. Cancels ongoing * editing if the sending column is the editingColumn and the column's * editable changed to <code>false</code>, otherwise does nothing. * * @param column the <code>TableColumn</code> which sent the change * notifcation * @param editable the new value of the column's editable property */ private void updateEditingAfterColumnChanged(TableColumn column, boolean editable) { if (!isEditing()) return; int viewIndex = convertColumnIndexToView(column.getModelIndex()); if ((viewIndex < 0) || (viewIndex != getEditingColumn())) return; getCellEditor().cancelCellEditing(); }
/** * Adjusts editing state after column's property change. Cancels ongoing * editing if the sending column is the editingColumn and the column's * editable changed to <code>false</code>, otherwise does nothing. * * @param column the <code>TableColumn</code> which sent the change * notifcation * @param editable the new value of the column's editable property */ private void updateEditingAfterColumnChanged(TableColumn column, boolean editable) { if (!isEditing()) return; int viewIndex = convertColumnIndexToView(column.getModelIndex()); if ((viewIndex < 0) || (viewIndex != getEditingColumn())) return; getCellEditor().cancelCellEditing(); }
/** * {@inheritDoc} * * PENDING JW: this is implemented to duplicate this table's lookup code * if either the row or the column is not visible. That's not good * enough if subclasses implemented a different strategy! We do it * anyway for now, mostly we will be lucky and improve the situation * against using toString always. * */ @Override public String getStringAt(int row, int column) { int viewRow = table.convertRowIndexToView(row); int viewColumn = table.convertColumnIndexToView(column); if ((viewRow >= 0) && (viewColumn >= 0)) { return table.getStringAt(viewRow, viewColumn); } TableCellRenderer renderer = getRendererByModelColumn(column); if (renderer instanceof StringValue) { return ((StringValue) renderer).getString(getValueAt(row, column)); } // no luck - return default return super.getStringAt(row, column); }
/** * 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; }