Jerome Cance
Jerome Cance

Reputation: 8183

Best way to create new multi file wizard plugin in Eclipse?

I want to create an eclipse plugin which appears in the "new" menu like "new class" (for example "new MyStructure").

The goal of this plugin is to ask a name and a folder where to place the generated content.

The generated content is created by copying an existing standard directory like the following (${dir} represents the selected directory in the wizard and ${name} the name asked in the wizard) :

$dir
    - ${name}.java
    - css
        - Default${name}Style.css
    - ${name}Editor.java
    - ${name}.config

each of this file is based on an existing file content, something like eclipse code template where I can specify dynamic ${name} and package.

How can I easily done this eclipse plugin ?

Upvotes: 4

Views: 721

Answers (1)

Arne Deutsch
Arne Deutsch

Reputation: 14769

  1. Create an extension of org.eclipse.ui.newWizards to create the wizard
  2. Use the class org.eclipse.swt.widgets.DirectoryDialog to let the user select a directory
  3. Use an text field to let the user input the ${name}
  4. Use java.io.* to copy the files to the specified directory (or use org.eclipse.core.resources if you want to copy to the workspace)
  5. Create an extension of org.eclipse.ui.perspectiveExtensions with newWizardShortcut to add the new wizard to the perspective you want to extend

Upvotes: 3

Related Questions