use of com.intellij.ui.ColoredTableCellRenderer in project android by JetBrains.
the class NlMarginPropertyAccumulator method createTableCellRenderer.
private static ColoredTableCellRenderer createTableCellRenderer() {
return new ColoredTableCellRenderer() {
@Override
protected void customizeCellRenderer(JTable table, @Nullable Object value, boolean selected, boolean hasFocus, int row, int column) {
assert value instanceof MarginGroupNode;
MarginGroupNode node = (MarginGroupNode) value;
NlMarginPropertyAccumulator accumulator = node.getAccumulator();
append("[");
append(node, accumulator.myAllMargin, null);
append(", ");
append(node, accumulator.myLeftMargin, accumulator.myStartMargin);
append(", ");
append(node, accumulator.myTopMargin, null);
append(", ");
append(node, accumulator.myRightMargin, accumulator.myEndMargin);
append(", ");
append(node, accumulator.myBottomMargin, null);
append("]");
}
private void append(@NotNull MarginGroupNode node, @NotNull String propertyName, @Nullable String propertyOverride) {
SimpleTextAttributes attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
PTableItem property = node.getItemByName(propertyName);
PTableItem override = propertyOverride != null ? node.getItemByName(propertyOverride) : null;
String value = null;
if (override != null) {
value = override.getResolvedValue();
if (!override.isDefaultValue(value)) {
attributes = SimpleTextAttributes.SYNTHETIC_ATTRIBUTES;
}
}
if (property != null && value == null) {
value = property.getResolvedValue();
if (!property.isDefaultValue(value)) {
attributes = SimpleTextAttributes.SYNTHETIC_ATTRIBUTES;
}
}
if (value == null) {
value = "?";
}
append(value, attributes);
}
};
}
use of com.intellij.ui.ColoredTableCellRenderer 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;
}
Aggregations