1 11 package org.eclipse.jdt.internal.ui.wizards; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.IProgressMonitor; 15 16 import org.eclipse.core.resources.IFile; 17 import org.eclipse.core.resources.IResource; 18 19 import org.eclipse.jdt.core.IJavaElement; 20 21 import org.eclipse.jdt.ui.wizards.NewEnumWizardPage; 22 23 import org.eclipse.jdt.internal.ui.JavaPlugin; 24 import org.eclipse.jdt.internal.ui.JavaPluginImages; 25 26 public class NewEnumCreationWizard extends NewElementWizard { 27 28 private NewEnumWizardPage fPage; 29 private boolean fOpenEditorOnFinish; 30 31 public NewEnumCreationWizard() { 32 this(null, true); 33 } 34 35 public NewEnumCreationWizard(NewEnumWizardPage page, boolean openEditorOnFinish) { 36 setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWENUM); 37 setDialogSettings(JavaPlugin.getDefault().getDialogSettings()); 38 setWindowTitle(NewWizardMessages.NewEnumCreationWizard_title); 39 40 fPage= page; 41 fOpenEditorOnFinish= openEditorOnFinish; 42 } 43 44 47 public void addPages() { 48 super.addPages(); 49 if (fPage == null) { 50 fPage= new NewEnumWizardPage(); 51 fPage.init(getSelection()); 52 } 53 addPage(fPage); 54 } 55 56 59 protected boolean canRunForked() { 60 return !fPage.isEnclosingTypeSelected(); 61 } 62 63 66 protected void finishPage(IProgressMonitor monitor) throws InterruptedException , CoreException { 67 fPage.createType(monitor); } 69 70 73 public boolean performFinish() { 74 warnAboutTypeCommentDeprecation(); 75 boolean res= super.performFinish(); 76 if (res) { 77 IResource resource= fPage.getModifiedResource(); 78 if (resource != null) { 79 selectAndReveal(resource); 80 if (fOpenEditorOnFinish) { 81 openResource((IFile) resource); 82 } 83 } 84 } 85 return res; 86 } 87 88 91 public IJavaElement getCreatedElement() { 92 return fPage.getCreatedType(); 93 } 94 } 95 | Popular Tags |