Set focus after quickfix [message #881260] |
Mon, 04 June 2012 08:42 |
Michael Ehrmann Messages: 2 Registered: June 2012 |
Junior Member |
|
|
Hi,
We're trying to implement a quickfix using a ISemanticModification, which introduces a new object in the model. Now we want to set the focus to this model, to let the user modify (refactor) the newly introduced random name of the object.
acceptor.accept(issue, "introduce prototype", "Introduce a new prototype", null, new ISemanticModification() {
public void apply(EObject element, IModificationContext context) throws Exception {
Prototype newPrototype = ExamplePackage.eINSTANCE.getExampleFactory().createPrototype();
model.getPrototypes().add(newPrototype);
Now we want to set the focus.
I understand that this would be possible by using
EditorUtils.getActiveXtextEditor().setHighlightRange(offset, length, true);
But we struggle determining offset/length.
I tried locationInFileProvider.getFullTextRegion(newPrototype); as well as but this seems to return bogus values.
NodeModelUtils.getNode(newPrototype); seems also not possible.
It seems to me that the underlying model still has not yet been updated.
Anyone can give a hint?
|
|
|
Re: Set focus after quickfix [message #881411 is a reply to message #881260] |
Mon, 04 June 2012 13:55 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Michael,
I'm afraid you'll have to schedule a UI job that performs that task.
Alternatively you may want to use the underlying JFace API that allows
to access the ITextViewer.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 04.06.12 10:43, schrieb Michael Ehrmann:
> Hi,
>
> We're trying to implement a quickfix using a ISemanticModification,
> which introduces a new object in the model. Now we want to set the focus
> to this model, to let the user modify (refactor) the newly introduced
> random name of the object.
>
>
> acceptor.accept(issue, "introduce prototype", "Introduce a new
> prototype", null, new ISemanticModification() {
> public void apply(EObject element, IModificationContext context) throws
> Exception {
>
> Prototype newPrototype =
> ExamplePackage.eINSTANCE.getExampleFactory().createPrototype();
> model.getPrototypes().add(newPrototype);
>
>
>
> Now we want to set the focus.
> I understand that this would be possible by using
>
>
> EditorUtils.getActiveXtextEditor().setHighlightRange(offset, length, true);
>
>
>
> But we struggle determining offset/length.
>
> I tried locationInFileProvider.getFullTextRegion(newPrototype); as well
> as getSignificantTextRegion but this seems to return bogus values.
>
> NodeModelUtils.getNode(newPrototype); seems also not possible.
>
> It seems to me that the underlying model still has not yet been updated.
> Anyone can give a hint?
>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.04208 seconds