Bug 283427 - [refactoring] [api] RefactoringWizardOpenOperation/RefactoringWizard should have a way to use a specified IRunnableContext
Summary: [refactoring] [api] RefactoringWizardOpenOperation/RefactoringWizard should h...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P2 enhancement (vote)
Target Milestone: 3.6 M6   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2009-07-14 10:51 EDT by Min Idzelis CLA
Modified: 2010-03-08 15:15 EST (History)
4 users (show)

See Also:


Attachments
Proposed fix (7.90 KB, patch)
2010-03-04 14:47 EST, Markus Keller CLA
no flags Details | Diff
Proposed fix 2 (8.28 KB, patch)
2010-03-04 15:07 EST, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Min Idzelis CLA 2009-07-14 10:51:40 EDT
I'm launching a Refactoring from within a project properties page. I'm using the RefactoringWizardOpenOperation class to open the refactoring wizard. It turns out that when using this class, it will create an internal RefactoringWizard/Dialog and load the refactoring in it. During this time, the ApplicationWindow runnable context is used to report status while the wizard is being initialized. This is bad, because there already is a Dialog open. This has a few problems. 1) You can cancel the dialog, but the operation would still be running. 2) You can't cancel the operation since it is blocked by a modal dialog. 

I wanted to fix this by creating a properties page that implements IRunnableContext with a progress monitor itself. Properties pages are not a IRunnableContext, but it was relatively easy to make it so using ProgressMonitorPart. (Except that cancelation is not supported) 

It turns out even after I did the work to create a Properties page with a progress monitor, there was no way for me to pass in that IRunnableContext to the Wizard. RefactoringWizard is hard coded to use PlatformUI.getWorkbench().getActiveWorkbenchWindow() as the IRunnableContext when calculating the user input pages. (RefactoringWizard#getStartingPage()) Additionally, I can't override this method since it calls package-private and calls other private methods. 

My request is to modify RefactoringWizardOpenOperation and RefactoringWizard to accept a IRunnableContext for execution.
Comment 1 Markus Keller CLA 2009-08-10 09:59:25 EDT
> RefactoringWizardOpenOperation
Makes sense.

> RefactoringWizard
Should first check whether we cannot just replace PlatformUI.getWorkbench().getActiveWorkbenchWindow() with getContainer() (beware, the second could be null).
Comment 2 Markus Keller CLA 2010-03-04 14:47:58 EST
Created attachment 161016 [details]
Proposed fix

Sorry, I'm a little late with this, but could you please check whether the attached patch suits your needs? Thanks.
Comment 3 Markus Keller CLA 2010-03-04 15:07:00 EST
Created attachment 161020 [details]
Proposed fix 2

Overriding RefactoringWizard#getInitialComputationContext() may be inconvenient if the implementor of the wizard is not the same as the one who starts the refactoring.

RefactoringWizard#setInitialComputationContext(IRunnableContext) separates these concerns.
Comment 4 Min Idzelis CLA 2010-03-08 15:09:26 EST
I've reviewed the proposed patch. It meets my needs perfectly. Thank you very much!
Comment 5 Markus Keller CLA 2010-03-08 15:15:00 EST
Thanks for the quick review. Released to HEAD.