Java 类com.intellij.openapi.util.Iconable 实例源码

项目:intellij-ce-playground    文件:JavaGenerateMemberCompletionContributor.java   
private static void addGetterSetterElements(CompletionResultSet result, PsiClass parent, Set<MethodSignature> addedSignatures) {
  int count = 0;
  for (PsiField field : parent.getFields()) {
    if (field instanceof PsiEnumConstant) continue;

    List<PsiMethod> prototypes = ContainerUtil.newSmartList();
    Collections.addAll(prototypes, GetterSetterPrototypeProvider.generateGetterSetters(field, true));
    Collections.addAll(prototypes, GetterSetterPrototypeProvider.generateGetterSetters(field, false));
    for (final PsiMethod prototype : prototypes) {
      if (parent.findMethodBySignature(prototype, false) == null && addedSignatures.add(prototype.getSignature(PsiSubstitutor.EMPTY))) {
        Icon icon = prototype.getIcon(Iconable.ICON_FLAG_VISIBILITY);
        result.addElement(createGenerateMethodElement(prototype, PsiSubstitutor.EMPTY, icon, "", new InsertHandler<LookupElement>() {
          @Override
          public void handleInsert(InsertionContext context, LookupElement item) {
            removeLookupString(context);

            insertGenerationInfos(context, Collections.singletonList(new PsiGenerationInfo<PsiMethod>(prototype)));
          }
        }));

        if (count++ > 100) return;
      }
    }
  }
}
项目:intellij-ce-playground    文件:JavaLookupElementBuilder.java   
public static LookupElementBuilder forMethod(@NotNull PsiMethod method,
                                             @NotNull String lookupString, final @NotNull PsiSubstitutor substitutor,
                                             @Nullable PsiClass qualifierClass) {
  LookupElementBuilder builder = LookupElementBuilder.create(method, lookupString)
    .withIcon(method.getIcon(Iconable.ICON_FLAG_VISIBILITY))
    .withPresentableText(method.getName())
    .withTailText(PsiFormatUtil.formatMethod(method, substitutor,
                                             PsiFormatUtilBase.SHOW_PARAMETERS,
                                             PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE));
  final PsiType returnType = method.getReturnType();
  if (returnType != null) {
    builder = builder.withTypeText(substitutor.substitute(returnType).getPresentableText());
  }
  builder = setBoldIfInClass(method, qualifierClass, builder);
  return builder;
}
项目:intellij-ce-playground    文件:ReferenceExpressionCompletionContributor.java   
@Nullable
private static ExpressionLookupItem getSingleArrayElementAccess(PsiElement element, LookupElement item) {
  if (item.getObject() instanceof PsiLocalVariable) {
    final PsiLocalVariable variable = (PsiLocalVariable)item.getObject();
    final PsiType type = variable.getType();
    final PsiExpression expression = variable.getInitializer();
    if (type instanceof PsiArrayType && expression instanceof PsiNewExpression) {
      final PsiNewExpression newExpression = (PsiNewExpression)expression;
      final PsiExpression[] dimensions = newExpression.getArrayDimensions();
      if (dimensions.length == 1 && "1".equals(dimensions[0].getText()) && newExpression.getArrayInitializer() == null) {
        final String text = variable.getName() + "[0]";
        return new ExpressionLookupItem(createExpression(text, element), variable.getIcon(Iconable.ICON_FLAG_VISIBILITY), text, text);
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:ReferenceExpressionCompletionContributor.java   
private static void addArrayMemberAccessors(final PsiElement element, final String prefix, final PsiType itemType,
                                            final PsiElement qualifier, final Consumer<LookupElement> result, PsiModifierListOwner object,
                                            final PsiType expectedType)
    throws IncorrectOperationException {
  if (itemType instanceof PsiArrayType && expectedType.isAssignableFrom(((PsiArrayType)itemType).getComponentType())) {
    final PsiExpression conversion = createExpression(getQualifierText(qualifier) + prefix + "[0]", element);
    result.consume(new ExpressionLookupItem(conversion, object.getIcon(Iconable.ICON_FLAG_VISIBILITY), prefix + "[...]", prefix) {
      @Override
      public void handleInsert(InsertionContext context) {
        FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.SECOND_SMART_COMPLETION_ARRAY_MEMBER);

        final int tailOffset = context.getTailOffset();
        final String callSpace = getSpace(CodeStyleSettingsManager.getSettings(element.getProject()).SPACE_WITHIN_BRACKETS);
        context.getDocument().insertString(tailOffset, "[" + callSpace + callSpace + "]");
        context.getEditor().getCaretModel().moveToOffset(tailOffset + 1 + callSpace.length());
      }
    });
  }
}
项目:intellij-ce-playground    文件:BaseSmartPointerPsiNode.java   
@Override
public void update(PresentationData data) {
  final PsiElement value = getPsiElement();
  if (value == null || !value.isValid()) {
    setValue(null);
  }
  if (getPsiElement() == null) return;

  int flags = Iconable.ICON_FLAG_VISIBILITY;
  if (isMarkReadOnly()) {
    flags |= Iconable.ICON_FLAG_READ_STATUS;
  }

  LOG.assertTrue(value.isValid());

  Icon icon = value.getIcon(flags);
  data.setIcon(icon);
  data.setPresentableText(myName);
  if (isDeprecated()) {
    data.setAttributesKey(CodeInsightColors.DEPRECATED_ATTRIBUTES);
  }
  updateImpl(data);
  for(ProjectViewNodeDecorator decorator: Extensions.getExtensions(ProjectViewNodeDecorator.EP_NAME, myProject)) {
    decorator.decorate(this, data);
  }
}
项目:intellij-ce-playground    文件:JavaFileIconPatcher.java   
private static Icon replaceIcon(VirtualFile file, @Iconable.IconFlags int flags, Project project, Icon baseIcon) {
  FileType fileType = file.getFileType();
  if (fileType == StdFileTypes.JAVA && !FileIndexUtil.isJavaSourceFile(project, file)) {
    return PlatformIcons.JAVA_OUTSIDE_SOURCE_ICON;
  }

  PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
  if (psiFile instanceof PsiClassOwner && psiFile.getViewProvider().getBaseLanguage() == StdLanguages.JAVA) {
    PsiClass[] classes = ((PsiClassOwner)psiFile).getClasses();
    if (classes.length > 0) {
      // prefer icon of the class named after file
      final String fileName = file.getNameWithoutExtension();
      for (PsiClass aClass : classes) {
        if (aClass instanceof SyntheticElement) {
          return baseIcon;
        }
        if (Comparing.strEqual(aClass.getName(), fileName)) {
          return aClass.getIcon(flags);
        }
      }
      return classes[classes.length - 1].getIcon(flags);
    }
  }
  return baseIcon;
}
项目:intellij-ce-playground    文件:MethodCellRenderer.java   
public Component getListCellRendererComponent(
        JList list,
        Object value,
        int index,
        boolean isSelected,
        boolean cellHasFocus) {
  super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

  PsiMethod method = (PsiMethod) value;

  final String text = PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY,
            PsiFormatUtil.SHOW_CONTAINING_CLASS | PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS,
            PsiFormatUtil.SHOW_TYPE);
  setText(text);

  Icon icon = method.getIcon(Iconable.ICON_FLAG_VISIBILITY);
  if(icon != null) setIcon(icon);
  return this;
}
项目:intellij-ce-playground    文件:CompilerIconLayerProvider.java   
@Override
public Icon getLayerIcon(@NotNull Iconable element, boolean isLocked) {
  VirtualFile vFile = null;
  Project project = null;
  if (element instanceof PsiModifierListOwner) {
    project = ((PsiModifierListOwner) element).getProject();
    final PsiFile containingFile = ((PsiModifierListOwner) element).getContainingFile();
    vFile = containingFile == null ? null : containingFile.getVirtualFile();
  }
  else if (element instanceof PsiDirectory) {
    project = ((PsiDirectory) element).getProject();
    vFile = ((PsiDirectory) element).getVirtualFile();
  }
  if (vFile != null && isExcluded(vFile, project)) {
    return PlatformIcons.EXCLUDED_FROM_COMPILE_ICON;
  }
  return null;
}
项目:intellij-ce-playground    文件:PsiFileNode.java   
@Override
protected void updateImpl(PresentationData data) {
  PsiFile value = getValue();
  data.setPresentableText(value.getName());
  data.setIcon(value.getIcon(Iconable.ICON_FLAG_READ_STATUS));

  VirtualFile file = getVirtualFile();
  if (file != null && file.is(VFileProperty.SYMLINK)) {
    String target = file.getCanonicalPath();
    if (target == null) {
      data.setAttributesKey(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES);
      data.setTooltip(CommonBundle.message("vfs.broken.link"));
    }
    else {
      data.setTooltip(FileUtil.toSystemDependentName(target));
    }
  }
}
项目:intellij-ce-playground    文件:EventHandlerEditorRenderer.java   
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
  clear();
  PropertyTable.updateRenderer(this, selected);

  if (value == StringsComboEditor.UNSET) {
    append(StringsComboEditor.UNSET);
  }
  else if (value instanceof EventHandlerEditor.PsiMethodWrapper) {
    PsiMethod method = ((EventHandlerEditor.PsiMethodWrapper)value).getMethod();
    setIcon(method.getIcon(Iconable.ICON_FLAG_VISIBILITY));
    append(method.getName());

    PsiClass psiClass = method.getContainingClass();
    if (psiClass != null) {
      append(" (" + psiClass.getQualifiedName() + ")");
    }
  }
}
项目:intellij-ce-playground    文件:AndroidIconProvider.java   
@Nullable
@Override
public Icon getIcon(@NotNull PsiElement element, @Iconable.IconFlags int flags) {
  if (element instanceof XmlFile) {
    final VirtualFile file = ((XmlFile)element).getVirtualFile();
    if (file != null && !FN_ANDROID_MANIFEST_XML.equals(file.getName())) {
      VirtualFile parent = file.getParent();
      if (parent != null) {
        String parentName = parent.getName();
        int index = parentName.indexOf('-');
        if (index != -1) {
          FolderConfiguration config = FolderConfiguration.getConfigForFolder(parentName);
          if (config != null && config.getLocaleQualifier() != null && ResourceFolderType.getFolderType(parentName) != null) {
            return FlagManager.get().getFlag(config);
          }
        }
      }
    }
  }

  return null;
}
项目:intellij-ce-playground    文件:I18nReferenceContributor.java   
@NotNull
@Override
public Object[] getVariants() {
  final Project project = myElement.getProject();
  PropertiesReferenceManager referenceManager = PropertiesReferenceManager.getInstance(project);
  final List<LookupElement> variants = new ArrayList<LookupElement>();
  referenceManager.processPropertiesFiles(GlobalSearchScopesCore.projectProductionScope(project), new PropertiesFileProcessor() {
    public boolean process(String baseName, PropertiesFile propertiesFile) {
      final Icon icon = propertiesFile.getContainingFile().getIcon(Iconable.ICON_FLAG_READ_STATUS);
      final String relativePath = ProjectUtil.calcRelativeToProjectPath(propertiesFile.getVirtualFile(), project);
      variants.add(LookupElementBuilder.create(propertiesFile, baseName)
                     .withIcon(icon)
                     .withTailText(" (" + relativePath + ")", true));
      return true;
    }
  }, this);
  return variants.toArray(new LookupElement[variants.size()]);
}
项目:intellij-ce-playground    文件:GroovyFileIconProvider.java   
@Nullable
@Override
public Icon getIcon(@NotNull VirtualFile virtualFile, @Iconable.IconFlags int flags, @Nullable Project project) {
  if (project == null || virtualFile.getFileType() != GroovyFileType.GROOVY_FILE_TYPE) return null;
  final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
  if (!(psiFile instanceof GroovyFile)) return null;
  final GroovyFile file = (GroovyFile)psiFile;
  final Icon icon;
  if (file.isScript()) {
    icon = GroovyScriptTypeDetector.getIcon(file);
  }
  else if (GrFileIndexUtil.isGroovySourceFile(file)) {
    final GrTypeDefinition[] typeDefinitions = file.getTypeDefinitions();
    icon = typeDefinitions.length > 0
           ? typeDefinitions[0].getIcon(flags)
           : JetgroovyIcons.Groovy.Groovy_16x16;
  }
  else {
    icon = JetgroovyIcons.Groovy.Groovy_outsideSources;
  }
  return ElementBase.createLayeredIcon(psiFile, icon, ElementBase.transformFlags(psiFile, flags));
}
项目:intellij-ce-playground    文件:GrFileItemPresentationProvider.java   
@Override
public ItemPresentation getPresentation(@NotNull final GroovyFile file) {
  return new ItemPresentation() {
    @Override
    public String getPresentableText() {
      return GroovyBundle.message("groovy.file.0", file.getName());
    }

    @Override
    public String getLocationString() {
      PsiDirectory directory = file.getContainingDirectory();
      return ItemPresentationProviders.getItemPresentation(directory).getPresentableText();
    }

    @Override
    public Icon getIcon(boolean unused) {
      return file.getIcon(Iconable.ICON_FLAG_VISIBILITY | Iconable.ICON_FLAG_READ_STATUS);
    }
  };
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLSchemaFileNode.java   
private PresentationData updatePresentationData(PresentationData data) {
    PsiFile value = getValue();
    data.setPresentableText(value.getName());
    data.setIcon(value.getIcon(Iconable.ICON_FLAG_READ_STATUS));
    final Project project = getProject();
    if(project != null && !project.isDisposed()) {
        String schemaUrl = JSGraphQLSchemaLanguageProjectService.getService(project).getSchemaUrl();
        if (StringUtils.isNotEmpty(schemaUrl)) {
            final VirtualFile baseDir = JSGraphQLConfigurationProvider.getService(project).getConfigurationBaseDir();
            if(baseDir != null) {
                final String comparableSchemaUrl = schemaUrl.replace("\\", "/");
                final String comparableBaseDir = baseDir.getPath().replace("\\", "/");
                if(comparableSchemaUrl.startsWith(comparableBaseDir)) {
                    schemaUrl = schemaUrl.substring(comparableBaseDir.length());
                    if(schemaUrl.length() > 1 && (schemaUrl.startsWith("/") || schemaUrl.startsWith("\\"))) {
                        schemaUrl = schemaUrl.substring(1);
                    }
                }
            }
            data.setLocationString(schemaUrl);
        }
    }
    return data;
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLEndpointIconProvider.java   
@Nullable
@Override
public Icon getIcon(@NotNull PsiElement element, @Iconable.IconFlags int flags) {
    if (element.getLanguage() != JSGraphQLEndpointLanguage.INSTANCE) {
        return null;
    }
    if (element instanceof JSGraphQLEndpointNamedTypeDef) {
        if (element.getParent() instanceof JSGraphQLEndpointNamedTypeDefinition) {
            return getTypeDefinitionIcon((JSGraphQLEndpointNamedTypeDefinition) element.getParent());
        }
    }
    if (element instanceof JSGraphQLEndpointNamedTypeDefinition) {
        return getTypeDefinitionIcon((JSGraphQLEndpointNamedTypeDefinition) element);
    }
    if (element instanceof JSGraphQLEndpointProperty) {
        return JSGraphQLIcons.Schema.Field;
    }
    if (element instanceof JSGraphQLEndpointInputValueDefinition) {
        return JSGraphQLIcons.Schema.Attribute;
    }
    if(element instanceof JSGraphQLEndpointImportDeclaration) {
        return JSGraphQLIcons.Files.GraphQLSchema;
    }
    return null;
}
项目:tools-idea    文件:JavaPresentationUtil.java   
public static ItemPresentation getFieldPresentation(final PsiField psiField) {
  return new ColoredItemPresentation() {
    @Override
    public String getPresentableText() {
      return psiField.getName();
    }

    @Override
    public TextAttributesKey getTextAttributesKey() {
      if (psiField.isDeprecated()) {
        return CodeInsightColors.DEPRECATED_ATTRIBUTES;
      }
      return null;
    }

    @Override
    public String getLocationString() {
      return getJavaSymbolContainerText(psiField);
    }

    @Override
    public Icon getIcon(boolean open) {
      return psiField.getIcon(Iconable.ICON_FLAG_VISIBILITY);
    }
  };
}
项目:tools-idea    文件:JavaGenerateMemberCompletionContributor.java   
private static void addGetterSetterElements(CompletionResultSet result, PsiClass parent) {
  List<PsiMethod> prototypes = ContainerUtil.newArrayList();
  for (PsiField field : parent.getFields()) {
    if (!(field instanceof PsiEnumConstant)) {
      prototypes.add(GenerateMembersUtil.generateGetterPrototype(field));
      prototypes.add(GenerateMembersUtil.generateSetterPrototype(field));
    }
  }
  for (final PsiMethod prototype : prototypes) {
    if (parent.findMethodBySignature(prototype, false) == null) {
      Icon icon = prototype.getIcon(Iconable.ICON_FLAG_VISIBILITY);
      result.addElement(createGenerateMethodElement(prototype, PsiSubstitutor.EMPTY, icon, "", new InsertHandler<LookupElement>() {
        @Override
        public void handleInsert(InsertionContext context, LookupElement item) {
          removeLookupString(context);

          insertGenerationInfos(context, Arrays.asList(new PsiGenerationInfo<PsiMethod>(prototype)));
        }
      }));
    }
  }
}
项目:tools-idea    文件:JavaLookupElementBuilder.java   
public static LookupElementBuilder forMethod(@NotNull PsiMethod method,
                                             @NotNull String lookupString, final @NotNull PsiSubstitutor substitutor,
                                             @Nullable PsiClass qualifierClass) {
  LookupElementBuilder builder = LookupElementBuilder.create(method, lookupString)
    .withIcon(method.getIcon(Iconable.ICON_FLAG_VISIBILITY))
    .withPresentableText(method.getName())
    .withTailText(PsiFormatUtil.formatMethod(method, substitutor,
                                             PsiFormatUtilBase.SHOW_PARAMETERS,
                                             PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE));
  final PsiType returnType = method.getReturnType();
  if (returnType != null) {
    builder = builder.withTypeText(substitutor.substitute(returnType).getPresentableText());
  }
  builder = setBoldIfInClass(method, qualifierClass, builder);
  return builder;
}
项目:tools-idea    文件:ReferenceExpressionCompletionContributor.java   
@Nullable
private static ExpressionLookupItem getSingleArrayElementAccess(PsiElement element, LookupElement item) {
  if (item.getObject() instanceof PsiLocalVariable) {
    final PsiLocalVariable variable = (PsiLocalVariable)item.getObject();
    final PsiType type = variable.getType();
    final PsiExpression expression = variable.getInitializer();
    if (type instanceof PsiArrayType && expression instanceof PsiNewExpression) {
      final PsiNewExpression newExpression = (PsiNewExpression)expression;
      final PsiExpression[] dimensions = newExpression.getArrayDimensions();
      if (dimensions.length == 1 && "1".equals(dimensions[0].getText()) && newExpression.getArrayInitializer() == null) {
        final String text = variable.getName() + "[0]";
        final PsiExpression conversion = createExpression(text, element);
        ExpressionLookupItem result = new ExpressionLookupItem(conversion);
        result.setIcon(variable.getIcon(Iconable.ICON_FLAG_VISIBILITY));
        return result;
      }
    }
  }
  return null;
}
项目:tools-idea    文件:BaseSmartPointerPsiNode.java   
@Override
public void update(PresentationData data) {
  final PsiElement value = getPsiElement();
  if (value == null || !value.isValid()) {
    setValue(null);
  }
  if (getPsiElement() == null) return;

  int flags = Iconable.ICON_FLAG_VISIBILITY;
  if (isMarkReadOnly()) {
    flags |= Iconable.ICON_FLAG_READ_STATUS;
  }

  LOG.assertTrue(value.isValid());

  Icon icon = value.getIcon(flags);
  data.setIcon(icon);
  data.setPresentableText(myName);
  if (isDeprecated()) {
    data.setAttributesKey(CodeInsightColors.DEPRECATED_ATTRIBUTES);
  }
  updateImpl(data);
  for(ProjectViewNodeDecorator decorator: Extensions.getExtensions(ProjectViewNodeDecorator.EP_NAME, myProject)) {
    decorator.decorate(this, data);
  }
}
项目:tools-idea    文件:JavaFileIconPatcher.java   
private static Icon replaceIcon(VirtualFile file, @Iconable.IconFlags int flags, Project project, Icon baseIcon) {
  FileType fileType = file.getFileType();
  if (fileType == StdFileTypes.JAVA && !FileIndexUtil.isJavaSourceFile(project, file)) {
    return PlatformIcons.JAVA_OUTSIDE_SOURCE_ICON;
  }

  PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
  if (psiFile instanceof PsiClassOwner && psiFile.getViewProvider().getBaseLanguage() == StdLanguages.JAVA) {
    PsiClass[] classes = ((PsiClassOwner)psiFile).getClasses();
    if (classes.length > 0) {
      // prefer icon of the class named after file
      final String fileName = file.getNameWithoutExtension();
      for (PsiClass aClass : classes) {
        if (aClass instanceof SyntheticElement) {
          return baseIcon;
        }
        if (Comparing.strEqual(aClass.getName(), fileName)) {
          return aClass.getIcon(flags);
        }
      }
      return classes[classes.length - 1].getIcon(flags);
    }
  }
  return baseIcon;
}
项目:tools-idea    文件:MethodCellRenderer.java   
public Component getListCellRendererComponent(
        JList list,
        Object value,
        int index,
        boolean isSelected,
        boolean cellHasFocus) {
  super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

  PsiMethod method = (PsiMethod) value;

  final String text = PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY,
            PsiFormatUtil.SHOW_CONTAINING_CLASS | PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS,
            PsiFormatUtil.SHOW_TYPE);
  setText(text);

  Icon icon = method.getIcon(Iconable.ICON_FLAG_VISIBILITY);
  if(icon != null) setIcon(icon);
  return this;
}
项目:tools-idea    文件:CompilerIconLayerProvider.java   
@Override
public Icon getLayerIcon(@NotNull Iconable element, boolean isLocked) {
  VirtualFile vFile = null;
  Project project = null;
  if (element instanceof PsiModifierListOwner) {
    project = ((PsiModifierListOwner) element).getProject();
    final PsiFile containingFile = ((PsiModifierListOwner) element).getContainingFile();
    vFile = containingFile == null ? null : containingFile.getVirtualFile();
  }
  else if (element instanceof PsiDirectory) {
    project = ((PsiDirectory) element).getProject();
    vFile = ((PsiDirectory) element).getVirtualFile();
  }
  if (vFile != null && isExcluded(vFile, project)) {
    return PlatformIcons.EXCLUDED_FROM_COMPILE_ICON;
  }
  return null;
}
项目:tools-idea    文件:ElementBase.java   
@Nullable
private Icon computeIcon(@Iconable.IconFlags int flags) {
  PsiElement psiElement = (PsiElement)this;
  if (!psiElement.isValid()) return null;

  if (Registry.is("psi.deferIconLoading")) {
    Icon baseIcon = LastComputedIcon.get(psiElement, flags);
    if (baseIcon == null) {
      TIntObjectHashMap<Icon> cache = getUserData(BASE_ICONS);
      if (cache == null) {
        cache = putUserDataIfAbsent(BASE_ICONS, new TIntObjectHashMap<Icon>());
      }
      synchronized (cache) {
        if (!cache.containsKey(flags)) {
          cache.put(flags, computeBaseIcon(flags));
        }
        baseIcon = cache.get(flags);
      }
    }
    return IconDeferrer.getInstance().defer(baseIcon, new ElementIconRequest(psiElement, flags), ICON_COMPUTE);
  }

  return computeIconNow(psiElement, flags);
}
项目:tools-idea    文件:BaseShowRecentFilesAction.java   
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
  if (value instanceof VirtualFile) {
    VirtualFile virtualFile = (VirtualFile)value;
    String name = virtualFile.getPresentableName();
    setIcon(IconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, myProject));

    FileStatus fileStatus = FileStatusManager.getInstance(myProject).getStatus(virtualFile);
    TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null , null, EffectType.LINE_UNDERSCORE,
                                                   Font.PLAIN);
    append(name, SimpleTextAttributes.fromTextAttributes(attributes));

    if (!selected && FileEditorManager.getInstance(myProject).isFileOpen(virtualFile)) {
      setBackground(LightColors.SLIGHTLY_GREEN);
    }
  }
}
项目:tools-idea    文件:PsiFileNode.java   
@Override
protected void updateImpl(PresentationData data) {
  PsiFile value = getValue();
  data.setPresentableText(value.getName());
  data.setIcon(value.getIcon(Iconable.ICON_FLAG_READ_STATUS));

  VirtualFile file = getVirtualFile();
  if (file != null && file.is(VFileProperty.SYMLINK)) {
    String target = file.getCanonicalPath();
    if (target == null) {
      data.setAttributesKey(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES);
      data.setTooltip(CommonBundle.message("vfs.broken.link"));
    }
    else {
      data.setTooltip(FileUtil.toSystemDependentName(target));
    }
  }
}
项目:tools-idea    文件:GrFileItemPresentationProvider.java   
@Override
public ItemPresentation getPresentation(final GroovyFile file) {
  return new ItemPresentation() {
    @Override
    public String getPresentableText() {
      return GroovyBundle.message("groovy.file.0", file.getName());
    }

    @Override
    public String getLocationString() {
      PsiDirectory directory = file.getContainingDirectory();
      return ItemPresentationProviders.getItemPresentation(directory).getPresentableText();
    }

    @Override
    public Icon getIcon(boolean unused) {
      return file.getIcon(Iconable.ICON_FLAG_VISIBILITY | Iconable.ICON_FLAG_READ_STATUS);
    }
  };
}
项目:salesforce-plugin    文件:ApexFileIconPatcher.java   
@Override
public Icon patchIcon(Icon baseIcon, VirtualFile file, @Iconable.IconFlags int flags, @Nullable Project project) {
    if (project == null) return baseIcon;

    Icon result = baseIcon;
    PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
    if (psiFile instanceof ApexClassFile) {
        ApexClassFile apexClassFile = (ApexClassFile)psiFile;
        if (apexClassFile.isException()) {
            result = getIconWithVisibility(ApexIcons.EXCEPTION, apexClassFile, flags);
        } else if (apexClassFile.isInterface()) {
            result = getIconWithVisibility(ApexIcons.INTERFACE, apexClassFile, flags);
        } else if (apexClassFile.isClass()) {
            result =  getIconWithVisibility(ApexIcons.CLASS, apexClassFile, flags);
        } else if (apexClassFile.isEnum()) {
            result = getIconWithVisibility(ApexIcons.ENUM, apexClassFile, flags);
        } else if (apexClassFile.isTrigger()) {
            // Triggers do not have any visibility
            result = ApexTriggerFileType.INSTANCE.getIcon();
        }
    }
    return result;
}
项目:salesforce-plugin    文件:ApexFileIconPatcher.java   
private Icon getIconWithVisibility(@NotNull Icon baseIcon, @NotNull PsiFile psiFile, @Iconable.IconFlags int flags) {
    if (flags == 0) {
        // we are displaying the Icon in the project tree - add visibility to base Icon
        ApexDeclaration apexDeclaration = PsiTreeUtil.getChildOfType(psiFile, ApexDeclaration.class);
        if (apexDeclaration != null) {
            if (apexDeclaration.isProtected()) {
                return IconUtilities.createIconRow(baseIcon, ApexIcons.PROTECTED);
            }
            if (apexDeclaration.isPrivate()) {
                return IconUtilities.createIconRow(baseIcon, ApexIcons.PRIVATE);
            }
            if (apexDeclaration.isPublic()) {
                return IconUtilities.createIconRow(baseIcon, ApexIcons.PUBLIC);
            }
            if (apexDeclaration.isGlobal()) {
                return IconUtilities.createIconRow(baseIcon, ApexIcons.GLOBAL);
            }
        }
    }

    // we are display the Icon on the tab - do not add visibility
    return baseIcon;
}
项目:consulo-csharp    文件:CSharpLookupElementBuilder.java   
@RequiredReadAction
private static <E extends DotNetGenericParameterListOwner & DotNetQualifiedElement> LookupElementBuilder buildTypeLikeElement(@NotNull E element, @NotNull DotNetGenericExtractor extractor)
{
    String genericText = CSharpElementPresentationUtil.formatGenericParameters(element, extractor);

    String name = CSharpNamedElement.getEscapedName(element);

    LookupElementBuilder builder = LookupElementBuilder.create(element, name + (extractor == DotNetGenericExtractor.EMPTY ? "" : genericText));

    builder = builder.withPresentableText(name); // always show only name

    builder = builder.withIcon(IconDescriptorUpdaters.getIcon(element, Iconable.ICON_FLAG_VISIBILITY));

    builder = builder.withTypeText(element.getPresentableParentQName());

    builder = builder.withTailText(genericText, true);

    if(extractor == DotNetGenericExtractor.EMPTY)
    {
        builder = withGenericInsertHandler(element, builder);
    }
    return builder;
}
项目:consulo-apache-thrift    文件:ThriftSubDeclarationPresentationProvider.java   
@Override
public ItemPresentation getPresentation(final ThriftSubDeclaration item) {
  return new ItemPresentation() {
    @Nullable
    @Override
    public String getPresentableText() {
      return item.getName();
    }

    @Nullable
    @Override
    public String getLocationString() {
      ThriftTopLevelDeclaration topLevelDeclaration = PsiTreeUtil.getParentOfType(item, ThriftTopLevelDeclaration.class, true);
      return topLevelDeclaration != null ? topLevelDeclaration.getName() : item.getContainingFile().getName();
    }

    @Nullable
    @Override
    public Icon getIcon(boolean unused) {
return IconDescriptorUpdaters.getIcon(item, Iconable.ICON_FLAG_VISIBILITY);
    }
  };
}
项目:consulo-apache-thrift    文件:ThriftTopLevelDeclarationPresentationProvider.java   
@Override
public ItemPresentation getPresentation(final ThriftDeclaration item) {
  return new ItemPresentation() {
    @Nullable
    @Override
    public String getPresentableText() {
      return item.getName();
    }

    @Nullable
    @Override
    public String getLocationString() {
      return item.getContainingFile().getName();
    }

    @Nullable
    @Override
    public Icon getIcon(boolean unused) {
      return IconDescriptorUpdaters.getIcon(item, Iconable.ICON_FLAG_VISIBILITY);
    }
  };
}
项目:intellij-thrift    文件:ThriftSubDeclarationPresentationProvider.java   
@Override
public ItemPresentation getPresentation(final ThriftSubDeclaration item) {
  return new ItemPresentation() {
    @Nullable
    @Override
    public String getPresentableText() {
      return item.getName();
    }

    @Nullable
    @Override
    public String getLocationString() {
      ThriftTopLevelDeclaration topLevelDeclaration = PsiTreeUtil.getParentOfType(item, ThriftTopLevelDeclaration.class, true);
      return topLevelDeclaration != null ? topLevelDeclaration.getName() : item.getContainingFile().getName();
    }

    @Nullable
    @Override
    public Icon getIcon(boolean unused) {
      return item.getIcon(Iconable.ICON_FLAG_VISIBILITY);
    }
  };
}
项目:intellij-thrift    文件:ThriftTopLevelDeclarationPresentationProvider.java   
@Override
public ItemPresentation getPresentation(final ThriftDeclaration item) {
  return new ItemPresentation() {
    @Nullable
    @Override
    public String getPresentableText() {
      return item.getName();
    }

    @Nullable
    @Override
    public String getLocationString() {
      PsiFile containingFile = item.getContainingFile();
      return containingFile == null ? null : containingFile.getName();
    }

    @Nullable
    @Override
    public Icon getIcon(boolean unused) {
      return item.getIcon(Iconable.ICON_FLAG_VISIBILITY);
    }
  };
}
项目:consulo    文件:Switcher.java   
@Override
protected void customizeCellRenderer(@Nonnull JList list, Object value, int index, boolean selected, boolean hasFocus) {
  if (value instanceof FileInfo) {
    Project project = mySwitcherPanel.project;
    VirtualFile virtualFile = ((FileInfo)value).getFirst();
    String renderedName = ((FileInfo)value).getNameForRendering();
    setIcon(VfsIconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, project));

    FileStatus fileStatus = FileStatusManager.getInstance(project).getStatus(virtualFile);
    open = FileEditorManager.getInstance(project).isFileOpen(virtualFile);
    TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null, null, EffectType.LINE_UNDERSCORE, Font.PLAIN);
    append(renderedName, SimpleTextAttributes.fromTextAttributes(attributes));

    // calc color the same way editor tabs do this, i.e. including EPs
    Color color = EditorTabbedContainer.calcTabColor(project, virtualFile);

    if (!selected && color != null) {
      setBackground(color);
    }
    SpeedSearchUtil.applySpeedSearchHighlighting(mySwitcherPanel, this, false, selected);
  }
}
项目:consulo    文件:PsiFileNode.java   
@Override
protected void updateImpl(PresentationData data) {
  PsiFile value = getValue();
  data.setPresentableText(value.getName());
  data.setIcon(IconDescriptorUpdaters.getIcon(value, Iconable.ICON_FLAG_READ_STATUS));

  VirtualFile file = getVirtualFile();
  if (file != null && file.is(VFileProperty.SYMLINK)) {
    String target = file.getCanonicalPath();
    if (target == null) {
      data.setAttributesKey(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES);
      data.setTooltip(CommonBundle.message("vfs.broken.link"));
    }
    else {
      data.setTooltip(FileUtil.toSystemDependentName(target));
    }
  }
}
项目:consulo    文件:FileChooserDialogImpl.java   
private void showRecentFilesPopup() {
  final JBList files = new JBList(getRecentFiles()) {
    @Override
    public Dimension getPreferredSize() {
      return new Dimension(myPathTextField.getField().getWidth(), super.getPreferredSize().height);
    }
  };
  files.setCellRenderer(new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      final String path = value.toString();
      append(path);
      final VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(new File(path));
      if (file != null) {
        setIcon(VfsIconUtil.getIcon(file, Iconable.ICON_FLAG_READ_STATUS, null));
      }
    }
  });
  JBPopupFactory.getInstance().createListPopupBuilder(files).setItemChoosenCallback(new Runnable() {
    @Override
    public void run() {
      myPathTextField.getField().setText(files.getSelectedValue().toString());
    }
  }).createPopup().showUnderneathOf(myPathTextField.getField());
}
项目:consulo-java    文件:JavaPresentationUtil.java   
public static ItemPresentation getFieldPresentation(final PsiField psiField) {
  return new ColoredItemPresentation() {
    @Override
    public String getPresentableText() {
      return psiField.getName();
    }

    @Override
    public TextAttributesKey getTextAttributesKey() {
      if (psiField.isDeprecated()) {
        return CodeInsightColors.DEPRECATED_ATTRIBUTES;
      }
      return null;
    }

    @Override
    public String getLocationString() {
      return getJavaSymbolContainerText(psiField);
    }

    @Override
    public Icon getIcon(boolean open) {
      return IconDescriptorUpdaters.getIcon(psiField, Iconable.ICON_FLAG_VISIBILITY);
    }
  };
}
项目:consulo-java    文件:JavaLookupElementBuilder.java   
public static LookupElementBuilder forMethod(@NotNull PsiMethod method,
                                             @NotNull String lookupString, final @NotNull PsiSubstitutor substitutor,
                                             @Nullable PsiClass qualifierClass) {
  LookupElementBuilder builder = LookupElementBuilder.create(method, lookupString)
    .withIcon(IconDescriptorUpdaters.getIcon(method, Iconable.ICON_FLAG_VISIBILITY))
    .withPresentableText(method.getName())
    .withTailText(PsiFormatUtil.formatMethod(method, substitutor,
                                             PsiFormatUtilBase.SHOW_PARAMETERS,
                                             PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE));
  final PsiType returnType = method.getReturnType();
  if (returnType != null) {
    builder = builder.withTypeText(substitutor.substitute(returnType).getPresentableText());
  }
  builder = setBoldIfInClass(method, qualifierClass, builder);
  return builder;
}