> Are you thinking of using this for templates? e.g. No Content, Full
> Page, My Custom Template etc?
see http://wiki.objectstyle.org/confluence/display/WOL/Custom+Project+Templates
for most of the nitty gritty (the same underlying system is being
used here)
ProjectTemplate pt =
ProjectTemplate.loadProjectTemplateNamed("Component Templates",
"WOComponent");
loads a template named "WOComponent" from the template folder "Custom
Templates" -- this will look inside the templateengine plugin for
defaults, but also supports the same overrides as Project Templates --
this is the generalization of it, basically. You can also enumerate
the templates available in the "Component Templates" group, which will
be the combination of builtins + overrides.
pt.addInput(new ProjectInput("name", ProjectInput.Type.String));
if you don't declare a template.xml with variables in it (you can also
use TemplateInputsWizardPage, though I think for components I wouldn't
bother supporting this), you can explicitly add custom project inputs
-- the most obvious being a "name" for the component.
pt.setValueForInputNamed("SomeName", "name");
then you can also programmatically set the value of inputs
InstallTemplateOperation top = new InstallTemplateOperation(pt,
project, targetFolder);
new ProgressMonitorDialog(getShell()).run(false, false, top);
and finally install the template ... this installs the given template
into the targetFolder within the given project. You get top level
access to that targetFolder, so if your template has a test.html in
it, it will end up as targetFolder/test.html ... In the case of a
bundle component, your template would like have a __name__.wo folder
in it. For an html component, it would just be __name__.html and
would appear at the top level.
so rough overview:
1) make a couple built in component template formats -- bundle, single
file, etc, and put them in something like templateengine/
ComponentTemplates (it looks for w/ and w/o the space inside the plugin)
2) make your combo box of templates based on the
loadProjectTemplates("Component Templates")
3) decide on a couple hard-coded variable names that component will
use (for first version at least) and set those in code
4) execute the template op (it doesn't have to be a progress dialog --
there are lots of ways to execute a workspace modify op)
5) profit from custom component templates
The cool thing with this, which is also nice w/ the project templates,
is that you can just drop your own custom ones into the Library/App
Support/WOLips/Component Templates folder, or even override the built-
in ones, and they will appear in the picker. I actually think this
system, or something like it, should be built into Eclipse, because it
makes it so much easier to make codeless custom templates (ala Xcode).
ms
This archive was generated by hypermail 2.0.0 : Tue Feb 24 2009 - 12:01:38 EST