XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/875558/#msg_875558
Have created a simple query language to use with a BIRT ODA driver.

Instead of using the XText generated Editor for my query language, I
will need to present the user with a TextViewer in the DataSet Wizard in
order to specify the query string.

I am still a novice when it comes to XText, but I did look but haven't
found any documentation, examples or newsgroup entries regarding a use
case like this.

Can anyone give me an example on how to go about doing this.

thanks,
John]]>2012-05-23T00:40:33-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/875765/#msg_875765
I don't know if it will fits your needs but you can use a plugin provided by the guys of Itemis, used in the Yakindu project.
They provide a JFace integration plugin and more stuff too.
I used it in my project (simply used the StyledTextXtextAdapter class). It worked fine.

Hope this helps.
Massimo.]]>Massimo Rabbi2012-05-23T10:09:12-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/875939/#msg_875939
if you use Xtext 2.3, you may want to have a look at the
EmbeddedEditorFactory.

Am 23.05.12 02:40, schrieb John E. Conlon:
> Hi,
>
> Have created a simple query language to use with a BIRT ODA driver.
>
> Instead of using the XText generated Editor for my query language, I
> will need to present the user with a TextViewer in the DataSet Wizard in
> order to specify the query string.
>
> I am still a novice when it comes to XText, but I did look but haven't
> found any documentation, examples or newsgroup entries regarding a use
> case like this.
>
> Can anyone give me an example on how to go about doing this.
>
> thanks,
> John
>
>
>
>]]>Sebastian Zarnekow2012-05-23T15:32:21-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/876125/#msg_876125
Yes, that worked great!

I did the same as you and used the StyledTextXtextAdapter with a StyleText.

The video tutorial was very informative as well.

thanks much,

John

On 05/23/2012 05:09 AM, Massimo Rabbi wrote:
> Hi John,
> I don't know if it will fits your needs but you can use a plugin
> provided by the guys of Itemis, used in the Yakindu project.
> They provide a JFace integration plugin and more stuff too.
> I used it in my project (simply used the StyledTextXtextAdapter class).
> It worked fine.
>
> More information can be found watching this video tutorial took from the
> latest EclipseCon Europe.
> hxxp://www.fosslc.org/drupal/content/tmf-meets-gmf-combining-graphical-and-textual-modeling
>
>
> Repository for the yakindu project is here:
> hxxp://code.google.com/a/eclipselabs.org/p/yakindu/
>
> You can checkout their code and have a look.
> You can install the integration features you need using this update site
> hxxp://updates.yakindu.com/indigo/milestones
>
> Hope this helps.
> Massimo.]]>2012-05-24T00:22:56-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/876268/#msg_876268
Sebastian Zarnekow wrote on Wed, 23 May 2012 17:32

John,
if you use Xtext 2.3, you may want to have a look at the
EmbeddedEditorFactory.

Hi Sebastian,

Would that be the recommended way to use an Xtext editor in a multi-page one too?

Am 24.05.12 11:23, schrieb Vlad Dumitrescu:
> Sebastian Zarnekow wrote on Wed, 23 May 2012 17:32
>> John,
>> if you use Xtext 2.3, you may want to have a look at the
>> EmbeddedEditorFactory.
>
>
> Hi Sebastian,
>
> Would that be the recommended way to use a Xtext editor in a multi-page
> one too?
>
> regards,
> Vlad
>]]>Sebastian Zarnekow2012-05-24T20:25:27-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/876556/#msg_876556

regards,
Vlad
]]>Vlad Dumitrescu2012-05-24T20:35:35-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/905954/#msg_905954
does it work also on Eclipse 4?

I don't understand what I have to put in my @PostContruct method to see the xtext editor.

Very thank you.]]>Tommaso De Sica2012-08-31T11:10:04-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/906357/#msg_906357
Now I've got this doubt: in my part I have to insert a code like this:

Basic Eclipse 4 injection or com.google.inject.Injector that use also in StyledTextXtextAdapter definition? How can I get it?

Thanks all.]]>Tommaso De Sica2012-09-01T07:57:01-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/906390/#msg_906390
I don't know where you get the code snippet you copy-pasted.
However the injector you need to pass there is an instance of com.google.inject.Injector. It should be the injector relative to your dsl language.
You can get this injector via the generated plugin class inside the generated ui XText project (method getInjector(String languageName)).

