Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Embedded editor is missing some functionality(Error bar, error markers are missing)
Embedded editor is missing some functionality [message #987818] Wed, 28 November 2012 09:49 Go to next message
Gaspar DinFriend
Messages: 21
Registered: September 2012
Junior Member
Hello,

in my project I use an embedded version of the xtext editor within an eclipse RCP. It is created as described by the following code snippet:
IEditedResourceProvider resourceProvider = new IEditedResourceProvider() {
    public XtextResource createResource() {
        MyDslActivator activator = MyDslActivator.getInstance();
        Injector injector = activator.getInjector(MyDslActivator.COM_MYORG_MYDSL);

        XtextResourceSet rs = injector.getInstance(XtextResourceSet.class);
        rs.setClasspathURIContext(getClass());

        IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
        URI uri = URI.createDeviceURI("file:///temp/MyDsl.mydsl");
        XtextResource resource = (XtextResource) resourceFactory.createResource(uri);
        rs.getResources().add(resource);

        EcoreUtil.resolveAll(resource);

        if (!resource.getErrors().isEmpty()) {
            // handle error?
        }
        return resource;
    }};

MyDslActivator activator = MyDslActivator.getInstance();
Injector injector = activator.getInjector(MyDslActivator.COM_MYORG_MYDSL);
EmbeddedEditorFactory factory = injector.getInstance(EmbeddedEditorFactory.class);
EmbeddedEditor embeddedEditor = factory.newEditor(resourceProvider).withParent(parent);
EmbeddedEditorModelAccess partialEditorModelAccess = embeddedEditor.createPartialEditor(false);
embeddedEditor.createPartialEditor();

Unfortunately, some functionality is missing in the embedded version of the editor while it is available in the regular version, i.e. when opening a mydsl file:

1. The vertical error bar is missing. How can it be added to the view?
2. The error markers are not shown or they're partly missing. How can they be "reactivated"?

Regards,
Gaspar
Re: Embedded editor is missing some functionality [message #987864 is a reply to message #987818] Wed, 28 November 2012 12:40 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Gaspar,

did you try
factory.newEditor(resourceProvider).showErrorAndWarningAnnotations().withParent(parent);
?

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 28.11.12 10:50, schrieb Gaspar Din:
> Hello,
>
> in my project I use an embedded version of the xtext editor within an
> eclipse RCP. It is created as described by the following code snippet:
> IEditedResourceProvider resourceProvider = new IEditedResourceProvider() {
> public XtextResource createResource() {
> MyDslActivator activator = MyDslActivator.getInstance();
> Injector injector =
> activator.getInjector(MyDslActivator.COM_MYORG_MYDSL);
>
> XtextResourceSet rs = injector.getInstance(XtextResourceSet.class);
> rs.setClasspathURIContext(getClass());
>
> IResourceFactory resourceFactory =
> injector.getInstance(IResourceFactory.class);
> URI uri = URI.createDeviceURI("file:///temp/MyDsl.mydsl");
> XtextResource resource = (XtextResource)
> resourceFactory.createResource(uri);
> rs.getResources().add(resource);
>
> EcoreUtil.resolveAll(resource);
>
> if (!resource.getErrors().isEmpty()) {
> // handle error?
> }
> return resource;
> }};
>
> MyDslActivator activator = MyDslActivator.getInstance();
> Injector injector = activator.getInjector(MyDslActivator.COM_MYORG_MYDSL);
> EmbeddedEditorFactory factory =
> injector.getInstance(EmbeddedEditorFactory.class);
> EmbeddedEditor embeddedEditor =
> factory.newEditor(resourceProvider).withParent(parent);
> EmbeddedEditorModelAccess partialEditorModelAccess =
> embeddedEditor.createPartialEditor(false);
> embeddedEditor.createPartialEditor();
> Unfortunately, some functionality is missing in the embedded version of
> the editor while it is available in the regular version, i.e. when
> opening a mydsl file:
>
> 1. The vertical error bar is missing. How can it be added to the view?
> 2. The error markers are not shown or they're partly missing. How can
> they be "reactivated"?
>
> Regards,
> Gaspar
Re: Embedded editor is missing some functionality [message #987884 is a reply to message #987864] Wed, 28 November 2012 14:23 Go to previous messageGo to next message
Gaspar DinFriend
Messages: 21
Registered: September 2012
Junior Member
Hi Sebastian,

yes, I've already tried to use the call
factory.newEditor(resourceProvider).showErrorAndWarningAnnotations().withParent(parent);

and I've also added
LineNumberRulerColumn lineNumberRulerColumn = new LineNumberRulerColumn();
xtextSourceViewer.addVerticalRulerColumn(lineNumberRulerColumn);


but unfortunately I am still missing the error markers.
I've discovered that sometimes some errors get marked while typing or erasing some spaces in the editor. But while typing, the shown error markers changes or they disappear.
And even if a marker is shown, there is not always the explaining tooltip with the error description. And sometimes, there is no marker shown, but the tooltip comes up while howering over the erroneous element

Is it possible that some events are catched away by my application?

Regards,
Gaspar

Re: Embedded editor is missing some functionality [message #988305 is a reply to message #987884] Thu, 29 November 2012 10:37 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
You have to register the validator by means of withResourceValidator(..)
on the editor-builder.

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 28.11.12 15:23, schrieb Gaspar Din:
> Hi Sebastian,
>
> yes, I've already tried to use the call
> factory.newEditor(resourceProvider).showErrorAndWarningAnnotations().withParent(parent);
>
> and I've also added
> LineNumberRulerColumn lineNumberRulerColumn = new LineNumberRulerColumn();
> xtextSourceViewer.addVerticalRulerColumn(lineNumberRulerColumn);
>
> but unfortunately I am still missing the error markers.
> I've discovered that sometimes some errors get marked while typing or
> erasing some spaces in the editor. But while typing, the shown error
> markers changes or they disappear.
> And even if a marker is shown, there is not always the explaining
> tooltip with the error description. And sometimes, there is no marker
> shown, but the tooltip comes up while howering over the erroneous element
>
> Is it possible that some events are catched away by my application?
>
> Regards,
> Gaspar
>
>
Re: Embedded editor is missing some functionality [message #989783 is a reply to message #988305] Fri, 07 December 2012 18:08 Go to previous message
Gaspar DinFriend
Messages: 21
Registered: September 2012
Junior Member
Hello Sebastian,

I had no such method withResourceValidator(..) in my xtext libraries (I am using org.eclipse.xtext-2.3.1-final.zip).
So I added this method to EmbeddedEditorFactory class, copying it from a newer version of the file (this was the only difference, at least for this file). Then I made the call you suggested, setting the resource validator.
Unfortunately, this had no effects.
Any more ideas?

Greatings,
Gaspar.
Previous Topic:Errors and warnings not shown in my editor
Next Topic:no suggestions for node (xpath)
Goto Forum:
  


Current Time: Thu Mar 28 10:36:12 GMT 2024

Powered by FUDForum. Page generated in 0.03257 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top