Class NewTypeWizardPage
- All Implemented Interfaces:
org.eclipse.jface.dialogs.IDialogPage
,org.eclipse.jface.dialogs.IMessageProvider
,org.eclipse.jface.wizard.IWizardPage
- Direct Known Subclasses:
NewAnnotationWizardPage
,NewClassWizardPage
,NewEnumWizardPage
,NewInterfaceWizardPage
,NewModuleInfoWizardPage
,NewPackageWizardPage
,NewRecordWizardPage
,NewTestCaseWizardPageOne
,NewTestSuiteWizardPage
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
.
- Since:
- 2.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Class used in stub creation routines to add needed imports to a compilation unit. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Constant to signal that the created type is an annotation.static final int
Constant to signal that the created type is a class.protected static final String
Field ID of the enclosing type input field.protected static final String
Field ID of the enclosing type checkbox.static final int
Constant to signal that the created type is an enum.int
Abstract property flag.int
Final access flag.int
Private access flag.int
Protected access flag.int
Public access flag.int
Static access flag.protected org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField
protected org.eclipse.core.runtime.IStatus
protected org.eclipse.core.runtime.IStatus
protected org.eclipse.core.runtime.IStatus
protected org.eclipse.core.runtime.IStatus
protected org.eclipse.core.runtime.IStatus
protected org.eclipse.core.runtime.IStatus
protected org.eclipse.core.runtime.IStatus
protected org.eclipse.core.runtime.IStatus
protected org.eclipse.core.runtime.IStatus
static final int
Constant to signal that the created type is a interface.protected static final String
Field ID of the super interfaces input field.protected static final String
Field ID of the method stubs check boxes.protected static final String
Field ID of the modifier check boxes.protected static final String
Field ID of the package input field.static final int
Constant to signal that the created type is an record.protected static final String
Field ID of the modifier check boxes.protected static final String
Field ID of the super type input field.protected static final String
Field ID of the type name input field.Fields inherited from class org.eclipse.jdt.ui.wizards.NewContainerWizardPage
CONTAINER, fContainerStatus
Fields inherited from interface org.eclipse.jface.dialogs.IMessageProvider
ERROR, INFORMATION, NONE, WARNING
-
Constructor Summary
ConstructorsConstructorDescriptionNewTypeWizardPage
(boolean isClass, String pageName) Creates a newNewTypeWizardPage
.NewTypeWizardPage
(int typeKind, String pageName) Creates a newNewTypeWizardPage
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addSuperInterface
(String superInterface) Adds a super interface to the end of the list and selects it if it is not in the list yet.boolean
addSuperInterface
(String superInterface, IType type) Adds a super interface to the end of the list and selects it if it is not in the list yet.protected IType
Opens a selection dialog that allows to select an enclosing type.protected IPackageFragment
Opens a selection dialog that allows to select a package.protected IType
Opens a selection dialog that allows to select a super class.protected void
Opens a selection dialog that allows to select the super interfaces.protected String
constructCUContent
(ICompilationUnit cu, String typeContent, String lineDelimiter) Uses the New Java file template from the code template page to generate a compilation unit with the given type content.protected org.eclipse.core.runtime.IStatus
This method is a hook which gets called after the source folder's text input field has changed.protected void
createCommentControls
(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates the controls for the preference page links.protected org.eclipse.swt.widgets.Link
createCommentWithLinkControls
(org.eclipse.swt.widgets.Composite composite, int nColumns, boolean isModule) Creates the comment and link in the single line for the preference page links.protected void
createEnclosingTypeControls
(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates the controls for the enclosing type name field.protected IMethod[]
createInheritedMethods
(IType type, boolean doConstructors, boolean doUnimplementedMethods, NewTypeWizardPage.ImportsManager imports, org.eclipse.core.runtime.IProgressMonitor monitor) Creates the bodies of all unimplemented methods and constructors and adds them to the type.protected IMethod
createMainMethod
(IType type, NewTypeWizardPage.ImportsManager imports) Creates the stub for 'public static void main(String[] args)' methodprotected void
createModifierControls
(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates the controls for the modifiers radio/checkbox buttons.protected void
createPackageControls
(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates the controls for the package name field.protected void
createSeparator
(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates a separator line.protected void
createSuperClassControls
(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates the controls for the superclass name field.protected void
createSuperInterfacesControls
(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates the controls for the superclass name field.void
createType
(org.eclipse.core.runtime.IProgressMonitor monitor) Creates the new type using the entered field values.protected void
createTypeMembers
(IType newType, NewTypeWizardPage.ImportsManager imports, org.eclipse.core.runtime.IProgressMonitor monitor) Hook method that gets called fromcreateType
to support adding of unanticipated methods, fields, and inner types to the created type.protected void
createTypeNameControls
(org.eclipse.swt.widgets.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 org.eclipse.core.runtime.IStatus
Hook method that gets called when the enclosing type name has changed.protected String
getCompilationUnitName
(String typeName) Hook method that is called when evaluating the name of the compilation unit to create.Returns the created type ornull
is the type has not been created yet.Returns the enclosing type corresponding to the current input.protected String
Returns the label that is used for the enclosing type input field.Returns the text of the enclosing type input field.protected String
getFileComment
(ICompilationUnit parentCU) Deprecated.Instead of file templates, the new type code template specifies the stub for a compilation unit.protected String
getFileComment
(ICompilationUnit parentCU, String lineDelimiter) Hook method that gets called fromcreateType
to retrieve a file comment.org.eclipse.core.resources.IResource
Returns the resource handle that corresponds to the compilation unit to was or will be created or modified.int
Returns the selected modifiers.protected String
Returns the label that is used for the modifiers input field.Returns the package fragment corresponding to the current input.protected String
Returns the label that is used for the package input field.Returns the text of the package input field.org.eclipse.jface.operation.IRunnableWithProgress
Returns the runnable that creates the type using the current settings.org.eclipse.core.runtime.IStatus
org.eclipse.core.runtime.IStatus
org.eclipse.core.runtime.IStatus
Returns the content of the superclass input field.protected String
Returns the label that is used for the super class input field.org.eclipse.core.runtime.IStatus
Returns the chosen super interfaces.protected String
Returns the label that is used for the super interfaces input field.org.eclipse.core.runtime.IStatus
protected String
getTemplate
(String name, ICompilationUnit parentCU) Deprecated.Use getTemplate(String,ICompilationUnit,int)protected String
getTemplate
(String name, ICompilationUnit parentCU, int pos) Returns the string resulting from evaluation the given template in the context of the given compilation unit.protected String
getTypeComment
(ICompilationUnit parentCU) Deprecated.Use getTypeComment(ICompilationUnit, String)protected String
getTypeComment
(ICompilationUnit parentCU, String lineDelimiter) Hook method that gets called fromcreateType
to retrieve a type comment.Returns the type name entered into the type input field (without the default file extensionjava
, if entered).protected String
Returns the label that is used for the type name input field.protected String
getUniqueJavaTypeName
(IPackageFragment pack, String name) Generate a unique type name for some initially given name under the given package fragment.protected void
handleFieldChanged
(String fieldName) Hook method that gets called when a field on this page has changed.protected void
initTypePage
(IJavaElement elem) Initializes all fields provided by the page with a given selection.boolean
Returns if comments are added.boolean
Returns the selection state of the enclosing type checkbox.protected boolean
protected boolean
protected org.eclipse.core.runtime.IStatus
Hook method that gets called when the modifiers have changed.protected org.eclipse.core.runtime.IStatus
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
(String name, boolean canBeModified) Sets the super class name.void
setSuperClass
(ITypeBinding type, boolean canBeModified) Sets the super class name.void
setSuperInterfaces
(List<String> interfacesNames, boolean canBeModified) Sets the super interfaces.void
setSuperInterfacesList
(List<ITypeBinding> interfaceBindings, boolean canBeModified) Sets the super interfaces.void
setTypeName
(String name, boolean canBeModified) Sets the type name input field's text to the given value.protected org.eclipse.core.runtime.IStatus
Hook method that gets called when the superclass name has changed.protected org.eclipse.core.runtime.IStatus
Hook method that gets called when the list of super interface has changed.protected org.eclipse.core.runtime.IStatus
Hook method that gets called when the type name has changed.protected org.eclipse.core.runtime.IStatus
Hook provided to get called when the super interfaces get changed.Methods inherited from class org.eclipse.jdt.ui.wizards.NewContainerWizardPage
chooseContainer, createContainerControls, getContainerLabel, getCurrentTextSelection, getInitialJavaElement, getJavaProject, getMaxFieldWidth, getPackageFragmentRoot, getPackageFragmentRootText, getWorkspaceRoot, initContainerPage, initContainerPage, setFocusOnContainer, setPackageFragmentRoot
Methods inherited from class org.eclipse.jdt.ui.wizards.NewElementWizardPage
setVisible, updateStatus, updateStatus
Methods inherited from class org.eclipse.jface.wizard.WizardPage
canFlipToNextPage, getContainer, getDialogSettings, getImage, getName, getNextPage, getPreviousPage, getShell, getWizard, isCurrentPage, isPageComplete, setDescription, setErrorMessage, setImageDescriptor, setMessage, setPageComplete, setPreviousPage, setTitle, setWizard, toString
Methods inherited from class org.eclipse.jface.dialogs.DialogPage
convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, dispose, getControl, getDescription, getDialogFontName, getErrorMessage, getFont, getMessage, getMessageType, getTitle, getToolTipText, initializeDialogUnits, isControlCreated, performHelp, setButtonLayoutData, setControl, setMessage
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jface.dialogs.IDialogPage
createControl, dispose, getControl, getDescription, getErrorMessage, getMessage, getTitle, performHelp
Methods inherited from interface org.eclipse.jface.wizard.IWizardPage
getMinimumPageSize
-
Field Details
-
F_PUBLIC
public int F_PUBLICPublic access flag. See The Java Virtual Machine Specification for more details. -
F_PRIVATE
public int F_PRIVATEPrivate access flag. See The Java Virtual Machine Specification for more details. -
F_PROTECTED
public int F_PROTECTEDProtected access flag. See The Java Virtual Machine Specification for more details. -
F_STATIC
public int F_STATICStatic access flag. See The Java Virtual Machine Specification for more details. -
F_FINAL
public int F_FINALFinal access flag. See The Java Virtual Machine Specification for more details. -
F_ABSTRACT
public int F_ABSTRACTAbstract property flag. See The Java Virtual Machine Specification for more details. -
PACKAGE
Field ID of the package input field.- See Also:
-
ENCLOSING
Field ID of the enclosing type input field.- See Also:
-
ENCLOSINGSELECTION
Field ID of the enclosing type checkbox.- See Also:
-
TYPENAME
Field ID of the type name input field.- See Also:
-
SUPER
Field ID of the super type input field.- See Also:
-
INTERFACES
Field ID of the super interfaces input field.- See Also:
-
MODIFIERS
Field ID of the modifier check boxes.- See Also:
-
SEALEDMODIFIERS
Field ID of the modifier check boxes.- Since:
- 3.25
- See Also:
-
METHODS
Field ID of the method stubs check boxes.- See Also:
-
fAddCommentButton
protected org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField fAddCommentButton- Restriction:
- This field is not intended to be referenced by clients.
-
fEnclosingTypeStatus
protected org.eclipse.core.runtime.IStatus fEnclosingTypeStatus -
fPackageStatus
protected org.eclipse.core.runtime.IStatus fPackageStatus -
fTypeNameStatus
protected org.eclipse.core.runtime.IStatus fTypeNameStatus -
fSuperClassStatus
protected org.eclipse.core.runtime.IStatus fSuperClassStatus -
fModifierStatus
protected org.eclipse.core.runtime.IStatus fModifierStatus -
fSuperInterfacesStatus
protected org.eclipse.core.runtime.IStatus fSuperInterfacesStatus -
fSealedModifierStatus
protected org.eclipse.core.runtime.IStatus fSealedModifierStatus- Since:
- 3.25
-
fSealedSuperClassStatus
protected org.eclipse.core.runtime.IStatus fSealedSuperClassStatus- Since:
- 3.25
-
fSealedSuperInterfacesStatus
protected org.eclipse.core.runtime.IStatus fSealedSuperInterfacesStatus- Since:
- 3.25
-
CLASS_TYPE
public static final int CLASS_TYPEConstant to signal that the created type is a class.- Since:
- 3.1
- See Also:
-
INTERFACE_TYPE
public static final int INTERFACE_TYPEConstant to signal that the created type is a interface.- Since:
- 3.1
- See Also:
-
ENUM_TYPE
public static final int ENUM_TYPEConstant to signal that the created type is an enum.- Since:
- 3.1
- See Also:
-
ANNOTATION_TYPE
public static final int ANNOTATION_TYPEConstant to signal that the created type is an annotation.- Since:
- 3.1
- See Also:
-
RECORD_TYPE
public static final int RECORD_TYPEConstant to signal that the created type is an record.- Since:
- 3.21
- See Also:
- Restriction:
- This field is not intended to be referenced by clients.
-
-
Constructor Details
-
NewTypeWizardPage
Creates a newNewTypeWizardPage
.- Parameters:
isClass
-true
if a new class is to be created; otherwise an interface is to be createdpageName
- the wizard page's name
-
NewTypeWizardPage
Creates a newNewTypeWizardPage
.- Parameters:
typeKind
- Signals the kind of the type to be created. Valid kinds areCLASS_TYPE
,INTERFACE_TYPE
,ENUM_TYPE
andANNOTATION_TYPE
pageName
- the wizard page's name- Since:
- 3.1
-
-
Method Details
-
initTypePage
Initializes all fields provided by the page with a given selection.- Parameters:
elem
- the selection used to initialize this page ornull
if no selection was available
-
getUniqueJavaTypeName
Generate a unique type name for some initially given name under the given package fragment.- Parameters:
pack
- the package fragment under which to check for uniquenessname
- the type name to check for uniqueness- Returns:
- a type name string that is unique under the given package fragment. If the initial type name is not unique, it is suffixed with a number greater than or equal to 2.
- Since:
- 3.17
-
getPackageLabel
Returns the label that is used for the package input field.- Returns:
- the label that is used for the package input field.
- Since:
- 3.2
-
getEnclosingTypeLabel
Returns the label that is used for the enclosing type input field.- Returns:
- the label that is used for the enclosing type input field.
- Since:
- 3.2
-
getTypeNameLabel
Returns the label that is used for the type name input field.- Returns:
- the label that is used for the type name input field.
- Since:
- 3.2
-
getModifiersLabel
Returns the label that is used for the modifiers input field.- Returns:
- the label that is used for the modifiers input field
- Since:
- 3.2
-
getSuperClassLabel
Returns the label that is used for the super class input field.- Returns:
- the label that is used for the super class input field.
- Since:
- 3.2
-
getSuperInterfacesLabel
Returns the label that is used for the super interfaces input field.- Returns:
- the label that is used for the super interfaces input field.
- Since:
- 3.2
-
createSeparator
protected void createSeparator(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates a separator line. Expects aGridLayout
with at least 1 column.- Parameters:
composite
- the parent compositenColumns
- number of columns to span
-
createPackageControls
protected void createPackageControls(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates the controls for the package name field. Expects aGridLayout
with at least 4 columns.- Parameters:
composite
- the parent compositenColumns
- number of columns to span
-
createEnclosingTypeControls
protected void createEnclosingTypeControls(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates the controls for the enclosing type name field. Expects aGridLayout
with at least 4 columns.- Parameters:
composite
- the parent compositenColumns
- number of columns to span
-
createTypeNameControls
protected void createTypeNameControls(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates the controls for the type name field. Expects aGridLayout
with at least 2 columns.- Parameters:
composite
- the parent compositenColumns
- number of columns to span
-
createModifierControls
protected void createModifierControls(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates the controls for the modifiers radio/checkbox buttons. Expects aGridLayout
with at least 3 columns.- Parameters:
composite
- the parent compositenColumns
- number of columns to span
-
createSuperClassControls
protected void createSuperClassControls(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates the controls for the superclass name field. Expects aGridLayout
with at least 3 columns.- Parameters:
composite
- the parent compositenColumns
- number of columns to span
-
createSuperInterfacesControls
protected void createSuperInterfacesControls(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates the controls for the superclass name field. Expects aGridLayout
with at least 3 columns.- Parameters:
composite
- the parent compositenColumns
- number of columns to span
-
createCommentControls
protected void createCommentControls(org.eclipse.swt.widgets.Composite composite, int nColumns) Creates the controls for the preference page links. Expects aGridLayout
with at least 3 columns.- Parameters:
composite
- the parent compositenColumns
- number of columns to span- Since:
- 3.1
-
createCommentWithLinkControls
protected org.eclipse.swt.widgets.Link createCommentWithLinkControls(org.eclipse.swt.widgets.Composite composite, int nColumns, boolean isModule) Creates the comment and link in the single line for the preference page links. Expects aGridLayout
with at least 2 columns.- Parameters:
composite
- the parent compositenColumns
- number of columns to spanisModule
- if it is module or package- Returns:
- link is returned
- Since:
- 3.18
-
setFocus
protected void setFocus()Sets the focus on the type name input field. -
handleFieldChanged
Description copied from class:NewContainerWizardPage
Hook method that gets called when a field on this page has changed. For this page the method gets called when the source folder field changes.Every 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).
- Overrides:
handleFieldChanged
in classNewContainerWizardPage
- Parameters:
fieldName
- The name of the field that has changed (field id). For the source folder the field id isCONTAINER
-
getPackageText
Returns the text of the package input field.- Returns:
- the text of the package input field
-
getEnclosingTypeText
Returns the text of the enclosing type input field.- Returns:
- the text of the enclosing type input field
-
getPackageFragment
Returns the package fragment corresponding to the current input.- Returns:
- a package fragment or
null
if the input could not be resolved.
-
setPackageFragment
Sets the package fragment to the given value. The method updates the model and the text of the control.- Parameters:
pack
- the package fragment to be setcanBeModified
- iftrue
the package fragment is editable; otherwise it is read-only.
-
getEnclosingType
Returns the enclosing type corresponding to the current input.- Returns:
- the enclosing type or
null
if the enclosing type is not selected or the input could not be resolved
-
setEnclosingType
Sets the enclosing type. The method updates the underlying model and the text of the control.- Parameters:
type
- the enclosing typecanBeModified
- iftrue
the enclosing type field is editable; otherwise it is read-only.
-
isEnclosingTypeSelected
public boolean isEnclosingTypeSelected()Returns the selection state of the enclosing type checkbox.- Returns:
- the selection state of the enclosing type checkbox
-
setEnclosingTypeSelection
public void setEnclosingTypeSelection(boolean isSelected, boolean canBeModified) Sets the enclosing type checkbox's selection state.- Parameters:
isSelected
- the checkbox's selection statecanBeModified
- iftrue
the enclosing type checkbox is modifiable; otherwise it is read-only.
-
getTypeName
Returns the type name entered into the type input field (without the default file extensionjava
, if entered).- Returns:
- the type name
-
setTypeName
Sets the type name input field's text to the given value. Method doesn't update the model.- Parameters:
name
- the new type namecanBeModified
- iftrue
the type name field is editable; otherwise it is read-only.
-
getModifiers
public int getModifiers()Returns the selected modifiers.- Returns:
- the selected modifiers
- See Also:
-
setModifiers
public void setModifiers(int modifiers, boolean canBeModified) Sets the modifiers.- Parameters:
modifiers
-F_PUBLIC
,F_PRIVATE
,F_PROTECTED
,F_ABSTRACT
,F_FINAL
orF_STATIC
or a valid combination.canBeModified
- iftrue
the modifier fields are editable; otherwise they are read-only- See Also:
-
getSuperClass
Returns the content of the superclass input field.- Returns:
- the superclass name
-
setSuperClass
Sets the super class name.- Parameters:
name
- the new superclass namecanBeModified
- iftrue
the superclass name field is editable; otherwise it is read-only.
-
setSuperClass
Sets the super class name.- Parameters:
type
- the binding of superclasscanBeModified
- iftrue
the superclass name field is editable; otherwise it is read-only.- Since:
- 3.25
-
getSuperInterfaces
Returns the chosen super interfaces.- Returns:
- a list of chosen super interfaces. The list's elements
are of type
String
-
setSuperInterfaces
Sets the super interfaces.- Parameters:
interfacesNames
- a list of super interface. The method requires that the list's elements are of typeString
canBeModified
- iftrue
the super interface field is editable; otherwise it is read-only.
-
setSuperInterfacesList
Sets the super interfaces.- Parameters:
interfaceBindings
- a list of super interface bindings. The method requires that the list's elements are of typeITypeBinding
canBeModified
- iftrue
the super interface field is editable; otherwise it is read-only.- Since:
- 3.25
-
addSuperInterface
Adds a super interface to the end of the list and selects it if it is not in the list yet.- Parameters:
superInterface
- the fully qualified type name of the interface.- Returns:
- returns
true
if the interfaces has been added,false
if the interface already is in the list. - Since:
- 3.2
-
addSuperInterface
Adds a super interface to the end of the list and selects it if it is not in the list yet.- Parameters:
superInterface
- the fully qualified type name of the interface.type
- IType java element of the interface.- Returns:
- returns
true
if the interfaces has been added,false
if the interface already is in the list. - Since:
- 3.25
-
setAddComments
public void setAddComments(boolean doAddComments, boolean canBeModified) Sets 'Add comment' checkbox. The value set will only be used when creating source when the comment control is enabled (seeenableCommentControl(boolean)
- Parameters:
doAddComments
- iftrue
, comments are added.canBeModified
- iftrue
check box is editable; otherwise it is read-only.- Since:
- 3.1
-
enableCommentControl
public void enableCommentControl(boolean useAddCommentValue) Sets to use the 'Add comment' checkbox value. Clients that use the 'Add comment' checkbox additionally have to enable the control. This has been added for backwards compatibility.- Parameters:
useAddCommentValue
- iftrue
,- Since:
- 3.1
-
isAddComments
public boolean isAddComments()Returns if comments are added. This method can be overridden by clients. The selection of the comment control is taken if enabled (seeenableCommentControl(boolean)
, otherwise the settings as specified in the preferences is used.- Returns:
- Returns
true
if comments can be added - Since:
- 3.1
-
getModifiedResource
public org.eclipse.core.resources.IResource getModifiedResource()Returns the resource handle that corresponds to the compilation unit to was or will be created or modified.- Returns:
- A resource or null if the page contains illegal values.
- Since:
- 3.0
-
containerChanged
protected org.eclipse.core.runtime.IStatus containerChanged()Description copied from class:NewContainerWizardPage
This method is a hook which gets called after the source folder's text input field has changed. This default implementation updates the model and returns an error status. The underlying model is only valid if the returned status is OK.- Overrides:
containerChanged
in classNewContainerWizardPage
- Returns:
- the model's error status
-
packageChanged
protected org.eclipse.core.runtime.IStatus packageChanged()A hook method that gets called when the package field has changed. The method validates the package name and returns the status of the validation. The validation also updates the package fragment model.Subclasses may extend this method to perform their own validation.
- Returns:
- the status of the validation
-
enclosingTypeChanged
protected org.eclipse.core.runtime.IStatus enclosingTypeChanged()Hook method that gets called when the enclosing type name has changed. The method validates the enclosing type and returns the status of the validation. It also updates the enclosing type model.Subclasses may extend this method to perform their own validation.
- Returns:
- the status of the validation
-
getCompilationUnitName
Hook method that is called when evaluating the name of the compilation unit to create. By default, a file extensionjava
is added to the given type name, but implementors can override this behavior.- Parameters:
typeName
- the name of the type to create the compilation unit for.- Returns:
- the name of the compilation unit to be created for the given name
- Since:
- 3.2
-
typeNameChanged
protected org.eclipse.core.runtime.IStatus typeNameChanged()Hook method that gets called when the type name has changed. The method validates the type name and returns the status of the validation.Subclasses may extend this method to perform their own validation.
- Returns:
- the status of the validation
-
superClassChanged
protected org.eclipse.core.runtime.IStatus superClassChanged()Hook method that gets called when the superclass name has changed. The method validates the superclass name and returns the status of the validation.Subclasses may extend this method to perform their own validation.
- Returns:
- the status of the validation
-
isSuperTypeSealed
protected boolean isSuperTypeSealed()- Returns:
- returns if any of the super types is sealed or not
- Since:
- 3.25
-
isSuperClassFinal
protected boolean isSuperClassFinal()- Returns:
- returns true if the super class is final
- Since:
- 3.30
-
superInterfacesChanged
protected org.eclipse.core.runtime.IStatus superInterfacesChanged()Hook method that gets called when the list of super interface has changed. The method validates the super interfaces and returns the status of the validation.Subclasses may extend this method to perform their own validation.
- Returns:
- the status of the validation
-
validateSealedSuperInterfacesStatus
protected org.eclipse.core.runtime.IStatus validateSealedSuperInterfacesStatus()Hook provided to get called when the super interfaces get changed. This method validates if the sealed super interfaces can be extended/implemented by this typeSubclasses may extend this method to perform their own validation.
- Returns:
- the status of the validation
- Since:
- 3.25
-
modifiersChanged
protected org.eclipse.core.runtime.IStatus modifiersChanged()Hook method that gets called when the modifiers have changed. The method validates the modifiers and returns the status of the validation.Subclasses may extend this method to perform their own validation.
- Returns:
- the status of the validation
-
choosePackage
Opens a selection dialog that allows to select a package.- Returns:
- returns the selected package or
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.
- Since:
- 3.2
-
chooseEnclosingType
Opens a selection dialog that allows to select an enclosing type.- Returns:
- returns the selected type or
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.
- Since:
- 3.2
-
chooseSuperClass
Opens a selection dialog that allows to select a super class.- Returns:
- returns the selected type or
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.
- Since:
- 3.2
-
chooseSuperInterfaces
protected void chooseSuperInterfaces()Opens a selection dialog that allows to select the super interfaces. The selected interfaces are directly added to the wizard page usingaddSuperInterface(String)
.Clients can override this method if they want to offer a different dialog.
- Since:
- 3.2
-
createType
public void createType(org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException, InterruptedException Creates the new type using the entered field values.- Parameters:
monitor
- a progress monitor to report progress.- Throws:
org.eclipse.core.runtime.CoreException
- Thrown when the creation failed.InterruptedException
- Thrown when the operation was canceled.
-
constructCUContent
protected String constructCUContent(ICompilationUnit cu, String typeContent, String lineDelimiter) throws org.eclipse.core.runtime.CoreException Uses the New Java file template from the code template page to generate a compilation unit with the given type content.- Parameters:
cu
- The new created compilation unittypeContent
- The content of the type, including signature and type body.lineDelimiter
- The line delimiter to be used.- Returns:
- String Returns the result of evaluating the new file template with the given type content.
- Throws:
org.eclipse.core.runtime.CoreException
- when fetching the file comment fails or fetching the content for the new compilation unit fails- Since:
- 2.1
-
getCreatedType
Returns the created type ornull
is the type has not been created yet. The method only returns a valid type aftercreateType
has been called.- Returns:
- the created type
- See Also:
-
createTypeMembers
protected void createTypeMembers(IType newType, NewTypeWizardPage.ImportsManager imports, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException Hook method that gets called fromcreateType
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.
- Parameters:
newType
- the new type created viacreateType
imports
- an import manager which can be used to add new importsmonitor
- a progress monitor to report progress. Must not benull
- Throws:
org.eclipse.core.runtime.CoreException
- thrown when creation of the type members failed- See Also:
-
getFileComment
Deprecated.Instead of file templates, the new type code template specifies the stub for a compilation unit.- Parameters:
parentCU
- the current compilation unit- Returns:
- returns the file template or
null
-
getFileComment
protected String getFileComment(ICompilationUnit parentCU, String lineDelimiter) throws org.eclipse.core.runtime.CoreException Hook method that gets called fromcreateType
to retrieve a file comment. This default implementation returns the content of the 'file comment' template ornull
if no comment should be created.- Parameters:
parentCU
- the parent compilation unitlineDelimiter
- the line delimiter to use- Returns:
- the file comment or
null
if a file comment is not desired - Throws:
org.eclipse.core.runtime.CoreException
- when fetching the file comment fails- Since:
- 3.1
-
getTypeComment
Hook method that gets called fromcreateType
to retrieve a type comment. This default implementation returns the content of the 'type comment' template.- Parameters:
parentCU
- the parent compilation unitlineDelimiter
- the line delimiter to use- Returns:
- the type comment or
null
if a type comment is not desired - Since:
- 3.0
-
getTypeComment
Deprecated.Use getTypeComment(ICompilationUnit, String)- Parameters:
parentCU
- the current compilation unit- Returns:
- returns the template or
null
-
getTemplate
Deprecated.Use getTemplate(String,ICompilationUnit,int)- Parameters:
name
- the name of the templateparentCU
- the current compilation unit- Returns:
- returns the template or
null
-
getTemplate
Returns the string resulting from evaluation the given template in the context of the given compilation unit. This accesses the normal template page, not the code templates. To use code templates useconstructCUContent
to construct a compilation unit stub or getTypeComment for the comment of the type.- Parameters:
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 offset- Returns:
- return the template with the given name or
null
if the template could not be found.
-
createMainMethod
protected IMethod createMainMethod(IType type, NewTypeWizardPage.ImportsManager imports) throws org.eclipse.core.runtime.CoreException Creates the stub for 'public static void main(String[] args)' method- Parameters:
type
- the type for which the main method is to be createdimports
- an import manager to add all needed import statements- Returns:
- the created method.
- Throws:
org.eclipse.core.runtime.CoreException
- thrown when the creation fails.- Since:
- 3.25
-
createInheritedMethods
protected IMethod[] createInheritedMethods(IType type, boolean doConstructors, boolean doUnimplementedMethods, NewTypeWizardPage.ImportsManager imports, org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException Creates the bodies of all unimplemented methods and constructors and adds them to the type. Method is typically called by implementers ofNewTypeWizardPage
to add needed method and constructors.- Parameters:
type
- the type for which the new methods and constructor are to be createddoConstructors
- iftrue
unimplemented constructors are createddoUnimplementedMethods
- iftrue
unimplemented methods are createdimports
- an import manager to add all needed import statementsmonitor
- a progress monitor to report progress- Returns:
- the created methods.
- Throws:
org.eclipse.core.runtime.CoreException
- thrown when the creation fails.
-
getRunnable
public org.eclipse.jface.operation.IRunnableWithProgress getRunnable()Returns the runnable that creates the type using the current settings. The returned runnable must be executed in the UI thread.- Returns:
- the runnable to create the new type
-
getSuperClassStatus
public org.eclipse.core.runtime.IStatus getSuperClassStatus()- Returns:
- the error status based on super class
- Since:
- 3.25
-
getSuperInterfaceStatus
public org.eclipse.core.runtime.IStatus getSuperInterfaceStatus()- Returns:
- the error status based on super interface
- Since:
- 3.25
-
getSealedSuperClassStatus
public org.eclipse.core.runtime.IStatus getSealedSuperClassStatus()- Returns:
- the error status based on super class
- Since:
- 3.25
-
getSealedSuperInterfaceStatus
public org.eclipse.core.runtime.IStatus getSealedSuperInterfaceStatus()- Returns:
- the error status based on super interface
- Since:
- 3.25
-
getSealedModifierStatus
public org.eclipse.core.runtime.IStatus getSealedModifierStatus()- Returns:
- the error status based on super type
- Since:
- 3.25
-