use of com.intellij.navigation.ColoredItemPresentation in project intellij-community by JetBrains.
the class PyStructureViewElement method getPresentation.
@NotNull
@Override
public ItemPresentation getPresentation() {
final PyElement element = getValue();
final ItemPresentation presentation = element != null ? element.getPresentation() : null;
return new ColoredItemPresentation() {
@Nullable
@Override
public String getPresentableText() {
if (element instanceof PyFile) {
return element.getName();
}
return presentation != null ? presentation.getPresentableText() : PyNames.UNNAMED_ELEMENT;
}
@Nullable
@Override
public TextAttributesKey getTextAttributesKey() {
if (isInherited()) {
return CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES;
}
return null;
}
@Nullable
@Override
public String getLocationString() {
return null;
}
@Nullable
@Override
public Icon getIcon(boolean open) {
if (element == null) {
return null;
}
Icon normal_icon = element.getIcon(0);
// override normal
if (myIcon != null)
normal_icon = myIcon;
if (myVisibility == Visibility.NORMAL) {
return normal_icon;
} else {
LayeredIcon icon = new LayeredIcon(2);
icon.setIcon(normal_icon, 0);
Icon overlay = null;
if (myVisibility == Visibility.PRIVATE || myVisibility == Visibility.PROTECTED) {
overlay = PythonIcons.Python.Nodes.Lock;
} else if (myVisibility == Visibility.PREDEFINED) {
overlay = PythonIcons.Python.Nodes.Cyan_dot;
} else if (myVisibility == Visibility.INVISIBLE) {
overlay = PythonIcons.Python.Nodes.Red_inv_triangle;
}
if (overlay != null) {
icon.setIcon(overlay, 1);
}
return icon;
}
}
};
}
use of com.intellij.navigation.ColoredItemPresentation in project intellij-community by JetBrains.
the class ClassPresentationProvider method getPresentation.
@Override
public ItemPresentation getPresentation(@NotNull final PsiClass psiClass) {
return new ColoredItemPresentation() {
@Override
public String getPresentableText() {
return ClassPresentationUtil.getNameForClass(psiClass, false);
}
@Override
public String getLocationString() {
PsiFile file = psiClass.getContainingFile();
if (file instanceof PsiClassOwner) {
PsiClassOwner classOwner = (PsiClassOwner) file;
String packageName = classOwner.getPackageName();
if (packageName.isEmpty())
return null;
return "(" + packageName + ")";
}
return null;
}
@Override
public TextAttributesKey getTextAttributesKey() {
try {
if (psiClass.isDeprecated()) {
return CodeInsightColors.DEPRECATED_ATTRIBUTES;
}
} catch (IndexNotReadyException ignore) {
}
return null;
}
@Override
public Icon getIcon(boolean open) {
return psiClass.getIcon(Iconable.ICON_FLAG_VISIBILITY | Iconable.ICON_FLAG_READ_STATUS);
}
};
}
use of com.intellij.navigation.ColoredItemPresentation in project intellij-community by JetBrains.
the class PsiElementListCellRenderer method getNavigationItemAttributes.
@Nullable
protected TextAttributes getNavigationItemAttributes(Object value) {
TextAttributes attributes = null;
if (value instanceof NavigationItem) {
TextAttributesKey attributesKey = null;
final ItemPresentation presentation = ((NavigationItem) value).getPresentation();
if (presentation instanceof ColoredItemPresentation)
attributesKey = ((ColoredItemPresentation) presentation).getTextAttributesKey();
if (attributesKey != null) {
attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey);
}
}
return attributes;
}
use of com.intellij.navigation.ColoredItemPresentation in project intellij-community by JetBrains.
the class NodeRenderer method getSimpleTextAttributes.
public static SimpleTextAttributes getSimpleTextAttributes(@Nullable final ItemPresentation presentation, @NotNull EditorColorsScheme colorsScheme) {
if (presentation instanceof ColoredItemPresentation) {
final TextAttributesKey textAttributesKey = ((ColoredItemPresentation) presentation).getTextAttributesKey();
if (textAttributesKey == null)
return SimpleTextAttributes.REGULAR_ATTRIBUTES;
final TextAttributes textAttributes = colorsScheme.getAttributes(textAttributesKey);
return textAttributes == null ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.fromTextAttributes(textAttributes);
}
return SimpleTextAttributes.REGULAR_ATTRIBUTES;
}
Aggregations