Search in sources :

Example 6 with SimpleColoredText

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

the class ValueHint method evaluateAndShowHint.

@Override
protected void evaluateAndShowHint() {
    final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
    final DebuggerSession debuggerSession = debuggerContext.getDebuggerSession();
    if (debuggerSession == null || !debuggerSession.isPaused())
        return;
    try {
        final ExpressionEvaluator evaluator = getExpressionEvaluator(debuggerContext);
        if (evaluator == null)
            return;
        debuggerContext.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {

            @Override
            public Priority getPriority() {
                return Priority.HIGH;
            }

            @Override
            public void threadAction() {
                try {
                    final EvaluationContextImpl evaluationContext = debuggerContext.createEvaluationContext();
                    final String expressionText = ApplicationManager.getApplication().runReadAction(new Computable<String>() {

                        @Override
                        public String compute() {
                            return myCurrentExpression.getText();
                        }
                    });
                    final TextWithImports text = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expressionText);
                    final Value value = myValueToShow != null ? myValueToShow : evaluator.evaluate(evaluationContext);
                    final WatchItemDescriptor descriptor = new WatchItemDescriptor(getProject(), text, value);
                    if (!isActiveTooltipApplicable(value) || getType() == ValueHintType.MOUSE_OVER_HINT) {
                        if (getType() == ValueHintType.MOUSE_OVER_HINT) {
                            // force using default renderer for mouse over hint in order to not to call accidentally methods while rendering
                            // otherwise, if the hint is invoked explicitly, show it with the right "auto" renderer
                            descriptor.setRenderer(DebugProcessImpl.getDefaultRenderer(value));
                        }
                        descriptor.updateRepresentation(evaluationContext, new DescriptorLabelListener() {

                            @Override
                            public void labelChanged() {
                                if (getCurrentRange() != null) {
                                    if (getType() != ValueHintType.MOUSE_OVER_HINT || descriptor.isValueValid()) {
                                        final SimpleColoredText simpleColoredText = DebuggerTreeRenderer.getDescriptorText(debuggerContext, descriptor, true);
                                        if (isActiveTooltipApplicable(value)) {
                                            simpleColoredText.append(" (" + DebuggerBundle.message("active.tooltip.suggestion") + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
                                        }
                                        showHint(simpleColoredText, descriptor);
                                    }
                                }
                            }
                        });
                    } else {
                        createAndShowTree(expressionText, descriptor);
                    }
                } catch (EvaluateException e) {
                    LOG.debug(e);
                }
            }
        });
    } catch (EvaluateException e) {
        LOG.debug(e);
    }
}
Also used : SimpleColoredText(com.intellij.ui.SimpleColoredText) DescriptorLabelListener(com.intellij.debugger.ui.tree.render.DescriptorLabelListener) ExpressionEvaluator(com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator) WatchItemDescriptor(com.intellij.debugger.ui.impl.watch.WatchItemDescriptor) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) PrimitiveValue(com.sun.jdi.PrimitiveValue) Value(com.sun.jdi.Value) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl)

Example 7 with SimpleColoredText

use of com.intellij.ui.SimpleColoredText in project intellij-plugins by JetBrains.

the class ChooseActiveBuildConfigurationAction method createPopup.

