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.NewAnnotationWizardPage; 22 23 import org.eclipse.jdt.internal.ui.JavaPlugin; 24 import org.eclipse.jdt.internal.ui.JavaPluginImages; 25 26 public class NewAnnotationCreationWizard extends NewElementWizard { 27 28 private NewAnnotationWizardPage fPage; 29 private boolean fOpenEditorOnFinish; 30 31 public NewAnnotationCreationWizard(NewAnnotationWizardPage page, boolean openEditorOnFinish) { 32 setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWANNOT); 33 setDialogSettings(JavaPlugin.getDefault().getDialogSettings()); 34 setWindowTitle(NewWizardMessages.NewAnnotationCreationWizard_title); 35 36 fPage= page; 37 fOpenEditorOnFinish= openEditorOnFinish; 38 } 39 40 public NewAnnotationCreationWizard() { 41 this(null, true); 42 } 43 44 47 public void addPages() { 48 super.addPages(); 49 if (fPage == null) { 50 fPage= new NewAnnotationWizardPage(); 51 fPage.init(getSelection()); 52 } 53 addPage(fPage); 54 55 } 56 57 60 protected boolean canRunForked() { 61 return !fPage.isEnclosingTypeSelected(); 62 } 63 64 67 protected void finishPage(IProgressMonitor monitor) throws InterruptedException , CoreException { 68 fPage.createType(monitor); } 70 71 74 public boolean performFinish() { 75 warnAboutTypeCommentDeprecation(); 76 boolean res= super.performFinish(); 77 if (res) { 78 IResource resource= fPage.getModifiedResource(); 79 if (resource != null) { 80 selectAndReveal(resource); 81 if (fOpenEditorOnFinish) { 82 openResource((IFile) resource); 83 } 84 } 85 } 86 return res; 87 } 88 89 92 public IJavaElement getCreatedElement() { 93 return fPage.getCreatedType(); 94 } 95 } 96 | Popular Tags |