Bug 94304 [code manipulation] Fails to create a class in enum
With Eclipse I20050506-1600, I run a problem to create a inner class in enum: 1. select an enum in the package explorer 2. call new wizard to create a inner class 3. check the "Enclosing type" 4. Put a name in the "Name:" Field 5. Click the button "OK". I got the following exception: Caused by: java.lang.IllegalArgumentException: Node does not exist at org.eclipse.jdt.core.dom.rewrite.ListRewrite.insertBefore (ListRewrite.java:205) at org.eclipse.jdt.internal.core.CreateElementInCUOperation.insertASTNode (CreateElementInCUOperation.java:249) at org.eclipse.jdt.internal.core.CreateElementInCUOperation.generateNewCompilation UnitAST(CreateElementInCUOperation.java:184) at org.eclipse.jdt.internal.core.CreateElementInCUOperation.executeOperation (CreateElementInCUOperation.java:137) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:718) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1716) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation (JavaModelOperation.java:782) at org.eclipse.jdt.internal.core.SourceType.createType (SourceType.java:153) at org.eclipse.jdt.ui.wizards.NewTypeWizardPage.createType (NewTypeWizardPage.java:1808) at org.eclipse.jdt.internal.ui.wizards.NewClassCreationWizard.finishPage (NewClassCreationWizard.java:55) at org.eclipse.jdt.internal.ui.wizards.NewElementWizard$2.run (NewElementWizard.java:114) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:39) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:718) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1716) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3654) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:87) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:346) The samething can be done in Java editor.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewTypeWizardPage.java
IJavaElement[] elements= new IJavaElement[] { root.getJavaProject() };
		IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);
		TypeSelectionDialog2 dialog= new TypeSelectionDialog2(getShell(), false,
			getWizard().getContainer(), scope, IJavaSearchConstants.CLASS);
		dialog.setTitle(NewWizardMessages.NewTypeWizardPage_SuperClassDialog_title); 
		dialog.setMessage(NewWizardMessages.NewTypeWizardPage_SuperClassDialog_message); 
		dialog.setFilter(getSuperClass());
		if (dialog.open() == Window.OK) {
			return (IType) dialog.getFirstResult();
		}
		return null;
	}
	
	private void chooseSuperInterfaces() {
		IPackageFragmentRoot root= getPackageFragmentRoot();
		if (root == null) {
			return;
		}	
		IJavaProject project= root.getJavaProject();
		SuperInterfaceSelectionDialog dialog= new SuperInterfaceSelectionDialog(getShell(), getWizard().getContainer(), fSuperInterfacesDialogField, project);
		dialog.setTitle(getInterfaceDialogTitle());
		dialog.setMessage(NewWizardMessages.NewTypeWizardPage_InterfacesDialog_message); 
		dialog.open();
		List interfaces= fSuperInterfacesDialogField.getElements();
		if (interfaces.size() > 0) {
			Object element= interfaces.get(interfaces.size() - 1);
			TableViewer tableViewer= fSuperInterfacesDialogField.getTableViewer();
			tableViewer.refresh(element);
			tableViewer.editElement(element, 0);