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


Java AndroidFacet.getLocalResourceManager方法代码示例

本文整理汇总了Java中org.jetbrains.android.facet.AndroidFacet.getLocalResourceManager方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidFacet.getLocalResourceManager方法的具体用法?Java AndroidFacet.getLocalResourceManager怎么用?Java AndroidFacet.getLocalResourceManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jetbrains.android.facet.AndroidFacet的用法示例。


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

示例1: findAttributeDefinitionGlobally

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Nullable
private static AttributeDefinition findAttributeDefinitionGlobally(@NotNull AndroidFacet facet,
                                                                   @NotNull String namespace,
                                                                   @NotNull String localName) {
  ResourceManager resourceManager;
  if (ANDROID_URI.equals(namespace) || TOOLS_URI.equals(namespace)) {
    resourceManager = facet.getSystemResourceManager();
  }
  else if (namespace.equals(AUTO_URI) || namespace.startsWith(URI_PREFIX)) {
      resourceManager = facet.getLocalResourceManager();
  }
  else {
    resourceManager = facet.getSystemResourceManager();
  }

  if (resourceManager != null) {
    final AttributeDefinitions attrDefs = resourceManager.getAttributeDefinitions();

    if (attrDefs != null) {
      return attrDefs.getAttrDefByName(localName);
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:AndroidXmlDocumentationProvider.java

示例2: getResourceTypesInCurrentModule

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@NotNull
public static Set<String> getResourceTypesInCurrentModule(@NotNull AndroidFacet facet) {
  final Set<String> result = new HashSet<String>();
  final LocalResourceManager manager = facet.getLocalResourceManager();

  manager.processFileResources(null, new FileResourceProcessor() {
    @Override
    public boolean process(@NotNull VirtualFile resFile, @NotNull String resName, @NotNull String resFolderType) {
      if (ResourceType.getEnum(resFolderType) != null) {
        result.add(resFolderType);
      }
      return true;
    }
  });

  result.addAll(manager.getValueResourceTypes());
  if (manager.getIds(true).size() > 0) {
    result.add(ResourceType.ID.getName());
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ResourceReferenceConverter.java

示例3: prepareResourceFileRenaming

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
private static void prepareResourceFileRenaming(PsiFile file, String newName, Map<PsiElement, String> allRenames, AndroidFacet facet) {
  Project project = file.getProject();
  ResourceManager manager = facet.getLocalResourceManager();
  String type = manager.getFileResourceType(file);
  if (type == null) return;
  String name = file.getName();

  if (AndroidCommonUtils.getResourceName(type, name).equals(AndroidCommonUtils.getResourceName(type, newName))) {
    return;
  }

  List<PsiFile> resourceFiles = manager.findResourceFiles(type, AndroidCommonUtils.getResourceName(type, name), true, false);
  List<PsiFile> alternativeResources = new ArrayList<PsiFile>();
  for (PsiFile resourceFile : resourceFiles) {
    if (!resourceFile.getManager().areElementsEquivalent(file, resourceFile) && resourceFile.getName().equals(name)) {
      alternativeResources.add(resourceFile);
    }
  }
  if (alternativeResources.size() > 0) {
    int r = 0;
    if (ASK) {
      r = Messages.showDialog(project, message("rename.alternate.resources.question"), message("rename.dialog.title"),
                              new String[]{Messages.YES_BUTTON, Messages.NO_BUTTON}, 1, Messages.getQuestionIcon());
    }
    if (r == 0) {
      for (PsiFile candidate : alternativeResources) {
        allRenames.put(candidate, newName);
      }
    }
    else {
      return;
    }
  }
  PsiField[] resFields = AndroidResourceUtil.findResourceFieldsForFileResource(file, false);
  for (PsiField resField : resFields) {
    String newFieldName = AndroidCommonUtils.getResourceName(type, newName);
    allRenames.put(resField, AndroidResourceUtil.getFieldNameByResourceName(newFieldName));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:AndroidResourceRenameResourceProcessor.java

示例4: getInstance

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@Nullable
public static LocalResourceManager getInstance(@NotNull Module module) {
  AndroidFacet facet = AndroidFacet.getInstance(module);
  return facet != null ? facet.getLocalResourceManager() : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:LocalResourceManager.java

示例5: getNamespace

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
public String getNamespace(RadViewComponent component, boolean createNamespaceIfNecessary) {
  String attributeName = getAttributeName();
  XmlTag tag = component.getTag();
  boolean isLayoutParam = attributeName.startsWith(SdkConstants.ATTR_LAYOUT_RESOURCE_PREFIX);
  if (isLayoutParam) {
    tag = tag.getParentTag();
  }
  if (tag != null) {
    String tagName = tag.getName();
    if (SdkConstants.VIEW_TAG.equals(tagName)) {
      tagName = tag.getAttributeValue(SdkConstants.ATTR_CLASS);
    }
    if (tagName != null && tagName.indexOf('.') != -1) {
      // Custom view; see if this attribute should be in the app namespace or in the android namespace
      AndroidFacet facet = AndroidFacet.getInstance(tag);
      if (facet != null) {
        LocalResourceManager resourceManager = facet.getLocalResourceManager();
        String styleableName = tagName.substring(tagName.lastIndexOf('.') + 1);
        if (isLayoutParam) {
          styleableName += "_Layout";
        }
        StyleableDefinition styleable = resourceManager.getAttributeDefinitions().getStyleableByName(styleableName);
        if (styleable != null) {
          for (AttributeDefinition def : styleable.getAttributes()) {
            if (def.getName().equals(attributeName)) {
              // Local namespace
              String namespace = SdkConstants.AUTO_URI;
              if (createNamespaceIfNecessary) {
                final XmlFile file = PsiTreeUtil.getParentOfType(tag, XmlFile.class);
                if (file != null) {
                  SuppressLintIntentionAction.ensureNamespaceImported(facet.getModule().getProject(), file, namespace);
                }
              }
              return namespace;
            }
          }
        }
      }
    }
  }

  return SdkConstants.ANDROID_URI;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:PropertyWithNamespace.java


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