use of com.intellij.lang.properties.xml.XmlPropertiesFile in project intellij-community by JetBrains.
the class I18nUtil method defaultSuggestPropertiesFiles.
public static List<String> defaultSuggestPropertiesFiles(Project project) {
final List<String> paths = new ArrayList<>();
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
PropertiesReferenceManager.getInstance(project).processAllPropertiesFiles(new PropertiesFileProcessor() {
@Override
public boolean process(String baseName, PropertiesFile propertiesFile) {
if (propertiesFile instanceof XmlPropertiesFile) {
return true;
}
VirtualFile virtualFile = propertiesFile.getVirtualFile();
if (projectFileIndex.isInContent(virtualFile)) {
String path = FileUtil.toSystemDependentName(virtualFile.getPath());
paths.add(path);
}
return true;
}
});
return paths;
}
use of com.intellij.lang.properties.xml.XmlPropertiesFile in project intellij-community by JetBrains.
the class CreateResourceBundleDialogComponent method createPropertiesFiles.
private List<PsiFile> createPropertiesFiles() {
final Set<String> fileNames = getFileNamesToCreate();
final List<PsiFile> createdFiles = WriteCommandAction.runWriteCommandAction(myProject, new Computable<List<PsiFile>>() {
@Override
public List<PsiFile> compute() {
return ReadAction.compute(() -> ContainerUtil.map(fileNames, n -> {
final boolean isXml = myResourceBundle == null ? myUseXMLBasedPropertiesCheckBox.isSelected() : myResourceBundle.getDefaultPropertiesFile() instanceof XmlPropertiesFile;
if (isXml) {
FileTemplate template = FileTemplateManager.getInstance(myProject).getInternalTemplate("XML Properties File.xml");
LOG.assertTrue(template != null);
try {
return (PsiFile) FileTemplateUtil.createFromTemplate(template, n, null, myDirectory);
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
return myDirectory.createFile(n);
}
}));
}
});
combineToResourceBundleIfNeed(createdFiles);
return createdFiles;
}
Aggregations