/*
 * Copyright 2000-2009 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.lang.properties.editor;

import com.intellij.lang.properties.ResourceBundle;
import com.intellij.lang.properties.psi.PropertiesFile;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorPolicy;
import com.intellij.openapi.fileEditor.FileEditorProvider;
import com.intellij.openapi.fileEditor.FileEditorState;
import com.intellij.openapi.fileTypes.FileTypeConsumer;
import com.intellij.openapi.fileTypes.FileTypeFactory;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;

public class ResourceBundleEditorProvider extends FileTypeFactory implements FileEditorProvider, DumbAware {
  private static final ResourceBundleFileType RESOURCE_BUNDLE_FILE_TYPE = new ResourceBundleFileType();

  public boolean accept(@NotNull Project project, @NotNull VirtualFile file){
    if (file instanceof ResourceBundleAsVirtualFile) return true;
    PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
    return psiFile instanceof PropertiesFile && ((PropertiesFile)psiFile).getResourceBundle().getPropertiesFiles(project).size() > 1;
  }

  @NotNull
  public FileEditor createEditor(@NotNull Project project, @NotNull final VirtualFile file){
    ResourceBundle resourceBundle;
    if (file instanceof ResourceBundleAsVirtualFile) {
      resourceBundle = ((ResourceBundleAsVirtualFile)file).getResourceBundle();
    }
    else {
      PropertiesFile psiFile = (PropertiesFile)PsiManager.getInstance(project).findFile(file);
      if (psiFile == null) {
        throw new IllegalArgumentException("psifile cannot be null");
      }
      resourceBundle = psiFile.getResourceBundle();
    }

    return new ResourceBundleEditor(project, resourceBundle);
  }

  public void disposeEditor(@NotNull FileEditor editor) {
    Disposer.dispose(editor);
  }

  @NotNull
  public FileEditorState readState(@NotNull Element element, @NotNull Project project, @NotNull VirtualFile file) {
    return new ResourceBundleEditor.ResourceBundleEditorState(null);
  }

  public void writeState(@NotNull FileEditorState state, @NotNull Project project, @NotNull Element element){
  }

  @NotNull
  public FileEditorPolicy getPolicy() {
    return FileEditorPolicy.PLACE_AFTER_DEFAULT_EDITOR;
  }

  @NotNull
  public String getEditorTypeId(){
    return "ResourceBundle";
  }


  public void createFileTypes(@NotNull final FileTypeConsumer consumer) {
    consumer.consume(RESOURCE_BUNDLE_FILE_TYPE, "");
  }
}

@@ -640,16 +640,68 @@
 ditor;%0A%0A
+import com.intellij.lang.properties.PropertiesUtil;%0A
 import c
@@ -1887,77 +1887,135 @@
     
-return psiFile instanceof PropertiesFile && ((PropertiesFile)psi
+PropertiesFile propertiesFile = PropertiesUtil.getPropertiesFile(psiFile);%0A    return propertiesFile != null &&  properties
 File
-)
 .get
@@ -2370,33 +2370,26 @@
 se %7B%0A      P
-ropertie
 s
+i
 File psiFile
@@ -2395,24 +2395,8 @@
 e = 
-(PropertiesFile)
 PsiM
@@ -2569,23 +2569,57 @@
 undle = 
+PropertiesUtil.getPropertiesFile(
 psiFile
+)
 .getReso

Support for xml properties: resource bundle editor enabled