use of com.intellij.ui.LayeredIcon 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.ui.LayeredIcon in project intellij-community by JetBrains.
the class PySdkListCellRenderer method wrapIconWithWarningDecorator.
private static LayeredIcon wrapIconWithWarningDecorator(Icon icon) {
final LayeredIcon layered = new LayeredIcon(2);
layered.setIcon(icon, 0);
final Icon overlay = AllIcons.Actions.Cancel;
layered.setIcon(overlay, 1);
return layered;
}
use of com.intellij.ui.LayeredIcon in project kotlin by JetBrains.
the class KotlinCallHierarchyNodeDescriptor method update.
@Override
public final boolean update() {
CompositeAppearance oldText = myHighlightedText;
Icon oldIcon = getIcon();
int flags = Iconable.ICON_FLAG_VISIBILITY;
if (isMarkReadOnly()) {
flags |= Iconable.ICON_FLAG_READ_STATUS;
}
boolean changes = super.update();
PsiElement targetElement = getTargetElement();
String elementText = renderElement(targetElement);
if (elementText == null) {
String invalidPrefix = IdeBundle.message("node.hierarchy.invalid");
if (!myHighlightedText.getText().startsWith(invalidPrefix)) {
myHighlightedText.getBeginning().addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes());
}
return true;
}
Icon newIcon = targetElement.getIcon(flags);
if (changes && myIsBase) {
LayeredIcon icon = new LayeredIcon(2);
icon.setIcon(newIcon, 0);
icon.setIcon(AllIcons.Hierarchy.Base, 1, -AllIcons.Hierarchy.Base.getIconWidth() / 2, 0);
newIcon = icon;
}
setIcon(newIcon);
myHighlightedText = new CompositeAppearance();
TextAttributes mainTextAttributes = null;
if (myColor != null) {
mainTextAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN);
}
String packageName = null;
if (targetElement instanceof KtElement) {
packageName = KtPsiUtil.getPackageName((KtElement) targetElement);
} else {
PsiClass enclosingClass = PsiTreeUtil.getParentOfType(targetElement, PsiClass.class, false);
if (enclosingClass != null) {
packageName = JavaHierarchyUtil.getPackageName(enclosingClass);
}
}
myHighlightedText.getEnding().addText(elementText, mainTextAttributes);
if (usageCount > 1) {
myHighlightedText.getEnding().addText(IdeBundle.message("node.call.hierarchy.N.usages", usageCount), HierarchyNodeDescriptor.getUsageCountPrefixAttributes());
}
if (packageName == null) {
packageName = "";
}
myHighlightedText.getEnding().addText(" (" + packageName + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
myName = myHighlightedText.getText();
if (!(Comparing.equal(myHighlightedText, oldText) && Comparing.equal(getIcon(), oldIcon))) {
changes = true;
}
return changes;
}
use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.
the class IdeConsoleRootType method substituteIcon.
@Nullable
@Override
public Icon substituteIcon(@NotNull Project project, @NotNull VirtualFile file) {
FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(file.getName());
if (fileType == UnknownFileType.INSTANCE || fileType == PlainTextFileType.INSTANCE) {
return AllIcons.Debugger.ToolConsole;
}
Icon icon = fileType.getIcon();
Icon subscript = ((ScalableIcon) AllIcons.Debugger.ToolConsole).scale(.5f);
LayeredIcon icons = new LayeredIcon(2);
icons.setIcon(icon, 0);
icons.setIcon(subscript, 1, 8, 8);
return JBUI.scale(icons);
}
use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.
the class SameSignatureCallParametersProvider method createParametersLookupElement.
private static LookupElement createParametersLookupElement(final PsiMethod takeParametersFrom, PsiElement call, PsiMethod invoked) {
final PsiParameter[] parameters = takeParametersFrom.getParameterList().getParameters();
final String lookupString = StringUtil.join(parameters, psiParameter -> psiParameter.getName(), ", ");
final int w = PlatformIcons.PARAMETER_ICON.getIconWidth();
LayeredIcon icon = new LayeredIcon(2);
icon.setIcon(PlatformIcons.PARAMETER_ICON, 0, 2 * w / 5, 0);
icon.setIcon(PlatformIcons.PARAMETER_ICON, 1);
LookupElementBuilder element = LookupElementBuilder.create(lookupString).withIcon(icon);
if (PsiTreeUtil.isAncestor(takeParametersFrom, call, true)) {
element = element.withInsertHandler(new InsertHandler<LookupElement>() {
@Override
public void handleInsert(InsertionContext context, LookupElement item) {
context.commitDocument();
for (PsiParameter parameter : CompletionUtil.getOriginalOrSelf(takeParametersFrom).getParameterList().getParameters()) {
VariableLookupItem.makeFinalIfNeeded(context, parameter);
}
}
});
}
element.putUserData(JavaCompletionUtil.SUPER_METHOD_PARAMETERS, Boolean.TRUE);
return TailTypeDecorator.withTail(element, ExpectedTypesProvider.getFinalCallParameterTailType(call, invoked.getReturnType(), invoked));
}
Aggregations