1 11 package org.eclipse.jdt.ui.wizards; 12 13 import org.eclipse.core.runtime.IStatus; 14 15 import org.eclipse.swt.SWT; 16 import org.eclipse.swt.layout.GridLayout; 17 import org.eclipse.swt.widgets.Composite; 18 19 import org.eclipse.jface.dialogs.Dialog; 20 import org.eclipse.jface.viewers.IStructuredSelection; 21 22 import org.eclipse.ui.PlatformUI; 23 24 import org.eclipse.jdt.core.IJavaElement; 25 26 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 27 import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; 28 29 38 public class NewAnnotationWizardPage extends NewTypeWizardPage { 39 40 private final static String PAGE_NAME= "NewAnnotationWizardPage"; private final static int TYPE = NewTypeWizardPage.ANNOTATION_TYPE; 42 43 46 public NewAnnotationWizardPage() { 47 super(TYPE, PAGE_NAME); 48 49 setTitle(NewWizardMessages.NewAnnotationWizardPage_title); 50 setDescription(NewWizardMessages.NewAnnotationWizardPage_description); 51 } 52 53 55 62 public void init(IStructuredSelection selection) { 63 IJavaElement jelem= getInitialJavaElement(selection); 64 65 initContainerPage(jelem); 66 initTypePage(jelem); 67 doStatusUpdate(); 68 } 69 70 72 private void doStatusUpdate() { 73 IStatus[] status= new IStatus[] { 75 fContainerStatus, 76 isEnclosingTypeSelected() ? fEnclosingTypeStatus : fPackageStatus, 77 fTypeNameStatus, 78 fModifierStatus, 79 }; 80 81 updateStatus(status); 83 } 84 85 86 89 protected void handleFieldChanged(String fieldName) { 90 super.handleFieldChanged(fieldName); 91 92 doStatusUpdate(); 93 } 94 95 96 98 101 public void createControl(Composite parent) { 102 initializeDialogUnits(parent); 103 104 Composite composite= new Composite(parent, SWT.NONE); 105 106 int nColumns= 4; 107 108 GridLayout layout= new GridLayout(); 109 layout.numColumns= nColumns; 110 composite.setLayout(layout); 111 112 createContainerControls(composite, nColumns); 113 createPackageControls(composite, nColumns); 114 createEnclosingTypeControls(composite, nColumns); 115 116 createSeparator(composite, nColumns); 117 118 createTypeNameControls(composite, nColumns); 119 createModifierControls(composite, nColumns); 120 121 createCommentControls(composite, nColumns); 122 enableCommentControl(true); 123 124 setControl(composite); 125 126 Dialog.applyDialogFont(composite); 127 PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.NEW_ANNOTATION_WIZARD_PAGE); 128 } 129 130 133 public void setVisible(boolean visible) { 134 super.setVisible(visible); 135 if (visible) { 136 setFocus(); 137 } 138 } 139 } 140 | Popular Tags |