package org.jetbrains.plugins.javaFX.fxml;

import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeConsumer;
import com.intellij.openapi.fileTypes.FileTypeFactory;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;

/**
 * User: anna
 * Date: 1/8/13
 */
public class JavaFxFileTypeFactory extends FileTypeFactory {
  public static final String FXML_EXTENSION = "fxml";

  public static boolean isFxml(@NotNull PsiFile file) {
    final VirtualFile virtualFile = file.getViewProvider().getVirtualFile();
    return isFxml(virtualFile);
  }

  public static boolean isFxml(@NotNull VirtualFile virtualFile) {
    final FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(FXML_EXTENSION);
    return virtualFile.getFileType() == fileType && FXML_EXTENSION.equals(virtualFile.getExtension());
  }

  @Override
  public void createFileTypes(@NotNull FileTypeConsumer consumer) {
    final FileType fileType = consumer.getStandardFileTypeByName("XML");
    assert fileType != null;
    consumer.consume(fileType, FXML_EXTENSION);
  }
}

@@ -771,114 +771,78 @@
     
-final FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(FXML_EXTENSION);%0A    return
+return FXML_EXTENSION.equals(virtualFile.getExtension()) &&%0A          
  vir
@@ -871,68 +871,75 @@
  == 
-f
+F
 ileType
- && FXML_EXTENSION.equals(virtualFile.getExtension()
+Manager.getInstance().getFileTypeByExtension(FXML_EXTENSION
 );%0A 

check fxml extension first