package com.jetbrains.python.actions;

import com.intellij.ide.actions.CreateFileFromTemplateDialog;
import com.intellij.ide.actions.CreateFromTemplateAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiFile;
import com.jetbrains.python.PythonFileType;

/**
 * @author yole
 */
public class CreatePythonFileAction extends CreateFromTemplateAction<PsiFile> implements DumbAware {
  public CreatePythonFileAction() {
    super("Python File", "Creates a Python file from the specified template", PythonFileType.INSTANCE.getIcon());
  }

  @Override
  protected PsiFile createFile(String name, String templateName, PsiDirectory dir) {
    return createFileFromTemplate(name, templateName, dir);
  }

  @Override
  protected void checkBeforeCreate(String name, String templateName, PsiDirectory dir) {
    dir.checkCreateFile(name);
  }

  @Override
  protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {
    builder
      .setTitle("New Python file")
      .addKind("Python file", PythonFileType.INSTANCE.getIcon(), "Python Script")
      .addKind("Python unit test", PythonFileType.INSTANCE.getIcon(), "Python Unit Test");
  }

  @Override
  protected String getActionName(PsiDirectory directory, String newName, String templateName) {
    return "Create Python script " + newName; 
  }
}

@@ -86,22 +86,22 @@
 Template
-Dialog
+Action
 ;%0Aimport
@@ -129,24 +129,28 @@
 ions.CreateF
+ileF
 romTemplateA
@@ -140,38 +140,38 @@
 FileFromTemplate
-Action
+Dialog
 ;%0Aimport com.int
@@ -290,41 +290,8 @@
 ry;%0A
-import com.intellij.psi.PsiFile;%0A
 impo
@@ -406,16 +406,20 @@
  CreateF
+ileF
 romTempl
@@ -431,17 +431,8 @@
 tion
-%3CPsiFile%3E
  imp
@@ -610,307 +610,8 @@
  %7D%0A%0A
-  @Override%0A  protected PsiFile createFile(String name, String templateName, PsiDirectory dir) %7B%0A    return createFileFromTemplate(name, templateName, dir);%0A  %7D%0A%0A  @Override%0A  protected void checkBeforeCreate(String name, String templateName, PsiDirectory dir) %7B%0A    dir.checkCreateFile(name);%0A  %7D%0A%0A
   @O

Create JavaEE Web Page action