The new wizard page is implemented by the class
xper.eclipse.plugin.jdt.ui.annotation.NewAnnotationWizardPage
which sub-classes
org.eclipse.jdt.ui.wizards.NewTypeWizardPage
following the example in JDT Plug-in Developer Guide:Programmer’s Guide:JDT UI: Java wizard pages
The constructor is based on that from the equivalent Eclipse supplied class as follows
NewAnnotationWizardPage()
{
super(ANNOTATION_TYPE, "NewAnnotationWizardPage");
setTitle(NewWizardMessages.NewAnnotationWizardPage_title);
setDescription(NewWizardMessages.NewAnnotationWizardPage_description);
retention = RetentionPolicy.CLASS;
targets = EnumSet.noneOf(ElementType.class);
}
as is the initialization method
void init(IStructuredSelection theSelection) { IJavaElement element= getInitialJavaElement(theSelection); initContainerPage(element); initTypePage(element); retention = RetentionPolicy.CLASS; targets.clear(); updateStatus(); }
The initContainerPage(IJavaElement)
method is inherited from
org.eclipse.jdt.ui.wizards.NewContainerWizardPage
which is the super-class of NewTypeWizardPage
.
The initTypePage(IJavaElement)
method is inherited from NewTypeWizardPage
.
You might expect that this method would invoke initContainerPage(IJavaElement)
itself but apparently not.
The updateStatus()
method is as follows.
private void updateStatus()
{
updateStatus(
new IStatus[]
{
fContainerStatus,
isEnclosingTypeSelected()
?
fEnclosingTypeStatus
:
fPackageStatus,
fTypeNameStatus,
fModifierStatus,
});
}
It is responsible for collecting together the statuses of all the data required to construct the Annotation
and passing them to the updateStatus(IStatus[])
method inherited from the
org.eclipse.jdt.ui.wizards.NewElementWizardPage
class.
This method then updates the status of the wizard page as appropriate.
For example, if all the necessary data is present and there are no problems with it then the ‘Finish’ or ‘Next’ button will be enabled.
Alternatively if, for example, a name for the Annotation has been entered and then deleted then fTypeNameStatus
has an IStatus value with a severity of ERROR
and the message
Type name is empty.
which is duly displayed by the wizard as shown below.
Since an Annotation can legally be defined without any annotation this method is the same as that of the equivalent Eclipse supplied class.
Copyright (c) 2009 By Simon Lewis. All Rights Reserved