Graphical Interaction in Refactoring Rename Participant [message #259048] |
Thu, 12 March 2009 06:22  |
Eclipse User |
|
|
|
Hi Everyone
We're two students implementing JDT Integration for the Groovy Eclipse
Plug-in as our bachelor thesis. The Groovy Plug-in currently features
rename refactorings as well as extract an inline method refactorings
(implemented by our predecessors from our university). Our goal is to
get the rename refactorings to interact with Java sourcefiles.
Currently we're about to implement a rename participant for Java rename
refactorings, which should also update Groovy classes who use the
renamed Java element. And here we're stuck with the following problem:
Groovy references may be ambiguous, because the language is dynamically
typed. The existing refactoring solves this problem (in Groovy) by
presenting a RefactoringWizardPage to the user, where he or she can
select which ambiguous references should be updated anyway. We'd like to
have that interaction in our rename participant too, but to achieve
that, we need a reference to the ActiveWorkbenchWindow. It seems that
accessing the WorkbenchWindow (In case of refactorings usually passed by
reference to the WorkbenchActionDelegate which starts the refactoring)
is not easily feasible. A call to the anyway deprecated
PlatformUI.getWorkbench().getActiveWorkbench();
results in a nullpointer. Is there any other way to present user
interaction in rename participants that we haven't tought off yet?
Thanks in advance
Stefan Reinhard
|
|
|
|
Re: Graphical Interaction in Refactoring Rename Participant [message #259056 is a reply to message #259052] |
Fri, 13 March 2009 05:16  |
Eclipse User |
|
|
|
J.-P. Pellet wrote:
> I'm unsure about the getActiveWorkbench() call. What I experienced is
> that PlatformUI.getWorkbench().getActiveWorkbenchWindow() returns null
> if called from a non-UI thread. Are you sure you're calling this from
> the UI thread?
No, the RefactoringProcessor seems to run in it's own context...
> Try something like:
>
> PlatformUI.getWorkbench().getDisplay().syncExec( new Runnable() {
> public void run() {
> final IWorkbenchWindow window =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow();
> // ...
> }
> });
Yes, that way it's working perfect! Thank's a lot, you're my saviour!
Now we can get productive again.
Cheers
Stefan Reinhard
|
|
|
Powered by
FUDForum. Page generated in 0.02732 seconds