KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ltk > ui > refactoring > RefactoringUI


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.ui.refactoring;
12
13 import org.eclipse.ltk.core.refactoring.Change;
14 import org.eclipse.ltk.core.refactoring.PerformChangeOperation;
15 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
16
17 import org.eclipse.ltk.internal.ui.refactoring.RefactoringStatusDialog;
18 import org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog;
19 import org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2;
20 import org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation;
21 import org.eclipse.ltk.internal.ui.refactoring.history.RefactoringHistoryControl;
22 import org.eclipse.ltk.internal.ui.refactoring.history.SortableRefactoringHistoryControl;
23
24 import org.eclipse.swt.widgets.Composite;
25 import org.eclipse.swt.widgets.Shell;
26
27 import org.eclipse.jface.dialogs.Dialog;
28
29 import org.eclipse.ltk.ui.refactoring.history.IRefactoringHistoryControl;
30 import org.eclipse.ltk.ui.refactoring.history.ISortableRefactoringHistoryControl;
31 import org.eclipse.ltk.ui.refactoring.history.RefactoringHistoryControlConfiguration;
32
33 /**
34  * Central access point to access resources managed by the refactoring UI
35  * plug-in.
36  * <p>
37  * Note: this class is not intended to be extended by clients.
38  * </p>
39  *
40  * @since 3.0
41  */

42 public class RefactoringUI {
43
44     /**
45      * Creates a light-weight dialog to present a {@link RefactoringStatus} to
46      * the user. The following values are returned from the dialogs open method:
47      * <ul>
48      * <li>{@link org.eclipse.jface.dialogs.IDialogConstants#OK_ID IDialogConstants#OK_ID}:
49      * if the user has pressed the continue button.</li>
50      * <li>{@link org.eclipse.jface.dialogs.IDialogConstants#CANCEL_ID IDialogConstants#CANCEL_ID}:
51      * if the user has pressed the cancel button.</li>
52      * <li>{@link org.eclipse.jface.dialogs.IDialogConstants#BACK_ID IDialogConstants#BACK_ID}:
53      * if the user has pressed the back button.</li>
54      * </ul>
55      *
56      * @param status
57      * the status to present
58      * @param parent
59      * the parent shell of the dialog. May be <code>null</code> if
60      * the dialog is a top-level dialog
61      * @param windowTitle
62      * the dialog's window title
63      * @return a dialog to present a refactoring status.
64      *
65      * @since 3.2
66      */

67     public static Dialog createLightWeightStatusDialog(RefactoringStatus status, Shell parent, String JavaDoc windowTitle) {
68         return new RefactoringStatusDialog(status, parent, windowTitle, false, true);
69     }
70
71     /**
72      * Creates a control capable of presenting a refactoring history. Clients of
73      * this method can assume that the returned composite is an instance of
74      * {@link IRefactoringHistoryControl}.
75      *
76      * @param parent
77      * the parent control
78      * @param configuration
79      * the refactoring history control configuration
80      * @return the refactoring history control
81      *
82      * @since 3.2
83      */

84     public static Composite createRefactoringHistoryControl(Composite parent, RefactoringHistoryControlConfiguration configuration) {
85         return new RefactoringHistoryControl(parent, configuration);
86     }
87
88     /**
89      * Creates a dialog to present a {@link RefactoringStatus} to the user. The
90      * following values are returned from the dialogs open method:
91      * <ul>
92      * <li>{@link org.eclipse.jface.dialogs.IDialogConstants#OK_ID IDialogConstants#OK_ID}:
93      * if the user has pressed the continue button.</li>
94      * <li>{@link org.eclipse.jface.dialogs.IDialogConstants#CANCEL_ID IDialogConstants#CANCEL_ID}:
95      * if the user has pressed the cancel button.</li>
96      * <li>{@link org.eclipse.jface.dialogs.IDialogConstants#BACK_ID IDialogConstants#BACK_ID}:
97      * if the user has pressed the back button.</li>
98      * </ul>
99      *
100      * @param status
101      * the status to present
102      * @param parent
103      * the parent shell of the dialog. May be <code>null</code> if
104      * the dialog is a top-level dialog
105      * @param windowTitle
106      * the dialog's window title
107      * @param backButton
108      * if <code>true</code> the dialog will contain a back button;
109      * otherwise no back button will be present.
110      * @return a dialog to present a refactoring status.
111      */

112     public static Dialog createRefactoringStatusDialog(RefactoringStatus status, Shell parent, String JavaDoc windowTitle, boolean backButton) {
113         return new RefactoringStatusDialog(status, parent, windowTitle, backButton);
114     }
115
116     /**
117      * Creates a dialog capable of presenting the given refactoring wizard.
118      * Clients of this method can assume that the returned dialog is an instance
119      * of {@link org.eclipse.jface.wizard.IWizardContainer IWizardContainer}.
120      * However the dialog is not necessarily an instance of
121      * {@link org.eclipse.jface.wizard.WizardDialog WizardDialog}.
122      *
123      * @param wizard
124      * the refactoring wizard to create a dialog for
125      * @param parent
126      * the parent of the created dialog or <code>null</code> to
127      * create a top-level dialog
128      *
129      * @return the dialog
130      */

131     /* package */static Dialog createRefactoringWizardDialog(RefactoringWizard wizard, Shell parent) {
132         Dialog result;
133         if (wizard.needsWizardBasedUserInterface())
134             result= new RefactoringWizardDialog(parent, wizard);
135         else
136             result= new RefactoringWizardDialog2(parent, wizard);
137         return result;
138     }
139
140     /**
141      * Creates a control capable of presenting a refactoring history. Clients of
142      * this method can assume that the returned composite is an instance of
143      * {@link ISortableRefactoringHistoryControl}.
144      *
145      * @param parent
146      * the parent control
147      * @param configuration
148      * the refactoring history control configuration
149      * @return the refactoring history control
150      *
151      * @since 3.3
152      */

153     public static Composite createSortableRefactoringHistoryControl(Composite parent, RefactoringHistoryControlConfiguration configuration) {
154         return new SortableRefactoringHistoryControl(parent, configuration);
155     }
156
157     /**
158      * Creates a special perform change operations that knows how to batch undo
159      * operations in open editors into one undo object. The operation batches
160      * the undo operations for those editors that implement the interface
161      * {@link org.eclipse.jface.text.IRewriteTarget}.
162      *
163      * @param change
164      * the change to perform
165      *
166      * @return a special perform change operation that knows how to batch undo
167      * operations for open editors if they implement
168      * <code>IRewriteTarget
169      * </code>
170      */

171     public static PerformChangeOperation createUIAwareChangeOperation(Change change) {
172         return new UIPerformChangeOperation(null, change, null);
173     }
174
175     private RefactoringUI() {
176         // no instance
177
}
178 }
179
Popular Tags