Inserting editor generated by Xtext to FormPage [message #60015] |
Fri, 17 July 2009 07:24  |
Eclipse User |
|
|
|
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 #63018 is a reply to message #63011] |
Mon, 27 July 2009 03:19   |
Eclipse User |
|
|
|
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 #369096 is a reply to message #361994] |
Tue, 28 July 2009 10:50  |
Eclipse User |
|
|
|
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
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.09339 seconds