当前位置: 首页>>代码示例>>Java>>正文


Java Iconable类代码示例

本文整理汇总了Java中com.intellij.openapi.util.Iconable的典型用法代码示例。如果您正苦于以下问题:Java Iconable类的具体用法?Java Iconable怎么用?Java Iconable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Iconable类属于com.intellij.openapi.util包,在下文中一共展示了Iconable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addGetterSetterElements

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
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;
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:JavaGenerateMemberCompletionContributor.java

示例2: forMethod

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaLookupElementBuilder.java

示例3: getSingleArrayElementAccess

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
@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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ReferenceExpressionCompletionContributor.java

示例4: addArrayMemberAccessors

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
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());
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ReferenceExpressionCompletionContributor.java

示例5: update

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:BaseSmartPointerPsiNode.java

示例6: replaceIcon

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:JavaFileIconPatcher.java

示例7: getListCellRendererComponent

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:MethodCellRenderer.java

示例8: getLayerIcon

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
@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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:CompilerIconLayerProvider.java

示例9: updateImpl

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
@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));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PsiFileNode.java

示例10: customizeCellRenderer

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
@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() + ")");
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:EventHandlerEditorRenderer.java

示例11: getIcon

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
@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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:AndroidIconProvider.java

示例12: getVariants

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
@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()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:I18nReferenceContributor.java

示例13: getIcon

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
@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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GroovyFileIconProvider.java

示例14: getPresentation

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
@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);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:GrFileItemPresentationProvider.java

示例15: updatePresentationData

import com.intellij.openapi.util.Iconable; //导入依赖的package包/类
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;
}
 
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:25,代码来源:JSGraphQLSchemaFileNode.java


注:本文中的com.intellij.openapi.util.Iconable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。