本文整理汇总了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;
}
示例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;
}
示例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));
}
}
示例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;
}
示例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;
}