Search in sources :

Example 6 with SimpleColoredComponent

use of com.intellij.ui.SimpleColoredComponent in project intellij-community by JetBrains.

the class ShortcutDialog method setShortcut.

void setShortcut(T shortcut) {
    if (!equal(shortcut, myShortcutPanel.getShortcut())) {
        myShortcutPanel.setShortcut(shortcut);
    }
    myConflictsContainer.removeAll();
    if (shortcut != null) {
        for (String id : getConflicts(shortcut, myActionId, myKeymap)) {
            String path = id.equals(myActionId) ? null : getActionPath(id);
            if (path != null) {
                SimpleColoredComponent component = new SimpleColoredComponent();
                fill(component, id, path);
                myConflictsContainer.add(VerticalLayout.TOP, component);
            }
        }
        myConflictsPanel.revalidate();
        myConflictsPanel.repaint();
    }
    myConflictsPanel.setVisible(0 < myConflictsContainer.getComponentCount());
}
Also used : SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent)

Example 7 with SimpleColoredComponent

use of com.intellij.ui.SimpleColoredComponent in project intellij-community by JetBrains.

the class XValueHint method evaluateAndShowHint.

@Override
protected void evaluateAndShowHint() {
    myEvaluator.evaluate(myExpression, new XEvaluationCallbackBase() {

        @Override
        public void evaluated(@NotNull final XValue result) {
            result.computePresentation(new XValueNodePresentationConfigurator.ConfigurableXValueNodeImpl() {

                private XFullValueEvaluator myFullValueEvaluator;

                private boolean myShown = false;

                @Override
                public void applyPresentation(@Nullable Icon icon, @NotNull XValuePresentation valuePresenter, boolean hasChildren) {
                    if (isHintHidden()) {
                        return;
                    }
                    SimpleColoredText text = new SimpleColoredText();
                    text.append(StringUtil.trimMiddle(myValueName, 200), XDebuggerUIConstants.VALUE_NAME_ATTRIBUTES);
                    XValueNodeImpl.buildText(valuePresenter, text);
                    if (!hasChildren) {
                        SimpleColoredComponent component = HintUtil.createInformationComponent();
                        text.appendToComponent(component);
                        if (myFullValueEvaluator != null) {
                            component.append(myFullValueEvaluator.getLinkText(), XDebuggerTreeNodeHyperlink.TEXT_ATTRIBUTES, (Consumer<MouseEvent>) event -> DebuggerUIUtil.showValuePopup(myFullValueEvaluator, event, getProject(), getEditor()));
                            LinkMouseListenerBase.installSingleTagOn(component);
                        }
                        showHint(component);
                    } else if (getType() == ValueHintType.MOUSE_CLICK_HINT) {
                        if (!myShown) {
                            showTree(result);
                        }
                    } else {
                        if (getType() == ValueHintType.MOUSE_OVER_HINT) {
                            text.insert(0, "(" + KeymapUtil.getFirstKeyboardShortcutText("ShowErrorDescription") + ") ", SimpleTextAttributes.GRAYED_ATTRIBUTES);
                        }
                        JComponent component = createExpandableHintComponent(text, () -> showTree(result));
                        showHint(component);
                    }
                    myShown = true;
                }

                @Override
                public void setFullValueEvaluator(@NotNull XFullValueEvaluator fullValueEvaluator) {
                    myFullValueEvaluator = fullValueEvaluator;
                }

                @Override
                public boolean isObsolete() {
                    return isHintHidden();
                }
            }, XValuePlace.TOOLTIP);
        }

        @Override
        public void errorOccurred(@NotNull final String errorMessage) {
            if (getType() == ValueHintType.MOUSE_CLICK_HINT) {
                ApplicationManager.getApplication().invokeLater(() -> showHint(HintUtil.createErrorLabel(errorMessage)));
            }
            LOG.debug("Cannot evaluate '" + myExpression + "':" + errorMessage);
        }
    }, myExpressionPosition);
}
Also used : XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl) VirtualFile(com.intellij.openapi.vfs.VirtualFile) XDebugSessionImpl(com.intellij.xdebugger.impl.XDebugSessionImpl) XValue(com.intellij.xdebugger.frame.XValue) Disposer(com.intellij.openapi.util.Disposer) Logger(com.intellij.openapi.diagnostic.Logger) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) XDebugSession(com.intellij.xdebugger.XDebugSession) SimpleColoredText(com.intellij.ui.SimpleColoredText) XDebuggerEvaluateActionHandler(com.intellij.xdebugger.impl.actions.handlers.XDebuggerEvaluateActionHandler) HintUtil(com.intellij.codeInsight.hint.HintUtil) XValueNodePresentationConfigurator(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodePresentationConfigurator) XEvaluationCallbackBase(com.intellij.xdebugger.impl.ui.tree.nodes.XEvaluationCallbackBase) KeymapUtil(com.intellij.openapi.keymap.KeymapUtil) Nullable(org.jetbrains.annotations.Nullable) ConsoleView(com.intellij.execution.ui.ConsoleView) XSourcePosition(com.intellij.xdebugger.XSourcePosition) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ApplicationManager(com.intellij.openapi.application.ApplicationManager) LanguageConsoleView(com.intellij.execution.console.LanguageConsoleView) NotNull(org.jetbrains.annotations.NotNull) Consumer(com.intellij.util.Consumer) XDebuggerUtil(com.intellij.xdebugger.XDebuggerUtil) ValueHintType(com.intellij.xdebugger.impl.evaluate.quick.common.ValueHintType) DebuggerUIUtil(com.intellij.xdebugger.impl.ui.DebuggerUIUtil) ActionManager(com.intellij.openapi.actionSystem.ActionManager) ExpressionInfo(com.intellij.xdebugger.evaluation.ExpressionInfo) XDebuggerUIConstants(com.intellij.xdebugger.impl.ui.XDebuggerUIConstants) Project(com.intellij.openapi.project.Project) ShortcutSet(com.intellij.openapi.actionSystem.ShortcutSet) AbstractValueHint(com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent) ConsoleViewImpl(com.intellij.execution.impl.ConsoleViewImpl) XDebuggerTreeNodeHyperlink(com.intellij.xdebugger.frame.XDebuggerTreeNodeHyperlink) StringUtil(com.intellij.openapi.util.text.StringUtil) XFullValueEvaluator(com.intellij.xdebugger.frame.XFullValueEvaluator) Key(com.intellij.openapi.util.Key) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) Editor(com.intellij.openapi.editor.Editor) Disposable(com.intellij.openapi.Disposable) XValuePlace(com.intellij.xdebugger.frame.XValuePlace) MouseEvent(java.awt.event.MouseEvent) java.awt(java.awt) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) LinkMouseListenerBase(com.intellij.openapi.vcs.changes.issueLinks.LinkMouseListenerBase) Pair(com.intellij.openapi.util.Pair) XValuePresentation(com.intellij.xdebugger.frame.presentation.XValuePresentation) XValueMarkers(com.intellij.xdebugger.impl.frame.XValueMarkers) XDebuggerEvaluator(com.intellij.xdebugger.evaluation.XDebuggerEvaluator) javax.swing(javax.swing) XValuePresentation(com.intellij.xdebugger.frame.presentation.XValuePresentation) MouseEvent(java.awt.event.MouseEvent) XFullValueEvaluator(com.intellij.xdebugger.frame.XFullValueEvaluator) SimpleColoredText(com.intellij.ui.SimpleColoredText) XEvaluationCallbackBase(com.intellij.xdebugger.impl.ui.tree.nodes.XEvaluationCallbackBase) XValue(com.intellij.xdebugger.frame.XValue) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent)

Example 8 with SimpleColoredComponent

use of com.intellij.ui.SimpleColoredComponent in project intellij-community by JetBrains.

the class SimpleColoredComponentLinkMouseListener method tryGetTag.

@Override
protected Object tryGetTag(@NotNull MouseEvent e, @NotNull JTable table, int row, int column) {
    TableCellRenderer cellRenderer = table.getCellRenderer(row, column);
    Component component = cellRenderer.getTableCellRendererComponent(table, table.getValueAt(row, column), false, false, row, column);
    if (component instanceof SimpleColoredComponent) {
        Rectangle rc = table.getCellRect(row, column, false);
        return ((SimpleColoredComponent) component).getFragmentTagAt(e.getX() - rc.x);
    }
    return super.tryGetTag(e, table, row, column);
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent)

Example 9 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 10 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)

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