Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » edit Teneo-saved EMF Model in XText editor in RCP
edit Teneo-saved EMF Model in XText editor in RCP [message #1115780] Tue, 24 September 2013 11:18 Go to next message
Thomas Steinbach is currently offline Thomas Steinbach
Messages: 13
Registered: March 2013
Junior Member
Hello,

I ask you for help in the following situation.

What I have done until now:
- Data-Models are created with EMF and stored with Teneo in a database
- models are shown in a handcoded GEF-RCP
- the GEF-Editors for a specific model-object are opened with
workbenchPage.openEditor(new MyEditorInput(root), MyGEFEditor.editorID, false);

The problems are:
? all examples for opening an XText editor programmatically I have found are for models stored in files, but my models are stored in database, so in the CodeExample above "MyEditorInput" will not work
? since there is no XTextEditor generated I don't how to get the .editorID as in the code example

Thank you for your help,
Tom
Injecting throws errors [message #1116484 is a reply to message #1115780] Wed, 25 September 2013 10:08 Go to previous messageGo to next message
Thomas Steinbach is currently offline Thomas Steinbach
Messages: 13
Registered: March 2013
Junior Member
Hello,

I've found an example where the editor is created with injection.

So did the following:
- created the Hello-World example DSL from the xtext-tutorial
- created a simple ApplicationWindow with WindowBuilder (see code 1)
- got a bunch of errors (see code 2)

a simple ApplicationWindow, where I want to display the xtexteditor for the Hello-World example DSL:
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.xtext.resource.IResourceFactory;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.ui.editor.embedded.EmbeddedEditor;
import org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory;
import org.eclipse.xtext.ui.editor.embedded.IEditedResourceProvider;
import org.xtext.example.mydsl.MyDslStandaloneSetup;
import org.xtext.example.mydsl.ui.internal.MyDslActivator;

import com.google.inject.Inject;
import com.google.inject.Injector;

public class MainWindow {

	protected Shell shell;

	@Inject
	EmbeddedEditorFactory factory;
	
	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			MainWindow window = new MainWindow();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		createEditor();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	private void createEditor() {
		// TODO Auto-generated method stub
		IEditedResourceProvider resourceProvider = new IEditedResourceProvider() {
		    public XtextResource createResource() {
		        MyDslActivator activator = MyDslActivator.getInstance();
		        Injector injector = activator.getInjector(MyDslActivator.ORG_XTEXT_EXAMPLE_MYDSL_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.ORG_XTEXT_EXAMPLE_MYDSL_MYDSL);
		
		Injector injector = new MyDslStandaloneSetup().createInjector();
		
		injector.injectMembers(this);
		EmbeddedEditor embeddedEditor = factory.newEditor(resourceProvider).withParent(shell);
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setSize(450, 300);
		shell.setText("SWT Application");

	}

}


com.google.inject.ConfigurationException: Guice configuration errors:

1) No implementation for org.eclipse.xtext.parser.antlr.ITokenDefProvider annotated with @com.google.inject.name.Named(value=org.eclipse.xtext.ui.editor.contentassist.antlr.internal.Lexer.HIGHLIGHTING) was bound.
  while locating org.eclipse.xtext.parser.antlr.ITokenDefProvider annotated with @com.google.inject.name.Named(value=org.eclipse.xtext.ui.editor.contentassist.antlr.internal.Lexer.HIGHLIGHTING)
    for parameter 0 at org.eclipse.xtext.ui.editor.model.TokenTypeToStringMapper.setTokenDefProvider(Unknown Source)
  at org.eclipse.xtext.ui.editor.model.TokenTypeToStringMapper.setTokenDefProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.model.ITokenTypeToPartitionTypeMapper
    for field at org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration.partitionTypesMapper(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.sourceViewerConfigurationProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

2) No implementation for org.eclipse.jface.text.source.IAnnotationHover was bound.
  while locating com.google.inject.Provider<org.eclipse.jface.text.source.IAnnotationHover>
    for field at org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration.annotationHoverProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.sourceViewerConfigurationProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

3) No implementation for org.eclipse.xtext.ui.editor.contentassist.IContentAssistantFactory was bound.
  while locating org.eclipse.xtext.ui.editor.contentassist.IContentAssistantFactory
    for field at org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration.contentAssistantFactory(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.sourceViewerConfigurationProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

4) No implementation for org.eclipse.jface.text.presentation.IPresentationDamager was bound.
  while locating com.google.inject.Provider<org.eclipse.jface.text.presentation.IPresentationDamager>
    for field at org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration.damagerProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.sourceViewerConfigurationProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

5) No implementation for org.eclipse.jface.text.hyperlink.IHyperlinkDetector was bound.
  while locating org.eclipse.jface.text.hyperlink.IHyperlinkDetector
    for field at org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration.detector(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.sourceViewerConfigurationProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

6) No implementation for org.eclipse.xtext.ui.editor.autoedit.AbstractEditStrategyProvider was bound.
  while locating org.eclipse.xtext.ui.editor.autoedit.AbstractEditStrategyProvider
    for field at org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration.editStrategyProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.sourceViewerConfigurationProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

7) No implementation for org.eclipse.jface.text.reconciler.IReconciler was bound.
  while locating com.google.inject.Provider<org.eclipse.jface.text.reconciler.IReconciler>
    for field at org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration.reconcilerProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.sourceViewerConfigurationProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

