Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 275574 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/junit/wizards/NewTestCaseWizardPageOne.java (-10 / +31 lines)
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) {
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 314-319 Link Here
314
			fMethodStubsButtons.setEnabled(IDX_SETUP_CLASS, isJUnit4());
323
			fMethodStubsButtons.setEnabled(IDX_SETUP_CLASS, isJUnit4());
315
			fMethodStubsButtons.setEnabled(IDX_TEARDOWN_CLASS, isJUnit4());
324
			fMethodStubsButtons.setEnabled(IDX_TEARDOWN_CLASS, isJUnit4());
316
			fMethodStubsButtons.setEnabled(IDX_CONSTRUCTOR, !isJUnit4());
325
			fMethodStubsButtons.setEnabled(IDX_CONSTRUCTOR, !isJUnit4());
326
		} else if (fieldName.equals(SUPER)) {
327
			fSuperClassExplicitlySet= true;
317
		}
328
		}
318
		updateStatus(getStatusList());
329
		updateStatus(getStatusList());
319
	}
330
	}
Lines 1079-1095 Link Here
1079
	 * @see org.eclipse.jdt.ui.wizards.NewTypeWizardPage#superClassChanged()
1090
	 * @see org.eclipse.jdt.ui.wizards.NewTypeWizardPage#superClassChanged()
1080
	 */
1091
	 */
1081
	protected IStatus superClassChanged() {
1092
	protected IStatus superClassChanged() {
1082
		// replaces the super class validation of of the normal type wizard
1093
		enableBrowseButtonForSuperClass();
1083
		if (isJUnit4()) {
1084
			return new JUnitStatus();
1085
		}
1086
1087
		String superClassName= getSuperClass();
1094
		String superClassName= getSuperClass();
1088
		JUnitStatus status= new JUnitStatus();
1095
		JUnitStatus status= new JUnitStatus();
1096
		boolean isJUnit4= isJUnit4();
1089
		if (superClassName == null || superClassName.trim().equals("")) { //$NON-NLS-1$
1097
		if (superClassName == null || superClassName.trim().equals("")) { //$NON-NLS-1$
1090
			status.setError(WizardMessages.NewTestCaseWizardPageOne_error_superclass_empty);
1098
			if (!isJUnit4)
1099
				status.setError(WizardMessages.NewTestCaseWizardPageOne_error_superclass_empty);
1091
			return status;
1100
			return status;
1092
		}
1101
		}
1102
		if (isJUnit4 && superClassName.equals("java.lang.Object")) //$NON-NLS-1$
1103
			return status;
1093
		if (getPackageFragmentRoot() != null) {
1104
		if (getPackageFragmentRoot() != null) {
1094
			try {
1105
			try {
1095
				IType type= resolveClassNameToType(getPackageFragmentRoot().getJavaProject(), getPackageFragment(), superClassName);
1106
				IType type= resolveClassNameToType(getPackageFragmentRoot().getJavaProject(), getPackageFragment(), superClassName);
Lines 1188-1191 Link Here
1188
		return JUnitCorePlugin.TEST_SUPERCLASS_NAME;
1199
		return JUnitCorePlugin.TEST_SUPERCLASS_NAME;
1189
	}
1200
	}
1190
1201
1202
	/**
1203
	 * Returns the default value for the super class field.
1204
	 * 
1205
	 * @return the default value for the super class field
1206
	 * @since 3.7
1207
	 */
1208
	private String getDefaultSuperClassName() {
1209
		return isJUnit4() ? "java.lang.Object" : getJUnit3TestSuperclassName(); //$NON-NLS-1$
1210
	}
1211
1191
}
1212
}
(-)ui/org/eclipse/jdt/ui/wizards/NewTypeWizardPage.java (-1 / +10 lines)
Lines 1672-1678 Link Here
1672
	protected IStatus superClassChanged() {
1672
	protected IStatus superClassChanged() {
1673
		StatusInfo status= new StatusInfo();
1673
		StatusInfo status= new StatusInfo();
1674
		IPackageFragmentRoot root= getPackageFragmentRoot();
1674
		IPackageFragmentRoot root= getPackageFragmentRoot();
1675
		fSuperClassDialogField.enableButton(root != null);
1675
		enableBrowseButtonForSuperClass();
1676
1676
1677
		fSuperClassStubTypeContext= null;
1677
		fSuperClassStubTypeContext= null;
1678
1678
Lines 1698-1703 Link Here
1698
		return status;
1698
		return status;
1699
	}
1699
	}
1700
1700
1701
	/**
1702
	 * Sets the enable state of the browse button for super class dialog field.
1703
	 * 
1704
	 * @since 3.7
1705
	 */
1706
	protected void enableBrowseButtonForSuperClass() {
1707
		fSuperClassDialogField.enableButton(getPackageFragmentRoot() != null);
1708
	}
1709
1701
	private StubTypeContext getSuperClassStubTypeContext() {
1710
	private StubTypeContext getSuperClassStubTypeContext() {
1702
		if (fSuperClassStubTypeContext == null) {
1711
		if (fSuperClassStubTypeContext == null) {
1703
			String typeName;
1712
			String typeName;

Return to bug 275574