Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Parse Xtext Editor Contents inside CustomEditor
Parse Xtext Editor Contents inside CustomEditor [message #1386101] Fri, 13 June 2014 12:31 Go to next message
Kunal Khaware is currently offline Kunal KhawareFriend
Messages: 41
Registered: December 2013
Location: Hyderabad,India
Member

Hi,
I have created a CustomEditor which xtends XtextEditor and wants to parse the contents of Editor inside the doSave method.Below is my code snippet:

public class CustomEditor extends XtextEditor {
	
	public void init(IEditorSite site, IEditorInput editorInput) {
		
			super.init(site, editorInput);
			
			
		
	}
	@Override
	public void doSave(IProgressMonitor progressMonitor) {
		super.doSave(progressMonitor);
		
		
		
	}



I don't have Resource class Object to get all the contents,similarly how it does in doGenerate Method of Generator Class.

Any thoughts how to do this

Cheers

Kunal
Re: Parse Xtext Editor Contents inside CustomEditor [message #1386107 is a reply to message #1386101] Fri, 13 June 2014 12:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

you can ask an XtextEdior for its IXtextDocument. IXtextDocument implements IReadAccess<XtextResource>

thus you can

xtextEditor.getDocument().readOnly(new IUnitOfWork<Boolean, XtextResource>() {

			public Boolean exec(XtextResource state) throws Exception {
				// work with resource here
				return true;
			}
			
		});

http://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Parse Xtext Editor Contents inside CustomEditor [message #1386109 is a reply to message #1386107] Fri, 13 June 2014 12:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
btw what is the reason to do this not inside the IGenerator or a Customization of BuilderParticipant

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 13 June 2014 12:42]

Report message to a moderator

Re: Parse Xtext Editor Contents inside CustomEditor [message #1386171 is a reply to message #1386109] Sat, 14 June 2014 04:08 Go to previous message
Kunal Khaware is currently offline Kunal KhawareFriend
Messages: 41
Registered: December 2013
Location: Hyderabad,India
Member

I want to perform business logic whenever the content in Editor is changed and save is performed.The Generator runs each time and would impact the performance of the business logic , so I don't want to parse the contents inside IGenerator, instead I want to do inside doSave() method of my Custom Editor
Previous Topic:Specific cross-reference
Next Topic:2.6.1 released
Goto Forum:
  


Current Time: Fri Mar 29 11:31:38 GMT 2024

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

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

Back to the top