KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit > wizards > NewTestCaseCreationWizard


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.junit.wizards;
12
13 import org.eclipse.core.resources.IResource;
14
15 import org.eclipse.jdt.core.IType;
16
17 import org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageOne;
18 import org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageTwo;
19
20 import org.eclipse.jdt.internal.junit.ui.JUnitPlugin;
21
22 /**
23  * A wizard for creating test cases.
24  */

25 public class NewTestCaseCreationWizard extends JUnitWizard {
26
27     private NewTestCaseWizardPageOne fPage1;
28     private NewTestCaseWizardPageTwo fPage2;
29
30     public NewTestCaseCreationWizard() {
31         super();
32         setWindowTitle(WizardMessages.Wizard_title_new_testcase);
33         initDialogSettings();
34     }
35
36     protected void initializeDefaultPageImageDescriptor() {
37         setDefaultPageImageDescriptor(JUnitPlugin.getImageDescriptor("wizban/newtest_wiz.png")); //$NON-NLS-1$
38
}
39
40     /*
41      * @see Wizard#createPages
42      */

43     public void addPages() {
44         super.addPages();
45         fPage2= new NewTestCaseWizardPageTwo();
46         fPage1= new NewTestCaseWizardPageOne(fPage2);
47         addPage(fPage1);
48         fPage1.init(getSelection());
49         addPage(fPage2);
50     }
51     
52     /*
53      * @see Wizard#performFinish
54      */

55     public boolean performFinish() {
56         if (finishPage(fPage1.getRunnable())) {
57             IType newClass= fPage1.getCreatedType();
58         
59             IResource resource= newClass.getCompilationUnit().getResource();
60             if (resource != null) {
61                 selectAndReveal(resource);
62                 openResource(resource);
63             }
64             return true;
65         }
66         return false;
67     }
68 }
69
Popular Tags