How to launch an existing IDE action?

I'm writing a plugin that will add a custom group to the right clik -> New window. I want it to be a collection of file templates, so that instead of going New -> Java class -> select template from dropdown I would be able to go New -> myCustomGroup -> fooTemplate (so no dropdowns and no mixing of my custom templates with others).

So far I've been able to add a custom group and my actions to it, but I don't know how to open the new file from template Action, with a specific template already selected.

Is there an easy way to call the already exisitng action with a specific template name? I think the action is called "From Template". Even knowing how to call a generic new file action would be helpfull.

1 comment
Comment actions Permalink

In case anyone needs it, this is the code I used inside my actions actionPerformed method (the e is the AnActionEvent passed to my action)


FileTemplateManager fileTemplateManager = FileTemplateManager.getInstance();
FileTemplate[] templates = fileTemplateManager.getAllTemplates();
  
for(FileTemplate ft : templates){
     if(ft.getName().equals("Singleton")){
         AnAction action = new CreateFromTemplateAction(ft);
         action.actionPerformed(e);
     }
}

0

Please sign in to leave a comment.