Project Wizard

Optionally Xtext can also generate a project wizard for your DSL. Using this wizard a user can then with only a few clicks create a new project containing a sample model file and workflow. You enable the project wizard generation by adding the SimpleProjectWizardFragment fragment to the workflow:


<!-- project wizard fragment -->
<fragment class="org.eclipse.xtext.ui.generator.projectWizard.SimpleProjectWizardFragment"
generatorProjectName="${projectName}.generator"
modelFileExtension="mydsl"/>

Here:

After running the Xtext generator the DSL’s UI project will contain a new Xpand template MyDslNewProject.xpt inside the src folder (under the package <base-package>.ui.wizard). This workflow will be run by the project wizard when the user clicks the Finish button and it is responsible for initializing the project with some sample content. The default Xpand template generated by the fragment will when executed by the wizard create a sample model file and a simple workflow to run the model through the generator project’s MyDslGenerator.mwe workflow. As the Xpand template is in the src source folder you may of course modify it to generate whatever files you want. Just make sure to leave the top-level main definition in place, as that is the interface for the project wizard.

Customizing the project wizard

To further customize the creation of the project (e.g. add a nature and a builder or some additional dependencies) you can implement your own project creator. The default project creator is represented by the generated class MyDslProjectCreator (suitable for subclassing) and will simply create a new project with Java and plug-in natures and execute the main definition of the Xpand template as described above.

To add more pages or input fields to the project wizard you should subclass the class MyDslNewProjectWizard as appropriate. Don’t forget to register the subclass in the UI project’s plugin.xml. You may also want to make this additional project info available to the Xpand template, in which case you should create a subclass for MyDslProjectInfo to hold that information, as this is the context object which gets passed to the template when it’s executed.