use of javax.swing.table.DefaultTableCellRenderer in project intellij-community by JetBrains.
the class TaskExecutionTreeTable method getCellRenderer.
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
if (column == 0) {
final TableCellRenderer cellRenderer = super.getCellRenderer(row, column);
return new TableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component component = cellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
final Color bg = isSelected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
component.setBackground(bg);
return component;
}
};
} else if (column == 1) {
return new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setHorizontalAlignment(SwingConstants.RIGHT);
final Color fg = isSelected ? UIUtil.getTreeSelectionForeground() : SimpleTextAttributes.GRAY_ATTRIBUTES.getFgColor();
setForeground(fg);
return this;
}
};
}
return super.getCellRenderer(row, column);
}
use of javax.swing.table.DefaultTableCellRenderer in project android by JetBrains.
the class ThemeEditorTable method setRenderersAndEditors.
private void setRenderersAndEditors(@NotNull AndroidThemePreviewPanel previewPanel, @NotNull ParentRendererEditor.ThemeParentChangedListener themeParentChangedListener) {
Project project = myContext.getProject();
ResourcesCompletionProvider completionProvider = new ResourcesCompletionProvider(myContext);
final AttributeReferenceRendererEditor styleEditor = new AttributeReferenceRendererEditor(project, completionProvider);
setDefaultRenderer(Color.class, new DelegatingCellRenderer(new ColorRendererEditor(myContext, previewPanel, false)));
setDefaultRenderer(EditedStyleItem.class, new DelegatingCellRenderer(new AttributeReferenceRendererEditor(project, completionProvider)));
setDefaultRenderer(ConfiguredThemeEditorStyle.class, new DelegatingCellRenderer(new AttributeReferenceRendererEditor(project, completionProvider)));
setDefaultRenderer(String.class, new DelegatingCellRenderer(getDefaultRenderer(String.class)));
setDefaultRenderer(Integer.class, new DelegatingCellRenderer(new IntegerRenderer()));
setDefaultRenderer(Boolean.class, new DelegatingCellRenderer(new BooleanRendererEditor(myContext)));
setDefaultRenderer(Enum.class, new DelegatingCellRenderer(new EnumRendererEditor()));
setDefaultRenderer(Flag.class, new DelegatingCellRenderer(new FlagRendererEditor()));
setDefaultRenderer(AttributesTableModel.ParentAttribute.class, new DelegatingCellRenderer(new ParentRendererEditor(myContext, themeParentChangedListener)));
setDefaultRenderer(DrawableDomElement.class, new DelegatingCellRenderer(new DrawableRendererEditor(myContext, previewPanel, false)));
setDefaultRenderer(TableLabel.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Font regularFont = UIUtil.getLabelFont();
int regularFontSize = getFontMetrics(regularFont).getHeight();
Font headerFont = regularFont.deriveFont(regularFontSize * ThemeEditorConstants.ATTRIBUTES_HEADER_FONT_SCALE);
this.setFont(headerFont);
return this;
}
});
setDefaultEditor(Color.class, new DelegatingCellEditor(false, new ColorRendererEditor(myContext, previewPanel, true)));
setDefaultEditor(EditedStyleItem.class, new DelegatingCellEditor(false, new AttributeReferenceRendererEditor(project, completionProvider)));
setDefaultEditor(String.class, new DelegatingCellEditor(false, getDefaultEditor(String.class)));
setDefaultEditor(Integer.class, new DelegatingCellEditor(getDefaultEditor(Integer.class)));
setDefaultEditor(Boolean.class, new DelegatingCellEditor(false, new BooleanRendererEditor(myContext)));
setDefaultEditor(Enum.class, new DelegatingCellEditor(false, new EnumRendererEditor()));
setDefaultEditor(Flag.class, new DelegatingCellEditor(false, new FlagRendererEditor()));
setDefaultEditor(AttributesTableModel.ParentAttribute.class, new DelegatingCellEditor(false, new ParentRendererEditor(myContext, themeParentChangedListener)));
// We allow to edit style pointers as Strings.
setDefaultEditor(ConfiguredThemeEditorStyle.class, new DelegatingCellEditor(false, styleEditor));
setDefaultEditor(DrawableDomElement.class, new DelegatingCellEditor(false, new DrawableRendererEditor(myContext, previewPanel, true)));
}
use of javax.swing.table.DefaultTableCellRenderer in project android by JetBrains.
the class ResourceTablePanel method select.
public void select(@Nullable ResourceChooserItem item) {
if (item != null) {
myTable.setModel(new ResourceTableModel(item));
// Pick a font that can display the various translations
TableColumn valueColumn = myTable.getColumnModel().getColumn(1);
valueColumn.setCellRenderer(new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (column == 1) {
String s = value.toString();
component.setFont(FontUtil.getFontAbleToDisplay(s, table.getFont()));
} else {
component.setFont(table.getFont());
}
return component;
}
});
myNameLabel.setText(item.getName());
myTable.setRowHeight(ChooseResourceDialog.TABLE_CELL_HEIGHT);
myEditTranslationsLink.setVisible(item.getType() == ResourceType.STRING && !item.isFramework());
} else {
myNameLabel.setText("");
myTable.setModel(new DefaultTableModel(0, 2));
myEditTranslationsLink.setVisible(false);
}
}
use of javax.swing.table.DefaultTableCellRenderer in project android by JetBrains.
the class DownloadStatusColumnInfo method getRenderer.
@Nullable
@Override
public TableCellRenderer getRenderer(UpdaterTreeNode node) {
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer() {
@Override
public void setText(String text) {
}
};
IconInfo info = getIconInfo(node);
renderer.setIcon(info.getIcon());
renderer.getAccessibleContext().setAccessibleName(info.getName());
return renderer;
}
use of javax.swing.table.DefaultTableCellRenderer in project jdk8u_jdk by JetBrains.
the class XMBeanAttributes method getCellRenderer.
@Override
public synchronized TableCellRenderer getCellRenderer(int row, int column) {
//It can happen when MBean selection is switched at a very quick rate
if (row >= getRowCount()) {
return null;
} else {
if (column == VALUE_COLUMN) {
Object obj = getModel().getValueAt(row, column);
if (obj instanceof ZoomedCell) {
ZoomedCell cell = (ZoomedCell) obj;
if (cell.isInited()) {
DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) cell.getRenderer();
renderer.setToolTipText(getToolTip(row, column));
return renderer;
}
}
}
DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) super.getCellRenderer(row, column);
if (!isCellError(row, column)) {
if (!(isColumnEditable(column) && isWritable(row) && Utils.isEditableType(getClassName(row)))) {
renderer.setForeground(getDefaultColor());
}
}
return renderer;
}
}
Aggregations