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);
}
}
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;
}
};
}
};
}
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;
}
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;
}
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;
}
Aggregations