KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ltk > internal > ui > refactoring > actions > CreateRefactoringScriptAction


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.ltk.internal.ui.refactoring.actions;
12
13 import org.eclipse.core.runtime.Assert;
14
15 import org.eclipse.ltk.internal.ui.refactoring.IRefactoringHelpContextIds;
16 import org.eclipse.ltk.internal.ui.refactoring.scripting.CreateRefactoringScriptWizard;
17 import org.eclipse.ltk.internal.ui.refactoring.scripting.ScriptingMessages;
18
19 import org.eclipse.swt.widgets.Composite;
20
21 import org.eclipse.jface.action.IAction;
22 import org.eclipse.jface.dialogs.IDialogConstants;
23 import org.eclipse.jface.viewers.ISelection;
24 import org.eclipse.jface.wizard.IWizard;
25 import org.eclipse.jface.wizard.WizardDialog;
26
27 import org.eclipse.ui.IWorkbenchWindow;
28 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
29 import org.eclipse.ui.PlatformUI;
30
31 /**
32  * Action to create a refactoring script from the refactoring history.
33  *
34  * @since 3.2
35  */

36 public final class CreateRefactoringScriptAction implements IWorkbenchWindowActionDelegate {
37
38     /** The wizard height */
39     private static final int SIZING_WIZARD_HEIGHT= 610;
40
41     /** The wizard width */
42     private static final int SIZING_WIZARD_WIDTH= 500;
43
44     /**
45      * Shows the create script wizard.
46      *
47      * @param window
48      * the workbench window
49      */

50     public static void showCreateScriptWizard(final IWorkbenchWindow window) {
51         Assert.isNotNull(window);
52         final IWizard wizard= new CreateRefactoringScriptWizard();
53         final WizardDialog dialog= new WizardDialog(window.getShell(), wizard) {
54
55             protected final void createButtonsForButtonBar(final Composite parent) {
56                 super.createButtonsForButtonBar(parent);
57                 getButton(IDialogConstants.FINISH_ID).setText(ScriptingMessages.CreateRefactoringScriptAction_finish_button_label);
58             }
59         };
60         dialog.create();
61         dialog.getShell().setSize(Math.max(SIZING_WIZARD_WIDTH, dialog.getShell().getSize().x), SIZING_WIZARD_HEIGHT);
62         PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IRefactoringHelpContextIds.REFACTORING_CREATE_SCRIPT_PAGE);
63         dialog.open();
64     }
65
66     /** The workbench window, or <code>null</code> */
67     private IWorkbenchWindow fWindow= null;
68
69     /**
70      * {@inheritDoc}
71      */

72     public void dispose() {
73         // Do nothing
74
}
75
76     /**
77      * {@inheritDoc}
78      */

79     public void init(final IWorkbenchWindow window) {
80         fWindow= window;
81     }
82
83     /**
84      * {@inheritDoc}
85      */

86     public void run(final IAction action) {
87         if (fWindow != null) {
88             showCreateScriptWizard(fWindow);
89         }
90     }
91
92     /**
93      * {@inheritDoc}
94      */

95     public void selectionChanged(final IAction action, final ISelection selection) {
96         // Do nothing
97
}
98 }
99
Popular Tags