use of com.intellij.ui.SimpleTextAttributes 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);
}
}
});
}
use of com.intellij.ui.SimpleTextAttributes in project intellij-community by JetBrains.
the class SliceUsageCellRenderer method customizeCellRendererFor.
@Override
public void customizeCellRendererFor(@NotNull SliceUsage sliceUsage) {
boolean isForcedLeaf = sliceUsage instanceof JavaSliceDereferenceUsage;
//might come SliceTooComplexDFAUsage
JavaSliceUsage javaSliceUsage = sliceUsage instanceof JavaSliceUsage ? (JavaSliceUsage) sliceUsage : null;
TextChunk[] text = sliceUsage.getText();
boolean isInsideContainer = javaSliceUsage != null && javaSliceUsage.indexNesting != 0;
for (int i = 0, length = text.length; i < length; i++) {
TextChunk textChunk = text[i];
SimpleTextAttributes attributes = textChunk.getSimpleAttributesIgnoreBackground();
if (isForcedLeaf) {
attributes = attributes.derive(attributes.getStyle(), JBColor.LIGHT_GRAY, attributes.getBgColor(), attributes.getWaveColor());
}
boolean inUsage = BitUtil.isSet(attributes.getFontStyle(), Font.BOLD);
if (isInsideContainer && inUsage) {
//Color darker = Color.BLACK;//attributes.getBgColor() == null ? Color.BLACK : attributes.getBgColor().darker();
//attributes = attributes.derive(SimpleTextAttributes.STYLE_OPAQUE, attributes.getFgColor(), UIUtil.getTreeBackground().brighter(), attributes.getWaveColor());
//setMyBorder(IdeBorderFactory.createRoundedBorder(10, 3));
//setPaintFocusBorder(true);
}
append(textChunk.getText(), attributes);
if (i == 0) {
append(FontUtil.spaceAndThinSpace());
}
}
if (javaSliceUsage != null && javaSliceUsage.indexNesting != 0) {
append(" (Tracking container '" + getContainerName(javaSliceUsage) + (javaSliceUsage.syntheticField.isEmpty() ? "" : "." + javaSliceUsage.syntheticField) + "' contents)", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
}
PsiElement element = sliceUsage.getElement();
PsiMethod method;
PsiClass aClass;
while (true) {
method = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
aClass = method == null ? PsiTreeUtil.getParentOfType(element, PsiClass.class) : method.getContainingClass();
if (aClass instanceof PsiAnonymousClass) {
element = aClass;
} else {
break;
}
}
int methodOptions = PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS | PsiFormatUtilBase.SHOW_CONTAINING_CLASS;
String location = method != null ? PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY, methodOptions, PsiFormatUtilBase.SHOW_TYPE, 2) : aClass != null ? PsiFormatUtil.formatClass(aClass, PsiFormatUtilBase.SHOW_NAME) : null;
if (location != null) {
SimpleTextAttributes attributes = SimpleTextAttributes.GRAY_ATTRIBUTES;
append(" in " + location, attributes);
}
Language language = element == null ? JavaLanguage.INSTANCE : element.getLanguage();
if (language != JavaLanguage.INSTANCE) {
SliceLanguageSupportProvider foreignSlicing = LanguageSlicing.getProvider(element);
if (foreignSlicing == null) {
append(" (in " + language.getDisplayName() + " file - stopped here)", SimpleTextAttributes.EXCLUDED_ATTRIBUTES);
}
}
}
use of com.intellij.ui.SimpleTextAttributes in project intellij-community by JetBrains.
the class VcsLinkedTextComponent method render.
public void render(@NotNull ColoredTreeCellRenderer renderer) {
boolean isActive = mySelected || myUnderlined;
SimpleTextAttributes linkTextAttributes = isActive ? SimpleTextAttributes.LINK_ATTRIBUTES : SimpleTextAttributes.SYNTHETIC_ATTRIBUTES;
isActive = isActive || !myTransparent;
SimpleTextAttributes wrappedTextAttributes = PushLogTreeUtil.addTransparencyIfNeeded(SimpleTextAttributes.REGULAR_ATTRIBUTES, isActive);
if (!StringUtil.isEmptyOrSpaces(myTextBefore)) {
renderer.append(myTextBefore, wrappedTextAttributes);
renderer.append(" ");
}
if (!StringUtil.isEmptyOrSpaces(myHandledLink)) {
renderer.append(myHandledLink, PushLogTreeUtil.addTransparencyIfNeeded(linkTextAttributes, isActive), this);
}
renderer.append(myTextAfter, wrappedTextAttributes);
}
use of com.intellij.ui.SimpleTextAttributes in project intellij-plugins by JetBrains.
the class AbstractInfoCellRenderer method appendFrameInfo.
protected void appendFrameInfo(@NotNull FrameInfo info, boolean selected) {
append(info.toSimpleString());
final SimpleTextAttributes additionalInfoColorAttributes = selected ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES;
if (info.getPackageName() != null && info.getPackageName().length() > 0) {
append(" (" + info.getPackageName() + ")", additionalInfoColorAttributes);
}
if (info.isInnerClass() && info.getFileName() != null) {
String location = info.getFileName();
if (info.getFileLine() >= 0) {
location += ":" + info.getFileLine();
}
append(" " + location, additionalInfoColorAttributes);
}
}
use of com.intellij.ui.SimpleTextAttributes in project android by JetBrains.
the class PNameRenderer method getTableCellRendererComponent.
@Override
public Component getTableCellRendererComponent(@NotNull JTable table, @NotNull Object value, boolean isSelected, boolean cellHasFocus, int row, int column) {
myRenderer.clear();
PTable ptable = (PTable) table;
PTableItem item = (PTableItem) value;
myRenderer.getTableCellRendererComponent(table, value, isSelected, cellHasFocus, row, column);
myRenderer.setBackground(isSelected ? UIUtil.getTableSelectionBackground() : table.getBackground());
boolean hoveringOnStar = ptable.isHover(row, column) && hitTestStarIcon(ptable.getHoverPosition().x);
myStarLabel.setIcon(getStar(item.getStarState(), isSelected, hoveringOnStar));
myPanel.setBackground(isSelected ? UIUtil.getTableSelectionBackground() : table.getBackground());
SimpleTextAttributes attr = SimpleTextAttributes.REGULAR_ATTRIBUTES;
SearchUtil.appendFragments(((PTable) table).getSpeedSearch().getEnteredPrefix(), item.getName(), attr.getStyle(), attr.getFgColor(), attr.getBgColor(), myRenderer);
myRenderer.setToolTipText(item.getTooltipText());
return myPanel;
}
Aggregations