public static ListPopup createPopup(@NotNull Module module) {
    final DefaultActionGroup actionGroup = new DefaultActionGroup();
    final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(module);
    final FlexBuildConfiguration activeBc = manager.getActiveConfiguration();
    final FlexBuildConfiguration[] bcs = manager.getBuildConfigurations();
    Arrays.sort(bcs, (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()));
    for (final FlexBuildConfiguration bc : bcs) {
        actionGroup.add(new SelectBcAction(bc, manager));
    }
    actionGroup.addSeparator();
    actionGroup.add(new EditBcsAction(module));
    final DataContext dataContext = SimpleDataContext.getProjectContext(module.getProject());
    return new PopupFactoryImpl.ActionGroupPopup(FlexBundle.message("choose.build.configuration.popup.title", module.getName()), actionGroup, dataContext, false, false, false, true, null, -1, anAction -> anAction instanceof SelectBcAction && ((SelectBcAction) anAction).getBC() == activeBc, null) {

        @Override
        protected ListCellRenderer getListElementRenderer() {
            return new PopupListElementRenderer(this) {

                {
                //myRendererComponent.setBorder(new EmptyBorder(5, 0, 5, 0));
                }

                @Override
                protected JComponent createItemComponent() {
                    return new MyPanel();
                }

                @Override
                public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
                    MyPanel p = (MyPanel) myComponent;
                    p.clear();
                    PopupFactoryImpl.ActionItem actionItem = (PopupFactoryImpl.ActionItem) value;
                    AnAction anAction = actionItem.getAction();
                    SimpleColoredText text;
                    Icon icon;
                    boolean isActive;
                    if (anAction instanceof SelectBcAction) {
                        FlexBuildConfiguration bc = ((SelectBcAction) anAction).getBC();
                        isActive = bc == activeBc;
                        text = BCUtils.renderBuildConfiguration(bc, null, isActive);
                        icon = bc.getIcon();
                    } else {
                        text = new SimpleColoredText(anAction.getTemplatePresentation().getText(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
                        icon = anAction.getTemplatePresentation().getIcon();
                        isActive = false;
                    }
                    RowIcon rowIcon = new RowIcon(2);
                    rowIcon.setIcon(isActive ? (isSelected ? ICON_ACTIVE_SELECTED : ICON_ACTIVE) : ICON_EMPTY, 0);
                    rowIcon.setIcon(icon, 1);
                    p.setIcon(rowIcon);
                    if (isSelected) {
                        text = text.derive(SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES, true);
                        setSelected(p);
                    } else {
                        setDeselected(p);
                    }
                    p.setText(text);
                    mySeparatorComponent.setVisible(actionItem.isPrependWithSeparator());
                    return myRendererComponent;
                }
            };
        }
    };
}
Also used : PopupFactoryImpl(com.intellij.ui.popup.PopupFactoryImpl) SimpleColoredText(com.intellij.ui.SimpleColoredText) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) RowIcon(com.intellij.ui.RowIcon) PopupListElementRenderer(com.intellij.ui.popup.list.PopupListElementRenderer) SimpleDataContext(com.intellij.openapi.actionSystem.impl.SimpleDataContext) FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) RowIcon(com.intellij.ui.RowIcon) EmptyIcon(com.intellij.util.ui.EmptyIcon)

Example 8 with SimpleColoredText

use of com.intellij.ui.SimpleColoredText in project intellij-plugins by JetBrains.

the class BCUtils method renderBuildConfiguration.

public static SimpleColoredText renderBuildConfiguration(@NotNull FlexBuildConfiguration bc, @Nullable String moduleName, boolean bold) {
    SimpleColoredText text = new SimpleColoredText();
    text.append(bc.getShortText(), bold ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES);
    text.append(" (" + bc.getDescription() + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
    if (moduleName != null) {
        text.append(" - " + moduleName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
    return text;
}
Also used : SimpleColoredText(com.intellij.ui.SimpleColoredText)

Example 9 with SimpleColoredText

use of com.intellij.ui.SimpleColoredText in project intellij-plugins by JetBrains.

the class FlashUmlElementManager method decorate.

private SimpleColoredText decorate(String name) {
    int style = SimpleTextAttributes.STYLE_BOLD;
    final SimpleColoredText text = new SimpleColoredText();
    text.append(name, new SimpleTextAttributes(style, getFGColor()));
    return text;
}
Also used : SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) SimpleColoredText(com.intellij.ui.SimpleColoredText)

Example 10 with SimpleColoredText

use of com.intellij.ui.SimpleColoredText in project intellij-plugins by JetBrains.

the class FlashUmlElementManager method getClassPresentableName.

private SimpleColoredText getClassPresentableName(JSClass clazz) {
    int style = SimpleTextAttributes.STYLE_BOLD;
    if (clazz.isDeprecated())
        style |= SimpleTextAttributes.STYLE_STRIKEOUT;
    if (!clazz.isPhysical())
        style |= SimpleTextAttributes.STYLE_ITALIC;
    final SimpleColoredText text = new SimpleColoredText();
    String name = StringUtil.notNullize(clazz.getName());
    text.append(FlashUmlVfsResolver.fixVectorTypeName(name), new SimpleTextAttributes(style, getFGColor()));
    return text;
}
Also used : SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) SimpleColoredText(com.intellij.ui.SimpleColoredText)

Aggregations

SimpleColoredText (com.intellij.ui.SimpleColoredText)11 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)5 IDevice (com.android.ddmlib.IDevice)2 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)2 Pair (com.intellij.openapi.util.Pair)2 Test (org.junit.Test)2 HintUtil (com.intellij.codeInsight.hint.HintUtil)1 ExpressionEvaluator (com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator)1 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)1 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)1 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)1 WatchItemDescriptor (com.intellij.debugger.ui.impl.watch.WatchItemDescriptor)1 DescriptorLabelListener (com.intellij.debugger.ui.tree.render.DescriptorLabelListener)1 LanguageConsoleView (com.intellij.execution.console.LanguageConsoleView)1 ConsoleViewImpl (com.intellij.execution.impl.ConsoleViewImpl)1 ConsoleView (com.intellij.execution.ui.ConsoleView)1 FlexModuleType (com.intellij.lang.javascript.flex.FlexModuleType)1 FlexBuildConfigurationManager (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager)1 Disposable (com.intellij.openapi.Disposable)1 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1