How do you Create Templates in Flash Builder?
This question comes in from TJ, a listener of my second podcast, the Flextras Friday Lunch.
I read the docs and watched your video on this topic but I am not able to find out how to add new templates to Flash Builder. Do you know if it is possible to add new templates and where could I find this info if possible?
As far as I know, there is no way to create new templates through Flash Builder. You can only editing the existing templates. I think it's a pretty cool feature, but I also wish we could create new ones easily.
To create new templates, you're best bet is to look into creating an Eclipse plugin. As far as I know, this can't be done in ActionScript, so you'll need to create it in Java, or possibly CFML if you're a ColdFusion Developer and using ColdFusion Builder.
TJ also told me something interesting:
I even was able to find the source xml file (default_asfiletemplates.xml) in the com.adobe.flexide.as.core package on my local machine. I have played with this file along with editing and exporting others and trying to import to see if I can create more templates from the new nodes, but it doesn't work.
So, there is some XML file that seems to define the templates. I haven't taken a look at this file, but it does seem intriguing that this file exists. I found two instances of the file on my local machine, one for Flash Builder 4 an one for the 4.01 update. In each directory, there is a properties file. I would bet you'd have to edit both the property and XML file to add a new template, if possible.
There are also similar property files and XML files in com.adobe.flexide.css.core_4.0.1.277662 for CSS. I assume there are files for MXML and FlexUnit types too.
By modifying both the properties file and the XML templates file, I was able to get a quarter of the way there.
First, add a line like this to the end of the property file:
ASFileTemplates.NewJClass.Name=J Class
And add a new template entry in the XML file:
<template name="%ASFileTemplates.NewJClass.Name"
id="com.adobe.flexide.as.core.filetemplates.newjclass"
description="%ASFileTemplates.NewASInterface.Description"
context="new_actionscript_interface" enabled="true"
>
<![CDATA[${package_declaration}
{
${import_declaration}
${interface_declaration}
{
}
}]]>
</template>
You'll see something like this:

Unfortunately, the code appears to confuse the display a bit. And the "ActionScript" interface sort of runs into my new class. I assume this is because I Saved them in the wrong format and/or used Windows Notepad which uses different end of line characters than some other operating systems.
But, even though I have a new file type listed; there was no way to create a file from the new template from the "File New" menu. I assume you have to edit another config file somewhere for that purposes.
Can anyone take this to the next step? How about you stop by the Flextras booth at 360|Flex in DC and show it to me?




