use of javax.swing.table.TableCellRenderer in project EnrichmentMapApp by BaderLab.
the class HeatMapMainPanel method clearTableHeader.
private void clearTableHeader() {
JTableHeader header = table.getTableHeader();
TableColumnModel columnModel = table.getColumnModel();
if (columnModel.getColumnCount() > 0) {
TableColumn rankColumn = columnModel.getColumn(HeatMapTableModel.RANK_COL);
TableCellRenderer existingRenderer = rankColumn.getHeaderRenderer();
if (existingRenderer instanceof ColumnHeaderRankOptionRenderer) {
((ColumnHeaderRankOptionRenderer) existingRenderer).dispose(header);
}
}
}
use of javax.swing.table.TableCellRenderer in project groovy by apache.
the class ClosureRenderer method render.
private Component render() {
if (children.isEmpty() || defaultRenderer) {
defaultRenderer = true;
children.clear();
if (table != null) {
TableCellRenderer tcr;
if (tableHeader) {
tcr = table.getTableHeader().getDefaultRenderer();
} else {
tcr = table.getDefaultRenderer(table.getColumnClass(column));
}
children.add(tcr.getTableCellRendererComponent(table, value, selected, focused, row, column));
} else if (tree != null) {
TreeCellRenderer tcr;
tcr = new DefaultTreeCellRenderer();
children.add(tcr.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, focused));
} else if (list != null) {
ListCellRenderer lcr = (ListCellRenderer) UIManager.get("List.cellRenderer");
if (lcr == null) {
lcr = new DefaultListCellRenderer();
}
children.add(lcr.getListCellRendererComponent(list, value, row, selected, focused));
}
}
Object o = update.call();
if (o instanceof Component) {
return (Component) o;
} else {
return (Component) children.get(0);
}
}
use of javax.swing.table.TableCellRenderer in project android by JetBrains.
the class IconPickerDialogTest method tableToString.
@NotNull
public static String tableToString(@NotNull JTable table, int startRow, int endRow, int startColumn, int endColumn, int cellWidth) {
StringBuilder sb = new StringBuilder();
String formatString = "%-" + Integer.toString(cellWidth) + "s";
for (int row = Math.max(0, startRow); row < Math.min(endRow, table.getRowCount()); row++) {
for (int column = Math.max(0, startColumn); column < Math.min(table.getColumnCount(), endColumn); column++) {
Object value = table.getValueAt(row, column);
TableCellRenderer renderer = table.getCellRenderer(row, column);
Component component = renderer.getTableCellRendererComponent(table, value, false, false, row, column);
DefaultTableCellRenderer label = (DefaultTableCellRenderer) component;
assertThat(label.getText()).isEmpty();
String cell = label.getAccessibleContext().getAccessibleName();
if (cell.length() > cellWidth) {
cell = cell.substring(0, cellWidth - 3) + "...";
}
sb.append(String.format(formatString, cell));
}
sb.append('\n');
}
return sb.toString();
}
use of javax.swing.table.TableCellRenderer in project intellij-plugins by JetBrains.
the class EditableTreeTable method getCellRenderer.
// copied from TableView
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
ListTreeTableModelOnColumns model = (ListTreeTableModelOnColumns) getTableModel();
ColumnInfo columnInfo = model.getColumnInfos()[convertColumnIndexToModel(column)];
T item = (T) getValueAt(convertRowIndexToModel(row), 0);
final TableCellRenderer renderer = columnInfo.getCustomizedRenderer(item, columnInfo.getRenderer(item));
return renderer == null ? super.getCellRenderer(row, column) : renderer;
}
use of javax.swing.table.TableCellRenderer in project intellij-community by JetBrains.
the class InjectionsSettingsUI method createLanguageCellRenderer.
private static TableCellRenderer createLanguageCellRenderer() {
return new TableCellRenderer() {
final JLabel myLabel = new JLabel();
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
final InjInfo injection = (InjInfo) value;
// fix for a marvellous Swing peculiarity: AccessibleJTable likes to pass null here
if (injection == null)
return myLabel;
final String languageId = injection.injection.getInjectedLanguageId();
final Language language = InjectedLanguage.findLanguageById(languageId);
final FileType fileType = language == null ? null : language.getAssociatedFileType();
myLabel.setIcon(fileType == null ? null : fileType.getIcon());
myLabel.setText(language == null ? languageId : language.getDisplayName());
setLabelColors(myLabel, table, isSelected, row);
return myLabel;
}
};
}
Aggregations