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 NewEnumWizardPage extends NewTypeWizardPage { 39 40 private final static String PAGE_NAME= "NewEnumWizardPage"; private final static int TYPE = NewTypeWizardPage.ENUM_TYPE; 42 43 46 public NewEnumWizardPage() { 47 super(TYPE, PAGE_NAME); 48 49 setTitle(NewWizardMessages.NewEnumWizardPage_title); 50 setDescription(NewWizardMessages.NewEnumWizardPage_description); 51 } 52 53 55 62 public void init(IStructuredSelection selection) { 63 IJavaElement jelem= getInitialJavaElement(selection); 64 65 initContainerPage(jelem); 66 initTypePage(jelem); 67 68 doStatusUpdate(); 69 } 70 71 73 private void doStatusUpdate() { 74 IStatus[] status= new IStatus[] { 76 fContainerStatus, 77 isEnclosingTypeSelected() ? fEnclosingTypeStatus : fPackageStatus, 78 fTypeNameStatus, 79 fModifierStatus, 80 fSuperInterfacesStatus 81 }; 82 83 updateStatus(status); 85 } 86 87 88 91 protected void handleFieldChanged(String fieldName) { 92 super.handleFieldChanged(fieldName); 93 94 doStatusUpdate(); 95 } 96 97 98 100 103 public void createControl(Composite parent) { 104 initializeDialogUnits(parent); 105 106 Composite composite= new Composite(parent, SWT.NONE); 107 composite.setFont(parent.getFont()); 108 109 int nColumns= 4; 110 111 GridLayout layout= new GridLayout(); 112 layout.numColumns= nColumns; 113 composite.setLayout(layout); 114 115 createContainerControls(composite, nColumns); 116 createPackageControls(composite, nColumns); 117 createEnclosingTypeControls(composite, nColumns); 118 119 createSeparator(composite, nColumns); 120 121 createTypeNameControls(composite, nColumns); 122 createModifierControls(composite, nColumns); 123 124 createSuperInterfacesControls(composite, nColumns); 125 126 createCommentControls(composite, nColumns); 127 enableCommentControl(true); 128 129 setControl(composite); 130 131 Dialog.applyDialogFont(composite); 132 PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.NEW_ENUM_WIZARD_PAGE); 133 } 134 135 138 public void setVisible(boolean visible) { 139 super.setVisible(visible); 140 if (visible) { 141 setFocus(); 142 } 143 } 144 145 } 146 | Popular Tags |