use of com.intellij.lang.properties.ResourceBundle in project intellij-community by JetBrains.
the class ResourcesFavoriteNodeProvider method isInvalidElement.
@Override
public boolean isInvalidElement(final Object element) {
if (element instanceof ResourceBundle) {
ResourceBundle resourceBundle = (ResourceBundle) element;
List<PropertiesFile> propertiesFiles = resourceBundle.getPropertiesFiles();
if (propertiesFiles.size() == 1) {
//todo result.add(new PsiFileNode(myProject, propertiesFiles.iterator().next(), this));
return true;
}
}
return false;
}
use of com.intellij.lang.properties.ResourceBundle in project intellij-community by JetBrains.
the class AddNewPropertyFileAction method update.
@Override
public void update(AnActionEvent e) {
final Navigatable[] data = CommonDataKeys.NAVIGATABLE_ARRAY.getData(e.getDataContext());
if (data != null && data.length == 1) {
if (data[0] instanceof ResourceBundleNode || data[0] instanceof CustomResourceBundlePropertiesFileNode) {
final ResourceBundle resourceBundle = (ResourceBundle) ((ProjectViewNode) data[0]).getValue();
LOG.assertTrue(resourceBundle != null);
if (CreateResourceBundleDialogComponent.getResourceBundlePlacementDirectory(resourceBundle) != null) {
e.getPresentation().setEnabledAndVisible(true);
return;
}
}
}
e.getPresentation().setEnabledAndVisible(false);
}
use of com.intellij.lang.properties.ResourceBundle in project intellij-community by JetBrains.
the class AddNewPropertyFileAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final ResourceBundle resourceBundle = getResourceBundle(e);
new CreateResourceBundleDialogComponent.Dialog(e.getProject(), null, resourceBundle).show();
}
use of com.intellij.lang.properties.ResourceBundle in project intellij-community by JetBrains.
the class CreateResourceBundleDialogComponent method combineToResourceBundleIfNeed.
private void combineToResourceBundleIfNeed(Collection<PsiFile> files) {
Collection<PropertiesFile> createdFiles = ContainerUtil.map(files, (NotNullFunction<PsiFile, PropertiesFile>) dom -> {
final PropertiesFile file = PropertiesImplUtil.getPropertiesFile(dom);
LOG.assertTrue(file != null, dom.getName());
return file;
});
ResourceBundle mainBundle = myResourceBundle;
final Set<ResourceBundle> allBundles = new HashSet<>();
if (mainBundle != null) {
allBundles.add(mainBundle);
}
boolean needCombining = false;
for (PropertiesFile file : createdFiles) {
final ResourceBundle rb = file.getResourceBundle();
if (mainBundle == null) {
mainBundle = rb;
} else if (!mainBundle.equals(rb)) {
needCombining = true;
}
allBundles.add(rb);
}
if (needCombining) {
final List<PropertiesFile> toCombine = new ArrayList<>(createdFiles);
final String baseName = getBaseName();
if (myResourceBundle != null) {
toCombine.addAll(myResourceBundle.getPropertiesFiles());
}
ResourceBundleManager manager = ResourceBundleManager.getInstance(mainBundle.getProject());
for (ResourceBundle bundle : allBundles) {
manager.dissociateResourceBundle(bundle);
}
manager.combineToResourceBundle(toCombine, baseName);
}
}
use of com.intellij.lang.properties.ResourceBundle in project intellij-community by JetBrains.
the class DissociateResourceBundleAction method extractResourceBundles.
@NotNull
private static Collection<ResourceBundle> extractResourceBundles(final AnActionEvent event) {
final Set<ResourceBundle> targetResourceBundles = new HashSet<>();
final ResourceBundle[] chosenResourceBundles = event.getData(ResourceBundle.ARRAY_DATA_KEY);
if (chosenResourceBundles != null) {
for (ResourceBundle resourceBundle : chosenResourceBundles) {
if (resourceBundle.getPropertiesFiles().size() > 1) {
targetResourceBundles.add(resourceBundle);
}
}
}
final PsiElement[] psiElements = event.getData(LangDataKeys.PSI_ELEMENT_ARRAY);
if (psiElements != null) {
for (PsiElement element : psiElements) {
final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(element);
if (propertiesFile != null) {
final ResourceBundle bundle = propertiesFile.getResourceBundle();
if (bundle.getPropertiesFiles().size() > 1) {
targetResourceBundles.add(bundle);
}
}
}
}
return targetResourceBundles;
}
Aggregations