CreateFileFromTemplateAction vs. CreateFromTemplateActionBase - can I have the best of both worlds?

Answered

All of the template-based file creation actions in my plugin extend CreateFileFromTemplateAction. Doing so provides some wonderful inherited behavior such as a selector for multiple templates for the same file type, etc. However, one of the users of my plugin wanted to take advantage of unset attributes where a template attribute that's not populated by default is included in the file creation dialog automatically as a JTextField (to be honest, I didn't even know that feature existed until he pointed it out!).

After digging in a bit, it seems like that behavior is offered by implementations of CreateFromTemplateActionBase and CreateFromTemplateDialog/CreateFromTemplatePanel. I'm trying to figure out if there's some way to leverage both of these feature sets in my own template-based file creation actions without having to implement things from scratch.

I can see how CreateFromTemplateDialog and CreateFromTemplatePanel get the unset attributes and, if present, add them to the resulting dialog. However, I can't see how I might be able to add that same logic to the dialog produced by a CreateFileFromTemplateAction derivative. The latter encapsulates dialog construction through its buildDialog() method and the CreateFileFromTemplatedialog.Builder instance that's passed to it.

Any thoughts on how to provide a "best of both worlds" template-based file creation dialog? Thanks much in advance!

2 comments
Comment actions Permalink
Official comment

Unfortunately, this doesn't seem to be readily available at the moment, unless you're willing to copy-paste parts of the implementations into your plugin. I've created https://youtrack.jetbrains.com/issue/IDEA-161451 for that, which you can vote/watch or even provide a patch if you want to.

Comment actions Permalink

Thanks, Peter.  That's what I figured.  I appreciate you opening the enhancement request as well!

0

Please sign in to leave a comment.