KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ltk > internal > ui > refactoring > scripting > ShowRefactoringHistoryWizard


1 /*******************************************************************************
2  * Copyright (c) 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.scripting;
12
13 import org.eclipse.core.runtime.Assert;
14
15 import org.eclipse.ltk.core.refactoring.history.RefactoringHistory;
16
17 import org.eclipse.ltk.internal.ui.refactoring.RefactoringPluginImages;
18 import org.eclipse.ltk.internal.ui.refactoring.RefactoringUIPlugin;
19
20 import org.eclipse.jface.dialogs.IDialogSettings;
21 import org.eclipse.jface.wizard.Wizard;
22
23 /**
24  * Wizard to show the global refactoring history
25  *
26  * @since 3.2
27  */

28 public final class ShowRefactoringHistoryWizard extends Wizard {
29
30     /** The dialog settings key */
31     private static String JavaDoc DIALOG_SETTINGS_KEY= "ShowRefactoringHistoryWizard"; //$NON-NLS-1$
32

33     /** Has the wizard new dialog settings? */
34     private boolean fNewSettings;
35
36     /** The refactoring history */
37     private RefactoringHistory fRefactoringHistory;
38
39     /** The show refactoring history wizard page */
40     private final ShowRefactoringHistoryWizardPage fWizardPage;
41
42     /**
43      * Creates a new show refactoring history wizard.
44      */

45     public ShowRefactoringHistoryWizard() {
46         setNeedsProgressMonitor(false);
47         setWindowTitle(ScriptingMessages.ShowRefactoringHistoryWizard_title);
48         setDefaultPageImageDescriptor(RefactoringPluginImages.DESC_WIZBAN_SHOW_HISTORY);
49         final IDialogSettings settings= RefactoringUIPlugin.getDefault().getDialogSettings();
50         final IDialogSettings section= settings.getSection(DIALOG_SETTINGS_KEY);
51         if (section == null)
52             fNewSettings= true;
53         else {
54             fNewSettings= false;
55             setDialogSettings(section);
56         }
57         fWizardPage= new ShowRefactoringHistoryWizardPage(this);
58     }
59
60     /**
61      * {@inheritDoc}
62      */

63     public void addPages() {
64         super.addPages();
65         addPage(fWizardPage);
66     }
67
68     /**
69      * Returns the refactoring history to create a script from.
70      *
71      * @return the refactoring history.
72      */

73     public RefactoringHistory getRefactoringHistory() {
74         return fRefactoringHistory;
75     }
76
77     /**
78      * {@inheritDoc}
79      */

80     public boolean performFinish() {
81         if (fNewSettings) {
82             final IDialogSettings settings= RefactoringUIPlugin.getDefault().getDialogSettings();
83             IDialogSettings section= settings.getSection(DIALOG_SETTINGS_KEY);
84             section= settings.addNewSection(DIALOG_SETTINGS_KEY);
85             setDialogSettings(section);
86         }
87         fWizardPage.performFinish();
88         return true;
89     }
90
91     /**
92      * Sets the refactoring history to use.
93      *
94      * @param history
95      * the refactoring history to use
96      */

97     public void setRefactoringHistory(final RefactoringHistory history) {
98         Assert.isNotNull(history);
99         fRefactoringHistory= history;
100     }
101
102 }
Popular Tags