Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Using ModifyListener in XtextEditor
Using ModifyListener in XtextEditor [message #723444] Thu, 08 September 2011 15:08 Go to next message
Vitaly Savickas is currently offline Vitaly SavickasFriend
Messages: 62
Registered: March 2010
Member
Hello,

is there a service in XtextEditor that is similar to standard modify listener? I need to modify keyboard input as it is typed (replace character combinations with other characters). I thought value converters can do the trick, but firstly, as I understand they are used to parse a string to a datatype, and secondly, when I've written one for an EString rule it didn't have any effect, though debugging shows it should be working.

Regards,
Vitaly
Re: Using ModifyListener in XtextEditor [message #723446 is a reply to message #723444] Thu, 08 September 2011 15:12 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

have a look at the IAutoEditStrategy and its Xtext implementations.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Using ModifyListener in XtextEditor [message #723472 is a reply to message #723446] Thu, 08 September 2011 16:03 Go to previous messageGo to next message
Vitaly Savickas is currently offline Vitaly SavickasFriend
Messages: 62
Registered: March 2010
Member
Thank you!

I guess this is what I need, I'll give it a go. The implementation of the strategies in default autoedit class isn't easy to understand though:)

But in case I need a value converter too, any guess why it has no effect? If I simply change a returned string, the result is still the same.

Regards,
Vitaly
Re: Using ModifyListener in XtextEditor [message #723727 is a reply to message #723472] Fri, 09 September 2011 09:23 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

the value converter is used only fpr "internal conversion", e.g. in the model file you have an escaped keyword (^key) but in the semantic model the value is key or the file contains the string 123 but in the model it is the number 123. So if, what you want is that the displayed string is different, you go for the IAutoEditStrategy and if you want adapted values in the semantic model (but no modification in the model file) you use value converters.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Using ModifyListener in XtextEditor [message #723755 is a reply to message #723727] Fri, 09 September 2011 11:16 Go to previous message
Vitaly Savickas is currently offline Vitaly SavickasFriend
Messages: 62
Registered: March 2010
Member
Thanks again. It seems I need an AutoEditStrategy then. But it's really hard to understand how it works. I am looking at the implementation of MultiLineTerminalsEditStrategy and cannot get a clue of what's going on. No comments, no description in javadoc. Is there any documentation on AutoEditStrategies?

My problem seems quite trivial - changing a specific character or set of characters to another character, but this must be context sensitive, not as a shortcut edit stragegy i.e. I only need this to get triggered within an EString rule, as well as to have some timing before substitution to check if next character entered contributes to a different shortcut.

Regards,
Vitaly
Previous Topic:XBase extension works! But only with manual classpath.
Next Topic:Using the reconciler programmatically
Goto Forum:
  


Current Time: Wed Sep 25 03:41:56 GMT 2024

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

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

Back to the top