private static LookupElementBuilder createOverridingLookupElement(boolean implemented, final PsiMethod baseMethod, PsiClass baseClass, PsiSubstitutor substitutor) { RowIcon icon = new RowIcon(baseMethod.getIcon(0), implemented ? AllIcons.Gutter.ImplementingMethod : AllIcons.Gutter.OverridingMethod); return createGenerateMethodElement(baseMethod, substitutor, icon, baseClass.getName(), new InsertHandler<LookupElement>() { @Override public void handleInsert(InsertionContext context, LookupElement item) { removeLookupString(context); final PsiClass parent = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getStartOffset(), PsiClass.class, false); if (parent == null) return; List<PsiMethod> prototypes = OverrideImplementUtil.overrideOrImplementMethod(parent, baseMethod, false); insertGenerationInfos(context, OverrideImplementUtil.convert2GenerationInfos(prototypes)); } }); }
protected Icon patchIcon(Icon original, VirtualFile file) { Icon icon = original; final Bookmark bookmarkAtFile = BookmarkManager.getInstance(myProject).findFileBookmark(file); if (bookmarkAtFile != null) { final RowIcon composite = new RowIcon(2, RowIcon.Alignment.CENTER); composite.setIcon(icon, 0); composite.setIcon(bookmarkAtFile.getIcon(), 1); icon = composite; } if (!file.isWritable()) { icon = LayeredIcon.create(icon, PlatformIcons.LOCKED_ICON); } if (file.is(VFileProperty.SYMLINK)) { icon = LayeredIcon.create(icon, PlatformIcons.SYMLINK_ICON); } return icon; }
private static LookupElementBuilder createOverridingLookupElement(final PsiClass parent, boolean implemented, final PsiMethod baseMethod, PsiClass baseClass, PsiSubstitutor substitutor) { RowIcon icon = new RowIcon(2); icon.setIcon(baseMethod.getIcon(0), 0); icon.setIcon(implemented ? AllIcons.Gutter.ImplementingMethod : AllIcons.Gutter.OverridingMethod, 1); return createGenerateMethodElement(baseMethod, substitutor, icon, baseClass.getName(), new InsertHandler<LookupElement>() { @Override public void handleInsert(InsertionContext context, LookupElement item) { removeLookupString(context); List<PsiMethod> prototypes = OverrideImplementUtil.overrideOrImplementMethod(parent, baseMethod, false); insertGenerationInfos(context, OverrideImplementUtil.convert2GenerationInfos(prototypes)); } }); }
@Nonnull public Icon toIcon() { Icon mainIcon = null; if(myLayerIcons == null) { mainIcon = myMainIcon; } else { LayeredIcon layeredIcon = new LayeredIcon(myLayerIcons.size() + 1); layeredIcon.setIcon(myMainIcon, 0); for (int i = 0; i < myLayerIcons.size(); i++) { Icon icon = myLayerIcons.get(i); layeredIcon.setIcon(icon, i + 1); } mainIcon = layeredIcon; } if(myRightIcon == null) { return mainIcon == null ? EmptyIcon.ICON_16 : mainIcon; } else { RowIcon baseIcon = new RowIcon(2); baseIcon.setIcon(mainIcon, 0); baseIcon.setIcon(myRightIcon, 1); return baseIcon; } }
protected Icon patchIcon(Icon original, VirtualFile file) { Icon icon = original; final Bookmark bookmarkAtFile = BookmarkManager.getInstance(myProject).findFileBookmark(file); if (bookmarkAtFile != null) { final RowIcon composite = new RowIcon(2, RowIcon.Alignment.CENTER); composite.setIcon(icon, 0); composite.setIcon(bookmarkAtFile.getIcon(), 1); icon = composite; } if (!file.isWritable()) { icon = LayeredIcon.create(icon, AllIcons.Nodes.Locked); } if (file.is(VFileProperty.SYMLINK)) { icon = LayeredIcon.create(icon, AllIcons.Nodes.Symlink); } return icon; }
private static LookupElementBuilder createOverridingLookupElement(boolean implemented, final PsiMethod baseMethod, PsiClass baseClass, PsiSubstitutor substitutor) { RowIcon icon = new RowIcon(IconDescriptorUpdaters.getIcon(baseMethod, 0), implemented ? AllIcons.Gutter.ImplementingMethod : AllIcons.Gutter.OverridingMethod); return createGenerateMethodElement(baseMethod, substitutor, icon, baseClass.getName(), new InsertHandler<LookupElement>() { @Override public void handleInsert(InsertionContext context, LookupElement item) { removeLookupString(context); final PsiClass parent = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getStartOffset(), PsiClass.class, false); if(parent == null) { return; } List<PsiMethod> prototypes = OverrideImplementUtil.overrideOrImplementMethod(parent, baseMethod, false); insertGenerationInfos(context, OverrideImplementUtil.convert2GenerationInfos(prototypes)); } }); }
public static Icon getClassIcon(int flags, @NotNull PsiClass aClass, @Nullable Icon symbolIcon) { Icon base = Iconable.LastComputedIcon.get(aClass, flags); if (base == null) { if (symbolIcon == null) { symbolIcon = ElementPresentationUtil.getClassIconOfKind(aClass, ElementPresentationUtil.getBasicClassKind(aClass)); } RowIcon baseIcon = ElementBase.createLayeredIcon(aClass, symbolIcon, 0); base = ElementPresentationUtil.addVisibilityIcon(aClass, flags, baseIcon); } return IconDeferrer.getInstance().defer(base, new ClassIconRequest(aClass, flags, symbolIcon), FULL_ICON_EVALUATOR); }
@Override public Icon getElementIcon(final int flags) { Icon methodIcon = myBaseIcon != null ? myBaseIcon : hasModifierProperty(PsiModifier.ABSTRACT) ? PlatformIcons.ABSTRACT_METHOD_ICON : PlatformIcons.METHOD_ICON; RowIcon baseIcon = ElementPresentationUtil.createLayeredIcon(methodIcon, this, false); return ElementPresentationUtil.addVisibilityIcon(this, flags, baseIcon); }
@Override @NotNull public Icon getElementIcon(final int flags) { final RowIcon rowIcon = ElementBase.createLayeredIcon(this, PlatformIcons.FIELD_ICON, 0); rowIcon.setIcon(PlatformIcons.PUBLIC_ICON, 1); return rowIcon; }
@Override protected void setVisibilityIcon(MemberInfo memberInfo, RowIcon icon) { PsiMember member = memberInfo.getMember(); PsiModifierList modifiers = member != null ? member.getModifierList() : null; if (modifiers != null) { VisibilityIcons.setVisibilityIcon(modifiers, icon); } else { icon.setIcon(IconUtil.getEmptyIcon(true), VISIBILITY_ICON_POSITION); } }
@Nullable private static Icon computeIconNow(@NotNull PsiElement element, @Iconable.IconFlags int flags) { final Icon providersIcon = PsiIconUtil.getProvidersIcon(element, flags); if (providersIcon != null) { return providersIcon instanceof RowIcon ? (RowIcon)providersIcon : createLayeredIcon(element, providersIcon, flags); } return ((ElementBase)element).getElementIcon(flags); }
@Nullable protected Icon getElementIcon(@Iconable.IconFlags int flags) { final PsiElement element = (PsiElement)this; if (!element.isValid()) return null; RowIcon baseIcon; final boolean isLocked = (flags & ICON_FLAG_READ_STATUS) != 0 && !element.isWritable(); int elementFlags = isLocked ? FLAGS_LOCKED : 0; if (element instanceof ItemPresentation && ((ItemPresentation)element).getIcon(false) != null) { baseIcon = createLayeredIcon(this, ((ItemPresentation)element).getIcon(false), elementFlags); } else if (element instanceof PsiFile) { PsiFile file = (PsiFile)element; VirtualFile virtualFile = file.getVirtualFile(); final Icon fileTypeIcon; if (virtualFile == null) { fileTypeIcon = file.getFileType().getIcon(); } else { fileTypeIcon = IconUtil.getIcon(virtualFile, flags & ~ICON_FLAG_READ_STATUS, file.getProject()); } return createLayeredIcon(this, fileTypeIcon, elementFlags); } else { return null; } return baseIcon; }
public static RowIcon createLayeredIcon(Iconable instance, Icon icon, int flags) { List<Icon> layersFromProviders = new SmartList<Icon>(); for (IconLayerProvider provider : Extensions.getExtensions(IconLayerProvider.EP_NAME)) { final Icon layerIcon = provider.getLayerIcon(instance, (flags & FLAGS_LOCKED) != 0); if (layerIcon != null) { layersFromProviders.add(layerIcon); } } if (flags != 0 || !layersFromProviders.isEmpty()) { List<Icon> iconLayers = new SmartList<Icon>(); for(IconLayer l: ourIconLayers) { if ((flags & l.flagMask) != 0) { iconLayers.add(l.icon); } } iconLayers.addAll(layersFromProviders); LayeredIcon layeredIcon = new LayeredIcon(1 + iconLayers.size()); layeredIcon.setIcon(icon, 0); for (int i = 0; i < iconLayers.size(); i++) { Icon icon1 = iconLayers.get(i); layeredIcon.setIcon(icon1, i+1); } icon = layeredIcon; } RowIcon baseIcon = new RowIcon(2); baseIcon.setIcon(icon, 0); return baseIcon; }
@NotNull public static Icon getEmptyIcon(boolean showVisibility) { RowIcon baseIcon = new RowIcon(2); baseIcon.setIcon(createEmptyIconLike(PlatformIcons.CLASS_ICON_PATH), 0); if (showVisibility) { baseIcon.setIcon(createEmptyIconLike(PlatformIcons.PUBLIC_ICON_PATH), 1); } return baseIcon; }
@Override @Nullable public Icon getIcon(int flags) { final Icon icon = myFile.getIcon(flags); RowIcon baseIcon = ElementBase.createLayeredIcon(this, icon, 0); return ElementPresentationUtil.addVisibilityIcon(this, flags, baseIcon); }
@Nullable @Override protected Icon getElementIcon(@IconFlags int flags) { Icon icon = getIconInner(); final boolean isLocked = (flags & ICON_FLAG_READ_STATUS) != 0 && !isWritable(); RowIcon rowIcon = createLayeredIcon(this, icon, ElementPresentationUtil.getFlags(this, isLocked) | getFlagsInner()); if ((flags & ICON_FLAG_VISIBILITY) != 0) { VisibilityIcons.setVisibilityIcon(getModifierList(), rowIcon); } return rowIcon; }
private static void addSuperMethods(final GrTypeDefinition psiClass, CompletionResultSet completionResultSet, boolean toImplement) { final Collection<CandidateInfo> candidates = GroovyOverrideImplementExploreUtil.getMethodsToOverrideImplement(psiClass, toImplement); for (CandidateInfo candidateInfo : candidates) { final PsiMethod method = (PsiMethod)candidateInfo.getElement(); if (method.isConstructor()) continue; RowIcon icon = new RowIcon(2); icon.setIcon(method.getIcon(0), 0); icon.setIcon(toImplement ? AllIcons.Gutter.ImplementingMethod : AllIcons.Gutter.OverridingMethod, 1); PsiSubstitutor substitutor = candidateInfo.getSubstitutor(); String parameters = PsiFormatUtil.formatMethod(method, substitutor, PsiFormatUtilBase.SHOW_PARAMETERS, PsiFormatUtilBase.SHOW_NAME); String visibility = VisibilityUtil.getVisibilityModifier(method.getModifierList()); String modifiers = (visibility == PsiModifier.PACKAGE_LOCAL ? "" : visibility + " "); PsiType type = substitutor.substitute(method.getReturnType()); String parentClassName = psiClass == null ? "" : psiClass.getName(); String signature = modifiers + (type == null ? "" : type.getPresentableText() + " ") + method.getName(); LookupElementBuilder lookupElement = LookupElementBuilder.create(method, signature) .appendTailText(parameters, false) .appendTailText("{...}", true) .withTypeText(parentClassName) .withIcon(icon) .withInsertHandler(new GroovyMethodOverrideHandler(psiClass)); completionResultSet.addElement(lookupElement); } }
@Override protected void setVisibilityIcon(GrMemberInfo memberInfo, RowIcon icon) { PsiMember member = memberInfo.getMember(); PsiModifierList modifiers = member != null ? member.getModifierList() : null; if (modifiers != null) { VisibilityIcons.setVisibilityIcon(modifiers, icon); } else { icon.setIcon(IconUtil.getEmptyIcon(true), VISIBILITY_ICON_POSITION); } }
@Override public void customizeCellRenderer(JTable table, final Object value, boolean isSelected, boolean hasFocus, final int row, final int column) { final int modelColumn = myTable.convertColumnIndexToModel(column); final M memberInfo = myTable.myTypesInfos.get(row); setToolTipText(myTable.myTypeInfoModel.getTooltipText(memberInfo)); switch (modelColumn) { case DISPLAY_NAME_COLUMN: { Icon memberIcon = myTable.getMemberIcon(memberInfo, 0); RowIcon icon = new RowIcon(3); icon.setIcon(memberIcon, MEMBER_ICON_POSITION); setIcon(icon); break; } default: { setIcon(null); } } setIconOpaque(false); setOpaque(false); final boolean cellEditable = myTable.myTypeInfoModel.isTypeEnabled(memberInfo); setEnabled(cellEditable); if (value == null) return; final int problem = myTable.myTypeInfoModel.checkForProblems(memberInfo); Color c = null; if (problem == MemberInfoModel.ERROR) { c = JBColor.RED; } else if (problem == MemberInfoModel.WARNING && !isSelected) { c = JBColor.BLUE; } append((String) value, new SimpleTextAttributes(Font.PLAIN, c)); }
@Nullable private static Icon computeIconNow(PsiElement element, @Iconable.IconFlags int flags) { final Icon providersIcon = PsiIconUtil.getProvidersIcon(element, flags); if (providersIcon != null) { return providersIcon instanceof RowIcon ? (RowIcon)providersIcon : createLayeredIcon(element, providersIcon, flags); } return ((ElementBase)element).getElementIcon(flags); }
protected Icon getAdjustedBaseIcon(Icon icon, @Iconable.IconFlags int flags) { Icon result = icon; if ((flags & ICON_FLAG_VISIBILITY) > 0) { RowIcon rowIcon = new RowIcon(2); rowIcon.setIcon(icon, 0); rowIcon.setIcon(VISIBILITY_ICON_PLACEHOLDER.getValue(), 1); result = rowIcon; } return result; }
@Nullable public Icon getIcon(int flags) { Icon icon = getIconInner(); final boolean isLocked = (flags & ICON_FLAG_READ_STATUS) != 0 && !isWritable(); RowIcon rowIcon = createLayeredIcon(this, icon, ElementPresentationUtil.getFlags(this, isLocked) | getFlagsInner()); if ((flags & ICON_FLAG_VISIBILITY) != 0) { VisibilityIcons.setVisibilityIcon(getModifierList(), rowIcon); } return rowIcon; }
@Nonnull private static Icon computeBaseIcon(@Nonnull PsiElement element, int flags) { Icon icon = computeBaseIcon(element); if ((flags & Iconable.ICON_FLAG_VISIBILITY) > 0) { return new RowIcon(icon, ourVisibilityIconPlaceholder.getValue()); } return icon; }
@Nonnull public static Icon getEmptyIcon(boolean showVisibility) { RowIcon baseIcon = new RowIcon(2); baseIcon.setIcon(EmptyIcon.create(getDefaultNodeIconSize()), 0); if (showVisibility) { baseIcon.setIcon(EmptyIcon.create(getDefaultNodeIconSize()), 1); } return baseIcon; }
@Override public void customizeRenderer(ColoredTreeCellRenderer renderer, JTree tree, @Nonnull Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { renderer.clear(); renderer.setIcon(Bookmark.DEFAULT_ICON); if (value instanceof Bookmark) { Bookmark bookmark = (Bookmark)value; BookmarkItem.setupRenderer(renderer, myProject, bookmark, selected); if (renderer.getIcon() != null) { RowIcon icon = new RowIcon(3, RowIcon.Alignment.CENTER); icon.setIcon(bookmark.getIcon(), 0); icon.setIcon(JBUI.scale(EmptyIcon.create(1)), 1); icon.setIcon(renderer.getIcon(), 2); renderer.setIcon(icon); } else { renderer.setIcon(bookmark.getIcon()); } } else { renderer.append(getListName(myProject)); } }
private static Icon buildIcon(final JSNamedElement node) { Icon icon = IconDescriptorUpdaters.getIcon(node, 0); if(node instanceof JSFunction) { final JSFunction function = (JSFunction) node; final Icon accessIcon; if(function.isGetProperty()) { accessIcon = AllIcons.Nodes.Read_access; } else if(function.isSetProperty()) { accessIcon = AllIcons.Nodes.Write_access; } else { accessIcon = null; } if(accessIcon != null) { final LayeredIcon layeredIcon = new LayeredIcon(1); layeredIcon.setIcon(accessIcon, 0, 1, 3); RowIcon rowIcon = new RowIcon(2); rowIcon.setIcon(layeredIcon, 1); rowIcon.setIcon(icon, 0); icon = rowIcon; } } return icon; }
@Override public Icon getElementIcon(final int flags) { Icon methodIcon = hasModifierProperty(PsiModifier.ABSTRACT) ? PlatformIcons.ABSTRACT_METHOD_ICON : PlatformIcons.METHOD_ICON; RowIcon baseIcon = ElementPresentationUtil.createLayeredIcon(methodIcon, this, false); return ElementPresentationUtil.addVisibilityIcon(this, flags, baseIcon); }
@Override public Icon getElementIcon(final int flags) { final RowIcon baseIcon = ElementPresentationUtil.createLayeredIcon(myBaseIcon, this, false); return ElementPresentationUtil.addVisibilityIcon(this, flags, baseIcon); }
@Override public Icon getElementIcon(final int flags) { final RowIcon baseIcon = ElementPresentationUtil.createLayeredIcon(PlatformIcons.VARIABLE_ICON, this, false); return ElementPresentationUtil.addVisibilityIcon(this, flags, baseIcon); }