コード例 #1
0
  public void prepareRenaming(
      final PsiElement element, final String newName, final Map<PsiElement, String> allRenames) {
    final Project project = element.getProject();
    ResourceBundle resourceBundle = ((IProperty) element).getPropertiesFile().getResourceBundle();

    final Map<PsiElement, String> allRenamesCopy =
        new LinkedHashMap<PsiElement, String>(allRenames);
    allRenames.clear();
    for (final Map.Entry<PsiElement, String> e : allRenamesCopy.entrySet()) {
      final IProperty property = (IProperty) e.getKey();
      final List<IProperty> properties =
          PropertiesUtil.findAllProperties(resourceBundle, property.getUnescapedKey());
      for (final IProperty toRename : properties) {
        allRenames.put(toRename.getPsiElement(), e.getValue());
      }
    }
  }
  @Nullable
  private static List<Locale> extractLocalesFromString(final String rawLocales) {
    if (rawLocales.isEmpty()) {
      return Collections.emptyList();
    }
    final String[] splitRawLocales = rawLocales.split(",");
    final List<Locale> locales = new ArrayList<>(splitRawLocales.length);

    for (String rawLocale : splitRawLocales) {
      final Locale locale = PropertiesUtil.getLocale("_" + rawLocale + ".properties");
      if (locale == PropertiesUtil.DEFAULT_LOCALE) {
        return null;
      } else if (!locales.contains(locale)) {
        locales.add(locale);
      }
    }
    return locales;
  }
コード例 #3
0
 @Override
 public void actionPerformed(final AnActionEvent e) {
   final List<PropertiesFile> propertiesFiles = getPropertiesFiles(e);
   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();
     ResourceBundleManager.getInstance(project)
         .combineToResourceBundle(propertiesFiles, newBaseName);
     final ResourceBundle resourceBundle = propertiesFiles.get(0).getResourceBundle();
     FileEditorManager.getInstance(project)
         .openFile(new ResourceBundleAsVirtualFile(resourceBundle), true);
     ProjectView.getInstance(project).refresh();
   }
 }