KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > ui > actions > OpenNewClassWizardAction


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
12 package org.eclipse.jdt.ui.actions;
13
14 import org.eclipse.core.runtime.CoreException;
15
16 import org.eclipse.jface.viewers.IStructuredSelection;
17
18 import org.eclipse.ui.INewWizard;
19 import org.eclipse.ui.PlatformUI;
20
21 import org.eclipse.jdt.ui.wizards.NewClassWizardPage;
22
23 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
24 import org.eclipse.jdt.internal.ui.JavaPluginImages;
25 import org.eclipse.jdt.internal.ui.actions.ActionMessages;
26 import org.eclipse.jdt.internal.ui.wizards.NewClassCreationWizard;
27
28 /**
29  * <p>Action that opens the new class wizard. The action initialized the wizard with either the selection
30  * as configured by {@link #setSelection(IStructuredSelection)} or takes a preconfigured
31  * new class wizard page, see {@link #setConfiguredWizardPage(NewClassWizardPage)}.</p>
32  *
33  * <p>
34  * This class may be instantiated; it is not intended to be subclassed.
35  * </p>
36  *
37  * @since 3.2
38  */

39 public class OpenNewClassWizardAction extends AbstractOpenWizardAction {
40     
41     private NewClassWizardPage fPage;
42     private boolean fOpenEditorOnFinish;
43
44     /**
45      * Creates an instance of the <code>OpenNewClassWizardAction</code>.
46      */

47     public OpenNewClassWizardAction() {
48         setText(ActionMessages.OpenNewClassWizardAction_text);
49         setDescription(ActionMessages.OpenNewClassWizardAction_description);
50         setToolTipText(ActionMessages.OpenNewClassWizardAction_tooltip);
51         setImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWCLASS);
52         PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_CLASS_WIZARD_ACTION);
53         
54         fPage= null;
55         fOpenEditorOnFinish= true;
56     }
57     
58     /**
59      * Sets a page to be used by the wizard or <code>null</code> to use a page initialized with values
60      * from the current selection (see {@link #getSelection()} and {@link #setSelection(IStructuredSelection)}).
61      * @param page the page to use or <code>null</code>
62      */

63     public void setConfiguredWizardPage(NewClassWizardPage page) {
64         fPage= page;
65     }
66     
67     /**
68      * Specifies if the wizard will open the created type with the default editor. The default behaviour is to open
69      * an editor.
70      *
71      * @param openEditorOnFinish if set, the wizard will open the created type with the default editor
72      *
73      * @since 3.3
74      */

75     public void setOpenEditorOnFinish(boolean openEditorOnFinish) {
76         fOpenEditorOnFinish= openEditorOnFinish;
77     }
78     
79     /* (non-Javadoc)
80      * @see org.eclipse.jdt.ui.actions.AbstractOpenWizardAction#createWizard()
81      */

82     protected final INewWizard createWizard() throws CoreException {
83         return new NewClassCreationWizard(fPage, fOpenEditorOnFinish);
84     }
85 }
86
Popular Tags