To start the Personality Builder Wizard, select File > New > Other > AJAX Tooling > AJAX Personality from the workbench menubar. This wizard contains three wizard pages which are described in detail below.
The first page is used to collect general information about the AJAX runtime library to be targeted, as well as information about the artifacts that make up the AJAX library. The page is shown below.
The input descriptions for this page are as follows;
The second page is used to collect information pertaining to the personality's application wizard that will be generated. The application wizard is hooked into the "New Wizards" menu by extending the org.eclipse.ui.newWizards extension point. The application wizard is based on Variables, Views and Templates which are all used in constructing the content and behavior of the wizard. Variables are created based on the inputs needed at runtime by the personality's application wizard. Each variable can be displayed, as an input, on a View page. Each View is represented as a wizard page in the resulting applicaton wizard. There are a few predefined Variables that are always displayed as inputs on the first wizard page, but an arbitrary number of Variables and Views can be defined. Templates define the file templates for the files to be created by the application wizard. Any of the previously defined Variables can be used within the content of a Template, in the form ${varname}, so that the template content can be dynamic depending on choices within the application wizard at runtime. Once the Variables, Views, and Templates information is provided, the application wizard's content and behavior can be implemented via extensions within the generated ui plugin (see the org.eclipse.atf.templates.wizardModel extension point documentation for more info on this). The application wizard page is shown below.
The basic inputs are at the top of the page and described below;
In addition to the inputs at the top of the page, the inputs relating to the Variables, Views, and Templates are divided into respective tabs within a tabbed folder.
To create a new variable to use within the context of the application wizard, select the Variables tab, and click on the New Variable button. A new variable will be created in the table with empty attributes. The different attributes of a variable are described below;
To delete a variable, select the variable and click on the Remove Variable button. Variables that are defined by default cannot be removed.
Each view that is created translates into a wizard page that will be part of the personality's generated application wizard. By default the first view is pre-created and contains all of the default variables that are defined in the Variables tab. The Views tab is shown below.
From this tab, a new variable reference can be added to an existing view page, or a new view page can be created.
To add a variable reference to an existing view page, select the target view page in the view page table, and click the New Variable Reference button above the variable reference table. Then, select the Name of the variable reference that you would like to add to the page via the combo box in the Name column. A particular variable cannot be referenced more than once per a particular view page.
To create a new view, click on the New Page button. This will create a new view page with default values for the Name, Title, and Description attributes. The Name attribute should be a unique name relative to the other defined view pages. The Title and Description attributes are used as the title and description, respectively, of the wizard page which will be created to represent the view page. Once a new view page is created, at least one variable reference must be added to the page (i.e. it doesn't make sense to have a wizard page without any inputs).
Each Template specifies a file template for a file that will be created at runtime by the application wizard. After all inputs have been entered by the user (as defined by the Variables and Views), the wizard will generate files that constitute an AJAX personality application. This file generation is a type of Operation which is provided via the org.eclipse.atf.templates.operationFactory extension. Additional operations may be contributed through this extension point, but currently only the file creation operation is supported. Template definitions are to be entered in the Templates tab as shown below.
To create a new template, click on the New Template button. This will generate a new template without any content. In addition to the content, there are three attributes of a template that are described below.
The content text area for a particular template should contain the template content for the template. The content shown will correspond to the current template selected in the template table. The template content can contain references to any previously defined variables. In addition, the content can contain any legal JET notation. Each template's content is run through the JET engine at runtime to resolve JET expressions before the file is created.
The third and final wizard page is used to specify any personality specific code snippets that will be available to the user at application development time. The code snippets will be contributed via the org.eclipse.wst.common.snippets.SnippetContributions extension point, and will be accessible through the workbench's Snippets View.
Code snippets are created much like application wizard pages. They are based off of Variables and Templates. Much like application wizard templates, code snippet templates can refer to previously defined snippet variables and can also contain valid JET notation. For a snippet template that contains variables, a dialog window will pop up to prompt the user for the value of the variable(s) when the snippet is dragged from the Snippet View and dropped into the application file. This allows the content of the snippet to be dynamic based on user input. The code snippet wizard page looks something like this;
To define a new snippet, start by clicking the New Snippet button which will create a new snippet in the snippet table. The Name of the snippet should be unique relative to the rest of the defined snippets, and the Display Name will be the name that is used in the Snippets View to represent the snippet. Once these attributes are specified, new variables can be defined for the snippet to be referenced in the snippet's template. If variables are not required, the code snippet's template content can be specified without variable references. To create a new variable, select the target code snippet in the top table, and then click on the New Variable button above the variables table. This will create a new snippet variable with empty attributes. The descriptions of the snippet variable attributes are as follows;
Creating the code snippet's template is exactly like creating a file template for an application wizard. First, select the target code snippet in the top snippet table. Then, enter the code snippet's template content in the text area at the bottom. The content can reference any previously defined snippet variable for the selected snippet (in the form ${varname}). In addition, the content can contain any valid JET notation such as if or for control statements.
When the personality builder wizard's Finish button is selected, it will kick off the generation of three plugin projects. Each plugin, identified by the suffix it will contain in the name, and its contents are defined below;
Once the plugin projects are generated, they can be further modified or run as is, by either proper Eclipse install procedures or by running the runtime workbench.
Related tasks
Personality Builder Overview
Nature Artifact Handler extension point
Wizard Model extension point
Variable Factory extension point
Variable Renderer Factory extension point
Operation Factory extension point
Snippet Model extension point