KickJava   Java API By Example, From Geeks To Geeks.

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


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.ShowRefactoringHistoryWizard;
17
18 import org.eclipse.swt.widgets.Composite;
19
20 import org.eclipse.jface.action.IAction;
21 import org.eclipse.jface.dialogs.IDialogConstants;
22 import org.eclipse.jface.viewers.ISelection;
23 import org.eclipse.jface.wizard.IWizard;
24 import org.eclipse.jface.wizard.WizardDialog;
25
26 import org.eclipse.ui.IWorkbenchWindow;
27 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
28 import org.eclipse.ui.PlatformUI;
29
30 /**
31  * Action to show the global refactoring history.
32  *
33  * @since 3.2
34  */

35 public final class ShowRefactoringHistoryAction implements IWorkbenchWindowActionDelegate {
36
37     /** The wizard height */
38     private static final int SIZING_WIZARD_HEIGHT= 560;
39
40     /** The wizard width */
41     private static final int SIZING_WIZARD_WIDTH= 480;
42
43     /**
44      * Shows the refactoring history wizard.
45      *
46      * @param window
47      * the workbench window
48      */

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

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

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

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

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