|
|
|
|
|
Re: Open .xtext grammar in ModelEditor [message #1434571 is a reply to message #1431824] |
Tue, 30 September 2014 09:12 |
Alexander R Messages: 211 Registered: July 2013 |
Senior Member |
|
|
Hi,
the modeleditor I have to work with uses an EditingDomain. I tried to manipulate the initialization of the editingdomain in the following way:
protected void initializeEditingDomain() {
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
//added
adapterFactory.addAdapterFactory(new XtextAdapterFactory());
//definition of the commandstack....
editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
ResourceSet resSet = editingDomain.getResourceSet();
XtextPackage.eINSTANCE.eClass();
EcorePackage.eINSTANCE.eClass();
// global registratin
EPackage.Registry.INSTANCE.put(XtextFactory.eINSTANCE.getEPackage().getNsURI(), XtextFactory.eINSTANCE.getEPackage());
EPackage.Registry.INSTANCE.put(EcoreFactory.eINSTANCE.getEPackage().getNsURI(), EcoreFactory.eINSTANCE.getEPackage());
URI ecoreUri = URI.createURI(EcoreFactory.eINSTANCE.getEPackage().getNsURI(), true);
URI xtextUri = URI.createURI(XtextFactory.eINSTANCE.getEPackage().getNsURI(), true);
Resource ecoreResource = resSet.getResource(ecoreUri, true);
Resource xtextResource = resSet.getResource(xtextUri, true);
//loading the resources
ecoreResource.load(null);
xtextResource.load(null);
}
The java.net.MalformedURLException: unknown protocol: classpath appears again, because I don't know how to change the EditingDomain's resourceSet to a XtextResourceSet to use the xtextResourceSet.setClasspathURIContext().
Do you maybe know if it is even possible to change/modify an editingDomain's resourceSet?
Thanks,
Alex
|
|
|
Re: Open .xtext grammar in ModelEditor [message #1434727 is a reply to message #1434571] |
Tue, 30 September 2014 13:45 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Alex,
you can create your own editing domain in #initializeEditingDomain.
Something like
new AdapterFactoryEditingDomain(
adapterFactory, commandStack, xtextResourceSet)
instead of the default editing domain should do the trick.
Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 30.09.14 11:12, schrieb Alexander R:
> Hi,
>
> the modeleditor I have to work with uses an EditingDomain. I tried to
> manipulate the initialization of the editingdomain in the following way:
>
>
> protected void initializeEditingDomain() {
> adapterFactory = new
> ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
>
>
> //added
> adapterFactory.addAdapterFactory(new XtextAdapterFactory());
>
> //definition of the commandstack....
>
> editingDomain = new AdapterFactoryEditingDomain(adapterFactory,
> commandStack, new HashMap<Resource, Boolean>());
>
> ResourceSet resSet = editingDomain.getResourceSet();
>
> XtextPackage.eINSTANCE.eClass();
> EcorePackage.eINSTANCE.eClass();
>
> // global registratin
>
> EPackage.Registry.INSTANCE.put(XtextFactory.eINSTANCE.getEPackage().getNsURI(),
> XtextFactory.eINSTANCE.getEPackage());
>
> EPackage.Registry.INSTANCE.put(EcoreFactory.eINSTANCE.getEPackage().getNsURI(),
> EcoreFactory.eINSTANCE.getEPackage());
>
> URI ecoreUri =
> URI.createURI(EcoreFactory.eINSTANCE.getEPackage().getNsURI(), true);
> URI xtextUri =
> URI.createURI(XtextFactory.eINSTANCE.getEPackage().getNsURI(), true);
> Resource ecoreResource = resSet.getResource(ecoreUri, true);
> Resource xtextResource = resSet.getResource(xtextUri, true);
> //loading the resources
> ecoreResource.load(null);
> xtextResource.load(null);
> }
>
>
> The java.net.MalformedURLException: unknown protocol: classpath appears
> again, because I don't know how to change the EditingDomain's
> resourceSet to a XtextResourceSet to use the
> xtextResourceSet.setClasspathURIContext().
>
> Do you maybe know if it is even possible to change/modify an
> editingDomain's resourceSet?
>
> Thanks,
> Alex
|
|
|
|
|
|
|
|
|
|
|
Re: Open .xtext grammar in ModelEditor [message #1436842 is a reply to message #1436834] |
Fri, 03 October 2014 13:36 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Alex,
answers inline.
Am 03.10.14 15:23, schrieb Alexander R:
> Hello,
>
> Quote:
>> all required grammars (e.g.
>> Terminals.xtext) have to be on the classpath of your project
>
> -->On which project? The project where the grammar file is in? Or the
> project where the which implements the editor? (sorry for the stupid
> questions)
I was refering to the project with the grammar file that you want to open.
>
>
> Quote:
>> You do
>> have a dependency to org.eclipse.xtext from the project that is returned
>> by file.getProject()?
>
> -->Yes. It is a normal xtext project, with the grammar and all the
> generated packages. The dependencies are set for:
>
I see. Since it works with #getClass as the URI context, I'm assuming
there's something wrong somewhere in your code. Would it possible for
you to share the full class that contains the init logic for the editing
domain?
Regards,
Sebastian
>
> org.eclipse.xtext;visibility:=reexport,
> org.eclipse.xtext.xbase;resolution:=optional;visibility:=reexport,
> org.eclipse.xtext.generator;resolution:=optional,
> org.eclipse.xtext.util, org.eclipse.xtext.common.types,
>
>
> Thanks again for your time!
>
>
>
|
|
|
|
|
|
|
|
|
|
|