public class NewTestSuiteWizardPage extends NewTypeWizardPage
NewTestSuiteWizardPage
contains controls and validation routines
for the single page in the 'New JUnit TestSuite Wizard'.
Clients can use the page as-is and add it to their own wizard, or extend it to modify validation or add and remove controls.
NewTypeWizardPage.ImportsManager
Modifier and Type | Field and Description |
---|---|
static String |
CLASSES_IN_SUITE
Field ID of the class in suite field.
|
static String |
COMMENT_START |
static String |
END_MARKER
The string used to mark the end of the generated code
|
static String |
JUNIT4TOGGLE
Field ID of the junit4 toggle field.
|
static String |
NON_COMMENT_END_MARKER |
static String |
NON_COMMENT_START_MARKER |
static String |
START_MARKER
The string used to mark the beginning of the generated code
|
ANNOTATION_TYPE, CLASS_TYPE, ENCLOSING, ENCLOSINGSELECTION, ENUM_TYPE, F_ABSTRACT, F_FINAL, F_PRIVATE, F_PROTECTED, F_PUBLIC, F_STATIC, fEnclosingTypeStatus, fModifierStatus, fPackageStatus, fSuperClassStatus, fSuperInterfacesStatus, fTypeNameStatus, INTERFACE_TYPE, INTERFACES, METHODS, MODIFIERS, PACKAGE, SUPER, TYPENAME
CONTAINER, fContainerStatus
ERROR, INFORMATION, NONE, WARNING
Constructor and Description |
---|
NewTestSuiteWizardPage()
Creates a new
NewTestSuiteWizardPage . |
Modifier and Type | Method and Description |
---|---|
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 void |
createClassesInSuiteControl(Composite parent,
int nColumns)
Creates the controls for the list of classes in the suite.
|
void |
createControl(Composite parent) |
protected void |
createJUnit4Controls(Composite composite,
int nColumns)
Creates the controls for the JUnit 4 toggle control.
|
protected void |
createMethodStubSelectionControls(Composite composite,
int nColumns)
Creates the controls for the method stub selection buttons.
|
void |
createType(IProgressMonitor monitor)
Creates the new type using the entered field values.
|
protected void |
createTypeMembers(IType type,
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 |
handleFieldChanged(String fieldName)
Hook method that gets called when a field on this page has changed.
|
boolean |
hasUpdatedExistingClass()
Returns true iff an existing suite() method has been replaced.
|
void |
init(IStructuredSelection selection)
Should be called from the wizard with the initial selection.
|
boolean |
isJUnit4()
Returns
true if the test suite should be created as Junit 4 suite |
void |
setJUnit4(boolean isJUnit4,
boolean isEnabled)
Specifies if the test should be created as JUnit 4 test.
|
void |
setVisible(boolean visible) |
protected IStatus |
typeNameChanged()
Hook method that gets called when the type name has changed.
|
protected void |
updateClassesInSuiteTable()
Updates the classes in the suite table.
|
addSuperInterface, chooseEnclosingType, choosePackage, chooseSuperClass, chooseSuperInterfaces, containerChanged, createCommentControls, createEnclosingTypeControls, createInheritedMethods, createModifierControls, createPackageControls, createSeparator, createSuperClassControls, createSuperInterfacesControls, createTypeNameControls, enableCommentControl, enclosingTypeChanged, getCompilationUnitName, getCreatedType, getEnclosingType, getEnclosingTypeLabel, getEnclosingTypeText, getFileComment, getFileComment, getModifiedResource, getModifiers, getModifiersLabel, getPackageFragment, getPackageLabel, getPackageText, getRunnable, getSuperClass, getSuperClassLabel, getSuperInterfaces, getSuperInterfacesLabel, getTemplate, getTemplate, getTypeComment, getTypeComment, getTypeName, getTypeNameLabel, initTypePage, isAddComments, isEnclosingTypeSelected, modifiersChanged, packageChanged, setAddComments, setEnclosingType, setEnclosingTypeSelection, setFocus, setModifiers, setPackageFragment, setSuperClass, setSuperInterfaces, setTypeName, superClassChanged, superInterfacesChanged
chooseContainer, createContainerControls, getContainerLabel, getCurrentTextSelection, getInitialJavaElement, getJavaProject, getMaxFieldWidth, getPackageFragmentRoot, getPackageFragmentRootText, getWorkspaceRoot, initContainerPage, setFocusOnContainer, setPackageFragmentRoot
updateStatus, updateStatus
canFlipToNextPage, getContainer, getDialogSettings, getImage, getName, getNextPage, getPreviousPage, getShell, getWizard, isCurrentPage, isPageComplete, setDescription, setErrorMessage, setImageDescriptor, setMessage, setPageComplete, setPreviousPage, setTitle, setWizard, toString
convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, dispose, getControl, getDescription, getDialogFontName, getErrorMessage, getFont, getMessage, getMessageType, getTitle, getToolTipText, initializeDialogUnits, isControlCreated, performHelp, setButtonLayoutData, setControl, setMessage
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dispose, getControl, getDescription, getErrorMessage, getMessage, getTitle, performHelp
public static final String NON_COMMENT_END_MARKER
public static final String NON_COMMENT_START_MARKER
public static final String COMMENT_START
public static final String START_MARKER
public static final String END_MARKER
public static final String CLASSES_IN_SUITE
public static final String JUNIT4TOGGLE
public NewTestSuiteWizardPage()
NewTestSuiteWizardPage
.public void createControl(Composite parent)
protected void createMethodStubSelectionControls(Composite composite, int nColumns)
GridLayout
with
at least 3 columns.composite
- the parent compositenColumns
- number of columns to spanpublic void init(IStructuredSelection selection)
selection
- the initial selectionprotected void handleFieldChanged(String fieldName)
NewContainerWizardPage
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).
handleFieldChanged
in class NewTypeWizardPage
fieldName
- The name of the field that has changed (field id). For the
source folder the field id is CONTAINER
public void setVisible(boolean visible)
setVisible
in interface IDialogPage
setVisible
in class NewElementWizardPage
protected void updateClassesInSuiteTable()
protected void createClassesInSuiteControl(Composite parent, int nColumns)
GridLayout
with
at least 3 columns.parent
- the parent compositenColumns
- number of columns to spanprotected void createTypeMembers(IType type, NewTypeWizardPage.ImportsManager imports, IProgressMonitor monitor) throws CoreException
NewTypeWizardPage
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.
createTypeMembers
in class NewTypeWizardPage
type
- the new type created via createType
imports
- an import manager which can be used to add new importsmonitor
- a progress monitor to report progress. Must not be null
CoreException
- thrown when creation of the type members failedNewTypeWizardPage.createType(IProgressMonitor)
public void createType(IProgressMonitor monitor) throws CoreException, InterruptedException
NewTypeWizardPage
createType
in class NewTypeWizardPage
monitor
- a progress monitor to report progress.CoreException
- Thrown when the creation failed.InterruptedException
- Thrown when the operation was canceled.public boolean hasUpdatedExistingClass()
true
is returned if an existing test suite has been replacedprotected IStatus typeNameChanged()
NewTypeWizardPage
Subclasses may extend this method to perform their own validation.
typeNameChanged
in class NewTypeWizardPage
protected void createJUnit4Controls(Composite composite, int nColumns)
GridLayout
with
at least 3 columns.composite
- the parent compositenColumns
- number of columns to spanpublic void setJUnit4(boolean isJUnit4, boolean isEnabled)
isJUnit4
- If set, a JUnit 4 test will be createdisEnabled
- if true
the modifier fields are
editable; otherwise they are read-onlypublic boolean isJUnit4()
true
if the test suite should be created as Junit 4 suitetrue
if the test suite should be created as Junit 4 testprotected String constructCUContent(ICompilationUnit cu, String typeContent, String lineDelimiter) throws CoreException
NewTypeWizardPage
constructCUContent
in class NewTypeWizardPage
cu
- The new created compilation unittypeContent
- The content of the type, including signature and type
body.lineDelimiter
- The line delimiter to be used.CoreException
- when fetching the file comment fails or fetching the content for the
new compilation unit fails
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.