Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Open .xtext grammar in ModelEditor
Open .xtext grammar in ModelEditor [message #1431314] Thu, 25 September 2014 14:11 Go to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi all,

I would like to know if it is possible to open a grammar file in a modeleditor even if
the file bases on other metamodels and uses the common terminals?


Here the case. I want to open this grammar file: (just a simple example)

// automatically generated by Xtext
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

import "http://de/ubt/ai1/medamodel/"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

Village returns Village:
	{Village}
	'Village'
	'{'
	('houses' '{' houses+=House ("," houses+=House)* '}')?
	('streets' '{' streets+=Street ("," streets+=Street)* '}')?
	'}';

House returns House:
	{House}
	'House'
	name=EString;

Street returns Street:
	{Street}
	'Street'
	name=EString
	'{'
	('number' number=EInt)?
	'}';

EString returns ecore::EString:
	STRING | ID;

EInt returns ecore::EInt:
	'-'? INT;



When I use the Sample Reflective Ecore Modeleditor I got the following exception:

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: java.net.MalformedURLException: unknown protocol: classpath
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
	at org.eclipse.xtext.xtext.XtextLinkingService.getUsedGrammar(XtextLinkingService.java:134)
	at org.eclipse.xtext.xtext.XtextLinkingService.getLinkedObjects(XtextLinkingService.java:90)
	at org.eclipse.xtext.linking.impl.Linker.getLinkedObject(Linker.java:209)
	at org.eclipse.xtext.linking.impl.Linker.ensureIsLinked(Linker.java:118)
	at org.eclipse.xtext.linking.impl.Linker.ensureLinked(Linker.java:67)
	at org.eclipse.xtext.linking.impl.Linker.ensureLinked(Linker.java:56)
	at org.eclipse.xtext.linking.impl.Linker.ensureModelLinked(Linker.java:231)
	at org.eclipse.xtext.linking.impl.Linker.doLinkModel(Linker.java:227)
	at org.eclipse.xtext.linking.impl.AbstractCleaningLinker.linkModel(AbstractCleaningLinker.java:43)
	at org.eclipse.xtext.xtext.XtextLinker.linkModel(XtextLinker.java:220)
	at org.eclipse.xtext.resource.XtextResource.doLinking(XtextResource.java:292)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLinking(LazyLinkingResource.java:88)
	at org.eclipse.xtext.xtext.GrammarResource.superDoLinking(GrammarResource.java:42)
	at org.eclipse.xtext.xtext.GrammarResource$LinkingTrigger.installDerivedState(GrammarResource.java:75)
	at org.eclipse.xtext.resource.DerivedStateAwareResource.installDerivedState(DerivedStateAwareResource.java:145)
	at org.eclipse.xtext.resource.DerivedStateAwareResource.getContents(DerivedStateAwareResource.java:48)
	at org.eclipse.xtext.xtext.GrammarResource.getErrors(GrammarResource.java:51)
	at org.eclipse.emf.ecore.presentation.EcoreEditor.analyzeResourceProblems(EcoreEditor.java:1287)
	at org.eclipse.emf.ecore.presentation.EcoreEditor.createModelGen(EcoreEditor.java:1169)
	at org.eclipse.emf.ecore.presentation.EcoreEditor.createModel(EcoreEditor.java:1257)
	at org.eclipse.emf.ecore.presentation.EcoreEditor.createPages(EcoreEditor.java:1326)
	at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:358)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:142)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:96)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:323)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:877)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:857)
	at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:119)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:333)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:254)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:102)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:71)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53)
	at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:949)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:633)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1147)
	at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer$1.handleEvent(LazyStackRenderer.java:65)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:41)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:180)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4688)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:205)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:80)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:58)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
	at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:171)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:576)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:543)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:619)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.bringToTop(PartServiceImpl.java:331)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1046)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3112)
	at org.eclipse.ui.internal.WorkbenchPage.access$21(WorkbenchPage.java:3034)
	at org.eclipse.ui.internal.WorkbenchPage$8.run(WorkbenchPage.java:3016)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3012)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2976)
	at org.eclipse.ui.actions.OpenWithMenu.openEditor(OpenWithMenu.java:338)
	at org.eclipse.ui.actions.OpenWithMenu$3.handleEvent(OpenWithMenu.java:216)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: java.net.MalformedURLException: unknown protocol: classpath
	at java.net.URL.<init>(URL.java:593)
	at java.net.URL.<init>(URL.java:483)
	at java.net.URL.<init>(URL.java:432)
	at org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.createInputStream(URIHandlerImpl.java:199)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:360)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1269)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	... 107 more



