|
Lines 159-164
Link Here
|
| 159 |
private Label fImage; |
159 |
private Label fImage; |
| 160 |
|
160 |
|
| 161 |
/** |
161 |
/** |
|
|
162 |
* Indicates whether the super class field was explicitly modified by the user. |
| 163 |
* |
| 164 |
* @since 3.7 |
| 165 |
*/ |
| 166 |
private boolean fSuperClassExplicitlySet= false; |
| 167 |
|
| 168 |
/** |
| 162 |
* Creates a new <code>NewTestCaseCreationWizardPage</code>. |
169 |
* Creates a new <code>NewTestCaseCreationWizardPage</code>. |
| 163 |
* @param page2 The second page |
170 |
* @param page2 The second page |
| 164 |
* |
171 |
* |
|
Lines 249-254
Link Here
|
| 249 |
} |
256 |
} |
| 250 |
} |
257 |
} |
| 251 |
setJUnit4(isJunit4, true); |
258 |
setJUnit4(isJunit4, true); |
|
|
259 |
setSuperClass(getDefaultSuperClassName(), true); |
| 260 |
fSuperClassExplicitlySet= false; //set to false when default value is set |
| 252 |
|
261 |
|
| 253 |
updateStatus(getStatusList()); |
262 |
updateStatus(getStatusList()); |
| 254 |
} |
263 |
} |
|
Lines 288-298
Link Here
|
| 288 |
private void internalSetJUnit4(boolean isJUnit4) { |
297 |
private void internalSetJUnit4(boolean isJUnit4) { |
| 289 |
fIsJunit4= isJUnit4; |
298 |
fIsJunit4= isJUnit4; |
| 290 |
fJunit4Status= junit4Changed(); |
299 |
fJunit4Status= junit4Changed(); |
| 291 |
if (fIsJunit4) { |
300 |
if (!fSuperClassExplicitlySet || getSuperClass().trim().equals("")) { //$NON-NLS-1$ |
| 292 |
setSuperClass("java.lang.Object", false); //$NON-NLS-1$ |
301 |
setSuperClass(getDefaultSuperClassName(), true); |
| 293 |
} else { |
302 |
fSuperClassExplicitlySet= false; //set back to false when default value is set |
| 294 |
setSuperClass(getJUnit3TestSuperclassName(), true); |
|
|
| 295 |
} |
303 |
} |
|
|
304 |
fSuperClassStatus= superClassChanged(); //validate superclass field when toggled |
| 296 |
handleFieldChanged(JUNIT4TOGGLE); |
305 |
handleFieldChanged(JUNIT4TOGGLE); |
| 297 |
} |
306 |
} |
| 298 |
|
307 |
|
|
Lines 315-320
Link Here
|
| 315 |
fMethodStubsButtons.setEnabled(IDX_SETUP_CLASS, isJUnit4()); |
324 |
fMethodStubsButtons.setEnabled(IDX_SETUP_CLASS, isJUnit4()); |
| 316 |
fMethodStubsButtons.setEnabled(IDX_TEARDOWN_CLASS, isJUnit4()); |
325 |
fMethodStubsButtons.setEnabled(IDX_TEARDOWN_CLASS, isJUnit4()); |
| 317 |
fMethodStubsButtons.setEnabled(IDX_CONSTRUCTOR, !isJUnit4()); |
326 |
fMethodStubsButtons.setEnabled(IDX_CONSTRUCTOR, !isJUnit4()); |
|
|
327 |
} else if (fieldName.equals(SUPER)) { |
| 328 |
fSuperClassExplicitlySet= true; |
| 318 |
} |
329 |
} |
| 319 |
updateStatus(getStatusList()); |
330 |
updateStatus(getStatusList()); |
| 320 |
} |
331 |
} |
|
Lines 1085-1101
Link Here
|
| 1085 |
*/ |
1096 |
*/ |
| 1086 |
@Override |
1097 |
@Override |
| 1087 |
protected IStatus superClassChanged() { |
1098 |
protected IStatus superClassChanged() { |
| 1088 |
// replaces the super class validation of of the normal type wizard |
1099 |
super.superClassChanged(); |
| 1089 |
if (isJUnit4()) { |
|
|
| 1090 |
return new JUnitStatus(); |
| 1091 |
} |
| 1092 |
|
| 1093 |
String superClassName= getSuperClass(); |
1100 |
String superClassName= getSuperClass(); |
| 1094 |
JUnitStatus status= new JUnitStatus(); |
1101 |
JUnitStatus status= new JUnitStatus(); |
|
|
1102 |
boolean isJUnit4= isJUnit4(); |
| 1095 |
if (superClassName == null || superClassName.trim().equals("")) { //$NON-NLS-1$ |
1103 |
if (superClassName == null || superClassName.trim().equals("")) { //$NON-NLS-1$ |
| 1096 |
status.setError(WizardMessages.NewTestCaseWizardPageOne_error_superclass_empty); |
1104 |
if (!isJUnit4) |
|
|
1105 |
status.setError(WizardMessages.NewTestCaseWizardPageOne_error_superclass_empty); |
| 1097 |
return status; |
1106 |
return status; |
| 1098 |
} |
1107 |
} |
|
|
1108 |
if (isJUnit4 && superClassName.equals("java.lang.Object")) //$NON-NLS-1$ |
| 1109 |
return status; |
| 1099 |
if (getPackageFragmentRoot() != null) { |
1110 |
if (getPackageFragmentRoot() != null) { |
| 1100 |
try { |
1111 |
try { |
| 1101 |
IType type= resolveClassNameToType(getPackageFragmentRoot().getJavaProject(), getPackageFragment(), superClassName); |
1112 |
IType type= resolveClassNameToType(getPackageFragmentRoot().getJavaProject(), getPackageFragment(), superClassName); |
|
Lines 1195-1198
Link Here
|
| 1195 |
return JUnitCorePlugin.TEST_SUPERCLASS_NAME; |
1206 |
return JUnitCorePlugin.TEST_SUPERCLASS_NAME; |
| 1196 |
} |
1207 |
} |
| 1197 |
|
1208 |
|
|
|
1209 |
/** |
| 1210 |
* Returns the default value for the super class field. |
| 1211 |
* |
| 1212 |
* @return the default value for the super class field |
| 1213 |
* @since 3.7 |
| 1214 |
*/ |
| 1215 |
private String getDefaultSuperClassName() { |
| 1216 |
return isJUnit4() ? "java.lang.Object" : getJUnit3TestSuperclassName(); //$NON-NLS-1$ |
| 1217 |
} |
| 1218 |
|
| 1198 |
} |
1219 |
} |