Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XtextEditor manipulation(Adding/Editing some functionality to the XtextEditor)
XtextEditor manipulation [message #1059996] Wed, 22 May 2013 09:30 Go to next message
Edwin Tuzar is currently offline Edwin Tuzar
Messages: 10
Registered: April 2013
Junior Member
Hello everyone,
could someone help me with the following problem, please:
I want to be able when I'm pressing in a view (like the outline) on a object from my model to be able to show in the editor only that element + subelements and the rest of the things in the editor I would like to have them collapsed or grayed.
Something like this:
View:
Red
Blue
Black

and if I click on Red in the editor should show me:
+myLanguage
Red name id 
 subelementOfRed name id
 subelement2OfRed id
+code
Red name id
 subelementOfRed name id
+code

the + is for collapse code

More info: now I have the XtextEditor and the IXtextDocument, I got also the model from : IXTextDocument.readOnly(new IUnitOfWork<Object, XtextResource>()).
But I'm a little stuck of how should I make this thing to collapse in between (I get the right elements from the model)


Thanks in advance!


Edwin W.T.
Re: XtextEditor manipulation [message #1060017 is a reply to message #1059996] Wed, 22 May 2013 10:32 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1085
Registered: July 2009
Senior Member
Hi,

I did some foldig customizations in a project. The corresponding code is in the folding package and the TerminologyXtextEditor (just as inspiration for how to collapse regions).

You will have to solve the following problems:
* identify the folding regions that correspond to the outline view selection
* find a good hook for your selection change in the view (OutlineWithEditorLinker?), where you collapse/expand the regions

A very hacky (but possibly minimal effort) idea if there was a 1:1 correspondence between outline element and text element (which seems not to be your use case).
When you select an element in the outline view, the corresponding model element is expanded automatically, so you could simply collapse *all* regions first.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: XtextEditor manipulation [message #1060027 is a reply to message #1060017] Wed, 22 May 2013 11:01 Go to previous messageGo to next message
Edwin Tuzar is currently offline Edwin Tuzar
Messages: 10
Registered: April 2013
Junior Member
Thanks for the quick answer.
I will look into it, but first I have another question, because I already did something in another way.
I used the ISourceViewer sourceViewer to show only what I'm interested and it works, but now I have only the problem that if I have more elements (at different offsets) will take only my last element with the function: sourceViewer.setVisibleRegion(offset, length); can I somehow make more regions visible in the same time ?
This will resolve my problem faster Smile.


Edwin W.T.
Re: XtextEditor manipulation [message #1060091 is a reply to message #1060027] Thu, 23 May 2013 02:09 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1085
Registered: July 2009
Senior Member
Hi,

Quote:
A projection source viewer is a source viewer which supports multiple visible regions which can dynamically be changed.
(Projection Viewer Java Doc)

So I guess, folding is the way to show more than one region at a time.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: XtextEditor manipulation [message #1060237 is a reply to message #1060091] Thu, 23 May 2013 12:13 Go to previous messageGo to next message
Edwin Tuzar is currently offline Edwin Tuzar
Messages: 10
Registered: April 2013
Junior Member
Is there a nice way to get the offset in the xtexteditor when you have the EMF object from the state ( IXTextDocument.readOnly(new IUnitOfWork<Object, XtextResource>())) ?

Edwin W.T.
Re: XtextEditor manipulation [message #1060264 is a reply to message #1060237] Thu, 23 May 2013 13:35 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1085
Registered: July 2009
Senior Member
Hi,

use NodeModelUtils.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: XtextEditor manipulation [message #1060336 is a reply to message #1060264] Fri, 24 May 2013 04:13 Go to previous message
Edwin Tuzar is currently offline Edwin Tuzar
Messages: 10
Registered: April 2013
Junior Member
Hi,
This is so perfect, thanks a lot!


Edwin W.T.
Previous Topic:EMF changes do not reflect Xtext Document
Next Topic:LLVM Suport
Goto Forum:
  


Current Time: Tue May 28 17:11:40 EDT 2013

Powered by FUDForum. Page generated in 0.02509 seconds