Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2008 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 25-30
Link Here
|
25 |
import org.eclipse.jface.dialogs.Dialog; |
25 |
import org.eclipse.jface.dialogs.Dialog; |
26 |
import org.eclipse.jface.dialogs.IDialogConstants; |
26 |
import org.eclipse.jface.dialogs.IDialogConstants; |
27 |
import org.eclipse.jface.dialogs.MessageDialog; |
27 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
|
28 |
import org.eclipse.jface.operation.IRunnableContext; |
28 |
import org.eclipse.jface.window.Window; |
29 |
import org.eclipse.jface.window.Window; |
29 |
import org.eclipse.jface.wizard.IWizardContainer; |
30 |
import org.eclipse.jface.wizard.IWizardContainer; |
30 |
|
31 |
|
Lines 111-116
Link Here
|
111 |
* the user. |
112 |
* the user. |
112 |
*/ |
113 |
*/ |
113 |
public int run(final Shell parent, final String dialogTitle) throws InterruptedException { |
114 |
public int run(final Shell parent, final String dialogTitle) throws InterruptedException { |
|
|
115 |
return run(parent, dialogTitle, null); |
116 |
} |
117 |
|
118 |
/** |
119 |
* Opens the refactoring dialog for the refactoring wizard passed to the constructor. |
120 |
* The method first checks the initial conditions of the refactoring. If the condition |
121 |
* checking returns a status with a severity of {@link RefactoringStatus#FATAL} then |
122 |
* a message dialog is opened containing the corresponding status message. No wizard |
123 |
* dialog is opened in this situation. If the condition checking passes then the |
124 |
* refactoring dialog is opened. |
125 |
* <p> |
126 |
* The methods ensures that the workspace lock is held while the condition checking, |
127 |
* change creation and change execution is performed. Clients can't make any assumption |
128 |
* about the thread in which these steps are executed. However the framework ensures |
129 |
* that the workspace lock is transfered to the thread in which the execution of the |
130 |
* steps takes place. |
131 |
* </p> |
132 |
* @param parent the parent shell for the dialog or <code>null</code> if the dialog |
133 |
* is a top level dialog |
134 |
* @param dialogTitle the dialog title of the message box presenting the failed |
135 |
* condition check (if any) |
136 |
* @param context the runnable context to use for conditions checking before the |
137 |
* refactoring wizard dialog is visible. If <code>null</code>, the workbench window's |
138 |
* progress service is used. |
139 |
* |
140 |
* @return {@link #INITIAL_CONDITION_CHECKING_FAILED} if the initial condition checking |
141 |
* failed and no wizard dialog was presented. Otherwise either {@link IDialogConstants#OK_ID} |
142 |
* or {@link IDialogConstants#CANCEL_ID} is returned depending on whether the user |
143 |
* has pressed the OK or cancel button on the wizard dialog. |
144 |
* |
145 |
* @throws InterruptedException if the initial condition checking got canceled by |
146 |
* the user. |
147 |
* |
148 |
* @since 3.5 |
149 |
*/ |
150 |
public int run(final Shell parent, final String dialogTitle, final IRunnableContext context) throws InterruptedException { |
114 |
Assert.isNotNull(dialogTitle); |
151 |
Assert.isNotNull(dialogTitle); |
115 |
final Refactoring refactoring= fWizard.getRefactoring(); |
152 |
final Refactoring refactoring= fWizard.getRefactoring(); |
116 |
final IJobManager manager= Job.getJobManager(); |
153 |
final IJobManager manager= Job.getJobManager(); |
Lines 123-129
Link Here
|
123 |
manager.beginRule(ResourcesPlugin.getWorkspace().getRoot(), null); |
160 |
manager.beginRule(ResourcesPlugin.getWorkspace().getRoot(), null); |
124 |
|
161 |
|
125 |
refactoring.setValidationContext(parent); |
162 |
refactoring.setValidationContext(parent); |
126 |
fInitialConditions= checkInitialConditions(refactoring, parent, dialogTitle); |
163 |
fInitialConditions= checkInitialConditions(refactoring, parent, dialogTitle, context); |
127 |
if (fInitialConditions.hasFatalError()) { |
164 |
if (fInitialConditions.hasFatalError()) { |
128 |
String message= fInitialConditions.getMessageMatchingSeverity(RefactoringStatus.FATAL); |
165 |
String message= fInitialConditions.getMessageMatchingSeverity(RefactoringStatus.FATAL); |
129 |
MessageDialog.openInformation(parent, dialogTitle, message); |
166 |
MessageDialog.openInformation(parent, dialogTitle, message); |
Lines 160-170
Link Here
|
160 |
|
197 |
|
161 |
//---- private helper methods ----------------------------------------------------------------- |
198 |
//---- private helper methods ----------------------------------------------------------------- |
162 |
|
199 |
|
163 |
private RefactoringStatus checkInitialConditions(Refactoring refactoring, Shell parent, String title) throws InterruptedException { |
200 |
private RefactoringStatus checkInitialConditions(Refactoring refactoring, Shell parent, String title, IRunnableContext context) throws InterruptedException { |
164 |
try { |
201 |
try { |
165 |
CheckConditionsOperation cco= new CheckConditionsOperation(refactoring, CheckConditionsOperation.INITIAL_CONDITONS); |
202 |
CheckConditionsOperation cco= new CheckConditionsOperation(refactoring, CheckConditionsOperation.INITIAL_CONDITONS); |
166 |
IProgressService service= PlatformUI.getWorkbench().getProgressService(); |
203 |
WorkbenchRunnableAdapter workbenchRunnableAdapter= new WorkbenchRunnableAdapter(cco, ResourcesPlugin.getWorkspace().getRoot()); |
167 |
service.busyCursorWhile(new WorkbenchRunnableAdapter(cco, ResourcesPlugin.getWorkspace().getRoot())); |
204 |
if (context == null) { |
|
|
205 |
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(workbenchRunnableAdapter); |
206 |
} else if (context instanceof IProgressService) { |
207 |
((IProgressService) context).busyCursorWhile(workbenchRunnableAdapter); |
208 |
} else { |
209 |
context.run(true, true, workbenchRunnableAdapter); |
210 |
} |
168 |
return cco.getStatus(); |
211 |
return cco.getStatus(); |
169 |
} catch (InvocationTargetException e) { |
212 |
} catch (InvocationTargetException e) { |
170 |
ExceptionHandler.handle(e, parent, title, |
213 |
ExceptionHandler.handle(e, parent, title, |