Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Inserting editor generated by Xtext to FormPage
Inserting editor generated by Xtext to FormPage [message #60015] Fri, 17 July 2009 11:24 Go to next message
David  is currently offline David Friend
Messages: 5
Registered: July 2009
Junior Member
Hello,

it is possible to insert editor generated by Xtext to
org.eclipse.ui.forms.editor.FormPage?
Now we use org.eclipse.swt.widgets.Text in this form page to enter part of
a configuration specified in our DSL. Our idea is to add support of syntax
coloring etc. by using editor generated by Xtext instead it.

Thanks,
David
Re: Inserting editor generated by Xtext to FormPage [message #60255 is a reply to message #60015] Fri, 17 July 2009 18:11 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi David,

I'm not that familiar with all this SWT and JFace stuff, but it should
be possible to reuse the XtextEditor.
Usually one would try to obtain the SourceViewer from the editor and use
the underlying widget directly.

Hope that helps,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 17.07.2009 13:24 Uhr, schrieb David:
> Hello,
>
> it is possible to insert editor generated by Xtext to
> org.eclipse.ui.forms.editor.FormPage?
> Now we use org.eclipse.swt.widgets.Text in this form page to enter part
> of a configuration specified in our DSL. Our idea is to add support of
> syntax coloring etc. by using editor generated by Xtext instead it.
>
> Thanks,
> David
>
Re: Inserting editor generated by Xtext to FormPage [message #63011 is a reply to message #60255] Sun, 26 July 2009 17:09 Go to previous messageGo to next message
David  is currently offline David Friend
Messages: 5
Registered: July 2009
Junior Member
Hi Sebastian,

thank you very much for your help.

Yes, if it would be possible to get instance of SourceViewer, one could
get instance of StyledText and place it to a container in FormPage.
Unfortunately, method getSourceViewer of class AbstractTextEditor is
protected and it is not accessible from an instance of XtextEditor.

It is possible to get SourceViewer from an instance of XtextEditor?

Thank you,
David


Sebastian Zarnekow wrote:

> Hi David,

> I'm not that familiar with all this SWT and JFace stuff, but it should
> be possible to reuse the XtextEditor.
> Usually one would try to obtain the SourceViewer from the editor and use
> the underlying widget directly.

> Hope that helps,
> Sebastian
Re: Inserting editor generated by Xtext to FormPage [message #63018 is a reply to message #63011] Mon, 27 July 2009 07:19 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi David,

it is possible to exchange the concrete class of the XtextEditor via
google guice. You should create a subclass and introduce a method that
exposes the SourceViewer.

The binding in your UIModule should look like this:

Class<? extends XtextEditor> bindEditor() {
return MyEditor.class;
}

and the editor class may look as follows.

public class MyEditor extends XtextEditor {

public ISourceViewer publicGetSourceViewer() {
return getSourceViewer(); // final and protected in super class
}
}

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 26.07.2009 19:09 Uhr, schrieb David:
> Hi Sebastian,
>
> thank you very much for your help.
> Yes, if it would be possible to get instance of SourceViewer, one could
> get instance of StyledText and place it to a container in FormPage.
> Unfortunately, method getSourceViewer of class AbstractTextEditor is
> protected and it is not accessible from an instance of XtextEditor.
> It is possible to get SourceViewer from an instance of XtextEditor?
>
> Thank you,
> David
>
>
> Sebastian Zarnekow wrote:
>
>> Hi David,
>
>> I'm not that familiar with all this SWT and JFace stuff, but it should
>> be possible to reuse the XtextEditor.
>> Usually one would try to obtain the SourceViewer from the editor and
>> use the underlying widget directly.
>
>> Hope that helps,
>> Sebastian
>
>
Re: Inserting editor generated by Xtext to FormPage [message #361994 is a reply to message #63018] Tue, 28 July 2009 13:55 Go to previous messageGo to next message
David  is currently offline David Friend
Messages: 5
Registered: July 2009
Junior Member
Hi Sebastian,

thank you very much. I created the concrete class and registered it in
UIModule. However, opening file in our DSL still creates an instance of
XTextEditor.

Following code results in printing "Not an instance of TBPEditor":

IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject("Test-Project-1");
IFile file = project.getFile(new Path("test.tbp"));
file.create(new ByteArrayInputStream("".getBytes()), true, null);
FileEditorInput editorInput = new FileEditorInput(file);

XtextEditor editor = (XtextEditor) getPage().openEditor(editorInput,
"org.objectweb.dsrg.sofa.tbp.TBP");
if (editor instanceof TBPEditor) {
System.out.println("Instance of TBPEditor.")
} else {
System.out.println("Not an instance of TBPEditor");

Best wishes,
David

Sebastian Zarnekow wrote:

> Hi David,

> it is possible to exchange the concrete class of the XtextEditor via
> google guice. You should create a subclass and introduce a method that
> exposes the SourceViewer.

> The binding in your UIModule should look like this:

> Class<? extends XtextEditor> bindEditor() {
> return MyEditor.class;
> }

> and the editor class may look as follows.

> public class MyEditor extends XtextEditor {

> public ISourceViewer publicGetSourceViewer() {
> return getSourceViewer(); // final and protected in super class
> }
> }

> Regards,
> Sebastian
Re: Inserting editor generated by Xtext to FormPage [message #369096 is a reply to message #361994] Tue, 28 July 2009 14:50 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi David,

sorry, my previous post was misleading. The bind-Method in your UIModule
has to be public.

Hope that helps,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


Am 28.07.2009 15:55 Uhr, schrieb David:
> Hi Sebastian,
>
> thank you very much. I created the concrete class and registered it in
> UIModule. However, opening file in our DSL still creates an instance of
> XTextEditor.
>
> Following code results in printing "Not an instance of TBPEditor":
>
> IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
> IProject project = root.getProject("Test-Project-1");
> IFile file = project.getFile(new Path("test.tbp"));
> file.create(new ByteArrayInputStream("".getBytes()), true, null);
> FileEditorInput editorInput = new FileEditorInput(file);
>
> XtextEditor editor = (XtextEditor) getPage().openEditor(editorInput,
> "org.objectweb.dsrg.sofa.tbp.TBP");
> if (editor instanceof TBPEditor) {
> System.out.println("Instance of TBPEditor.")
> } else {
> System.out.println("Not an instance of TBPEditor");
>
> Best wishes,
> David
>
> Sebastian Zarnekow wrote:
>
>> Hi David,
>
>> it is possible to exchange the concrete class of the XtextEditor via
>> google guice. You should create a subclass and introduce a method that
>> exposes the SourceViewer.
>
>> The binding in your UIModule should look like this:
>
>> Class<? extends XtextEditor> bindEditor() {
>> return MyEditor.class;
>> }
>
>> and the editor class may look as follows.
>
>> public class MyEditor extends XtextEditor {
>
>> public ISourceViewer publicGetSourceViewer() {
>> return getSourceViewer(); // final and protected in super class
>> }
>> }
>
>> Regards,
>> Sebastian
>
>
Previous Topic:Hidden Terminals
Next Topic:[XText] about grammar ambiguity, left recursion
Goto Forum:
  


Current Time: Sat Sep 28 00:39:57 GMT 2024

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

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

Back to the top