### Eclipse Workspace Patch 1.0 #P org.eclipse.ltk.ui.refactoring Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ltk.ui.refactoring/META-INF/MANIFEST.MF,v retrieving revision 1.36 diff -u -r1.36 MANIFEST.MF --- META-INF/MANIFEST.MF 2 Oct 2009 08:41:05 -0000 1.36 +++ META-INF/MANIFEST.MF 4 Mar 2010 19:43:55 -0000 @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.ltk.ui.refactoring; singleton:=true -Bundle-Version: 3.4.200.qualifier +Bundle-Version: 3.5.0.qualifier Bundle-Activator: org.eclipse.ltk.internal.ui.refactoring.RefactoringUIPlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %providerName Index: src/org/eclipse/ltk/ui/refactoring/RefactoringWizard.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/RefactoringWizard.java,v retrieving revision 1.32 diff -u -r1.32 RefactoringWizard.java --- src/org/eclipse/ltk/ui/refactoring/RefactoringWizard.java 3 Aug 2009 12:01:14 -0000 1.32 +++ src/org/eclipse/ltk/ui/refactoring/RefactoringWizard.java 4 Mar 2010 19:43:55 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -400,9 +400,21 @@ /* * XXX: Can return null if there's no user input page and change creation has been cancelled. - * The only way to avoid this would be setChangeCreationCancelable(true). + * The only way to avoid this would be setChangeCreationCancelable(false). */ - return computeUserInputSuccessorPage(null, PlatformUI.getWorkbench().getActiveWorkbenchWindow()); + return computeUserInputSuccessorPage(null, getInitialComputationContext()); + } + + /** + * Returns the runnable context that is used while computing refactoring conditions and change + * while the refactoring dialog is not yet shown. The default implementation returns the active + * workbench window. Subclasses may override. + * + * @return a runnable context + * @since 3.5 + */ + protected IRunnableContext getInitialComputationContext() { + return PlatformUI.getWorkbench().getActiveWorkbenchWindow(); } /** Index: src/org/eclipse/ltk/ui/refactoring/RefactoringWizardOpenOperation.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/RefactoringWizardOpenOperation.java,v retrieving revision 1.22 diff -u -r1.22 RefactoringWizardOpenOperation.java --- src/org/eclipse/ltk/ui/refactoring/RefactoringWizardOpenOperation.java 11 Sep 2008 12:01:08 -0000 1.22 +++ src/org/eclipse/ltk/ui/refactoring/RefactoringWizardOpenOperation.java 4 Mar 2010 19:43:55 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,6 +25,7 @@ import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.window.Window; import org.eclipse.jface.wizard.IWizardContainer; @@ -111,6 +112,42 @@ * the user. */ public int run(final Shell parent, final String dialogTitle) throws InterruptedException { + return run(parent, dialogTitle, null); + } + + /** + * Opens the refactoring dialog for the refactoring wizard passed to the constructor. + * The method first checks the initial conditions of the refactoring. If the condition + * checking returns a status with a severity of {@link RefactoringStatus#FATAL} then + * a message dialog is opened containing the corresponding status message. No wizard + * dialog is opened in this situation. If the condition checking passes then the + * refactoring dialog is opened. + *

+ * The methods ensures that the workspace lock is held while the condition checking, + * change creation and change execution is performed. Clients can't make any assumption + * about the thread in which these steps are executed. However the framework ensures + * that the workspace lock is transfered to the thread in which the execution of the + * steps takes place. + *

+ * @param parent the parent shell for the dialog or null if the dialog + * is a top level dialog + * @param dialogTitle the dialog title of the message box presenting the failed + * condition check (if any) + * @param context the runnable context to use for conditions checking before the + * refactoring wizard dialog is visible. If null, the workbench window's + * progress service is used. + * + * @return {@link #INITIAL_CONDITION_CHECKING_FAILED} if the initial condition checking + * failed and no wizard dialog was presented. Otherwise either {@link IDialogConstants#OK_ID} + * or {@link IDialogConstants#CANCEL_ID} is returned depending on whether the user + * has pressed the OK or cancel button on the wizard dialog. + * + * @throws InterruptedException if the initial condition checking got canceled by + * the user. + * + * @since 3.5 + */ + public int run(final Shell parent, final String dialogTitle, final IRunnableContext context) throws InterruptedException { Assert.isNotNull(dialogTitle); final Refactoring refactoring= fWizard.getRefactoring(); final IJobManager manager= Job.getJobManager(); @@ -123,7 +160,7 @@ manager.beginRule(ResourcesPlugin.getWorkspace().getRoot(), null); refactoring.setValidationContext(parent); - fInitialConditions= checkInitialConditions(refactoring, parent, dialogTitle); + fInitialConditions= checkInitialConditions(refactoring, parent, dialogTitle, context); if (fInitialConditions.hasFatalError()) { String message= fInitialConditions.getMessageMatchingSeverity(RefactoringStatus.FATAL); MessageDialog.openInformation(parent, dialogTitle, message); @@ -160,11 +197,17 @@ //---- private helper methods ----------------------------------------------------------------- - private RefactoringStatus checkInitialConditions(Refactoring refactoring, Shell parent, String title) throws InterruptedException { + private RefactoringStatus checkInitialConditions(Refactoring refactoring, Shell parent, String title, IRunnableContext context) throws InterruptedException { try { CheckConditionsOperation cco= new CheckConditionsOperation(refactoring, CheckConditionsOperation.INITIAL_CONDITONS); - IProgressService service= PlatformUI.getWorkbench().getProgressService(); - service.busyCursorWhile(new WorkbenchRunnableAdapter(cco, ResourcesPlugin.getWorkspace().getRoot())); + WorkbenchRunnableAdapter workbenchRunnableAdapter= new WorkbenchRunnableAdapter(cco, ResourcesPlugin.getWorkspace().getRoot()); + if (context == null) { + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(workbenchRunnableAdapter); + } else if (context instanceof IProgressService) { + ((IProgressService) context).busyCursorWhile(workbenchRunnableAdapter); + } else { + context.run(true, true, workbenchRunnableAdapter); + } return cco.getStatus(); } catch (InvocationTargetException e) { ExceptionHandler.handle(e, parent, title,