Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext-enabled TextArea(Xtext Editor inside a TextArea )
Xtext-enabled TextArea [message #1080744] Tue, 06 August 2013 10:31 Go to next message
Priya Sabut is currently offline Priya SabutFriend
Messages: 41
Registered: September 2012
Member
Hi All,
I have a usecase where I will be providing my dsl in a textarea(SWT Text control) embedded into an Editor in my eclipse plug-in. I want to use Xtext's feature of Syntax Highlighting, validation, code completion etc.

Is there a way to do this ?

Regards,
Priya
Re: Xtext-enabled TextArea [message #1080759 is a reply to message #1080744] Tue, 06 August 2013 10:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

yes searching for EmbeddedEditorFactory will help.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext-enabled TextArea [message #1080796 is a reply to message #1080759] Tue, 06 August 2013 11:38 Go to previous messageGo to next message
Priya Sabut is currently offline Priya SabutFriend
Messages: 41
Registered: September 2012
Member
Hi Christian,
I did search for EmbeddedEditorFactory, but could not proceed!

Would you please share some more information to start with ? Any document an post will be helpful.

Regards,
Priya
Re: Xtext-enabled TextArea [message #1080800 is a reply to message #1080796] Tue, 06 August 2013 11:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
sorry i dont know any specific document.
you may dive into https://github.com/cdietrich/mql (but you have to look what you can use yourself)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext-enabled TextArea [message #1080808 is a reply to message #1080796] Tue, 06 August 2013 11:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
So you couldn't find
http://download.eclipse.org/modeling/tmf/xtext/javadoc/2.4/org/eclipse/xtext/ui/editor/embedded/EmbeddedEditorFactory.html

On 06/08/2013 1:38 PM, Priya Sabut wrote:
> Hi Christian,
> I did search for EmbeddedEditorFactory, but could not proceed!
>
> Would you please share some more information to start with ? Any
> document an post will be helpful.
>
> Regards,
> Priya


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Xtext-enabled TextArea [message #1080811 is a reply to message #1080808] Tue, 06 August 2013 11:53 Go to previous messageGo to next message
Priya Sabut is currently offline Priya SabutFriend
Messages: 41
Registered: September 2012
Member
Hi Ed,
I found the link you mentioned but how to do with it! I am very new to this. I am wondering from where will I start ? How and where will I use this class ? I am completely blank Sad

Thanks & Regards,
Priya
Re: Xtext-enabled TextArea [message #1081650 is a reply to message #1080811] Wed, 07 August 2013 14:00 Go to previous messageGo to next message
Priya Sabut is currently offline Priya SabutFriend
Messages: 41
Registered: September 2012
Member
Any help please ?

Regards,
Priya
Re: Xtext-enabled TextArea [message #1081653 is a reply to message #1081650] Wed, 07 August 2013 14:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Did you have a look at my code?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext-enabled TextArea [message #1081814 is a reply to message #1081653] Wed, 07 August 2013 18:30 Go to previous messageGo to next message
Priya Sabut is currently offline Priya SabutFriend
Messages: 41
Registered: September 2012
Member
Hi Christian,
I got the code pointed by you. There were some errors, when I tried to 'Generate Xtext Artifacts', the import rule was conflicting with some other rule. Then I changes the multiplicity of import from * to + , then it compiled fine.

Now I wonder, what the code is doing. I saw the example project, it has three dsl files. Can you please explain a little what the behavior is ? How should I know what the project is providing ?

When I open the .mql dsl, it has some methods and all, but my requirement is how can I make an swt textarea to be xtext-enabled ? I mean instead of using editor provided by xtext, I will enter my language into the textarea and the textare should provide me all the editor functionality(like syntax checking, code completion etc...). Is your project doing this ? If yes, could you please tell me the steps- how to test/use the functionality written into the plug-in ?

Regards,
Priya
Re: Xtext-enabled TextArea [message #1081834 is a reply to message #1081814] Wed, 07 August 2013 19:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi there is a view called modelquerylanguageview that has 2 editors embedded

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext-enabled TextArea [message #1082130 is a reply to message #1081834] Thu, 08 August 2013 05:52 Go to previous messageGo to next message
Priya Sabut is currently offline Priya SabutFriend
Messages: 41
Registered: September 2012
Member
Thanks a lot Christian Smile

I am too much excited to see this. I hope this will surely help me. I am looking into the code right now Rolling Eyes . I will update you for any help. Thanks

Regards,
Priya
Re: Xtext-enabled TextArea [message #1086483 is a reply to message #1080744] Wed, 14 August 2013 09:04 Go to previous messageGo to next message
Priya Sabut is currently offline Priya SabutFriend
Messages: 41
Registered: September 2012
Member
Hi Christian,

I am able to create my own view(xtext-enabled) the same way it was done in your code.

Inside my grammar I am using FullJvmFormalParameter and JvmTypeReference types for my function argument and return types resp. For below method definition(language), the editor is not showing any error

function getXC(String xc): String {
return xc;
}
function getName(String a, java.util.ArrayList s)
: String {
if(a.equals('A')){
return a
}
else return "";
}

But I am getting error markers when I write the function inside my view "Couldn't resolve reference to JvmType 'String'.". Attaching the screen shoot for your reference.

Could you please tell, what am I missing here ?

[Updated on: Wed, 14 August 2013 09:07]

Report message to a moderator

Re: Xtext-enabled TextArea [message #1086486 is a reply to message #1086483] Wed, 14 August 2013 09:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

The question is: did you do the changes i do in the uimodule?
if not you need a physical java project you let the resource you edit point to respectively come from


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext-enabled TextArea [message #1086487 is a reply to message #1086486] Wed, 14 August 2013 09:09 Go to previous messageGo to next message
Priya Sabut is currently offline Priya SabutFriend
Messages: 41
Registered: September 2012
Member
For view, whatever is needed I did that. I am not sure what am I missing Sad

Sorry, I did not understand the second sentence!!

Re: Xtext-enabled TextArea [message #1086490 is a reply to message #1086487] Wed, 14 August 2013 09:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

if the resource you edit physically comes from a java project and the resource you create is tied to this java project it should work out of the box (IResourceSetProvider)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext-enabled TextArea [message #1086496 is a reply to message #1086490] Wed, 14 August 2013 09:18 Go to previous messageGo to next message
Priya Sabut is currently offline Priya SabutFriend
Messages: 41
Registered: September 2012
Member
For editor I have the resource tied to java project and it is working fine.

But how can I tie a view to java project ? The problem I am facing is in the view
Re: Xtext-enabled TextArea [message #1086498 is a reply to message #1086496] Wed, 14 August 2013 09:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

using a different version of org.eclipse.xtext.ui.editor.embedded.IEditedResourceProvider

e.g.

public class ModelQueryLanguageEditedResourceProvider implements IEditedResourceProvider {

	@Inject
	IResourceSetProvider rsp;
	
	private IProject project;

	public IProject getProject() {
		return project;
	}

	public void setProject(IProject project) {
		this.project = project;
	}

	public XtextResource createResource() {
		return (XtextResource) rsp.get(project).createResource(URI.createURI("platform./resource/"+project.getname()+"/test.mql"));
	}

}


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

[Updated on: Wed, 14 August 2013 09:20]

Report message to a moderator

Re: Xtext-enabled TextArea [message #1086502 is a reply to message #1086498] Wed, 14 August 2013 09:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
P.S: sorry further digging you have to do yourself

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext-enabled TextArea [message #1086505 is a reply to message #1086502] Wed, 14 August 2013 09:29 Go to previous messageGo to next message
Priya Sabut is currently offline Priya SabutFriend
Messages: 41
Registered: September 2012
Member
any link or any doc talking about it ?
Re: Xtext-enabled TextArea [message #1086508 is a reply to message #1086505] Wed, 14 August 2013 09:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
nope i fear you have to google

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext-enabled TextArea [message #1086519 is a reply to message #1086508] Wed, 14 August 2013 09:48 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
P.S: are you sure it dosent work with

public class ModelQueryLanguageEditedResourceProvider implements IEditedResourceProvider {

	@Inject
	IResourceSetProvider rsp;
	
	private IProject project;

	public IProject getProject() {
		return project;
	}

	public void setProject(IProject project) {
		this.project = project;
	}

	public XtextResource createResource() {
		return (XtextResource) rsp.get(project).createResource(URI.createURI("test.mql"));
	}

}


simply call setProject on the ModelQueryLanguageEditedResourceProvider
you pass to the embeddedEditorFactory


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:M2M transformation and file comments
Next Topic:Word wrap on ConfigurableCompletionProposal tooltips - how?
Goto Forum:
  


Current Time: Fri Apr 19 10:05:02 GMT 2024

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

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

Back to the top