Search in sources :

Example 1 with SimpleColoredText

use of com.intellij.ui.SimpleColoredText 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 2 with SimpleColoredText

use of com.intellij.ui.SimpleColoredText in project android by JetBrains.

the class DeviceRendererTest method deviceNameRendering2.

@Test
public void deviceNameRendering2() throws Exception {
    String serial = "123";
    IDevice d = createDevice(true, "Avdname", "google", "nexus 4", "4.2", "17", serial, IDevice.DeviceState.BOOTLOADER);
    SimpleColoredText target = new SimpleColoredText();
    DeviceRenderer.renderDeviceName(d, target);
    String name = target.toString();
    assertFalse(StringUtil.containsIgnoreCase(name, "Nexus 4"));
    assertTrue(StringUtil.containsIgnoreCase(name, "Avdname"));
    assertTrue(StringUtil.containsIgnoreCase(name, IDevice.DeviceState.BOOTLOADER.toString()));
    assertTrue(StringUtil.containsIgnoreCase(name, serial));
}
Also used : SimpleColoredText(com.intellij.ui.SimpleColoredText) IDevice(com.android.ddmlib.IDevice) Test(org.junit.Test)

Example 3 with SimpleColoredText

use of com.intellij.ui.SimpleColoredText in project android by JetBrains.

the class DeviceRendererTest method deviceNameRendering1.

@Test
public void deviceNameRendering1() throws Exception {
    String serial = "123";
    IDevice d = createDevice(false, null, "google", "nexus 4", "4.2", "17", serial, IDevice.DeviceState.ONLINE);
    SimpleColoredText target = new SimpleColoredText();
    DeviceRenderer.renderDeviceName(d, target);
    String name = target.toString();
    assertEquals("Google Nexus 4 Android 4.2, API 17", name);
    // status should be shown only if !online
    assertFalse(StringUtil.containsIgnoreCase(name, IDevice.DeviceState.ONLINE.toString()));
    // serial should be shown only if !online
    assertFalse(StringUtil.containsIgnoreCase(name, serial));
}
Also used : SimpleColoredText(com.intellij.ui.SimpleColoredText) IDevice(com.android.ddmlib.IDevice) Test(org.junit.Test)

Example 4 with SimpleColoredText

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

the class FocusDebugger method propertyChange.

@Override
public void propertyChange(PropertyChangeEvent evt) {
    final Object newValue = evt.getNewValue();
    final Object oldValue = evt.getOldValue();
    boolean affectsDebugger = false;
    if (newValue instanceof Component && isInsideDebuggerDialog((Component) newValue)) {
        affectsDebugger |= true;
    }
    if (oldValue instanceof Component && isInsideDebuggerDialog((Component) oldValue)) {
        affectsDebugger |= true;
    }
    final SimpleColoredText text = new SimpleColoredText();
    text.append(evt.getPropertyName(), maybeGrayOut(new SimpleTextAttributes(SimpleTextAttributes.STYLE_UNDERLINE, null), affectsDebugger));
    text.append(" newValue=", maybeGrayOut(SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES, affectsDebugger));
    text.append(evt.getNewValue() + "", maybeGrayOut(SimpleTextAttributes.REGULAR_ATTRIBUTES, affectsDebugger));
    text.append(" oldValue=" + evt.getOldValue(), maybeGrayOut(SimpleTextAttributes.REGULAR_ATTRIBUTES, affectsDebugger));
    myLogModel.addElement(new FocusElement(text, new Throwable()));
    SwingUtilities.invokeLater(() -> {
        if (myLog != null && myLog.isShowing()) {
            final int h = myLog.getFixedCellHeight();
            myLog.scrollRectToVisible(new Rectangle(0, myLog.getPreferredSize().height - h, myLog.getWidth(), h));
            if (myLog.getModel().getSize() > 0) {
                myLog.setSelectedIndex(myLog.getModel().getSize() - 1);
            }
        }
    });
}
Also used : SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) SimpleColoredText(com.intellij.ui.SimpleColoredText)

Example 5 with SimpleColoredText

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

the class BCCombo method initCombo.

private void initCombo() {
    setMinimumSize(new Dimension(150, getMinimumSize().height));
    final Collection<FlexBuildConfiguration> allConfigs = new ArrayList<>();
    final Module[] modules = ModuleManager.getInstance(myProject).getModules();
    mySingleModuleProject = modules.length == 1;
    for (final Module module : modules) {
        if (ModuleType.get(module) instanceof FlexModuleType) {
            for (final FlexBuildConfiguration config : FlexBuildConfigurationManager.getInstance(module).getBuildConfigurations()) {
                allConfigs.add(config);
                myBCToModuleMap.put(config, module);
            }
        }
    }
    myAllConfigs = allConfigs.toArray(new FlexBuildConfiguration[allConfigs.size()]);
    setRenderer(new ColoredListCellRendererWrapper() {

        @Override
        protected void doCustomize(final JList list, final Object value, final int index, final boolean selected, final boolean hasFocus) {
            if (value instanceof Pair) {
                final String moduleName = (String) ((Pair) value).first;
                final String configName = (String) ((Pair) value).second;
                //setIcon(PlatformIcons.ERROR_INTRODUCTION_ICON);
                if (moduleName.isEmpty() || configName.isEmpty()) {
                    append(new SimpleColoredText("[none]", SimpleTextAttributes.ERROR_ATTRIBUTES));
                } else {
                    append(BCUtils.renderMissingBuildConfiguration(configName, moduleName));
                }
            } else {
                assert value instanceof FlexBuildConfiguration : value;
                final FlexBuildConfiguration bc = (FlexBuildConfiguration) value;
                setIcon(bc.getIcon());
                append(BCUtils.renderBuildConfiguration(bc, mySingleModuleProject ? null : myBCToModuleMap.get(bc).getName()));
            }
        }
    });
    addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            // remove invalid entry
            final Object selectedItem = getSelectedItem();
            final Object firstItem = getItemAt(0);
            if (selectedItem instanceof FlexBuildConfiguration && !(firstItem instanceof FlexBuildConfiguration)) {
                setModel(new DefaultComboBoxModel(myAllConfigs));
                setSelectedItem(selectedItem);
            }
        }
    });
}
Also used : ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) SimpleColoredText(com.intellij.ui.SimpleColoredText) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) ActionListener(java.awt.event.ActionListener) FlexModuleType(com.intellij.lang.javascript.flex.FlexModuleType) Module(com.intellij.openapi.module.Module) ColoredListCellRendererWrapper(com.intellij.ui.ColoredListCellRendererWrapper) Pair(com.intellij.openapi.util.Pair)

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