use of javax.swing.table.TableCellRenderer in project intellij-community by JetBrains.
the class TableLinkMouseListener method getTagAt.
@Override
@Nullable
public Object getTagAt(@NotNull final MouseEvent e) {
// TODO[yole]: don't update renderer on every event, like it's done in TreeLinkMouseListener
Object tag;
JTable table = (JTable) e.getSource();
int row = table.rowAtPoint(e.getPoint());
int column = table.columnAtPoint(e.getPoint());
if (row == -1 || column == -1)
return null;
TableCellRenderer cellRenderer = table.getCellRenderer(row, column);
if (cellRenderer instanceof DualView.TableCellRendererWrapper) {
cellRenderer = ((DualView.TableCellRendererWrapper) cellRenderer).getRenderer();
}
if (cellRenderer instanceof TreeTableView.CellRendererWrapper) {
cellRenderer = ((TreeTableView.CellRendererWrapper) cellRenderer).getBaseRenderer();
}
if (cellRenderer instanceof ColoredTableCellRenderer) {
final ColoredTableCellRenderer renderer = (ColoredTableCellRenderer) cellRenderer;
tag = forColoredRenderer(e, table, row, column, renderer);
} else {
tag = tryGetTag(e, table, row, column);
}
return tag;
}
use of javax.swing.table.TableCellRenderer in project intellij-community by JetBrains.
the class TreeTableView method getCellRenderer.
public TableCellRenderer getCellRenderer(int row, int column) {
TableCellRenderer renderer = getColumnInfo(column).getRenderer(getRowElement(row));
final TableCellRenderer baseRenderer = renderer == null ? super.getCellRenderer(row, column) : renderer;
return new CellRendererWrapper(baseRenderer);
}
use of javax.swing.table.TableCellRenderer in project intellij-community by JetBrains.
the class MultiColumnList method setCellRenderer.
public void setCellRenderer(ListCellRenderer renderer) {
myRenderer = renderer;
setDefaultRenderer(Object.class, new TableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
final int index = getModel().toListIndex(row, column);
if (isSelected) {
myList.addSelectionInterval(index, index);
} else {
myList.removeSelectionInterval(index, index);
}
return myRenderer.getListCellRendererComponent(myList, value, index, isSelected, hasFocus);
}
});
}
use of javax.swing.table.TableCellRenderer in project intellij-community by JetBrains.
the class MultiColumnList method getPreferredSize.
@Override
public Dimension getPreferredSize() {
if (myPrefSize == null) {
Dimension dimension = new Dimension();
int rowHeight = 0;
for (int column = 0; column < getColumnCount(); column++) {
int columnWidth = 0;
for (int row = 0; row < getRowCount(); row++) {
final TableCellRenderer renderer = getCellRenderer(row, column);
if (renderer != null) {
final Object value = getValueAt(row, column);
final Component component = renderer.getTableCellRendererComponent(this, value, true, true, row, column);
if (component != null) {
final Dimension size = component.getPreferredSize();
rowHeight = Math.max(size.height, rowHeight);
columnWidth = Math.max(size.width, columnWidth);
}
}
}
getColumnModel().getColumn(column).setWidth(columnWidth + 5);
dimension.width += columnWidth + 5;
}
dimension.height = getRowCount() * rowHeight;
myPrefSize = dimension;
}
return myPrefSize;
}
use of javax.swing.table.TableCellRenderer in project intellij-community by JetBrains.
the class SwingHelper method setNoBorderCellRendererFor.
public static void setNoBorderCellRendererFor(@NotNull TableColumn column) {
final TableCellRenderer previous = column.getCellRenderer();
column.setCellRenderer(new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component component;
if (previous != null) {
component = previous.getTableCellRendererComponent(table, value, isSelected, false, row, column);
} else {
component = super.getTableCellRendererComponent(table, value, isSelected, false, row, column);
}
if (component instanceof JComponent) {
((JComponent) component).setBorder(null);
}
return component;
}
});
}
Aggregations