]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
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.NewAnnotationWizardPage; | |
22 | ||
23 | import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; | |
24 | import org.eclipse.jdt.internal.ui.JavaPlugin; | |
25 | import org.eclipse.jdt.internal.ui.JavaPluginImages; | |
26 | import org.eclipse.jdt.internal.ui.actions.ActionMessages; | |
27 | import org.eclipse.jdt.internal.ui.wizards.NewAnnotationCreationWizard; | |
28 | ||
29 | /** | |
30 | * <p>Action that opens the new annotation wizard.The action initialized the wizard with either the selection | |
31 | * as configured by {@link #setSelection(IStructuredSelection)} or takes a preconfigured | |
32 | * new annotation wizard page, see {@link #setConfiguredWizardPage(NewAnnotationWizardPage)}. | |
33 | * </p> | |
34 | * | |
35 | * <p> | |
36 | * This class may be instantiated; it is not intended to be subclassed. | |
37 | * </p> | |
38 | * | |
39 | * @since 3.2 | |
40 | * | |
41 | * @noextend This class is not intended to be subclassed by clients. | |
42 | */ | |
43 | public class OpenNewAnnotationWizardAction extends AbstractOpenWizardAction { | |
44 | ||
45 | private NewAnnotationWizardPage fPage; | |
46 | private boolean fOpenEditorOnFinish; | |
47 | ||
48 | /** | |
49 | * Creates an instance of the <code>OpenNewAnnotationWizardAction</code>. | |
50 | */ | |
51 | public OpenNewAnnotationWizardAction() { | |
52 | setText(ActionMessages.OpenNewAnnotationWizardAction_text); | |
53 | setDescription(ActionMessages.OpenNewAnnotationWizardAction_description); | |
54 | setToolTipText(ActionMessages.OpenNewAnnotationWizardAction_tooltip); | |
55 | setImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWANNOT); | |
56 | PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_ANNOTATION_WIZARD_ACTION); | |
57 | setShell(JavaPlugin.getActiveWorkbenchShell()); | |
58 | ||
59 | fPage= null; | |
60 | fOpenEditorOnFinish= true; | |
61 | } | |
62 | ||
63 | /** | |
64 | * Sets a page to be used by the wizard or <code>null</code> to use a page initialized with values | |
65 | * from the current selection (see {@link #getSelection()} and {@link #setSelection(IStructuredSelection)}). | |
66 | * @param page the page to use or <code>null</code> | |
67 | */ | |
68 | public void setConfiguredWizardPage(NewAnnotationWizardPage page) { | |
69 | fPage= page; | |
70 | } | |
71 | ||
72 | /** | |
73 | * Specifies if the wizard will open the created type with the default editor. The default behaviour is to open | |
74 | * an editor. | |
75 | * | |
76 | * @param openEditorOnFinish if set, the wizard will open the created type with the default editor | |
77 | * | |
78 | * @since 3.3 | |
79 | */ | |
80 | public void setOpenEditorOnFinish(boolean openEditorOnFinish) { | |
81 | fOpenEditorOnFinish= openEditorOnFinish; | |
82 | } | |
83 | ||
84 | /* (non-Javadoc) | |
85 | * @see org.eclipse.jdt.ui.actions.AbstractOpenWizardAction#createWizard() | |
86 | */ | |
87 | @Override | |
88 | protected final INewWizard createWizard() throws CoreException { | |
89 | return new NewAnnotationCreationWizard(fPage, fOpenEditorOnFinish); | |
90 | } | |
91 | } |