Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Action for a context menu on XtextEditor
Action for a context menu on XtextEditor [message #1403378] Wed, 23 July 2014 11:13 Go to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi everyone,

I am trying to implement a pop-up menu with an action for any kind of XtextEditors.
My plugin-configuration looks like this:

<plugin>
   <extension
         id=" Xtext Action"
         name="Xtext Action menu"
         point="org.eclipse.ui.popupMenus">
      <viewerContribution
            id="simple.editor.action.viewerContribution1"
            targetID="#TextEditorContext">
         <visibility>
            <objectClass
                  name="org.eclipse.jface.text.ITextSelection">
            </objectClass>
         </visibility>
         <action
               class="simple.editor.action.Action1"
               id="simple.editor.action.action1"
               label="Annotate xtext element"
               menubarPath="additions">
         </action>
      </viewerContribution>
   </extension>

</plugin>


The pop-up menu works fine, but only on every kind of texteditor (and not only for XtextEditors) (see : targetID="#TextEditorContext"). Is there maybe a targetID for only XtextEditors? I explored the XtextEditor in the runtime-workbench and found the following informations:

https://dl.dropboxusercontent.com/u/18688378/eclipseCoding/ids/xtexteditor.jpg

Maybe someone has any ideas how to solve this?

~Alex

[Updated on: Wed, 23 July 2014 15:20]

Report message to a moderator

Re: Action for a context menu on XtextEditor [message #1403416 is a reply to message #1403378] Wed, 23 July 2014 14:24 Go to previous messageGo to next message
Thomas Fritsch is currently offline Thomas FritschFriend
Messages: 28
Registered: April 2013
Location: Germany
Junior Member
Hi,

what happens if you use
targetID="org.eclipse.xtext.example.domainmodel.Domainmodel.EditorContext"
instead of
targetID="#TextEditorContext"
in your plugin.xml ?

~Thomas
Re: Action for a context menu on XtextEditor [message #1403421 is a reply to message #1403378] Wed, 23 July 2014 15:19 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi,

that's not the point. I want that the popup menu appears in EVERY XtextEditor for EVERY kind of DSL, wich is written in Xtext. Not for a specific XtextEditor, but for every XtextEditor.

To answer your question:
The popup menu would appear only in the editor of this specific Domainmodel-DSL.

~Alex
Re: Action for a context menu on XtextEditor [message #1403436 is a reply to message #1403421] Wed, 23 July 2014 16:14 Go to previous messageGo to next message
Thomas Fritsch is currently offline Thomas FritschFriend
Messages: 28
Registered: April 2013
Location: Germany
Junior Member
Ok, sorry for my misunderstanding.

To your original question:
I think it boils down to registering a new context menu id (in addition to "#TextEditorContext" and "#AbstractTextEditorContext") to a subclass of XtextEditor (or the XtextEditor itself).
Something similar to what is done in class org.eclipse.ui.texteditor.AbstractTextEditor in method createPartControl(Composite):
getEditorSite().registerContextMenu("#XtextEditorContext", ...);
But I must admit, I'm running out of knowledge here.

Btw: Thanks for pointing out the Plug-in Selection Spy. I wish I found this tool earlier.

~Thomas
Re: Action for a context menu on XtextEditor [message #1802559 is a reply to message #1403436] Mon, 11 February 2019 21:12 Go to previous message
Dat Nguyen is currently offline Dat NguyenFriend
Messages: 34
Registered: July 2014
Member
Hi Alexander,
Can you share with me the content of the class Action1?

[Updated on: Mon, 11 February 2019 21:12]

Report message to a moderator

Previous Topic:Loading classes in Xbase-based DSL with interpreter
Next Topic:Cross reference problem with rename element
Goto Forum:
  


Current Time: Thu Aug 22 06:51:51 GMT 2019

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

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

Back to the top