KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ltk > internal > ui > refactoring > history > RefactoringHistoryOverviewPage


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.history;
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.IRefactoringHelpContextIds;
18
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.layout.GridData;
21 import org.eclipse.swt.layout.GridLayout;
22 import org.eclipse.swt.widgets.Composite;
23
24 import org.eclipse.jface.dialogs.Dialog;
25 import org.eclipse.jface.dialogs.IDialogSettings;
26 import org.eclipse.jface.wizard.IWizardPage;
27 import org.eclipse.jface.wizard.WizardPage;
28
29 import org.eclipse.ui.PlatformUI;
30
31 import org.eclipse.ltk.ui.refactoring.history.RefactoringHistoryControlConfiguration;
32
33 /**
34  * Wizard page to give an overview a refactoring history.
35  *
36  * @since 3.2
37  */

38 public final class RefactoringHistoryOverviewPage extends WizardPage {
39
40     /** The page name */
41     private final static String JavaDoc PAGE_NAME= "historyOverviewPage"; //$NON-NLS-1$
42

43     /** The sort dialog setting */
44     private static final String JavaDoc SETTING_SORT= "org.eclipse.ltk.ui.refactoring.sortRefactorings"; //$NON-NLS-1$
45

46     /** The refactoring history control configuration to use */
47     private final RefactoringHistoryControlConfiguration fControlConfiguration;
48
49     /** The refactoring history control */
50     private SortableRefactoringHistoryControl fHistoryControl= null;
51
52     /** The refactoring history */
53     private final RefactoringHistory fRefactoringHistory;
54
55     /**
56      * Creates a new refactoring history overview page.
57      *
58      * @param history
59      * the refactoring history to overview
60      * @param title
61      * the title of the wizard page
62      * @param description
63      * the description of the wizard page
64      * @param configuration
65      * the refactoring history control configuration to use
66      */

67     public RefactoringHistoryOverviewPage(final RefactoringHistory history, final String JavaDoc title, final String JavaDoc description, final RefactoringHistoryControlConfiguration configuration) {
68         super(PAGE_NAME);
69         Assert.isNotNull(history);
70         Assert.isNotNull(configuration);
71         Assert.isNotNull(title);
72         Assert.isNotNull(description);
73         fRefactoringHistory= history;
74         fControlConfiguration= configuration;
75         setTitle(title);
76         setDescription(description);
77     }
78
79     /**
80      * {@inheritDoc}
81      */

82     public boolean canFlipToNextPage() {
83         return !fRefactoringHistory.isEmpty();
84     }
85
86     /**
87      * {@inheritDoc}
88      */

89     public void createControl(final Composite parent) {
90         initializeDialogUnits(parent);
91         final Composite composite= new Composite(parent, SWT.NULL);
92         composite.setLayout(new GridLayout());
93         composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
94         fHistoryControl= new SortableRefactoringHistoryControl(composite, fControlConfiguration) {
95
96             protected void createBottomButtonBar(final Composite control) {
97                 // No button bar
98
}
99         };
100         fHistoryControl.createControl();
101         boolean sortProjects= false;
102         final IDialogSettings settings= getWizard().getDialogSettings();
103         if (settings != null)
104             sortProjects= settings.getBoolean(SETTING_SORT);
105         if (sortProjects)
106             fHistoryControl.sortByProjects();
107         else
108             fHistoryControl.sortByDate();
109         fHistoryControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
110         setControl(composite);
111         Dialog.applyDialogFont(composite);
112         PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IRefactoringHelpContextIds.REFACTORING_HISTORY_WIZARD_PAGE);
113     }
114
115     /**
116      * {@inheritDoc}
117      */

118     public IWizardPage getNextPage() {
119         return getWizard().getNextPage(this);
120     }
121
122     /**
123      * {@inheritDoc}
124      */

125     public IWizardPage getPreviousPage() {
126         return getWizard().getPreviousPage(this);
127     }
128
129     /**
130      * Gets called if the wizard is finished.
131      */

132     public void performFinish() {
133         final IDialogSettings settings= getWizard().getDialogSettings();
134         if (settings != null)
135             settings.put(SETTING_SORT, fHistoryControl.isSortByProjects());
136     }
137
138     /**
139      * {@inheritDoc}
140      */

141     public void setPageComplete(final boolean complete) {
142         super.setPageComplete(true);
143     }
144
145     /**
146      * {@inheritDoc}
147      */

148     public void setVisible(boolean visible) {
149         fHistoryControl.setInput(fRefactoringHistory);
150         super.setVisible(visible);
151     }
152 }
153
Popular Tags