org.eclipse.wst.jsdt.ui.wizards
Class NewTypeWizardPage

java.lang.Object
  extended by WizardPage
      extended by org.eclipse.wst.jsdt.ui.wizards.NewElementWizardPage
          extended by org.eclipse.wst.jsdt.ui.wizards.NewContainerWizardPage
              extended by org.eclipse.wst.jsdt.ui.wizards.NewTypeWizardPage
Direct Known Subclasses:
NewClassWizardPage, NewInterfaceWizardPage

public abstract class NewTypeWizardPage
extends NewContainerWizardPage

The class 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.

Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.

See Also:
NewClassWizardPage, NewInterfaceWizardPage, org.eclipse.wst.jsdt.ui.wizards.NewEnumWizardPage, org.eclipse.wst.jsdt.ui.wizards.NewAnnotationWizardPage

Nested Class Summary
static class NewTypeWizardPage.ImportsManager
          Class used in stub creation routines to add needed imports to a compilation unit.
 
Field Summary
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.
static int ENUM_TYPE
          Constant to signal that the created type is an enum.
 int F_ABSTRACT
          Abstract property flag.
 int F_FINAL
          Final access flag.
 int F_PRIVATE
          Private access flag.
 int F_PROTECTED
          Protected access flag.
 int F_PUBLIC
          Public access flag.
 int F_STATIC
          Static access flag.
static int INTERFACE_TYPE
          Constant to signal that the created type is a interface.
 
Constructor Summary
NewTypeWizardPage(boolean isClass, java.lang.String pageName)
          Creates a new NewTypeWizardPage.
NewTypeWizardPage(int typeKind, java.lang.String pageName)
          Creates a new NewTypeWizardPage.
 
Method Summary
 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.
 void createType(IProgressMonitor monitor)
          Creates the new type using the entered field values.
 void enableCommentControl(boolean useAddCommentValue)
          Sets to use the 'Add comment' checkbox value.
 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.
 java.lang.String getEnclosingTypeText()
          Returns the text of the enclosing type input field.
 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.
 IPackageFragment getPackageFragment()
          Returns the package fragment corresponding to the current input.
 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.
 java.util.List getSuperInterfaces()
          Returns the chosen super interfaces.
 java.lang.String getTypeName()
          Returns the type name entered into the type input field.
 boolean isAddComments()
          Returns if comments are added.
 boolean isEnclosingTypeSelected()
          Returns the selection state of the enclosing type checkbox.
 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.
 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.
 
Methods inherited from class org.eclipse.wst.jsdt.ui.wizards.NewContainerWizardPage
getJavaProject, getPackageFragmentRoot, getPackageFragmentRootText, setPackageFragmentRoot
 
Methods inherited from class org.eclipse.wst.jsdt.ui.wizards.NewElementWizardPage
setVisible
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

F_PUBLIC

public int F_PUBLIC
Public access flag. See The JavaScript Virtual Machine Specification for more details.


F_PRIVATE

public int F_PRIVATE
Private access flag. See The JavaScript Virtual Machine Specification for more details.


F_PROTECTED

public int F_PROTECTED
Protected access flag. See The JavaScript Virtual Machine Specification for more details.


F_STATIC

public int F_STATIC
Static access flag. See The JavaScript Virtual Machine Specification for more details.


F_FINAL

public int F_FINAL
Final access flag. See The JavaScript Virtual Machine Specification for more details.


F_ABSTRACT

public int F_ABSTRACT
Abstract property flag. See The JavaScript Virtual Machine Specification for more details.


CLASS_TYPE

public static final int CLASS_TYPE
Constant to signal that the created type is a class.

See Also:
Constant Field Values

INTERFACE_TYPE

public static final int INTERFACE_TYPE
Constant to signal that the created type is a interface.

See Also:
Constant Field Values

ENUM_TYPE

public static final int ENUM_TYPE
Constant to signal that the created type is an enum.

See Also:
Constant Field Values

ANNOTATION_TYPE

public static final int ANNOTATION_TYPE
Constant to signal that the created type is an annotation.

