public abstract class NewTypeWizardPage extends NewContainerWizardPage
NewTypeWizardPage contains controls and validation routines
for a 'New Type WizardPage'. Implementors decide which components to add and to enable.
Implementors can also customize the validation code. NewTypeWizardPage
is intended to serve as base class of all wizards that create types like applets, servlets, classes,
interfaces, etc.
See NewClassWizardPage or NewInterfaceWizardPage for an
example usage of the NewTypeWizardPage.
NewClassWizardPage,
org.eclipse.wst.jsdt.ui.wizards.NewInterfaceWizardPage| Modifier and Type | Class and Description |
|---|---|
static class |
NewTypeWizardPage.ImportsManager
Class used in stub creation routines to add needed imports to a
compilation unit.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
ANNOTATION_TYPE
Constant to signal that the created type is an annotation.
|
static int |
CLASS_TYPE
Constant to signal that the created type is a class.
|
protected static java.lang.String |
ENCLOSING
Field ID of the enclosing type input field.
|
protected static java.lang.String |
ENCLOSINGSELECTION
Field ID of the enclosing type checkbox.
|
static int |
ENUM_TYPE
Constant to signal that the created type is an enum.
|
int |
F_ABSTRACT
Abstract property flag.
|
int |
F_PRIVATE
Private access flag.
|
int |
F_PUBLIC
Public access flag.
|
int |
F_STATIC
Static access flag.
|
protected IStatus |
fEnclosingTypeStatus |
protected IStatus |
fModifierStatus |
protected IStatus |
fPackageStatus |
protected IStatus |
fSuperClassStatus |
protected IStatus |
fSuperInterfacesStatus |
protected IStatus |
fTypeNameStatus |
static int |
INTERFACE_TYPE
Constant to signal that the created type is a interface.
|
protected static java.lang.String |
INTERFACES
Field ID of the super interfaces input field.
|
protected static java.lang.String |
METHODS
Field ID of the method stubs check boxes.
|
protected static java.lang.String |
MODIFIERS
Field ID of the modifier check boxes.
|
protected static java.lang.String |
PACKAGE
Field ID of the package input field.
|
protected static java.lang.String |
SUPER
Field ID of the super type input field.
|
protected static java.lang.String |
TYPENAME
Field ID of the type name input field.
|
CONTAINER, fContainerStatus| Constructor and Description |
|---|
NewTypeWizardPage(boolean isClass,
java.lang.String pageName)
Creates a new
NewTypeWizardPage. |
NewTypeWizardPage(int typeKind,
java.lang.String pageName)
Creates a new
NewTypeWizardPage. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addSuperInterface(java.lang.String superInterface)
Adds a super interface to the end of the list and selects it if it is not in the list yet.
|
protected IType |
chooseEnclosingType()
Opens a selection dialog that allows to select an enclosing type.
|
protected IPackageFragment |
choosePackage()
Opens a selection dialog that allows to select a package.
|
protected IType |
chooseSuperClass()
Opens a selection dialog that allows to select a super class.
|
protected java.lang.String |
constructCUContent(IJavaScriptUnit cu,
java.lang.String typeContent,
java.lang.String lineDelimiter)
Uses the New JavaScript file template from the code template page to generate a
compilation unit with the given type content.
|
protected IStatus |
containerChanged()
This method is a hook which gets called after the source folder's
text input field has changed.
|
protected void |
createCommentControls(Composite composite,
int nColumns)
Creates the controls for the preference page links.
|
protected void |
createEnclosingTypeControls(Composite composite,
int nColumns)
Creates the controls for the enclosing type name field.
|
protected IFunction[] |
createInheritedMethods(IType type,
boolean doConstructors,
boolean doUnimplementedMethods,
NewTypeWizardPage.ImportsManager imports,
IProgressMonitor monitor)
Creates the bodies of all unimplemented methods and constructors and adds them to the type.
|
protected void |
createModifierControls(Composite composite,
int nColumns)
Creates the controls for the modifiers radio/checkbox buttons.
|
protected void |
createPackageControls(Composite composite,
int nColumns)
Creates the controls for the package name field.
|
protected void |
createSeparator(Composite composite,
int nColumns)
Creates a separator line.
|
protected void |
createSuperClassControls(Composite composite,
int nColumns)
Creates the controls for the superclass name field.
|
protected void |
createSuperInterfacesControls(Composite composite,
int nColumns)
Creates the controls for the superclass name field.
|
void |
createType(IProgressMonitor monitor)
Creates the new type using the entered field values.
|
protected void |
createTypeMembers(IType newType,
NewTypeWizardPage.ImportsManager imports,
IProgressMonitor monitor)
Hook method that gets called from
createType to support adding of
unanticipated methods, fields, and inner types to the created type. |
protected void |
createTypeNameControls(Composite composite,
int nColumns)
Creates the controls for the type name field.
|
void |
enableCommentControl(boolean useAddCommentValue)
Sets to use the 'Add comment' checkbox value.
|
protected IStatus |
enclosingTypeChanged()
Hook method that gets called when the enclosing type name has changed.
|
protected java.lang.String |
getCompilationUnitName(java.lang.String typeName)
Hook method that is called when evaluating the name of the compilation unit to create.
|
IType |
getCreatedType()
Returns the created type or
null is the type has not been created yet. |
IType |
getEnclosingType()
Returns the enclosing type corresponding to the current input.
|
protected java.lang.String |
getEnclosingTypeLabel()
Returns the label that is used for the enclosing type input field.
|
java.lang.String |
getEnclosingTypeText()
Returns the text of the enclosing type input field.
|
protected java.lang.String |
getFileComment(IJavaScriptUnit parentCU)
Deprecated.
Instead of file templates, the new type code template
specifies the stub for a compilation unit.
|
protected java.lang.String |
getFileComment(IJavaScriptUnit parentCU,
java.lang.String lineDelimiter)
Hook method that gets called from
createType to retrieve
a file comment. |
IResource |
getModifiedResource()
Returns the resource handle that corresponds to the compilation unit to was or
will be created or modified.
|
int |
getModifiers()
Returns the selected modifiers.
|
protected java.lang.String |
getModifiersLabel()
Returns the label that is used for the modifiers input field.
|
IPackageFragment |
getPackageFragment()
Returns the package fragment corresponding to the current input.
|
protected java.lang.String |
getPackageLabel()
Returns the label that is used for the package input field.
|
java.lang.String |
getPackageText()
Returns the text of the package input field.
|
IRunnableWithProgress |
getRunnable()
Returns the runnable that creates the type using the current settings.
|
java.lang.String |
getSuperClass()
Returns the content of the superclass input field.
|
protected java.lang.String |
getSuperClassLabel()
Returns the label that is used for the super class input field.
|
java.util.List |
getSuperInterfaces()
Returns the chosen super interfaces.
|
protected java.lang.String |
getSuperInterfacesLabel()
Returns the label that is used for the super interfaces input field.
|
protected java.lang.String |
getTemplate(java.lang.String name,
IJavaScriptUnit parentCU,
int pos)
Returns the string resulting from evaluation the given template in
the context of the given compilation unit.
|
protected java.lang.String |
getTypeComment(IJavaScriptUnit parentCU,
java.lang.String lineDelimiter)
Hook method that gets called from
createType to retrieve
a type comment. |
java.lang.String |
getTypeName()
Returns the type name entered into the type input field.
|
protected java.lang.String |
getTypeNameLabel()
Returns the label that is used for the type name input field.
|
protected void |
handleFieldChanged(java.lang.String fieldName)
Hook method that gets called when a field on this page has changed.
|
protected void |
initTypePage(IJavaScriptElement elem)
Initializes all fields provided by the page with a given selection.
|
boolean |
isAddComments()
Returns if comments are added.
|
boolean |
isEnclosingTypeSelected()
Returns the selection state of the enclosing type checkbox.
|
protected IStatus |
modifiersChanged()
Hook method that gets called when the modifiers have changed.
|
protected IStatus |
packageChanged()
A hook method that gets called when the package field has changed.
|
void |
setAddComments(boolean doAddComments,
boolean canBeModified)
Sets 'Add comment' checkbox.
|
void |
setEnclosingType(IType type,
boolean canBeModified)
Sets the enclosing type.
|
void |
setEnclosingTypeSelection(boolean isSelected,
boolean canBeModified)
Sets the enclosing type checkbox's selection state.
|
protected void |
setFocus()
Sets the focus on the type name input field.
|
void |
setModifiers(int modifiers,
boolean canBeModified)
Sets the modifiers.
|
void |
setPackageFragment(IPackageFragment pack,
boolean canBeModified)
Sets the package fragment to the given value.
|
void |
setSuperClass(java.lang.String name,
boolean canBeModified)
Sets the super class name.
|
void |
setSuperInterfaces(java.util.List interfacesNames,
boolean canBeModified)
Sets the super interfaces.
|
void |
setTypeName(java.lang.String name,
boolean canBeModified)
Sets the type name input field's text to the given value.
|
protected IStatus |
superClassChanged()
Hook method that gets called when the superclass name has changed.
|
protected IStatus |
superInterfacesChanged()
Hook method that gets called when the list of super interface has changed.
|
protected IStatus |
typeNameChanged()
Hook method that gets called when the type name has changed.
|
chooseContainer, createContainerControls, getContainerLabel, getCurrentTextSelection, getInitialJavaElement, getJavaProject, getMaxFieldWidth, getPackageFragmentRoot, getPackageFragmentRootText, getWorkspaceRoot, initContainerPage, setFocusOnContainer, setPackageFragmentRootsetVisible, updateStatus, updateStatuspublic int F_PUBLIC
public int F_PRIVATE
public int F_STATIC
public int F_ABSTRACT
protected static final java.lang.String PACKAGE
protected static final java.lang.String ENCLOSING
protected static final java.lang.String ENCLOSINGSELECTION
protected static final java.lang.String TYPENAME
protected static final java.lang.String SUPER
protected static final java.lang.String INTERFACES
protected static final java.lang.String MODIFIERS
protected static final java.lang.String METHODS
protected IStatus fEnclosingTypeStatus
protected IStatus fPackageStatus
protected IStatus fTypeNameStatus
protected IStatus fSuperClassStatus
protected IStatus fModifierStatus
protected IStatus fSuperInterfacesStatus
public static final int CLASS_TYPE
public static final int INTERFACE_TYPE
public static final int ENUM_TYPE
public static final int ANNOTATION_TYPE
public NewTypeWizardPage(boolean isClass,
java.lang.String pageName)
NewTypeWizardPage.isClass - true if a new class is to be created; otherwise
an interface is to be createdpageName - the wizard page's namepublic NewTypeWizardPage(int typeKind,
java.lang.String pageName)
NewTypeWizardPage.typeKind - Signals the kind of the type to be created. Valid kinds are
CLASS_TYPE, INTERFACE_TYPE, ENUM_TYPE and ANNOTATION_TYPEpageName - the wizard page's nameprotected void initTypePage(IJavaScriptElement elem)
elem - the selection used to initialize this page or
null if no selection was availableprotected java.lang.String getPackageLabel()
protected java.lang.String getEnclosingTypeLabel()
protected java.lang.String getTypeNameLabel()
protected java.lang.String getModifiersLabel()
protected java.lang.String getSuperClassLabel()
protected java.lang.String getSuperInterfacesLabel()
protected void createSeparator(Composite composite,
int nColumns)
GridLayout with at least 1 column.composite - the parent compositenColumns - number of columns to spanprotected void createPackageControls(Composite composite,
int nColumns)
GridLayout with at
least 4 columns.composite - the parent compositenColumns - number of columns to spanprotected void createEnclosingTypeControls(Composite composite,
int nColumns)
GridLayout with at
least 4 columns.composite - the parent compositenColumns - number of columns to spanprotected void createTypeNameControls(Composite composite,
int nColumns)
GridLayout with at
least 2 columns.composite - the parent compositenColumns - number of columns to spanprotected void createModifierControls(Composite composite,
int nColumns)
GridLayout with at least 3 columns.composite - the parent compositenColumns - number of columns to spanprotected void createSuperClassControls(Composite composite,
int nColumns)
GridLayout
with at least 3 columns.composite - the parent compositenColumns - number of columns to spanprotected void createSuperInterfacesControls(Composite composite,
int nColumns)
GridLayout with
at least 3 columns.composite - the parent compositenColumns - number of columns to spanprotected void createCommentControls(Composite composite,
int nColumns)
GridLayout with
at least 3 columns.composite - the parent compositenColumns - number of columns to spanprotected void setFocus()
protected void handleFieldChanged(java.lang.String fieldName)
NewContainerWizardPageEvery sub type is responsible to call this method when a field on its page has changed. Subtypes override (extend) the method to add verification when a own field has a dependency to an other field. For example the class name input must be verified again when the package field changes (check for duplicated class names).
handleFieldChanged in class NewContainerWizardPagefieldName - The name of the field that has changed (field id). For the
source folder the field id is CONTAINERpublic java.lang.String getPackageText()
public java.lang.String getEnclosingTypeText()
public IPackageFragment getPackageFragment()
null if the input
could not be resolved.public void setPackageFragment(IPackageFragment pack, boolean canBeModified)
pack - the package fragment to be setcanBeModified - if true the package fragment is
editable; otherwise it is read-only.public IType getEnclosingType()
null if the enclosing type is
not selected or the input could not be resolvedpublic void setEnclosingType(IType type, boolean canBeModified)
type - the enclosing typecanBeModified - if true the enclosing type field is
editable; otherwise it is read-only.public boolean isEnclosingTypeSelected()
public void setEnclosingTypeSelection(boolean isSelected,
boolean canBeModified)
isSelected - the checkbox's selection statecanBeModified - if true the enclosing type checkbox is
modifiable; otherwise it is read-only.public java.lang.String getTypeName()
public void setTypeName(java.lang.String name,
boolean canBeModified)
name - the new type namecanBeModified - if true the type name field is
editable; otherwise it is read-only.public int getModifiers()
Flagspublic void setModifiers(int modifiers,
boolean canBeModified)
modifiers - F_PUBLIC, F_PRIVATE,
F_PROTECTED, F_ABSTRACT, F_FINAL
or F_STATIC or a valid combination.canBeModified - if true the modifier fields are
editable; otherwise they are read-onlyFlagspublic java.lang.String getSuperClass()
public void setSuperClass(java.lang.String name,
boolean canBeModified)
name - the new superclass namecanBeModified - if true the superclass name field is
editable; otherwise it is read-only.public java.util.List getSuperInterfaces()
Stringpublic void setSuperInterfaces(java.util.List interfacesNames,
boolean canBeModified)
interfacesNames - a list of super interface. The method requires that
the list's elements are of type StringcanBeModified - if true the super interface field is
editable; otherwise it is read-only.public boolean addSuperInterface(java.lang.String superInterface)
superInterface - the fully qualified type name of the interface.trueif the interfaces has been added, false
if the interface already is in the list.public void setAddComments(boolean doAddComments,
boolean canBeModified)
enableCommentControl(boolean)doAddComments - if true, comments are added.canBeModified - if true check box is
editable; otherwise it is read-only.public void enableCommentControl(boolean useAddCommentValue)
useAddCommentValue - if true,public boolean isAddComments()
enableCommentControl(boolean), otherwise
the settings as specified in the preferences is used.true if comments can be addedpublic IResource getModifiedResource()
protected IStatus containerChanged()
NewContainerWizardPagecontainerChanged in class NewContainerWizardPageprotected IStatus packageChanged()
Subclasses may extend this method to perform their own validation.
protected IStatus enclosingTypeChanged()
Subclasses may extend this method to perform their own validation.
protected java.lang.String getCompilationUnitName(java.lang.String typeName)
java is added to the given type name, but implementors can override this behavior.typeName - the name of the type to create the compilation unit for.protected IStatus typeNameChanged()
Subclasses may extend this method to perform their own validation.
protected IStatus superClassChanged()
Subclasses may extend this method to perform their own validation.
protected IStatus superInterfacesChanged()
Subclasses may extend this method to perform their own validation.
protected IStatus modifiersChanged()
Subclasses may extend this method to perform their own validation.
protected IPackageFragment choosePackage()
null if the dialog has been canceled.
The caller typically sets the result to the package input field.
Clients can override this method if they want to offer a different dialog.
protected IType chooseEnclosingType()
null if the dialog has been canceled.
The caller typically sets the result to the enclosing type input field.
Clients can override this method if they want to offer a different dialog.
protected IType chooseSuperClass()
null if the dialog has been canceled.
The caller typically sets the result to the super class input field.
Clients can override this method if they want to offer a different dialog.
public void createType(IProgressMonitor monitor)
throws CoreException,
java.lang.InterruptedException
monitor - a progress monitor to report progress.CoreException - Thrown when the creation failed.java.lang.InterruptedException - Thrown when the operation was canceled.protected java.lang.String constructCUContent(IJavaScriptUnit cu, java.lang.String typeContent, java.lang.String lineDelimiter) throws CoreException
cu - The new created compilation unittypeContent - The content of the type, including signature and type
body.lineDelimiter - The line delimiter to be used.CoreExceptionpublic IType getCreatedType()
null is the type has not been created yet. The method
only returns a valid type after createType has been called.createType(IProgressMonitor)protected void createTypeMembers(IType newType, NewTypeWizardPage.ImportsManager imports, IProgressMonitor monitor) throws CoreException
createType to support adding of
unanticipated methods, fields, and inner types to the created type.
Implementers can use any methods defined on IType to manipulate the
new type.
The source code of the new type will be formatted using the platform's formatter. Needed imports are added by the wizard at the end of the type creation process using the given import manager.
newType - the new type created via createTypeimports - an import manager which can be used to add new importsmonitor - a progress monitor to report progress. Must not be nullCoreException - thrown when creation of the type members failedcreateType(IProgressMonitor)protected java.lang.String getFileComment(IJavaScriptUnit parentCU)
parentCU - the current compilation unitnullprotected java.lang.String getFileComment(IJavaScriptUnit parentCU, java.lang.String lineDelimiter) throws CoreException
createType to retrieve
a file comment. This default implementation returns the content of the
'file comment' template or null if no comment should be created.parentCU - the parent compilation unitlineDelimiter - the line delimiter to usenull if a file comment
is not desiredCoreExceptionprotected java.lang.String getTypeComment(IJavaScriptUnit parentCU, java.lang.String lineDelimiter)
createType to retrieve
a type comment. This default implementation returns the content of the
'type comment' template.parentCU - the parent compilation unitlineDelimiter - the line delimiter to usenull if a type comment
is not desiredprotected java.lang.String getTemplate(java.lang.String name,
IJavaScriptUnit parentCU,
int pos)
constructCUContent to construct a compilation unit stub or
getTypeComment for the comment of the type.name - the template to be evaluatedparentCU - the templates evaluation contextpos - a source offset into the parent compilation unit. The
template is evaluated at the given source offsetnull if the template could not be found.protected IFunction[] createInheritedMethods(IType type, boolean doConstructors, boolean doUnimplementedMethods, NewTypeWizardPage.ImportsManager imports, IProgressMonitor monitor) throws CoreException
NewTypeWizardPage to add
needed method and constructors.type - the type for which the new methods and constructor are to be createddoConstructors - if true unimplemented constructors are createddoUnimplementedMethods - if true unimplemented methods are createdimports - an import manager to add all needed import statementsmonitor - a progress monitor to report progressCoreException - thrown when the creation fails.public IRunnableWithProgress getRunnable()
Copyright (c) IBM Corp. and others 2000, 2016. All Rights Reserved.