01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.ui.actions;
11:
12: import org.eclipse.core.runtime.CoreException;
13:
14: import org.eclipse.jface.viewers.IStructuredSelection;
15:
16: import org.eclipse.ui.INewWizard;
17: import org.eclipse.ui.PlatformUI;
18:
19: import org.eclipse.jdt.ui.wizards.NewInterfaceWizardPage;
20:
21: import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
22: import org.eclipse.jdt.internal.ui.JavaPluginImages;
23: import org.eclipse.jdt.internal.ui.actions.ActionMessages;
24: import org.eclipse.jdt.internal.ui.wizards.NewInterfaceCreationWizard;
25:
26: /**
27: * <p>Action that opens the new interface wizard. The action initialized the wizard with either the selection
28: * as configured by {@link #setSelection(IStructuredSelection)} or takes a preconfigured
29: * new interface wizard page, see {@link #setConfiguredWizardPage(NewInterfaceWizardPage)}.
30: * </p>
31: *
32: * <p>
33: * This class may be instantiated; it is not intended to be subclassed.
34: * </p>
35: *
36: * @since 3.2
37: */
38: public class OpenNewInterfaceWizardAction extends
39: AbstractOpenWizardAction {
40:
41: private NewInterfaceWizardPage fPage;
42: private boolean fOpenEditorOnFinish;
43:
44: /**
45: * Creates an instance of the <code>OpenNewInterfaceWizardAction</code>.
46: */
47: public OpenNewInterfaceWizardAction() {
48: setText(ActionMessages.OpenNewInterfaceWizardAction_text);
49: setDescription(ActionMessages.OpenNewInterfaceWizardAction_description);
50: setToolTipText(ActionMessages.OpenNewInterfaceWizardAction_tooltip);
51: setImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWINT);
52: PlatformUI.getWorkbench().getHelpSystem().setHelp(this ,
53: IJavaHelpContextIds.OPEN_INTERFACE_WIZARD_ACTION);
54:
55: fPage = null;
56: fOpenEditorOnFinish = true;
57: }
58:
59: /**
60: * Sets a page to be used by the wizard or <code>null</code> to use a page initialized with values
61: * from the current selection (see {@link #getSelection()} and {@link #setSelection(IStructuredSelection)}).
62: * @param page the page to use or <code>null</code>
63: */
64: public void setConfiguredWizardPage(NewInterfaceWizardPage page) {
65: fPage = page;
66: }
67:
68: /**
69: * Specifies if the wizard will open the created type with the default editor. The default behaviour is to open
70: * an editor.
71: *
72: * @param openEditorOnFinish if set, the wizard will open the created type with the default editor
73: *
74: * @since 3.3
75: */
76: public void setOpenEditorOnFinish(boolean openEditorOnFinish) {
77: fOpenEditorOnFinish = openEditorOnFinish;
78: }
79:
80: /* (non-Javadoc)
81: * @see org.eclipse.jdt.ui.actions.AbstractOpenWizardAction#createWizard()
82: */
83: protected final INewWizard createWizard() throws CoreException {
84: return new NewInterfaceCreationWizard(fPage,
85: fOpenEditorOnFinish);
86: }
87: }
|