Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Multipage Editor with Xtext(Using the xtext editor in multipage usecase)
Multipage Editor with Xtext [message #894444] Mon, 09 July 2012 09:25 Go to next message
Maxime D is currently offline Maxime DFriend
Messages: 27
Registered: June 2012
Junior Member
I would like to use my Xtext editor in a multi-page editor (created with the wizard through Eclipse RCP).

In fact, I'd like to know how to call my Xtext editor in my multi-page one.
I know where all my ui stuff is in my project but I can't find the right class.

I need to call it as :

XtextEditor myXtextEditor = new XtextEditor();


Anyone has infos about this ?

I also saw that there's an EmbeddedEditor object in the Xtext Javadoc, but there's no documentation on it and I can't find any information through the web about it.

Thanks.
Re: Multipage Editor with Xtext [message #894606 is a reply to message #894444] Mon, 09 July 2012 19:33 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 657
Registered: July 2009
Senior Member
The class is correct, but you have to create the XtextEditor using the
Google Guice Injector of your language.

Usually you do this by creating some anchor class (e.g. your multi-page
editor) that's registered in the plugin.xml with the
ExecutableExtensionFactory of you language and have all needed
properties injected (recursively) using the @Inject annotation.

See
http://www.eclipse.org/Xtext/documentation.html##equinoxSetup
for details, or have a look at how the UI plug-in of your language
registers the editor.

An uglier alternative is to obtain the injector from the Activator of
your language's UI plug-in and call

injector.getInstance(XtextEditor.class)

to create the editor.

Am 09.07.12 11:25, schrieb Maxime D:
> I would like to use my Xtext editor in a multi-page editor (created with
> the wizard through Eclipse RCP).
>
> In fact, I'd like to know how to call my Xtext editor in my multi-page one.
> I know where all my ui stuff is in my project but I can't find the right
> class.
>
> I need to call it as :
>
>
> XtextEditor myXtextEditor = new XtextEditor();
>
>
> Anyone has infos about this ?
>
> I also saw that there's an EmbeddedEditor object in the Xtext Javadoc,
> but there's no documentation on it and I can't find any information
> through the web about it.
>
> Thanks.


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Multipage Editor with Xtext [message #894808 is a reply to message #894606] Tue, 10 July 2012 15:25 Go to previous messageGo to next message
Maxime D is currently offline Maxime DFriend
Messages: 27
Registered: June 2012
Junior Member
Thank you for your response.

I tried the uglier way with injector but unfortunately it doesn't work for me.

For the official alternative, I already saw this possibility but I thought it was not possible for my case.
I have some questions about it.

In my multi-page editor project I have the following extension :
 <extension
         point="org.eclipse.ui.editors">
      <editor
            name="Sample Multi-page Editor"
            extensions="mpe"
            icon="icons/sample.gif"
            contributorClass="multieditor.editors.MultiPageEditorContributor"
            class="multieditor.editors.MultiPageEditor"
            id="multieditor.editors.MultiPageEditor">
      </editor>
  </extension>


And here I implement the MultiPageEditor class to create different tabs, for example.

I read your link, so I guess I have to write a new extension in my plug-in as :

   
 <extension point="org.eclipse.ui.editors">
    <editor
    class="<MyDsl>ExecutableExtensionFactory:
    org.eclipse.xtext.ui.editor.XtextEditor"
    contributorClass=
    "org.eclipse.ui.editors.text.TextEditorActionContributor"
    default="true"
    extensions="mydsl"
    id="org.eclipse.xtext.example.MyDsl"
    name="MyDsl Editor">
    </editor>
  </extension>



But the thing I don't understand is how can I use it after this. I see the @Inject annotation but I can't see how to use it in this case.

In fact, my use case is to create a dsl editor for my language with 2 tabs (like multi-page editor). I already finish my dsl editor with Xtext (great framework by the way) and I would like to create a second tab in this one.

And yes I'm quite new to Xtext, so any ints would be helpful, thanks Smile
Re: Multipage Editor with Xtext [message #895033 is a reply to message #894808] Wed, 11 July 2012 13:22 Go to previous messageGo to next message
Maxime D is currently offline Maxime DFriend
Messages: 27
Registered: June 2012
Junior Member
I found a previous thread about this, I'll try with the example provided in :

http://www.eclipse.org/forums/index.php/m/876556/

Re: Multipage Editor with Xtext [message #895078 is a reply to message #895033] Wed, 11 July 2012 15:44 Go to previous messageGo to next message
Maxime D is currently offline Maxime DFriend
Messages: 27
Registered: June 2012
Junior Member
Ok I found a solution, I don't know if this is the best way but it works.
I post here some lines, maybe it will help someone out there.

Injector myInjector = MyModelActivator.getInstance().getInjector(
					 "org.my.package.MyModel");
xtextEditor = myInjector.getInstance(XtextEditor.class);


I put this code in a method called createPageX(), on my multi-page editor project created with the wizard.
Re: Multipage Editor with Xtext [message #895261 is a reply to message #895078] Thu, 12 July 2012 09:37 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 657
Registered: July 2009
Senior Member
Am 11.07.12 17:44, schrieb Maxime D:
> Ok I found a solution, I don't know if this is the best way but it works.
> I post here some lines, maybe it will help someone out there.
>
>
> Injector myInjector = MyModelActivator.getInstance().getInjector(
> "org.my.package.MyModel");
> xtextEditor = myInjector.getInstance(XtextEditor.class);
>
>
> I put this code in a method called createPageX(), on my multi-page
> editor project created with the wizard.

Looks like my second proposal ;-)

--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Multipage Editor with Xtext [message #895297 is a reply to message #895261] Thu, 12 July 2012 11:57 Go to previous messageGo to next message
Maxime D is currently offline Maxime DFriend
Messages: 27
Registered: June 2012
Junior Member
Yes indeed. Thank you Wink
Re: Multipage Editor with Xtext [message #895378 is a reply to message #894444] Thu, 12 July 2012 15:47 Go to previous messageGo to next message
Maxime D is currently offline Maxime DFriend
Messages: 27
Registered: June 2012
Junior Member
By the way, I got an issue with the Outline View with this method.
In the multi-page editor, it says that "An Outline view is not available".

As I called my XtextEditor, did the outline view is automatically called either ?
Re: Multipage Editor with Xtext [message #895383 is a reply to message #895378] Thu, 12 July 2012 15:59 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 2936
Registered: July 2009
Senior Member
Your Multipage Editor has either to be adaptable to the
(Xtext-?)OutlineView or the Xtext editor. I'm not 100% sure. But it's
pretty basic Eclipse editor API and I sure you'll figure that out in one
newsgroup / forum or another.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 12.07.12 17:48, schrieb Maxime D:
> By the way, I got an issue with the Outline View with this method.
> In the multi-page editor, it says that "An Outline view is not available".
>
> As I called my XtextEditor, did the outline view is automatically called
> either ?
Re: Multipage Editor with Xtext [message #895468 is a reply to message #895383] Fri, 13 July 2012 07:32 Go to previous messageGo to next message
Maxime D is currently offline Maxime DFriend
Messages: 27
Registered: June 2012
Junior Member
Thank you for your response.

Indeed I talk about my Xtext OutlineView. So I guess I have to personalize the standard outline of multi-page editor in order to have the same OutlineView as a simple Xtext editor.
Re: Multipage Editor with Xtext [message #927160 is a reply to message #895468] Sat, 29 September 2012 10:16 Go to previous message
Stefano Cottafavi is currently offline Stefano CottafaviFriend
Messages: 53
Registered: July 2009
Member
Hi,
I managed to get it

http://wiki.eclipse.org/FAQ_How_do_I_create_an_Outline_view_for_my_own_language_editor%3F

so as per the eclipse FAQ I simply added this to my MPE


@Inject
OutlinePaje outlinePage;

@Inject
XtextEditor xtextEditor;

@Override
public Object getAdapter(Class adapter) {
	
 if (IContentOutlinePage.class.equals(adapter)) {
    
    outlinePage.setSourceViewer(
        xtextEditor.getInternalSourceViewer());

    return outlinePage;
 }
 return super.getAdapter(adapter);
		
}



I can appreciate the power of injection, now.

cheers
Ste

[Updated on: Sat, 29 September 2012 13:35]

Report message to a moderator

Previous Topic:Reference ecore model elements from Xtext based DSLs
Next Topic:Code completion for Java imports
Goto Forum:
  


Current Time: Sun Nov 23 14:48:25 GMT 2014

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

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