Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




EclipseJDT Plug-in Developer Guide
Previous Page Home Next Page

Java wizard pages

The org.eclipse.jdt.ui.wizards package provides wizard pages for creating and configuring Java elements.  Several prefabricated pages are provided for your use.

Creating new Java elements

A hierarchy of wizard pages support the creation of new Java elements.  

NewElementWizardPage is the abstract class that defines the basic operation of the wizard.  Additional abstract classes are provided in the hierarchy for making customizations to the functionality provided by the concrete wizards.

The concrete creation wizards can be used directly and generally are not intended to be subclassed. 

Contributing a classpath container wizard page

The interface IClasspathContainerPage defines a structure for contributing a wizard page that allows a user to define a new classpath container entry or edit an existing one.  If your plug-in has defined its own type of classpath container using the JDT Core org.eclipse.jdt.core.classpathContainerInitializer extension point, then you will probably want to define a corresponding wizard page for editing and creating classpath containers of this type.

Your plug-in's markup should provide an extension org.eclipse.jdt.ui.classpathContainerPageIn the extension markup, you provide the name of your class that implements IClasspathContainerPage.  If you need additional information in your wizard page about the classpath's context when it is selected, you can implement IClasspathContainerPageExtension. If your configuration page wants to returns more than one entry when being added, implement IClasspathContainerPageExtension2.

Customizing a wizard page

Besides using prefabricated pages, you can subclass the wizard pages to add your own input fields or to influence the code generation.  You should use the abstract classes in the NewElementWizardPage hierarchy to customize a wizard rather than subclassing the concrete classes.

Below is a sample of a new type wizard page that is customized to create JUnit test case classes. The page initializes the super class field with "junit.framework.TestCase" and adds a checkbox that controls whether method stubs for the setUp() and tearDown() method are to be created.

public class TestCaseWizardPage extends NewTypeWizardPage {
    private Button fCreateStubs;

    public TestCaseWizardPage() {
        super(true, "TestCaseWizardPage");

     * The wizard managing this wizard page must call this method
     * during initialization with a corresponding selection.
    public void init(IStructuredSelection selection) {
        IJavaElement jelem= getInitialJavaElement(selection);

    private void doStatusUpdate() {
        // define the components for which a status is desired
        IStatus[] status= new IStatus[] {
            isEnclosingTypeSelected() ? fEnclosingTypeStatus : fPackageStatus,

    protected void handleFieldChanged(String fieldName) {

    public void createControl(Composite parent) {
        Composite composite= new Composite(parent, SWT.NONE);
        int nColumns= 4;
        GridLayout layout= new GridLayout();
        layout.numColumns= nColumns;

        // Create the standard input fields
        createContainerControls(composite, nColumns);
        createPackageControls(composite, nColumns);
        createSeparator(composite, nColumns);
        createTypeNameControls(composite, nColumns);
        createSuperClassControls(composite, nColumns);

        // Create the checkbox controlling whether we want stubs
        fCreateStubs= new Button(composite, SWT.CHECK);
        fCreateStubs.setText("Add 'setUp()' and 'tearDown()' to new class");
        GridData gd= new GridData();
        gd.horizontalSpan= nColumns;


        // Initialize the super type field and mark it as read-only
        setSuperClass("junit.framework.TestCase", false);

    protected void createTypeMembers(IType newType, ImportsManager imports, IProgressMonitor monitor) throws CoreException {
        if (fCreateStubs.getSelection()) {
            String setUpMathod= "public void setUp() {}";
            newType.createMethod(setUpMathod, null, false, null);

            String tearDownMathod= "public void tearDown() {}";
            newType.createMethod(tearDownMathod, null, false, null); 

  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire