Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » extend the editor with popup menu(extend the editor with popup menu to add comments or so)
extend the editor with popup menu [message #866206] Mon, 30 April 2012 19:49 Go to next message
Mokhtar Abdu is currently offline Mokhtar AbduFriend
Messages: 104
Registered: November 2011
Senior Member
Hello,

i want to enable the user of my DSL right-click in some line and find an option like "good code" or "bad code". As a comment for example.

any help is appreciated. Thanks,
M.
Re: extend the editor with popup menu [message #866224 is a reply to message #866206] Mon, 30 April 2012 20:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13667
Registered: July 2009
Senior Member
Hi,

what is exactly your problem? you can have a look at DefaultRenameElementHandler as a starting(=copy & paste) point.

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: extend the editor with popup menu [message #866241 is a reply to message #866224] Mon, 30 April 2012 20:12 Go to previous messageGo to next message
Mokhtar Abdu is currently offline Mokhtar AbduFriend
Messages: 104
Registered: November 2011
Senior Member
Hi thank you for the answer. My problem is i want to have a popupmenu while editing the code of my new language, through which one can click "good" for example, then the comment "//good" would be inserted in the file where the cursor was active.
(i believe i am going the direction of plugin development but as xtext team were to be experienced with that also, i would appreciate any help in PDE also) Very Happy


Regards,
M
Re: extend the editor with popup menu [message #866251 is a reply to message #866241] Mon, 30 April 2012 20:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13667
Registered: July 2009
Senior Member
So,

here is what you have to do: google about eclipse command api and handlers and how you register them in a context menu.
then there is the task to actually implement the handler.
the code i gave you calls xtextdocument.readonly - you have to call xtextdocument.modify. or (depending on if you comments are implicite only) xtextdocument.replace

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 30 April 2012 20:38]

Report message to a moderator

Re: extend the editor with popup menu [message #866313 is a reply to message #866251] Mon, 30 April 2012 20:55 Go to previous messageGo to next message
Mokhtar Abdu is currently offline Mokhtar AbduFriend
Messages: 104
Registered: November 2011
Senior Member
thank you Christian, i will be trying this just as a plugin project first (not xtext) and hope to reach some success tonight Smile
Re: extend the editor with popup menu [message #866316 is a reply to message #866313] Mon, 30 April 2012 20:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13667
Registered: July 2009
Senior Member
Hi,

as i said: google is your friend: http://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: extend the editor with popup menu [message #866609 is a reply to message #866241] Tue, 01 May 2012 00:09 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2012-30-04 22:12, Xtexter Mising name wrote:
> Hi thank you for the answer. My problem is i want to have a popupmenu
> while editing the code of my new language, through which one can click
> "good" for example, then the comment "//good" would be inserted in the
> file where the cursor was active.
> (i believe i am going the direction of plugin development but as xtext
> team were to be experienced with that also, i would appreciate any help
> in PDE also) :d
>
If that is all you want to do the user can do things like that using
templates.

- henrik
Re: extend the editor with popup menu [message #867624 is a reply to message #866609] Tue, 01 May 2012 11:46 Go to previous message
Mokhtar Abdu is currently offline Mokhtar AbduFriend
Messages: 104
Registered: November 2011
Senior Member
thank you Henrik, it turns out that i will have to do plugin development. As a first use case to extend the editor (java text editor) with this popup menu option. I was just tempted by xtext as i was doing a project using this framework. So i knew that you here guys are very very experienced with plugins.

Regards,
M
Previous Topic:Modifying a file that's not open in an editor?
Next Topic:How to unit test global scoping
Goto Forum:
  


Current Time: Fri Dec 04 08:54:47 GMT 2020

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

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

Back to the top