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);
    }
  }
 private String canCreateAllFilesForAllLocales() {
   final String name = getBaseName();
   if (name.isEmpty()) {
     return "Base name is empty";
   }
   final Set<String> files = getFileNamesToCreate();
   if (files.isEmpty()) {
     return "No locales added";
   }
   for (PsiElement element : myDirectory.getChildren()) {
     if (element instanceof PsiFile) {
       if (element instanceof PropertiesFile) {
         PropertiesFile propertiesFile = (PropertiesFile) element;
         final String propertiesFileName = propertiesFile.getName();
         if (files.contains(propertiesFileName)) {
           return "Some of files already exist";
         }
       }
     }
   }
   return null;
 }