Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » xtext editor activator problem(xtext editor activator problem)
xtext editor activator problem [message #1735248] Thu, 16 June 2016 15:26 Go to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Hi,

How to capture the event when I click on save button in xtext editor?
Re: xtext editor activator problem [message #1735250 is a reply to message #1735248] Thu, 16 June 2016 15:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
have a look at org.eclipse.xtext.ui.editor.IXtextEditorCallback

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext editor activator problem [message #1735252 is a reply to message #1735250] Thu, 16 June 2016 15:59 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Oh thank you I was looking in AbstractDirtyStateAwareEditorCallback
Re: xtext editor activator problem [message #1735253 is a reply to message #1735252] Thu, 16 June 2016 16:08 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
I have written callback like this:

class JPLEditorCallback implements IXtextEditorCallback {

override afterCreatePartControl(XtextEditor editor) {
throw new UnsupportedOperationException("TODO: auto-generated method stub")
}

override afterSave(XtextEditor editor) {
println("After save is called #####################")
}

override afterSetInput(XtextEditor xtextEditor) {
throw new UnsupportedOperationException("TODO: auto-generated method stub")
}

override beforeDispose(XtextEditor editor) {
throw new UnsupportedOperationException("TODO: auto-generated method stub")
}

override beforeSetInput(XtextEditor xtextEditor) {
throw new UnsupportedOperationException("TODO: auto-generated method stub")
}

override onValidateEditorInputState(XtextEditor editor) {
throw new UnsupportedOperationException("TODO: auto-generated method stub")
}
}

How to bind this in ui module?
Re: xtext editor activator problem [message #1735256 is a reply to message #1735253] Thu, 16 June 2016 16:11 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
I have written like this

binder.bind(IXtextEditorCallback).annotatedWith(Names.named("JPLEditorCallback")).to(JPLEditorCallback);
Re: xtext editor activator problem [message #1735258 is a reply to message #1735256] Thu, 16 June 2016 16:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
simply create a configure method with an arbitrary configure<YourChoice> name

public void configureMyXtextEditorCallback(Binder binder) {
binder.bind(IXtextEditorCallback.class).annotatedWith(Names.named("dontcare")).to(DummyCallback.class);
}



and make sure onValidateEditorInputState returns true


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext editor activator problem [message #1735269 is a reply to message #1735258] Thu, 16 June 2016 17:24 Go to previous messageGo to next message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Yes I did it. but when I change something and change I am not getting anything inside afterSave method!
Re: xtext editor activator problem [message #1735271 is a reply to message #1735269] Thu, 16 June 2016 18:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext editor activator problem [message #1735400 is a reply to message #1735271] Sat, 18 June 2016 11:40 Go to previous message
Sachin Samaram is currently offline Sachin SamaramFriend
Messages: 271
Registered: April 2016
Senior Member
Yes it is working. Thanks
Previous Topic:Scoping the same EObject in an EObject in two contexts
Next Topic:Xtext error while creating file in xtext editor
Goto Forum:
  


Current Time: Tue Apr 23 11:42:54 GMT 2024

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

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

Back to the top