]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/ui/org/eclipse/jdt/ui/actions/OpenNewEnumWizardAction.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / ui / actions / OpenNewEnumWizardAction.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2011 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.NewEnumWizardPage;
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.NewEnumCreationWizard;
27
28 /**
29 * <p>Action that opens the new enum wizard. The action initialized the wizard with either the selection
30  * as configured by {@link #setSelection(IStructuredSelection)} or takes a preconfigured
31  * new enum wizard page, see {@link #setConfiguredWizardPage(NewEnumWizardPage)}.
32  * </p>
33  *
34  * <p>
35  * This class may be instantiated; it is not intended to be subclassed.
36  * </p>
37  *
38  * @since 3.2
39  *
40  * @noextend This class is not intended to be subclassed by clients.
41  */
42 public class OpenNewEnumWizardAction extends AbstractOpenWizardAction {
43
44         private NewEnumWizardPage fPage;
45         private boolean fOpenEditorOnFinish;
46
47         /**
48          * Creates an instance of the <code>OpenNewEnumWizardAction</code>.
49          */
50         public OpenNewEnumWizardAction() {
51                 setText(ActionMessages.OpenNewEnumWizardAction_text);
52                 setDescription(ActionMessages.OpenNewEnumWizardAction_description);
53                 setToolTipText(ActionMessages.OpenNewEnumWizardAction_tooltip);
54                 setImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWENUM);
55                 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_ENUM_WIZARD_ACTION);
56
57                 fPage= null;
58                 fOpenEditorOnFinish= true;
59         }
60
61         /**
62          * Sets a page to be used by the wizard or <code>null</code> to use a page initialized with values
63          * from the current selection (see {@link #getSelection()} and {@link #setSelection(IStructuredSelection)}).
64          * @param page the page to use or <code>null</code>
65          */
66         public void setConfiguredWizardPage(NewEnumWizardPage page) {
67                 fPage= page;
68         }
69
70         /**
71          * Specifies if the wizard will open the created type with the default editor. The default behaviour is to open
72          * an editor.
73          *
74          * @param openEditorOnFinish if set, the wizard will open the created type with the default editor
75          *
76          * @since 3.3
77          */
78         public void setOpenEditorOnFinish(boolean openEditorOnFinish) {
79                 fOpenEditorOnFinish= openEditorOnFinish;
80         }
81
82         /* (non-Javadoc)
83          * @see org.eclipse.jdt.ui.actions.AbstractOpenWizardAction#createWizard()
84          */
85         @Override
86         protected final INewWizard createWizard() throws CoreException {
87                 return new NewEnumCreationWizard(fPage, fOpenEditorOnFinish);
88         }
89 }