public CreateFromTemplateAction(FileTemplate template) {
   super(
       template.getName(),
       null,
       FileTypeManagerEx.getInstanceEx()
           .getFileTypeByExtension(template.getExtension())
           .getIcon());
   myTemplate = template;
 }
  private EditorHighlighter createHighlighter() {
    if (myTemplate != null && myProject != null && myVelocityFileType != FileTypes.UNKNOWN) {
      return EditorHighlighterFactory.getInstance()
          .createEditorHighlighter(
              myProject, new LightVirtualFile("aaa." + myTemplate.getExtension() + ".ft"));
    }

    FileType fileType = null;
    if (myTemplate != null) {
      fileType = FileTypeManager.getInstance().getFileTypeByExtension(myTemplate.getExtension());
    }
    if (fileType == null) {
      fileType = FileTypes.PLAIN_TEXT;
    }
    SyntaxHighlighter originalHighlighter =
        SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null);
    if (originalHighlighter == null) originalHighlighter = new PlainSyntaxHighlighter();
    return new LexerEditorHighlighter(
        new TemplateHighlighter(originalHighlighter),
        EditorColorsManager.getInstance().getGlobalScheme());
  }
 @Override
 public boolean isModified() {
   if (myModified) {
     return true;
   }
   String name = (myTemplate == null) ? "" : myTemplate.getName();
   String extension = (myTemplate == null) ? "" : myTemplate.getExtension();
   if (!Comparing.equal(name, myNameField.getText())) {
     return true;
   }
   if (!Comparing.equal(extension, myExtensionField.getText())) {
     return true;
   }
   if (myTemplate != null) {
     if (myTemplate.isReformatCode() != myAdjustBox.isSelected()) {
       return true;
     }
   }
   return false;
 }
  @Override
  public void reset() {
    final String text = (myTemplate == null) ? "" : myTemplate.getText();
    String name = (myTemplate == null) ? "" : myTemplate.getName();
    String extension = (myTemplate == null) ? "" : myTemplate.getExtension();
    String description = (myTemplate == null) ? "" : myTemplate.getDescription();

    if ((description.length() == 0) && (myDefaultDescriptionUrl != null)) {
      try {
        description = UrlUtil.loadText(myDefaultDescriptionUrl);
      } catch (IOException e) {
        LOG.error(e);
      }
    }

    EditorFactory.getInstance().releaseEditor(myTemplateEditor);
    myFile = createFile(text, name);
    myTemplateEditor = createEditor();

    boolean adjust = (myTemplate != null) && myTemplate.isReformatCode();
    myNameField.setText(name);
    myExtensionField.setText(extension);
    myAdjustBox.setSelected(adjust);
    String desc = description.length() > 0 ? description : EMPTY_HTML;

    // [myakovlev] do not delete these stupid lines! Or you get Exception!
    myDescriptionComponent.setContentType(CONTENT_TYPE_PLAIN);
    myDescriptionComponent.setEditable(true);
    myDescriptionComponent.setText(desc);
    myDescriptionComponent.setContentType(UIUtil.HTML_MIME);
    myDescriptionComponent.setText(desc);
    myDescriptionComponent.setCaretPosition(0);
    myDescriptionComponent.setEditable(false);

    myDescriptionPanel.setVisible(StringUtil.isNotEmpty(description));

    myNameField.setEditable((myTemplate != null) && (!myTemplate.isDefault()));
    myExtensionField.setEditable((myTemplate != null) && (!myTemplate.isDefault()));
    myModified = false;
  }