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-community by JetBrains.
the class PackagingElementNode method addErrorHighlighting.
private static SimpleTextAttributes addErrorHighlighting(boolean error, SimpleTextAttributes attributes) {
final TextAttributes textAttributes = attributes.toTextAttributes();
textAttributes.setEffectType(EffectType.WAVE_UNDERSCORE);
textAttributes.setEffectColor(error ? JBColor.RED : JBColor.GRAY);
return SimpleTextAttributes.fromTextAttributes(textAttributes);
}
use of com.intellij.ui.SimpleTextAttributes in project intellij-community by JetBrains.
the class LibraryTreeRenderer method customizeCellRenderer.
@Override
public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
Object userObject = node.getUserObject();
if (userObject instanceof NodeDescriptor) {
final NodeDescriptor descriptor = (NodeDescriptor) userObject;
setIcon(descriptor.getIcon());
append(descriptor.toString(), new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, descriptor.getColor()));
}
}
use of com.intellij.ui.SimpleTextAttributes in project intellij-community by JetBrains.
the class UnknownFileTypeDiffRequest method getComponent.
@NotNull
@Override
public JComponent getComponent(@NotNull final DiffContext context) {
final SimpleColoredComponent label = new SimpleColoredComponent();
label.setTextAlign(SwingConstants.CENTER);
label.append("Can't show diff for unknown file type. ", new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, UIUtil.getInactiveTextColor()));
if (myFileName != null) {
label.append("Associate", SimpleTextAttributes.LINK_ATTRIBUTES, new Runnable() {
@Override
public void run() {
FileType type = FileTypeChooser.associateFileType(myFileName);
if (type != null)
onSuccess(context);
}
});
LinkMouseListenerBase.installSingleTagOn(label);
}
return new DiffUtil.CenteredPanel(label, JBUI.Borders.empty(5));
}
Aggregations