use of com.intellij.ui.LayeredIcon in project intellij-plugins by JetBrains.
the class DartTypeHierarchyNodeDescriptor method update.
public final boolean update() {
boolean changes = super.update();
final DartClass dartClass = getDartClass();
if (dartClass == null) {
final String invalidPrefix = IdeBundle.message("node.hierarchy.invalid");
if (!myHighlightedText.getText().startsWith(invalidPrefix)) {
myHighlightedText.getBeginning().addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes());
}
return true;
}
if (changes && myIsBase) {
final LayeredIcon icon = new LayeredIcon(2);
icon.setIcon(getIcon(), 0);
icon.setIcon(AllIcons.Hierarchy.Base, 1, -AllIcons.Hierarchy.Base.getIconWidth() / 2, 0);
setIcon(icon);
}
final CompositeAppearance oldText = myHighlightedText;
myHighlightedText = new CompositeAppearance();
TextAttributes classNameAttributes = null;
if (myColor != null) {
classNameAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN);
}
final String libraryName = DartResolveUtil.getLibraryName(dartClass.getContainingFile());
myHighlightedText.getEnding().addText(dartClass.getName(), classNameAttributes);
myHighlightedText.getEnding().addText(" (" + libraryName + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
myName = myHighlightedText.getText();
if (!Comparing.equal(myHighlightedText, oldText)) {
changes = true;
}
return changes;
}
use of com.intellij.ui.LayeredIcon in project intellij-plugins by JetBrains.
the class Struts2IconProvider method getIcon.
@Nullable
public Icon getIcon(@NotNull final PsiElement element, final int flags) {
if (!(element instanceof PsiClass)) {
return null;
}
// IconProvider queries non-physical PSI as well (e.g. completion items); check validity
if (!element.isPhysical() || !element.isValid()) {
return null;
}
// no icons when no facet present
final Module module = ModuleUtilCore.findModuleForPsiElement(element);
if (module == null) {
return null;
}
final StrutsFacet strutsFacet = StrutsFacet.getInstance(module);
if (strutsFacet == null) {
return null;
}
// handle suitable JAVA classes --> overlay icon
final PsiClass psiClass = (PsiClass) element;
if (psiClass.isInterface() || psiClass.isEnum() || !psiClass.hasModifierProperty(PsiModifier.PUBLIC) || psiClass.hasModifierProperty(PsiModifier.ABSTRACT) || !JamCommonUtil.isPlainJavaFile(psiClass.getContainingFile())) {
return null;
}
final StrutsModel strutsModel = StrutsManager.getInstance(psiClass.getProject()).getCombinedModel(module);
if (strutsModel == null || !strutsModel.isActionClass(psiClass)) {
return null;
}
final LayeredIcon layeredIcon = new LayeredIcon(2);
final Icon original = PsiClassImplUtil.getClassIcon(flags, psiClass);
layeredIcon.setIcon(original, 0);
layeredIcon.setIcon(Struts2Icons.Action_small, 1, StrutsIcons.OVERLAY_X_OFFSET, StrutsIcons.OVERLAY_Y_OFFSET);
return JBUI.scale(layeredIcon);
}
use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.
the class FindAllAction method updateTemplateIcon.
private void updateTemplateIcon(@Nullable EditorSearchSession session) {
if (session == null || getTemplatePresentation().getIcon() != null)
return;
Icon base = AllIcons.Actions.Find;
Icon text = IconUtil.textToIcon("ALL", session.getComponent(), JBUI.scale(6F));
LayeredIcon icon = new LayeredIcon(2);
icon.setIcon(base, 0);
icon.setIcon(text, 1, 0, base.getIconHeight() - text.getIconHeight());
getTemplatePresentation().setIcon(icon);
}
use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.
the class JavaFileIconPatcher method patchIcon.
@Override
public Icon patchIcon(final Icon baseIcon, final VirtualFile file, final int flags, final Project project) {
if (project == null) {
return baseIcon;
}
Icon icon = replaceIcon(file, flags, project, baseIcon);
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
if (fileIndex.isInSource(file) && CompilerManager.getInstance(project).isExcludedFromCompilation(file)) {
return new LayeredIcon(icon, PlatformIcons.EXCLUDED_FROM_COMPILE_ICON);
}
return icon;
}
use of com.intellij.ui.LayeredIcon in project intellij-community by JetBrains.
the class CallHierarchyNodeDescriptor method update.
public final boolean update() {
final CompositeAppearance oldText = myHighlightedText;
final Icon oldIcon = getIcon();
int flags = Iconable.ICON_FLAG_VISIBILITY;
if (isMarkReadOnly()) {
flags |= Iconable.ICON_FLAG_READ_STATUS;
}
boolean changes = super.update();
final PsiElement enclosingElement = getEnclosingElement();
if (enclosingElement == null) {
final String invalidPrefix = IdeBundle.message("node.hierarchy.invalid");
if (!myHighlightedText.getText().startsWith(invalidPrefix)) {
myHighlightedText.getBeginning().addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes());
}
return true;
}
Icon newIcon = enclosingElement.getIcon(flags);
if (changes && myIsBase) {
final 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);
}
if (enclosingElement instanceof PsiMethod) {
if (enclosingElement instanceof SyntheticElement) {
PsiFile file = enclosingElement.getContainingFile();
myHighlightedText.getEnding().addText(file != null ? file.getName() : IdeBundle.message("node.call.hierarchy.unknown.jsp"), mainTextAttributes);
} else {
final PsiMethod method = (PsiMethod) enclosingElement;
final StringBuilder buffer = new StringBuilder(128);
final PsiClass containingClass = method.getContainingClass();
if (containingClass != null) {
buffer.append(ClassPresentationUtil.getNameForClass(containingClass, false));
buffer.append('.');
}
final String methodText = PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS, PsiFormatUtilBase.SHOW_TYPE);
buffer.append(methodText);
myHighlightedText.getEnding().addText(buffer.toString(), mainTextAttributes);
}
} else if (FileTypeUtils.isInServerPageFile(enclosingElement) && enclosingElement instanceof PsiFile) {
final PsiFile file = PsiUtilCore.getTemplateLanguageFile(enclosingElement);
myHighlightedText.getEnding().addText(file.getName(), mainTextAttributes);
} else {
myHighlightedText.getEnding().addText(ClassPresentationUtil.getNameForClass((PsiClass) enclosingElement, false), mainTextAttributes);
}
if (myUsageCount > 1) {
myHighlightedText.getEnding().addText(IdeBundle.message("node.call.hierarchy.N.usages", myUsageCount), HierarchyNodeDescriptor.getUsageCountPrefixAttributes());
}
if (!(FileTypeUtils.isInServerPageFile(enclosingElement) && enclosingElement instanceof PsiFile)) {
final PsiClass containingClass = enclosingElement instanceof PsiMethod ? ((PsiMethod) enclosingElement).getContainingClass() : (PsiClass) enclosingElement;
if (containingClass != null) {
final String packageName = JavaHierarchyUtil.getPackageName(containingClass);
myHighlightedText.getEnding().addText(" (" + packageName + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
}
}
myName = myHighlightedText.getText();
if (!Comparing.equal(myHighlightedText, oldText) || !Comparing.equal(getIcon(), oldIcon)) {
changes = true;
}
return changes;
}
Aggregations