Regards,
Massimo.]]>Massimo Rabbi2012-09-01T10:14:15-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/994043/#msg_994043
I did try to use the MPE eq: you have mentioned,

Quote:

public class MultiPageEditor extends MultiPageEditorPart {

@Inject
private Provider<XtextEditor> editorProvider;

private XtextEditor editor;

but for me editor = editorProvider.get(); was giving a null pointer exception

Is there anything else I need to do for the @Injector to populate the values for editorProvider.

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de]]>Christian Dietrich2012-12-26T11:38:20-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/1000729/#msg_1000729
Thanks for the link, it was really useful. I am able to add XtextEditor on a MultiPageEditor.

Now I have one more issue, I am trying to add the EMF editor as another page on the MPE where the XtextEditor is already added.

How can I link the EMF editor to the xtext input file (the dsl file).

Please let me know your comments.

Thanks,
Kavitha]]>kavitha Mising name2013-01-15T10:43:07-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/1000758/#msg_1000758
sorry have no idea about is. you should be able to access the resource.

~Christian]]>Christian Dietrich2013-01-15T11:42:37-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/1729511/#msg_1729511
Not sure if you still check the forum after 5 years or not but could you please let me know how did you make the StyledTextXtextAdapter work ! The video also is deleted

The functionality is there! The problem is that the textEditor is totally empty and it does not show me the particular object that I want from Model. When I press ctrl+space I get the root of the model ! As if there is nothing in the Xtext resource file.

]]>Christian Dietrich2016-04-15T03:53:21-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/1729519/#msg_1729519
Thank you for your reply, I am using the code from sirius+Xtext integration on github. I just changed the code a little bit to run with double click on the object rather than a java extension.

So, if you just take a look at the createXtextEditor() method, there is segment for creating EmbeddedEditor. I just removed this EmbeddedEditor and added my code for SttyledTextXtextAdapter. So, the xtextresource is created based on the semantic element that I pass to this class. It is Weird because it works fine for the EmbeddedEditor and shows the text for the semantic element, but when I use StyledXtextAdapter it doesn't work and gives me empty text editor as if resource is totally empty! I can use content assistant and coloring is working but I guess the resource is just not set !

BTW, can I use StyledXtextCellEditor instead of StyledXtextAdapter ? They are pretty much the same, right ?

]]>Christian Dietrich2016-04-15T05:17:46-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/1729583/#msg_1729583
It is working now Now I see how it works

BTW, Do you know if I can embed this StyledTextAdapter in a label of a transition/edge? Currently I'm just showing this styledtext as a popup to the user, but I have seen in Yakindu they embedded sth like this into the label of the transition.

Thanks again,
Best Regards,
Parsa]]>Parsa Pourali2016-04-15T16:14:33-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/1729649/#msg_1729649
I found that the StyledXtextAdapter shows the full text of my DSL file perfectly. However, when I pass the offset and length of my node to the setVisibleRegion(), it throws the following error. And, I am sure that the length of file is OK and the offset exists. I tried to trace the code and found that when I pass the setVisibleRegion(1752,9) , it turns out to become (3503,-1752) somewhere inside and have no idea why ! I though you might have some idea !

Thanks,
Bests,
Parsa

