use of com.intellij.ui.SimpleColoredComponent in project intellij-community by JetBrains.
the class AbstractFindUsagesDialog method createNorthPanel.
@Override
protected JComponent createNorthPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbConstraints = new GridBagConstraints();
gbConstraints.insets = new Insets(0, 0, UIUtil.DEFAULT_VGAP, 0);
gbConstraints.fill = GridBagConstraints.NONE;
gbConstraints.weightx = 1;
gbConstraints.weighty = 1;
gbConstraints.anchor = GridBagConstraints.WEST;
final SimpleColoredComponent coloredComponent = new SimpleColoredComponent();
coloredComponent.setIpad(new Insets(0, 0, 0, 0));
coloredComponent.setMyBorder(null);
configureLabelComponent(coloredComponent);
panel.add(coloredComponent, gbConstraints);
return panel;
}
use of com.intellij.ui.SimpleColoredComponent in project intellij-community by JetBrains.
the class ShowUsagesTableCellRenderer method appendGroupText.
private void appendGroupText(JTable table, final GroupNode node, JPanel panel, Color fileBgColor, boolean isSelected) {
UsageGroup group = node == null ? null : node.getGroup();
if (group == null)
return;
GroupNode parentGroup = (GroupNode) node.getParent();
appendGroupText(table, parentGroup, panel, fileBgColor, isSelected);
if (node.canNavigateToSource()) {
SimpleColoredComponent renderer = new SimpleColoredComponent();
renderer.setIcon(group.getIcon(false));
SimpleTextAttributes attributes = deriveAttributesWithColor(SimpleTextAttributes.REGULAR_ATTRIBUTES, fileBgColor);
renderer.append(group.getText(myUsageView), attributes);
renderer.setBorder(null);
SpeedSearchUtil.applySpeedSearchHighlighting(table, renderer, false, isSelected);
panel.add(renderer);
}
}
use of com.intellij.ui.SimpleColoredComponent in project intellij-community by JetBrains.
the class ShowUsagesTableCellRenderer method getTableCellRendererComponent.
@Override
public Component getTableCellRendererComponent(JTable list, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
UsageNode usageNode = value instanceof UsageNode ? (UsageNode) value : null;
Usage usage = usageNode == null ? null : usageNode.getUsage();
Color fileBgColor = getBackgroundColor(isSelected, usage);
Color bg = UIUtil.getListSelectionBackground();
Color fg = UIUtil.getListSelectionForeground();
Color panelBackground = isSelected ? bg : fileBgColor == null ? list.getBackground() : fileBgColor;
Color panelForeground = isSelected ? fg : list.getForeground();
SimpleColoredComponent textChunks = new SimpleColoredComponent();
if (usageNode == null || usageNode instanceof ShowUsagesAction.StringNode) {
textChunks.append(ObjectUtils.notNull(value, "").toString(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
return textComponentSpanningWholeRow(textChunks, panelBackground, panelForeground, column, list);
}
if (usage == ShowUsagesAction.MORE_USAGES_SEPARATOR) {
textChunks.append("...<");
textChunks.append("more usages", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
textChunks.append(">...");
return textComponentSpanningWholeRow(textChunks, panelBackground, panelForeground, column, list);
}
if (usage == ShowUsagesAction.USAGES_OUTSIDE_SCOPE_SEPARATOR) {
textChunks.append("...<");
textChunks.append(UsageViewManagerImpl.outOfScopeMessage(myOutOfScopeUsages.get(), mySearchScope), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
textChunks.append(">...");
return textComponentSpanningWholeRow(textChunks, panelBackground, panelForeground, column, list);
}
boolean lineNumberColumn = column == 1;
JPanel panel = new JPanel(new FlowLayout(lineNumberColumn ? FlowLayout.RIGHT : FlowLayout.LEFT, 0, 0) {
@Override
public void layoutContainer(Container container) {
super.layoutContainer(container);
for (Component component : container.getComponents()) {
// align inner components
Rectangle b = component.getBounds();
Insets insets = container.getInsets();
component.setBounds(b.x, b.y, b.width, container.getSize().height - insets.top - insets.bottom);
}
}
});
panel.setFont(null);
panel.setBackground(panelBackground);
panel.setForeground(panelForeground);
// greying the current usage you originated your "find usages" from is turned off by @nik orders
//!myUsageView.isOriginUsage(usage);
boolean isEnabled = true;
if (!isEnabled) {
fg = UIUtil.getLabelDisabledForeground();
}
if (column == 0) {
appendGroupText(list, (GroupNode) usageNode.getParent(), panel, fileBgColor, isSelected);
} else {
if (usage != ShowUsagesAction.MORE_USAGES_SEPARATOR && usage != ShowUsagesAction.USAGES_OUTSIDE_SCOPE_SEPARATOR) {
UsagePresentation presentation = usage.getPresentation();
TextChunk[] text = presentation.getText();
if (lineNumberColumn) {
// line number
if (text.length != 0) {
TextChunk chunk = text[0];
textChunks.append(chunk.getText(), getAttributes(isSelected, fileBgColor, bg, fg, chunk));
}
} else if (column == 2) {
Icon icon = presentation.getIcon();
textChunks.setIcon(icon == null ? EmptyIcon.ICON_16 : icon);
textChunks.append("").appendTextPadding(JBUI.scale(16 + 5));
for (int i = 1; i < text.length; i++) {
TextChunk chunk = text[i];
textChunks.append(chunk.getText(), getAttributes(isSelected, fileBgColor, bg, fg, chunk));
}
} else {
assert false : column;
}
}
SpeedSearchUtil.applySpeedSearchHighlighting(list, textChunks, false, isSelected);
panel.add(textChunks);
}
if (!isEnabled) {
GuiUtils.enableChildren(panel, false);
}
return panel;
}
Aggregations