Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 08:01 Go to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 41
Registered: March 2015
Member
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 08:03]

Report message to a moderator

Re: Embedded Editor wont list references to an external Ecore model [message #1750019 is a reply to message #1750015] Thu, 15 December 2016 08:42 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 11367
Registered: July 2009
Senior Member
where is "the exisiting" model? in a project?!?

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Embedded Editor wont list references to an external Ecore model [message #1750020 is a reply to message #1750019] Thu, 15 December 2016 08:46 Go to previous messageGo to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 41
Registered: March 2015
Member
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 08:51 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 11367
Registered: July 2009
Senior Member
you should use IResourceSetProvider to obtain a project spĆ¼ecific resourceset

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Embedded Editor wont list references to an external Ecore model [message #1750022 is a reply to message #1750021] Thu, 15 December 2016 08:52 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 11367
Registered: July 2009
Senior Member
and dont do the resolveall thingy

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Embedded Editor wont list references to an external Ecore model [message #1750032 is a reply to message #1750022] Thu, 15 December 2016 10:29 Go to previous messageGo to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 41
Registered: March 2015
Member
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 11:04]

Report message to a moderator

Re: Embedded Editor wont list references to an external Ecore model [message #1750033 is a reply to message #1750032] Thu, 15 December 2016 11:05 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 11367
Registered: July 2009
Senior Member
IResourceSetProvider.get(project) gives you one (maybe downcast)

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Embedded Editor wont list references to an external Ecore model [message #1750034 is a reply to message #1750033] Thu, 15 December 2016 11:14 Go to previous messageGo to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 41
Registered: March 2015
Member
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 11:15]

Report message to a moderator

Re: Embedded Editor wont list references to an external Ecore model [message #1750036 is a reply to message #1750034] Thu, 15 December 2016 11:33 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 11367
Registered: July 2009
Senior Member
can you share a complete reproducable example?

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Embedded Editor wont list references to an external Ecore model [message #1750038 is a reply to message #1750036] Thu, 15 December 2016 11:40 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 11367
Registered: July 2009
Senior Member
p.s.: how do you uris looks like?

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Embedded Editor wont list references to an external Ecore model [message #1750039 is a reply to message #1750038] Thu, 15 December 2016 11:59 Go to previous messageGo to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 41
Registered: March 2015
Member
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 12:06 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 11367
Registered: July 2009
Senior Member
thats bad it should be platform:/resource/<project>/<path>/<file.extension>

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Embedded Editor wont list references to an external Ecore model [message #1750042 is a reply to message #1750040] Thu, 15 December 2016 12:14 Go to previous messageGo to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 41
Registered: March 2015
Member
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 12:19 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 11367
Registered: July 2009
Senior Member
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/...


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Embedded Editor wont list references to an external Ecore model [message #1750055 is a reply to message #1750044] Thu, 15 December 2016 14:18 Go to previous message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 41
Registered: March 2015
Member
Thank you again! Everything is fine now. Have a nice day!
Previous Topic:Getting the line number of the config file
Next Topic:Hide technical UID in XText editor
Goto Forum:
  


Current Time: Mon Nov 20 21:21:11 GMT 2017

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

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