View | Details | Raw Unified | Return to bug 283427 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.ltk.ui.refactoring; singleton:=true
4
Bundle-SymbolicName: org.eclipse.ltk.ui.refactoring; singleton:=true
5
Bundle-Version: 3.4.200.qualifier
5
Bundle-Version: 3.5.0.qualifier
6
Bundle-Activator: org.eclipse.ltk.internal.ui.refactoring.RefactoringUIPlugin
6
Bundle-Activator: org.eclipse.ltk.internal.ui.refactoring.RefactoringUIPlugin
7
Bundle-ActivationPolicy: lazy
7
Bundle-ActivationPolicy: lazy
8
Bundle-Vendor: %providerName
8
Bundle-Vendor: %providerName
(-)src/org/eclipse/ltk/ui/refactoring/RefactoringWizard.java (-3 / +19 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 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 157-162 Link Here
157
	private boolean fForcePreviewReview;
157
	private boolean fForcePreviewReview;
158
	private boolean fPreviewShown;
158
	private boolean fPreviewShown;
159
159
160
	private IRunnableContext fRunnableContext;
161
160
	/**
162
	/**
161
	 * Creates a new refactoring wizard for the given refactoring.
163
	 * Creates a new refactoring wizard for the given refactoring.
162
	 *
164
	 *
Lines 398-408 Link Here
398
		if (hasUserInput())
400
		if (hasUserInput())
399
			return super.getStartingPage();
401
			return super.getStartingPage();
400
402
403
		IRunnableContext context= fRunnableContext != null ? fRunnableContext : PlatformUI.getWorkbench().getActiveWorkbenchWindow();
401
		/*
404
		/*
402
		 * XXX: Can return null if there's no user input page and change creation has been cancelled.
405
		 * XXX: Can return null if there's no user input page and change creation has been cancelled.
403
		 * The only way to avoid this would be setChangeCreationCancelable(true).
406
		 * The only way to avoid this would be setChangeCreationCancelable(false).
404
		 */
407
		 */
405
		return computeUserInputSuccessorPage(null, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
408
		return computeUserInputSuccessorPage(null, context);
409
	}
410
411
	/**
412
	 * Sets the runnable context that will be used to computing refactoring conditions and change
413
	 * while the refactoring dialog is not yet shown. The default is to use the active workbench
414
	 * window.
415
	 * 
416
	 * @param context a runnable context, or <code>null</code> to re-set the default
417
	 * 
418
	 * @since 3.5
419
	 */
420
	public void setInitialComputationContext(IRunnableContext context) {
421
		fRunnableContext= context;
406
	}
422
	}
407
423
408
	/**
424
	/**
(-)src/org/eclipse/ltk/ui/refactoring/RefactoringWizardOpenOperation.java (-5 / +48 lines)
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,

Return to bug 283427