use of com.intellij.lang.properties.ResourceBundleManager in project intellij-community by JetBrains.
the class CombinePropertiesFilesAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent e) {
final List<PropertiesFile> initialPropertiesFiles = getPropertiesFiles(e);
final List<PropertiesFile> propertiesFiles = initialPropertiesFiles == null ? new ArrayList<>() : new ArrayList<>(initialPropertiesFiles);
final List<ResourceBundle> resourceBundles = getResourceBundles(e);
if (resourceBundles != null) {
for (ResourceBundle bundle : resourceBundles) {
propertiesFiles.addAll(bundle.getPropertiesFiles());
}
}
final String newBaseName = Messages.showInputDialog(propertiesFiles.get(0).getProject(), PropertiesBundle.message("combine.properties.files.prompt.text"), PropertiesBundle.message("combine.properties.files.title"), Messages.getQuestionIcon(), PropertiesUtil.getDefaultBaseName(propertiesFiles), new MyInputValidator(propertiesFiles));
if (newBaseName != null) {
final Project project = propertiesFiles.get(0).getProject();
final Set<ResourceBundle> uniqueBundlesToDissociate = new HashSet<>();
for (PropertiesFile file : propertiesFiles) {
final ResourceBundle resourceBundle = file.getResourceBundle();
if (resourceBundle.getPropertiesFiles().size() != 1) {
uniqueBundlesToDissociate.add(resourceBundle);
}
}
final ResourceBundleManager resourceBundleManager = ResourceBundleManager.getInstance(project);
for (ResourceBundle resourceBundle : uniqueBundlesToDissociate) {
resourceBundleManager.dissociateResourceBundle(resourceBundle);
}
final ResourceBundle resourceBundle = resourceBundleManager.combineToResourceBundleAndGet(propertiesFiles, newBaseName);
FileEditorManager.getInstance(project).openFile(new ResourceBundleAsVirtualFile(resourceBundle), true);
ProjectView.getInstance(project).refresh();
}
}
Aggregations