8) No implementation for org.eclipse.jface.text.presentation.IPresentationRepairer was bound.
  while locating com.google.inject.Provider<org.eclipse.jface.text.presentation.IPresentationRepairer>
    for field at org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration.repairerProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.sourceViewerConfigurationProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

9) No implementation for org.eclipse.jface.text.ITextHover was bound.
  while locating com.google.inject.Provider<org.eclipse.jface.text.ITextHover>
    for field at org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration.textHoverProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.sourceViewerConfigurationProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

10) No implementation for org.eclipse.jface.text.source.ICharacterPairMatcher was bound.
  while locating org.eclipse.jface.text.source.ICharacterPairMatcher
    for field at org.eclipse.xtext.ui.editor.doubleClicking.LexerTokenAndCharacterPairAwareStrategy.characterPairMatcher(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.doubleClicking.LexerTokenAndCharacterPairAwareStrategy
    for field at org.eclipse.xtext.ui.editor.doubleClicking.DoubleClickStrategyProvider.defaultDoubleClickStrategy(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.doubleClicking.DoubleClickStrategyProvider
    for field at org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration.doubleClickStrategyProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.sourceViewerConfigurationProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

11) No implementation for org.eclipse.jface.text.source.ICharacterPairMatcher was bound.
  while locating org.eclipse.jface.text.source.ICharacterPairMatcher
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.characterPairMatcher(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

12) No implementation for org.eclipse.jface.text.IDocumentPartitioner was bound.
  while locating com.google.inject.Provider<org.eclipse.jface.text.IDocumentPartitioner>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.documentPartitionerProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

13) No implementation for org.eclipse.xtext.ui.editor.quickfix.IssueResolutionProvider was bound.
  while locating org.eclipse.xtext.ui.editor.quickfix.IssueResolutionProvider
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.issueResolutionProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

14) No implementation for org.eclipse.xtext.parser.antlr.Lexer annotated with @com.google.inject.name.Named(value=org.eclipse.xtext.ui.editor.contentassist.antlr.internal.Lexer.HIGHLIGHTING) was bound.
  while locating com.google.inject.Provider<org.eclipse.xtext.parser.antlr.Lexer> annotated with @com.google.inject.name.Named(value=org.eclipse.xtext.ui.editor.contentassist.antlr.internal.Lexer.HIGHLIGHTING)
    for field at org.eclipse.xtext.ui.editor.model.DocumentTokenSource.lexer(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.model.DocumentTokenSource
    for parameter 0 at org.eclipse.xtext.ui.editor.model.XtextDocument.<init>(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.model.XtextDocument>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.documentProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

15) No implementation for org.eclipse.xtext.ui.editor.quickfix.IssueResolutionProvider was bound.
  while locating org.eclipse.xtext.ui.editor.quickfix.IssueResolutionProvider
    for field at org.eclipse.xtext.ui.editor.quickfix.AbstractIssueResolutionProviderAdapter.resolutionProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.quickfix.XtextQuickAssistProcessor
    for parameter 0 at org.eclipse.xtext.ui.editor.quickfix.XtextQuickAssistAssistant.<init>(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.quickfix.XtextQuickAssistAssistant>
    for field at org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration.quickAssistAssistentProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.XtextSourceViewerConfiguration>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder.sourceViewerConfigurationProvider(Unknown Source)
  while locating com.google.inject.Provider<org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory$Builder>
    for field at org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory.builderProvider(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorFactory
    for field at play.MainWindow.factory(Unknown Source)
  while locating play.MainWindow

15 errors
	at com.google.inject.internal.InjectorImpl.getMembersInjector(InjectorImpl.java:952)
	at com.google.inject.internal.InjectorImpl.getMembersInjector(InjectorImpl.java:957)
	at com.google.inject.internal.InjectorImpl.injectMembers(InjectorImpl.java:943)
	at play.MainWindow.createEditor(MainWindow.java:83)
	at play.MainWindow.open(MainWindow.java:46)
	at play.MainWindow.main(MainWindow.java:33)



Anyone any ideas? :-/
Re: Injecting throws errors [message #1313560 is a reply to message #1116484] Thu, 24 April 2014 19:44 Go to previous messageGo to next message
Philip Makedonski is currently offline Philip Makedonski
Messages: 10
Registered: May 2013
Junior Member
It's been a while since this was asked, but I've been thinking about the same functionality for a while now, and when I finally got the time to try and implement following similar steps I got similar errors. Did you figure this out or is there someone who could perhaps offer a tip or two on what the best way to go about this would be?
Re: Injecting throws errors [message #1314042 is a reply to message #1313560] Fri, 25 April 2014 02:13 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6230
Registered: July 2009
Senior Member
HI,

where does your injector come from http://koehnlein.blogspot.de/2012/11/xtext-tip-how-do-i-get-guice-injector.html
Previous Topic:scoping, auto complete and validation
Next Topic:Horstmann style formatter
Goto Forum:
  


Current Time: Fri Aug 29 12:28:40 EDT 2014

Powered by FUDForum. Page generated in 0.02138 seconds