java.lang.IllegalArgumentException: Invalid visible region argument
at org.eclipse.jface.text.TextViewer.setVisibleRegion(TextViewer.java:3678)
at org.eclipse.jface.text.source.projection.ProjectionViewer.setVisibleRegion(ProjectionViewer.java:703)
at org.yakindu.base.xtext.utils.jface.viewers.StyledTextXtextAdapter.setVisibleRegion(StyledTextXtextAdapter.java:269)
at com.uwaterloo.cs.forml.viewpoint.xtext.support.AbstractXtextEmbeddedEditor.createPartControl(AbstractXtextEmbeddedEditor.java:499)
at com.uwaterloo.cs.forml.viewpoint.xtext.support.AbstractXtextEmbeddedEditor.createXtextEditor(Unknown Source)
at com.uwaterloo.cs.forml.viewpoint.xtext.support.AbstractXtextEmbeddedEditor.showEditor(Unknown Source)
at com.uwaterloo.cs.forml.viewpoint.xtext.support.XtextEmbeddedEditorForGuard.showEditor(XtextEmbeddedEditorForGuard.java:106)
at com.uwaterloo.cs.forml.viewpoint.xtext.support.CreateEmbeddedEditors$1.run(CreateEmbeddedEditors.java:107)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:186)
at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:145)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:4761)
at com.uwaterloo.cs.forml.viewpoint.xtext.support.CreateEmbeddedEditors.runFormViewTransitionEditor(CreateEmbeddedEditors.java:70)
at com.uwaterloo.cs.forml.viewpoint.xtext.support.action.OpenXtextEmbeddedEditor.execute(OpenXtextEmbeddedEditor.java:70)
at org.eclipse.sirius.business.internal.helper.task.operations.ExternalJavaActionTask.execute(ExternalJavaActionTask.java:93)
at org.eclipse.sirius.business.internal.helper.task.ExecuteToolOperationTask.executeTask(ExecuteToolOperationTask.java:106)
at org.eclipse.sirius.business.internal.helper.task.ExecuteToolOperationTask.executeTask(ExecuteToolOperationTask.java:117)
at org.eclipse.sirius.business.internal.helper.task.ExecuteToolOperationTask.execute(ExecuteToolOperationTask.java:90)
at org.eclipse.sirius.business.api.helper.task.TaskExecutor.execute(TaskExecutor.java:64)
at org.eclipse.sirius.tools.api.command.SiriusCommand.doExecute(SiriusCommand.java:80)
at org.eclipse.emf.transaction.RecordingCommand.execute(RecordingCommand.java:135)
at org.eclipse.sirius.diagram.ui.tools.api.command.GMFCommandWrapper.doExecuteWithResult(GMFCommandWrapper.java:102)
at org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand.doExecute(AbstractTransactionalCommand.java:247)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
at org.eclipse.sirius.diagram.ui.tools.internal.commands.WrappingCommandIgnoringAffectedFiles.execute(WrappingCommandIgnoringAffectedFiles.java:124)
at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:516)
at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramCommandStack.execute(DDiagramCommandStack.java:71)
at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramCommandStack.execute(DDiagramCommandStack.java:52)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack.execute(DiagramCommandStack.java:156)
at org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart.performRequest(ConnectionEditPart.java:1476)
at org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramEdgeEditPart.performRequest(AbstractDiagramEdgeEditPart.java:703)
at org.eclipse.gef.tools.SelectEditPartTracker.performOpen(SelectEditPartTracker.java:194)
at org.eclipse.gef.tools.SelectEditPartTracker.handleDoubleClick(SelectEditPartTracker.java:137)
at org.eclipse.gef.tools.AbstractTool.mouseDoubleClick(AbstractTool.java:1069)
at org.eclipse.gef.tools.SelectionTool.mouseDoubleClick(SelectionTool.java:527)
at org.eclipse.gef.EditDomain.mouseDoubleClick(EditDomain.java:231)
at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseDoubleClicked(DomainEventDispatcher.java:291)
at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseDoubleClick(LightweightSystem.java:518)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:196)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4180)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3769)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:694)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
at org.eclipse.equinox.launcher.Main.main(Main.java:1488)

]]>Parsa Pourali2016-04-16T23:34:57-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/1729654/#msg_1729654
Christian Dietrich2016-04-17T07:48:05-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/1729730/#msg_1729730
Not sure what you mean by styledtextex, but I am using StyledText. my code is below. I found that this is related to the bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=352847

The bug is saying that offset = master.getLineOffset(line); should be changed to offset += master.getLineOffset(line); and in my case, I guess the it is the other way around !

Just thought it might be useful to know !
Thanks,
Bests,
Parsa]]>Parsa Pourali2016-04-18T14:51:59-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/1729732/#msg_1729732
Christian Dietrich2016-04-18T14:55:29-00:00Re: XText TextViewer instead of Editorhttps://www.eclipse.org/forums/index.php/mv/msg/354402/1729744/#msg_1729744
I just disregarded the Yakindu implementation of set visible region and have written my own class to override the set visible region for my purpose and it is working perfectly