13.1.1 Problem You want to create a plug-in that uses a wizard to create files and an editor to edit them. 13.1.2 Solution Use a PDE Wizard template. Create a new plug-in project, select the "Plug-in with a multi-page editor" template, and follow the onscreen directions to create a skeletal template, ready to be customized. 13.1.3 Discussion In this example, we're going to create a plug-in that Eclipse will associate with the file extension .new . The plug-in's wizard will enable the user to create files with this extension, and when the user double-clicks those files, they'll appear in the plug-in's editor. The PDE can help us out here by creating a template for our plug-in. Select New Project. In the New Project dialog, select Plug-in Development in the left box and Plug-in Project in the right box, and click Next . Specify the name of the project as org.cookbook.ch13.EditorPlugIn in the following dialog, as shown in Figure 13-1. Figure 13-1. Naming the plug-in Click Next once again to bring up the Plug-in Code Generators dialog shown in Figure 13-2. Select the "Plug-in with a multi-page editor" template, as shown in the figure, and click Next. Figure 13-2. Creating a plug-in with a multipage editor In the next dialog, give the provider name as Eclipse Cookbook , as shown in Figure 13-3, and click Next. Figure 13-3. Giving the provider name The following dialog enables you to give the extension you want to use for the files created by this plug-in; enter new here, as shown in Figure 13-4. Then click Next. Figure 13-4. Configuring the plug-in's editor In the last dialog, shown in Figure 13-5, set the file extension to new , and enter document.new as the initial filename. Figure 13-5. Configuring the wizard Finally, click Finish to create the code template for the plug-in. The following files are created by the PDE and added to the org.cookbook.ch13.EditorPlugIn project. org.cookbook.ch13.EditorPlugIn _ _ _build.properties Controls the build script _ _ _plugin.xml Plug-in manifest _ _ _src Source folder _ _org.cookbook.ch13.EditorPlugIn _ _EditorPlugInPlugin.java Plug-in's Java file _ _org.cookbook.ch13.EditorPlugIn.editors _ _MultiPageEditor.java Editor's code _ _MultiPageEditorContributor.java Editor actions _ _org.cookbook.ch13.EditorPlugIn.wizards _ _SampleNewWizard.java Wizard's code _ _SampleNewWizardPage.java Wizard's page 13.1.4 See Also Recipe 13.2 on customizing a wizard; Recipe 13.3 on customizing editors; Chapter 12 of Eclipse ( O'Reilly). |