See Also:
Constant Field Values
Constructor Detail

NewTypeWizardPage

public NewTypeWizardPage(boolean isClass,
                         java.lang.String pageName)
Creates a new NewTypeWizardPage.

Parameters:
isClass - true if a new class is to be created; otherwise an interface is to be created
pageName - the wizard page's name

NewTypeWizardPage

public NewTypeWizardPage(int typeKind,
                         java.lang.String pageName)
Creates a new NewTypeWizardPage.

Parameters:
typeKind - Signals the kind of the type to be created. Valid kinds are CLASS_TYPE, INTERFACE_TYPE, ENUM_TYPE and ANNOTATION_TYPE
pageName - the wizard page's name
Method Detail

getPackageText

public java.lang.String getPackageText()
Returns the text of the package input field.

Returns:
the text of the package input field

getEnclosingTypeText

public java.lang.String getEnclosingTypeText()
Returns the text of the enclosing type input field.

Returns:
the text of the enclosing type input field

getPackageFragment

public IPackageFragment getPackageFragment()
Returns the package fragment corresponding to the current input.

Returns:
a package fragment or null if the input could not be resolved.

setPackageFragment

public void setPackageFragment(IPackageFragment pack,
                               boolean canBeModified)
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 set
canBeModified - if true the package fragment is editable; otherwise it is read-only.

getEnclosingType

public IType 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

public void setEnclosingType(IType type,
                             boolean canBeModified)
Sets the enclosing type. The method updates the underlying model and the text of the control.

Parameters:
type - the enclosing type
canBeModified - if true 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 state
canBeModified - if true the enclosing type checkbox is modifiable; otherwise it is read-only.

getTypeName

public java.lang.String getTypeName()
Returns the type name entered into the type input field.

Returns:
the type name

setTypeName

public void setTypeName(java.lang.String name,
                        boolean canBeModified)
Sets the type name input field's text to the given value. Method doesn't update the model.

Parameters:
name - the new type name
canBeModified - if true 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:
Flags

setModifiers

public void setModifiers(int modifiers,
                         boolean canBeModified)
Sets the modifiers.

Parameters:
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-only
See Also:
Flags

getSuperClass

public java.lang.String getSuperClass()
Returns the content of the superclass input field.

Returns:
the superclass name

setSuperClass

public void setSuperClass(java.lang.String name,
                          boolean canBeModified)
Sets the super class name.

Parameters:
name - the new superclass name
canBeModified - if true the superclass name field is editable; otherwise it is read-only.

getSuperInterfaces

public java.util.List getSuperInterfaces()
Returns the chosen super interfaces.

Returns:
a list of chosen super interfaces. The list's elements are of type String

setSuperInterfaces

public void setSuperInterfaces(java.util.List interfacesNames,
                               boolean canBeModified)
Sets the super interfaces.

Parameters:
interfacesNames - a list of super interface. The method requires that the list's elements are of type String
canBeModified - if true the super interface field is editable; otherwise it is read-only.

addSuperInterface

public 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.

Parameters:
superInterface - the fully qualified type name of the interface.
Returns:
returns trueif the interfaces has been added, false if the interface already is in the list.

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 (see enableCommentControl(boolean)

Parameters:
doAddComments - if true, comments are added.
canBeModified - if true check box is editable; otherwise it is read-only.

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 - if true,

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 (see enableCommentControl(boolean), otherwise the settings as specified in the preferences is used.

Returns:
Returns true if comments can be added

getModifiedResource

public 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.

createType

public void createType(IProgressMonitor monitor)
                throws CoreException,
                       java.lang.InterruptedException
Creates the new type using the entered field values.

Parameters:
monitor - a progress monitor to report progress.
Throws:
CoreException - Thrown when the creation failed.
java.lang.InterruptedException - Thrown when the operation was canceled.

getCreatedType

public IType getCreatedType()
Returns the created type or null is the type has not been created yet. The method only returns a valid type after createType has been called.

Returns:
the created type
See Also:
createType(IProgressMonitor)

getRunnable

public 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