Search in sources :

Example 16 with SimpleColoredComponent

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;
}
Also used : SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent)

Example 17 with SimpleColoredComponent

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);
    }
}
Also used : UsageGroup(com.intellij.usages.UsageGroup) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) GroupNode(com.intellij.usages.impl.GroupNode) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent)

Example 18 with SimpleColoredComponent

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;
}
Also used : Usage(com.intellij.usages.Usage) TextChunk(com.intellij.usages.TextChunk) UsagePresentation(com.intellij.usages.UsagePresentation) UsageNode(com.intellij.usages.impl.UsageNode) EmptyIcon(com.intellij.util.ui.EmptyIcon) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent)

Aggregations

SimpleColoredComponent (com.intellij.ui.SimpleColoredComponent)18 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)8 NotNull (org.jetbrains.annotations.NotNull)6 TextRange (com.intellij.openapi.util.TextRange)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 UiUtil.revalidateAndRepaint (com.android.tools.idea.gradle.structure.configurables.ui.UiUtil.revalidateAndRepaint)1 HintUtil (com.intellij.codeInsight.hint.HintUtil)1 Descriptor (com.intellij.codeInspection.ex.Descriptor)1 InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)1 LanguageConsoleView (com.intellij.execution.console.LanguageConsoleView)1 ConsoleViewImpl (com.intellij.execution.impl.ConsoleViewImpl)1 ConsoleView (com.intellij.execution.ui.ConsoleView)1 DirDiffOperation (com.intellij.ide.diff.DirDiffOperation)1 AbstractTreeBuilder (com.intellij.ide.util.treeView.AbstractTreeBuilder)1 Disposable (com.intellij.openapi.Disposable)1 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 ShortcutSet (com.intellij.openapi.actionSystem.ShortcutSet)1 Application (com.intellij.openapi.application.Application)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1