/*
 * 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.ide.actions;

import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.fileTypes.ex.FileTypeChooser;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;

public class AssociateFileType extends AnAction {
  public void actionPerformed(AnActionEvent e) {
    DataContext dataContext = e.getDataContext();
    VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
    FileTypeChooser.associateFileType(file.getName());
  }

  public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    DataContext dataContext = e.getDataContext();
    VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
    Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    boolean haveSmthToDo;
    if (project == null || file == null || file.isDirectory()) {
      haveSmthToDo = false;
    }
    else {
      haveSmthToDo = file.getFileType() == FileTypes.UNKNOWN;
    }
    presentation.setVisible(haveSmthToDo || ActionPlaces.MAIN_MENU.equals(e.getPlace()));
    presentation.setEnabled(haveSmthToDo);
  }

}

@@ -1029,58 +1029,8 @@
 ) %7B%0A
-    DataContext dataContext = e.getDataContext();%0A
     
@@ -1040,32 +1040,42 @@
 tualFile file = 
+e.getData(
 PlatformDataKeys
@@ -1087,36 +1087,16 @@
 UAL_FILE
-.getData(dataContext
 );%0A    F
@@ -1573,16 +1573,150 @@
  else %7B%0A
+      // the action should also be available for files which have been auto-detected as text or as a particular language (IDEA-79574)%0A
       ha
@@ -1732,25 +1732,74 @@
 o = 
-file.getFileType(
+FileTypeManager.getInstance().getFileTypeByFileName(file.getName()
 ) ==

enable associate action for files with autodetected filetype (IDEA-79574)