Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Using ModifyListener in XtextEditor
Using ModifyListener in XtextEditor [message #723444] Thu, 08 September 2011 11:08 Go to next message
Eclipse UserFriend
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 11:12 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

have a look at the IAutoEditStrategy and its Xtext implementations.

Alex
Re: Using ModifyListener in XtextEditor [message #723472 is a reply to message #723446] Thu, 08 September 2011 12:03 Go to previous messageGo to next message
Eclipse UserFriend
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 05:23 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Using ModifyListener in XtextEditor [message #723755 is a reply to message #723727] Fri, 09 September 2011 07:16 Go to previous message
Eclipse UserFriend
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: Sun Jul 06 15:59:35 EDT 2025

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

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

Back to the top