KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > wizards > NewInterfaceCreationWizard


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.ui.wizards;
12
13 import org.eclipse.core.resources.IFile;
14 import org.eclipse.core.resources.IResource;
15
16 import org.eclipse.jdt.core.IJavaElement;
17
18 import org.eclipse.core.runtime.CoreException;
19 import org.eclipse.core.runtime.IProgressMonitor;
20
21 import org.eclipse.jdt.ui.wizards.NewInterfaceWizardPage;
22
23 import org.eclipse.jdt.internal.ui.JavaPlugin;
24 import org.eclipse.jdt.internal.ui.JavaPluginImages;
25
26 public class NewInterfaceCreationWizard extends NewElementWizard {
27
28     private NewInterfaceWizardPage fPage;
29     private boolean fOpenEditorOnFinish;
30     
31     public NewInterfaceCreationWizard(NewInterfaceWizardPage page, boolean openEditorOnFinish) {
32         setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWINT);
33         setDialogSettings(JavaPlugin.getDefault().getDialogSettings());
34         setWindowTitle(NewWizardMessages.NewInterfaceCreationWizard_title);
35         
36         fPage= page;
37         fOpenEditorOnFinish= openEditorOnFinish;
38     }
39     
40     public NewInterfaceCreationWizard() {
41         this(null, true);
42     }
43
44     /*
45      * @see Wizard#addPages
46      */

47     public void addPages() {
48         super.addPages();
49         if (fPage == null) {
50             fPage= new NewInterfaceWizardPage();
51             fPage.init(getSelection());
52         }
53         addPage(fPage);
54     }
55     
56     /* (non-Javadoc)
57      * @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#canRunForked()
58      */

59     protected boolean canRunForked() {
60         return !fPage.isEnclosingTypeSelected();
61     }
62
63     /* (non-Javadoc)
64      * @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
65      */

66     protected void finishPage(IProgressMonitor monitor) throws InterruptedException JavaDoc, CoreException {
67         fPage.createType(monitor); // use the full progress monitor
68
}
69         
70     /* (non-Javadoc)
71      * @see org.eclipse.jface.wizard.IWizard#performFinish()
72      */

73     public boolean performFinish() {
74         warnAboutTypeCommentDeprecation();
75         boolean res= super.performFinish();
76         if (res) {
77             IResource resource= fPage.getModifiedResource();
78             if (resource != null) {
79                 selectAndReveal(resource);
80                 if (fOpenEditorOnFinish) {
81                     openResource((IFile) resource);
82                 }
83             }
84         }
85         return res;
86     }
87     
88     /* (non-Javadoc)
89      * @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#getCreatedElement()
90      */

91     public IJavaElement getCreatedElement() {
92         return fPage.getCreatedType();
93     }
94     
95 }
96
Popular Tags