This occurs only when I import the terminals.

Any clue how I may solve this? (maybe in a selfmade editor?)

~Alex
Re: Open .xtext grammar in ModelEditor [message #1431367 is a reply to message #1431314] Thu, 25 September 2014 15:43 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Alex,

the grammar *.xtext file can usually not be opened in a model editor
because it still uses the discouraged classpath:/ protocol. Your
language's models (*.mydsl) can opened with the sample reflective model
editor, though.

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

Am 25.09.14 16:11, schrieb Alexander R:
> Hi all,
>
> I would like to know if it is possible to open a grammar file in a
> modeleditor even if
> the file bases on other metamodels and uses the common terminals?
>
> Here the case. I want to open this grammar file: (just a simple example)
>
>
> // automatically generated by Xtext
> grammar org.xtext.example.mydsl.MyDsl with
> org.eclipse.xtext.common.Terminals
>
> import "http://de/ubt/ai1/medamodel/"
> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>
> Village returns Village:
> {Village}
> 'Village'
> '{'
> ('houses' '{' houses+=House ("," houses+=House)* '}')?
> ('streets' '{' streets+=Street ("," streets+=Street)* '}')?
> '}';
>
> House returns House:
> {House}
> 'House'
> name=EString;
>
> Street returns Street:
> {Street}
> 'Street'
> name=EString
> '{'
> ('number' number=EInt)?
> '}';
>
> EString returns ecore::EString:
> STRING | ID;
>
> EInt returns ecore::EInt:
> '-'? INT;
>
>
>
> When I use the Sample Reflective Ecore Modeleditor I got the following
> exception:
>
>
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException:
> java.net.MalformedURLException: unknown protocol: classpath
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
>
> at
> org.eclipse.xtext.xtext.XtextLinkingService.getUsedGrammar(XtextLinkingService.java:134)
>
> at
> org.eclipse.xtext.xtext.XtextLinkingService.getLinkedObjects(XtextLinkingService.java:90)
>
> at
> org.eclipse.xtext.linking.impl.Linker.getLinkedObject(Linker.java:209)
> at
> org.eclipse.xtext.linking.impl.Linker.ensureIsLinked(Linker.java:118)
> at org.eclipse.xtext.linking.impl.Linker.ensureLinked(Linker.java:67)
> at org.eclipse.xtext.linking.impl.Linker.ensureLinked(Linker.java:56)
> at
> org.eclipse.xtext.linking.impl.Linker.ensureModelLinked(Linker.java:231)
> at org.eclipse.xtext.linking.impl.Linker.doLinkModel(Linker.java:227)
> at
> org.eclipse.xtext.linking.impl.AbstractCleaningLinker.linkModel(AbstractCleaningLinker.java:43)
>
> at org.eclipse.xtext.xtext.XtextLinker.linkModel(XtextLinker.java:220)
> at
> org.eclipse.xtext.resource.XtextResource.doLinking(XtextResource.java:292)
> at
> org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLinking(LazyLinkingResource.java:88)
>
> at
> org.eclipse.xtext.xtext.GrammarResource.superDoLinking(GrammarResource.java:42)
>
> at
> org.eclipse.xtext.xtext.GrammarResource$LinkingTrigger.installDerivedState(GrammarResource.java:75)
>
> at
> org.eclipse.xtext.resource.DerivedStateAwareResource.installDerivedState(DerivedStateAwareResource.java:145)
>
> at
> org.eclipse.xtext.resource.DerivedStateAwareResource.getContents(DerivedStateAwareResource.java:48)
>
> at
> org.eclipse.xtext.xtext.GrammarResource.getErrors(GrammarResource.java:51)
> at
> org.eclipse.emf.ecore.presentation.EcoreEditor.analyzeResourceProblems(EcoreEditor.java:1287)
>
> at
> org.eclipse.emf.ecore.presentation.EcoreEditor.createModelGen(EcoreEditor.java:1169)
>
> at
> org.eclipse.emf.ecore.presentation.EcoreEditor.createModel(EcoreEditor.java:1257)
>
> at
> org.eclipse.emf.ecore.presentation.EcoreEditor.createPages(EcoreEditor.java:1326)
>
> at
> org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:358)
>
> at
> org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:142)
>
> at
> org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:96)
>
> at
> org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:323)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> at java.lang.reflect.Method.invoke(Method.java:483)
> at
> org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
>
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:877)
>
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:857)
>
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:119)
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:333)
>
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:254)
> at
> org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
>
> at
> org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:102)
>
> at
> org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:71)
>
> at
> org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53)
>
> at
> org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:949)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:633)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700)
>
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685)
>
> at
> org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1147)
>
> at
> org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer$1.handleEvent(LazyStackRenderer.java:65)
>
> at
> org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:41)
>
> at
> org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:180)
> at
> org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
> at org.eclipse.swt.widgets.Display.syncExec(Display.java:4688)
> at
> org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:205)
>
> at
> org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
>
> at
> org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
>
> at
> org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
>
> at
> org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
>
> at
> org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
>
> at
> org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
>
> at
> org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
>
> at
> org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
>
> at
> org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
>
> at
> org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:80)
>
> at
> org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:58)
>
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
>
> at
> org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:171)
>
> at
> org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:576)
>
> at
> org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:543)
>
> at
> org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:619)
>
> at
> org.eclipse.e4.ui.internal.workbench.PartServiceImpl.bringToTop(PartServiceImpl.java:331)
>
> at
> org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1046)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3112)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.access$21(WorkbenchPage.java:3034)
> at
> org.eclipse.ui.internal.WorkbenchPage$8.run(WorkbenchPage.java:3016)
> at
> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3012)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2976)
> at
> org.eclipse.ui.actions.OpenWithMenu.openEditor(OpenWithMenu.java:338)
> at
> org.eclipse.ui.actions.OpenWithMenu$3.handleEvent(OpenWithMenu.java:216)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
> at
> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
>
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
>
> at
> org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
>
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
>
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
> at
> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> at java.lang.reflect.Method.invoke(Method.java:483)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
> Caused by: java.net.MalformedURLException: unknown protocol: classpath
> at java.net.URL.<init>(URL.java:593)
> at java.net.URL.<init>(URL.java:483)
> at java.net.URL.<init>(URL.java:432)
> at
> org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.createInputStream(URIHandlerImpl.java:199)
>
> at
> org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:360)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1269)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
>
> ... 107 more
>
>
>
> This occurs only when I import the terminals.
>
> Any clue how I may solve this? (maybe in a selfmade editor?)
>
> ~Alex
Re: Open .xtext grammar in ModelEditor [message #1431437 is a reply to message #1431367] Thu, 25 September 2014 17:44 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi,

this might be a problem.
Because I have to process the emf-models of the GRAMMAR (the real Xtext models, not the models written with xtext).
Is there maybe a way to resolve the references that use the discouraged classpath:/ protocol?
May it help if I serialize the .xtext files to .xmi files and then try to read them in an own editor by using a resourceset which contains
all necessary metamodels as a resource?

Any hints would be helpful!

~Alex
Re: Open .xtext grammar in ModelEditor [message #1431801 is a reply to message #1431437] Fri, 26 September 2014 06:54 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Am 25.09.14 19:44, schrieb Alexander R:
> Hi,
>
> this might be a problem. Because I have to process the emf-models of the
> GRAMMAR (the real Xtext models, not the models written with xtext). Is
> there maybe a way to resolve the references that use the discouraged
> classpath:/ protocol?
> May it help if I serialize the .xtext files to .xmi files and then try
> to read them in an own editor by using a resourceset which contains
> all necessary metamodels as a resource?
> Any hints would be helpful!
>
> ~Alex

You have to use an XtextResourceSet instead of a plain ResourceSet.
Ideally you also set the classpath URI context of that XtextResourceSet.
In standalone mode, this'd be a classloader, in Eclipse this is a
IJavaProject

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Open .xtext grammar in ModelEditor [message #1431824 is a reply to message #1431801] Fri, 26 September 2014 07:33 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi,

thanks for the hints!
I'll try it out with an editor that uses the XtextResourceSet to load the .xtext models,

Alex
Re: Open .xtext grammar in ModelEditor [message #1434571 is a reply to message #1431824] Tue, 30 September 2014 09:12 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
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 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
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 #1434915 is a reply to message #1434727] Tue, 30 September 2014 20:07 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi,

thanks for the hint! I've solved it this way:


ResourceSet xtextResourceSet = new XtextResourceSet();
		((XtextResourceSet) xtextResourceSet).addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
		// Create the editing domain with a special command stack.
		editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, xtextResourceSet);


But does the use of an XtextResourceSet limites anything or may I load and manage any EMF-Resources in it?

~Alex
Re: Open .xtext grammar in ModelEditor [message #1435223 is a reply to message #1434915] Wed, 01 October 2014 07:15 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Alex,

no, except for the added value of the possibility to resolve classpath
URIs, there are no known limitations.
Please note that you should configure the classpathURIContext of the
XtextResourceSet with the IProject of the currently edited resource.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Open .xtext grammar in ModelEditor [message #1435982 is a reply to message #1435223] Thu, 02 October 2014 08:09 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi,

thank you for your help. Setting the classpathURIContext is harder then I thought. I tried to locate the underlying resource of the editor to find the current IProject, but
at the time of initializeEditingDomain() all inputs are null. So this didn't work:

	try {
			((XtextResourceSet) xtextResourceSet).setClasspathURIContext(((FileEditorInput) getEditorInput()).getFile().getProject());
		} catch (Exception e) {
			e.printStackTrace();
		}


I will try to find out a good place in the generated Editor-class to set the setClasspathURIContext.


~Alex
Re: Open .xtext grammar in ModelEditor [message #1436639 is a reply to message #1435982] Fri, 03 October 2014 07:05 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
You can delay setting the classpathuricontext to when the data is about
to be loaded. This happens in the generated createModel method. Redefine
this method and set the classpathuricontext before calling
super.createModel.

Hallvard

On 02.10.14 10:09, Alexander R wrote:
> Hi,
>
> thank you for your help. Setting the classpathURIContext is harder then
> I thought. I tried to locate the underlying resource of the editor to
> find the current IProject, but at the time of initializeEditingDomain()
> all inputs are null. So this didn't work:
>
>
> try {
> ((XtextResourceSet)
> xtextResourceSet).setClasspathURIContext(((FileEditorInput)
> getEditorInput()).getFile().getProject());
> } catch (Exception e) {
> e.printStackTrace();
> }
>
>
> I will try to find out a good place in the generated Editor-class to set
> the setClasspathURIContext.
>
>
> ~Alex
Re: Open .xtext grammar in ModelEditor [message #1436812 is a reply to message #1436639] Fri, 03 October 2014 12:50 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi,

I tried out your hint and did the following:

public void createModel() {

		try {
			// set the classpath-uri-context of the resourceset of the
			// editingdomain

			IFile file = ((FileEditorInput) getEditorInput()).getFile();
			if (file != null) {
				XtextResourceSet set = (XtextResourceSet) editingDomain.getResourceSet();
				IProject project = file.getProject();
				
				set.setClasspathURIContext(project);
			}
		} catch (Exception e) {
			 
		}
...


But AFTER setting the setClasspathURIContext() by passing the IProject of the current edited resource, the references to Terminals.xtext may not be resolved. So it works fine if I don't set the setClasspathURIContext().

What am I doing wrong?

~Alex
Re: Open .xtext grammar in ModelEditor [message #1436821 is a reply to message #1436812] Fri, 03 October 2014 13:04 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
If you want to use the editor for a grammar, all required grammars (e.g.
Terminals.xtext) have to be on the classpath of your project. You do
have a dependency to org.eclipse.xtext from the project that is returned
by file.getProject()?

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Open .xtext grammar in ModelEditor [message #1436829 is a reply to message #1436812] Fri, 03 October 2014 13:15 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Works with:
 set.setClasspathURIContext(getClass());


Why?
Re: Open .xtext grammar in ModelEditor [message #1436834 is a reply to message #1436829] Fri, 03 October 2014 13:23 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
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)


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:

 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!


Re: Open .xtext grammar in ModelEditor [message #1436842 is a reply to message #1436834] Fri, 03 October 2014 13:36 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
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!
>
>
>
Re: Open .xtext grammar in ModelEditor [message #1436888 is a reply to message #1436842] Fri, 03 October 2014 15:09 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi,

sorry I don't think that I can share the code. Cause its an internal university project.
But it is basicly a generated EMF-Editor with some adjustment. The strange thing is, that also without setting the classpathcontext the Terminals.xtext grammar is found by the editor.
I don't know how, and why...
Re: Open .xtext grammar in ModelEditor [message #1437068 is a reply to message #1436888] Fri, 03 October 2014 21:23 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Am 03.10.14 17:09, schrieb Alexander R:
> I don't know how, and why...

It seems to me that you use a standalone configuration within Eclipse
but that's only a vague guess based on your descriptions. Hard to tell
without seeing the actual code. In standalone mode, it'll use a logic
based on classloaders. If no explicit classloader is given, the one from
the XtextResourceSet itself is used - which is the bundle loader that
can also see the Terminals.xtext. Just a coincidence, I'd say.
The crucial part is, that it'd be a possibly strange side effect, if you
configured standalone stuff by accident within Eclipse.

You should dig into the XtextResourceSetProvider to see how a resource
set is properly initialized from an IProject. Also please use an injected
@Inject Provider<XtextResourceSet> or ideally @Inject
XtextResourceSetProvider to init the resource set itself.

Best,
Sebastian
Re: Open .xtext grammar in ModelEditor [message #1438544 is a reply to message #1437068] Mon, 06 October 2014 07:19 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hello,

Quote:
It seems to me that you use a standalone configuration within Eclipse

How may I check this?
I may explain my scenario. I have some generated Editors which I have to adjust to read and process .xtext grammar. So I have changed the resourceset of the EditingDomain of the editor.
Then I start a second elicpse instance to check if the editor works. In this second runtime I have a xtextproject on which I try the editor.

What exactly means "Standalone-configuration"?

~Alex
Re: Open .xtext grammar in ModelEditor [message #1438551 is a reply to message #1438544] Mon, 06 October 2014 07:33 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Am 06.10.14 09:19, schrieb Alexander R:
> What exactly means "Standalone-configuration"?

Do you call the XtextStandaloneSetup somewhere?

A properly configured XtextResourceSet is best obtained from the
XtextResourceSetProvider but there you'd have to have the IProject
context available when you create the resource set. Don't know if that
fits into the lifecycle of your code / editor.

Regards,
Sebastian
Re: Open .xtext grammar in ModelEditor [message #1438571 is a reply to message #1438551] Mon, 06 October 2014 08:05 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
I never called a XtextStandaloneSetup in the editors code.
I've only add a dependency to
org.eclipse.xtext
.
And then initialized the XtextResourceSet "by hand" without any injection. But I will try out your hints!

Thanks a lot.

Alex

[Updated on: Mon, 06 October 2014 08:05]

Report message to a moderator

Re: Open .xtext grammar in ModelEditor [message #1438641 is a reply to message #1438571] Mon, 06 October 2014 09:59 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Maybe I should mentioned that the editor I am wirking with is NOT a Xtexteditor but only a modified "EMF-TreeEditor".
Is there even a way to inject a XtextResourceSetProvider in an own eclipse pluginproject? In my case a generated EMF Editor Pluginpoject?

~Alex
Re: Open .xtext grammar in ModelEditor [message #1438679 is a reply to message #1438641] Mon, 06 October 2014 10:56 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Am 06.10.14 11:59, schrieb Alexander R:
> Maybe I should mentioned that the editor I am wirking with is NOT a
> Xtexteditor but only a modified "EMF-TreeEditor".

You mentioned that already a few time within this thread.

> Is there even a way to inject a XtextResourceSetProvider in an own
> eclipse pluginproject? In my case a generated EMF Editor Pluginpoject?
>

Yes, there is. Please refer to the docs on dependency injection with
Xtext within Equinox:
https://www.eclipse.org/Xtext/documentation.html#equinoxSetup

Regards,
Sebastian

> ~Alex

--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Open .xtext grammar in ModelEditor [message #1438699 is a reply to message #1438679] Mon, 06 October 2014 11:32 Go to previous message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi,

I found a solution which seems to be right to me. The default IClasspathUriResolver for a XtextresourceSet was a ClassloaderClasspathUriResolver.
By adding a new instance of JdtClasspathUriResolver I could set the current ClasspathURIContext in the createModel() operation of the
generated EditorClass. Here the codesnippet:

        /*
          * @generated NOT
	 */
	public void createModel() {

		IProject thisProject = getProject();

		try {
                          // get current resource of the opend editor
			IFile file = ((FileEditorInput) getEditorInput()).getFile();
			if (file != null) {
				XtextResourceSet set = (XtextResourceSet) editingDomain.getResourceSet();
				IProject project = thisProject;			
				IJavaProject javaProject = JavaCore.create(project);
                             //set the resolver and the context
				set.setClasspathUriResolver(new JdtClasspathUriResolver());
				set.setClasspathURIContext(javaProject);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}


I debugged it and notices now, that the classpathuricontext is now set properly.

Thanks again for your help!

Alex


Previous Topic:Is a reference to an Enumeration Literal possible?
Next Topic:Reference some elements without them being on the classpath
Goto Forum:
  


Current Time: Tue Apr 23 17:59:52 GMT 2024

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

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

Back to the top