Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Xtext integration into Papyrus PopupEditor
Xtext integration into Papyrus PopupEditor [message #1384790] Mon, 02 June 2014 00:19 Go to next message
Davincho Huevada is currently offline Davincho HuevadaFriend
Messages: 7
Registered: June 2014
Junior Member
I am currently trying to integrate my Xtext grammar into the Papyrus Popup Editor.
There exists a document (http://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments/How-To/PapyrusDevelopperTutorial_OnXtext_v0%206_d2011-01-10.odt), which explains the necessary steps in detail. Unfortunately it is outdated and I am stuck at the step, where you have to implement your own methods "getTextToEdit" and "createPopupEditorHelper".
Do you have any running examples?
Cheers
Davincho

[Updated on: Mon, 02 June 2014 00:19]

Report message to a moderator

Re: Xtext integration into Papyrus PopupEditor [message #1384938 is a reply to message #1384790] Tue, 03 June 2014 08:53 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi Davincho,


We've changed the generic component in Luna. The principle is still really similar, but the class to extend and the methods to implement are slightly different.

The abstract editor class is now:

org.eclipse.papyrus.uml.xtext.integration.DefaultXtextDirectEditorConfiguration

You need to implement getTextToEdit(Object) and getParseCommand(EObject, EObject) (For model-to-text and text-to-model)

The last method to implement is getInjector(), which returns the Injector associated to your x-text grammar

The extension point to use is still the same. You can find an example in this class:

org.eclipse.papyrus.uml.textedit.property.xtext.ui.contributions.PropertyXtextDirectEditorConfiguration (Plugin: oep.uml.textedit.property.xtext.ui)


Regards,
Camille


Camille Letavernier
Re: Xtext integration into Papyrus PopupEditor [message #1385155 is a reply to message #1384938] Wed, 04 June 2014 16:07 Go to previous messageGo to next message
Davincho Huevada is currently offline Davincho HuevadaFriend
Messages: 7
Registered: June 2014
Junior Member
Hi Camille,
Thanks for your fast reply. After updating my Papyrus to the latest version, I got the Plugin with the necessary class in it (org.eclipse.papyrus.uml.xtext.integration.DefaultXtextDirectEditorConfiguration).
Now, after implementing the three methods, do I have to do something else in order to display the new editor as a choice in the context menu (see screenshot attached)?

index.php/fa/18211/0/
  • Attachment: shoty.png
    (Size: 15.65KB, Downloaded 1149 times)

[Updated on: Wed, 04 June 2014 16:07]

Report message to a moderator

Re: Xtext integration into Papyrus PopupEditor [message #1385399 is a reply to message #1385155] Fri, 06 June 2014 07:58 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi,

The extension point is still exactly the same, and works in the same way. So, you just need to fill:

org.eclipse.papyrus.extensionpoints.editor.DirectEditor

And specify the Editor Class and the object to edit:

 <extension
         point="org.eclipse.papyrus.extensionpoints.editors.DirectEditor">
      <DirectEditor
            language="Advanced Property Textual Editor"
            objectToEdit="org.eclipse.uml2.uml.Property">
         <popupeditor
               editorConfiguration="org.eclipse.papyrus.uml.textedit.property.xtext.ui.contributions.PropertyXtextDirectEditorConfiguration">
         </popupeditor>
      </DirectEditor>
   </extension>


Camille Letavernier
Re: Xtext integration into Papyrus PopupEditor [message #1385424 is a reply to message #1385399] Fri, 06 June 2014 10:55 Go to previous messageGo to next message
Davincho Huevada is currently offline Davincho HuevadaFriend
Messages: 7
Registered: June 2014
Junior Member
Hi,
Still have got no success with the integration.
Just for my general understanding, if I take your code and change it the following way:

<extension
         point="org.eclipse.papyrus.extensionpoints.editors.DirectEditor">
      <DirectEditor
            language="My Personal Editor"
            objectToEdit="org.eclipse.uml2.uml.Constraint">
         <popupeditor
               editorConfiguration="org.eclipse.papyrus.uml.textedit.property.xtext.ui.contributions.PropertyXtextDirectEditorConfiguration">
         </popupeditor>
      </DirectEditor>
   </extension>


After exporting my Xtext project (for example org.example.dsl) and org.example.dsl.ui as plugins and restarting Eclipse, my editor should be visible under Window -> Preferences -> Papyrus -> Embedded Editors -> Elements to edit (selecting org.eclipse.uml2.uml.Constraint) with the name "My Personal Editor".
Correct, or are there any steps missing?

Cheers
Re: Xtext integration into Papyrus PopupEditor [message #1385425 is a reply to message #1385424] Fri, 06 June 2014 11:02 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi,

Quote:
After exporting my Xtext project (for example org.example.dsl) and org.example.dsl.ui as plugins and restarting Eclipse, my editor should be visible under Window -> Preferences -> Papyrus -> Embedded Editors -> Elements to edit (selecting org.eclipse.uml2.uml.Constraint) with the name "My Personal Editor".
Correct, or are there any steps missing?


This should be sufficient. Is there an exception in your error log? Is everything properly included in your "build.properties" file? (Especially the plugin.xml)

Usually, before exporting your plug-in, you should test it with Run as > Eclipse Application, which avoids mistakes (And the console gives useful info as well, when anything goes wrong)

Camille


Camille Letavernier
Re: Xtext integration into Papyrus PopupEditor [message #1385631 is a reply to message #1385425] Tue, 10 June 2014 07:38 Go to previous messageGo to next message
Davincho Huevada is currently offline Davincho HuevadaFriend
Messages: 7
Registered: June 2014
Junior Member
Camille Letavernier wrote on Fri, 06 June 2014 07:02
Hi,

This should be sufficient. Is there an exception in your error log? Is everything properly included in your "build.properties" file? (Especially the plugin.xml)

Usually, before exporting your plug-in, you should test it with Run as > Eclipse Application, which avoids mistakes (And the console gives useful info as well, when anything goes wrong)



Everything compiles without any error - I can start a new Eclipse Application and use my Xtext grammar. Unfortunately I still cannot see my registered editor. Apparently Papyrus does not recognize that I am using one of its extension points.
Cheers


Re: Xtext integration into Papyrus PopupEditor [message #1387086 is a reply to message #1385631] Tue, 24 June 2014 02:57 Go to previous messageGo to next message
Davincho Huevada is currently offline Davincho HuevadaFriend
Messages: 7
Registered: June 2014
Junior Member
Okay, now at least I am getting a NullPointerException that means my Plugin gets loaded.

I debugged the Exception and realized that in the class DirectEditorExtensionPoint the following code:

protected static IPopupEditorConfiguration getPopupDirectEditorConfigurationClass(IConfigurationElement configElement)
  {
    IPopupEditorConfiguration configuration = null;
    try {
      for (IConfigurationElement childConfigElement : configElement.getChildren("popupeditor")) {
        for (String attname : childConfigElement.getAttributeNames()) {
          Activator.log.debug(attname);
        }

        Object config = childConfigElement.createExecutableExtension("editorConfiguration");
        if ((config instanceof IPopupEditorConfiguration))
          configuration = (IPopupEditorConfiguration)config;
      }
    }
    catch (CoreException e)
    {
      Activator.log(e);
      configuration = null;
    }
    return configuration;
  }

requires that the class, which is used for configuration, has to implement IPopupEditorConfiguration, as otherwise configuration would be null.

Is this correct?

My class defintion used for configuration looks like that:

public class ScalingPopupEditor extends org.eclipse.papyrus.uml.xtext.integration.DefaultXtextDirectEditorConfiguration implements IPopupEditorConfiguration


Cheers
Davincho

[Updated on: Tue, 24 June 2014 04:40]

Report message to a moderator

Re: Xtext integration into Papyrus PopupEditor [message #1451244 is a reply to message #1384938] Thu, 23 October 2014 14:39 Go to previous messageGo to next message
Miriam Hundemer is currently offline Miriam HundemerFriend
Messages: 12
Registered: February 2013
Junior Member
Hi Camille,

I managed to integrate my Xtext grammar into Papyrus with the help of your post and everything works just fine Smile

In my project I am using the Xtext editor to edit text in an UML comment in a UML class diagram. What I would love to do now is display the code highlighting provided by the Xtext editor in my UML comment.
Because right now, as soon as I save the text I composed in the Xtext editor, all code highlighting is gone in the UML comment and the text is just a simple string.

My research so far provided me only with hints as to how to alter and extend the code highlighting provided by xtext Sad But I simply want to display the given standard code highlighting in my UML comment. Is there any way to do this?
The problem seems to be that right now all the information I get from a parsed xtext object is a simple string without any additional information (like highlighting).
I could maybe write kind of my own parser and/or highlighter, but then I would have to provide knowledge about my xtext grammar for the code highlighting to be correct.

I really hope there is a simpler solution to this problem.


Thanks for any help.

Cheers Miriam
Re: Xtext integration into Papyrus PopupEditor [message #1451255 is a reply to message #1451244] Thu, 23 October 2014 15:02 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi Miriam,

That's currently pretty much impossible. The Comment supports HTML formatting, but this implies that Comment#body should contain HTML, which is probably incompatible with your own XText language.

Camille


Camille Letavernier
Re: Xtext integration into Papyrus PopupEditor [message #1451259 is a reply to message #1451255] Thu, 23 October 2014 15:05 Go to previous message
Miriam Hundemer is currently offline Miriam HundemerFriend
Messages: 12
Registered: February 2013
Junior Member
Hi Camille,

thank you very much for your fast reply. A pitty it doesn't work, but you saved me a lot of time searching around the internet Wink

I guess "normal" strings will have to do then.
Previous Topic:Papyrus C++ code generation
Next Topic:issue with applicable and applied stereotypes?
Goto Forum:
  


Current Time: Fri Mar 29 02:06:33 GMT 2024

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

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

Back to the top