Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-ui-dev] subclassed from NewTypeWizardPage



Technical questions and discussions about using eclipse and eclipse-based
tools, and developing plug-in tools should be posted to the newsgroups.
Mailing lists at eclipse.org are intended for use by developers actually
working on or otherwise contributing to day-to-day development. The
development mailing lists are the way design and implementation issues are
discussed and decisions voted on by the committers.

To answer your question: you use types from the JDT UI plug-in but forgot
to declare it as required in your plugin.xml

Dani


                                                                           
             "wupei"                                                       
             <wupeidx@xxxxxxx>                                             
             Sent by:                                                   To 
             jdt-ui-dev-admin@         <jdt-ui-dev@xxxxxxxxxxx>            
             eclipse.org                                                cc 
                                                                           
                                                                   Subject 
             18.10.2004 05:07          [jdt-ui-dev] subclassed from        
                                       NewTypeWizardPage                   
                                                                           
             Please respond to                                             
             jdt-ui-dev@eclips                                             
                   e.org                                                   
                                                                           
                                                                           




Hi folks,

Has anyone seen this error while trying to run their own wizard
(subclassed from NewTypeWizardPage)?

Unhandled exception caught in event loop.
Reason:
org/eclipse/jdt/ui/wizards/NewTypeWizardPage

Any suggestions appreciated.




My source: SampleNewWizard.java

package gffsd.wizards;

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.core.runtime.*;
import org.eclipse.jface.operation.*;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException;
import java.io.*;
import org.eclipse.ui.*;

/**
 * This is a sample new wizard. Its role is to create a new file
 * resource in the provided container. If the container resource
 * (a folder or a project) is selected in the workspace
 * when the wizard is opened, it will accept it as the target
 * container. The wizard creates one file with the extension
 * "mpe". If a sample multi-page editor (also available
 * as a template) is registered for the same extension, it will
 * be able to open it.
 */

public class SampleNewWizard extends Wizard implements INewWizard {
 private SimpleNewWizardPage2 page;
 private ISelection selection;

 /**
  * Constructor for SampleNewWizard.
  */
 public SampleNewWizard() {
  super();
  setNeedsProgressMonitor(true);
 }

 /**
  * Adding the page to the wizard.
  */

 public void addPages() {
  page = new SimpleNewWizardPage2(true,"haha");
  addPage(page);
 }

 /**
  * This method is called when 'Finish' button is pressed in
  * the wizard. We will create an operation and run it
  * using wizard as execution context.
  */
 public boolean performFinish() {

  return true;
 }


 /**
  * We will accept the selection in the workbench to see if
  * we can initialize from it.
  * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
  */
 public void init(IWorkbench workbench, IStructuredSelection selection) {
  this.selection = selection;
 }
}




package gffsd.wizards;

import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.help.WorkbenchHelp;


SimpleNewWizardPage2.java

public class SimpleNewWizardPage2 extends NewTypeWizardPage {

 /**
  * @param arg0
  * @param arg1
  */
 public SimpleNewWizardPage2(boolean arg0, String arg1) {
  super(arg0, arg1);
                setTitle("NewClassWizardPage.title");
                setDescription("NewClassWizardPage.description");
 }

 /*
  * @see
org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)

  */
 public void createControl(Composite parent) {
              initializeDialogUnits(parent);

                Composite composite= new Composite(parent, SWT.NONE);

                int nColumns= 4;

                GridLayout layout= new GridLayout();
                layout.numColumns= nColumns;
                composite.setLayout(layout);

                // pick & choose the wanted UI components
                createPackageControls(composite, nColumns);



                setControl(composite);

                Dialog.applyDialogFont(composite);
                WorkbenchHelp.setHelp(composite,
IJavaHelpContextIds.NEW_CLASS_WIZARD_PAGE);

 }
        /*
         * @see WizardPage#becomesVisible
         */
        public void setVisible(boolean visible) {
            super.setVisible(visible);
            if (visible) {
                setFocus();
            }
        }
        /**
         * The wizard owning this page is responsible for calling this
method with the
         * current selection. The selection is used to initialize the
fields of the wizard
         * page.
         *
         * @param selection used to initialize the fields
         */
        public void init(IStructuredSelection selection) {
            IJavaElement jelem= getInitialJavaElement(selection);
            initContainerPage(jelem);
            initTypePage(jelem);

        }

        protected void handleFieldChanged(String fieldName) {
            super.handleFieldChanged(fieldName);
        }


}

<?xml version="1.0" encoding="UTF-8"?>
<plugin
   id="gffsd"
   name="gffsd plugIn"
   version="1.0.0"
   provider-name="d"
   class="gffsd.gffsdPlugin">

   <runtime>
      <library name="gffsd.jar"/>
   </runtime>
   <requires>
      <import plugin="org.eclipse.core.resources"/>
      <import plugin="org.eclipse.ui"/>
   </requires>


   <extension
         point="org.eclipse.ui.newWizards">
      <category
            name="Sample Wizards"
            id="gffsd">
      </category>
      <wizard
            name="a file"
            icon="icons/sample.gif"
            category="gffsd"
            class="gffsd.wizards.SampleNewWizard"
            id="gffsd.wizards.SampleNewWizard">
      </wizard>
   </extension>

</plugin>



Back to the top