Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Embedded Editor wont list references to an external Ecore model
Embedded Editor wont list references to an external Ecore model [message #1750015] Thu, 15 December 2016 03:01 Go to next message
Eclipse UserFriend
Hello there,

i followed the tutorial from Christian to link my editor with an external model (https://christiandietrich.wordpress.com/2011/07/17/xtext-2-0-and-uml/)

Its working fine with the generated editor.

Now i want to reuse the editor in an swt component (inside an eclipse) but it wont show the elements from other models. here is what i did:

ArithmeticsActivator arithmeticsActivator = ArithmeticsActivator.getInstance();
Injector injector = arithmeticsActivator.getInjector(ArithmeticsActivator.ARITHMETICS_DSL);
XtextResourceSet XtextResourceSet = injector.getInstance(XtextResourceSet.class);
XtextResourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
xtextResource = (XtextResource) XtextResourceSet.createResource(URI.createURI(someObjectFromTheOtherModel.eResource().getURI().trimSegments(1)+"/temp.arithmetics"));

comp.setLayout(GridLayoutFactory.fillDefaults().margins(1, 1).create());

EmbeddedEditorFactory factory = injector.getInstance(EmbeddedEditorFactory.class);
EmbeddedEditor embeddedEditor = factory.newEditor(getResourceProvider()).showErrorAndWarningAnnotations().withParent(comp);
EmbeddedEditorModelAccess partialEditorModelAccess = embeddedEditor.createPartialEditor(false);
embeddedEditor.createPartialEditor();


The Editor shows up and works just fine, but when i try to link to an existing element (space + strg) nothing shows up.

Thx for your time.

[Updated on: Thu, 15 December 2016 03:03] by Moderator

Re: Embedded Editor wont list references to an external Ecore model [message #1750019 is a reply to message #1750015] Thu, 15 December 2016 03:42 Go to previous messageGo to next message
Eclipse UserFriend
where is "the exisiting" model? in a project?!?
Re: Embedded Editor wont list references to an external Ecore model [message #1750020 is a reply to message #1750019] Thu, 15 December 2016 03:46 Go to previous messageGo to next message
Eclipse UserFriend
Yes, and i tryed to use a URI besides the existing model, see:

xtextResource = (XtextResource) XtextResourceSet.createResource(URI.createURI(someObjectFromTheOtherModel.eResource().getURI().trimSegments(1)+"/temp.arithmetics"));
Re: Embedded Editor wont list references to an external Ecore model [message #1750021 is a reply to message #1750020] Thu, 15 December 2016 03:51 Go to previous messageGo to next message
Eclipse UserFriend
you should use IResourceSetProvider to obtain a project spüecific resourceset
Re: Embedded Editor wont list references to an external Ecore model [message #1750022 is a reply to message #1750021] Thu, 15 December 2016 03:52 Go to previous messageGo to next message
Eclipse UserFriend
and dont do the resolveall thingy
Re: Embedded Editor wont list references to an external Ecore model [message #1750032 is a reply to message #1750022] Thu, 15 December 2016 05:29 Go to previous messageGo to next message
Eclipse UserFriend
Hello Christian,

thx for your reply and time. Realy appreciate it.

Can you give me a short example? I have one Eobject from the model i would like to reference

My Problem is that factory.newEditor(getResourceProvider()) a XTextResourceSet requires

i also tryed to load the other model directly into my resource set, sadly it doesent work either

[Updated on: Thu, 15 December 2016 06:04] by Moderator

Re: Embedded Editor wont list references to an external Ecore model [message #1750033 is a reply to message #1750032] Thu, 15 December 2016 06:05 Go to previous messageGo to next message
Eclipse UserFriend
IResourceSetProvider.get(project) gives you one (maybe downcast)
Re: Embedded Editor wont list references to an external Ecore model [message #1750034 is a reply to message #1750033] Thu, 15 December 2016 06:14 Go to previous messageGo to next message
Eclipse UserFriend
i tryed that already:

XtextResourceSetProvider xtextResourceSetProvider = injector.getInstance(XtextResourceSetProvider.class);
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("Test");
XtextResourceSet XtextResourceSet = (org.eclipse.xtext.resource.XtextResourceSet) xtextResourceSetProvider.get(project);
// XtextResourceSet XtextResourceSet = injector.getInstance(XtextResourceSet.class);
xtextResource = (XtextResource) XtextResourceSet.createResource(URI.createURI(someObjectFromTheModel.eResource().getURI().trimSegments(1) + "/asdsad.arithmetics"));
Resource modelResource = XtextResourceSet.createResource(URI.createURI(someObjectFromTheModel.eResource().getURI().toString()));
try {
xtextResource.load(Collections.EMPTY_MAP);
modelResource.load(Collections.EMPTY_MAP);
} catch (IOException e1) {
e1.printStackTrace();
}
return xtextResource;

[Updated on: Thu, 15 December 2016 06:15] by Moderator

Re: Embedded Editor wont list references to an external Ecore model [message #1750036 is a reply to message #1750034] Thu, 15 December 2016 06:33 Go to previous messageGo to next message
Eclipse UserFriend
can you share a complete reproducable example?
Re: Embedded Editor wont list references to an external Ecore model [message #1750038 is a reply to message #1750036] Thu, 15 December 2016 06:40 Go to previous messageGo to next message
Eclipse UserFriend
p.s.: how do you uris looks like?
Re: Embedded Editor wont list references to an external Ecore model [message #1750039 is a reply to message #1750038] Thu, 15 December 2016 06:59 Go to previous messageGo to next message
Eclipse UserFriend
My URI looks like: file:/C:/Projekte/[...]/runtime-EclipseApplication/Test/mymodel.domain and file:/C:/Projekte/[...]/runtime-EclipseApplication/Test/asdsad.arithmetics

The code i posted in the first Comment of this topic is nearly the hole code i have. The first 5 lines are Wrapped in a method that returns an IEditedResourceProvider (named getResourceProvider()).
Re: Embedded Editor wont list references to an external Ecore model [message #1750040 is a reply to message #1750039] Thu, 15 December 2016 07:06 Go to previous messageGo to next message
Eclipse UserFriend
thats bad it should be platform:/resource/<project>/<path>/<file.extension>
Re: Embedded Editor wont list references to an external Ecore model [message #1750042 is a reply to message #1750040] Thu, 15 December 2016 07:14 Go to previous messageGo to next message
Eclipse UserFriend
Wow thank you Christian, i hardcoded the URIs to the platform-format and it works now. Can you explain that to me?
Re: Embedded Editor wont list references to an external Ecore model [message #1750044 is a reply to message #1750042] Thu, 15 December 2016 07:19 Go to previous messageGo to next message
Eclipse UserFriend
yes xtext behaves differently in standalone and eclipse mode and in eclipse mode everything is tied to projects
and emf uris for project look like platform:/resource/project/...
Re: Embedded Editor wont list references to an external Ecore model [message #1750055 is a reply to message #1750044] Thu, 15 December 2016 09:18 Go to previous message
Eclipse UserFriend
Thank you again! Everything is fine now. Have a nice day!
Previous Topic:Getting the line number of the config file
Next Topic:Localization of Double values (2,4 vs. 2.4)
Goto Forum:
  


Current Time: Tue May 13 14:04:51 EDT 2025

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

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

Back to the top