Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Outline tree selection elements are all of the same type
Outline tree selection elements are all of the same type [message #42916] Tue, 05 May 2009 13:52 Go to next message
Eclipse UserFriend
Hi everyone,

I registered a listener to outline tree selection. To do that, I created a
custom class extending XtextContentOutlinePage and overrode
bindIContentOutlinePage() in the generated class that extends
AbstractXXXUiModule. My custom class gets called, so everything is fine
and dandy there.

I'd like to do some meaningful events based on the nodes selected.
However, all items in the ITreeSelection object that I get are of type
ContentOutlineNode. Is there another way to register a listener on the
tree, so that I could get real objects underneath (auto-generated by the
grammar I created)?

Thank you.
Re: Outline tree selection elements are all of the same type [message #42947 is a reply to message #42916] Tue, 05 May 2009 14:49 Go to previous messageGo to next message
Eclipse UserFriend
Hi Paul,

I'm afraid it is currently not possible to get a semantic object from an
outline node, since we are kind of afraid to return EObjects to clients,
as they will most likely run into lifecycle issues due to frequently
recreated models (the parser actually throws a lot of EObject away and
recreates them everytime the user edits the DSL file).

If you hava a ContentOutlineNode and an IXtextDocument (may be obtained
from an editor), you may try to use something like this:

final ContentOutlineNode outlineNode = ..;
IXtextDocument doc = (IXtextDocument)textViewer.getDocument();
doc.readOnly(new UnitOfWork<Something>() {
public Something exec(XtextResource res) {
EObject model = res.getContents().get(0);
NodeAdapter adapter = NodeUtil.getNodeAdapter(model);
AbstractNode node = adapter.getParserNode();
EObject current =
ParseTreeUtil.getCurrentOrPrecedingNodeByOffset(
node,
outlineNode.getSelectionOffset() + outlineNode.getSelectionLenght());
return ...
}
});

Please file a bugzilla and describe your usecase.

Thanks,
Sebastian

Am 05.05.2009 19:52 Uhr, schrieb Paul Neyman:
> Hi everyone,
>
> I registered a listener to outline tree selection. To do that, I created
> a custom class extending XtextContentOutlinePage and overrode
> bindIContentOutlinePage() in the generated class that extends
> AbstractXXXUiModule. My custom class gets called, so everything is fine
> and dandy there.
> I'd like to do some meaningful events based on the nodes selected.
> However, all items in the ITreeSelection object that I get are of type
> ContentOutlineNode. Is there another way to register a listener on the
> tree, so that I could get real objects underneath (auto-generated by the
> grammar I created)?
>
> Thank you.
>
Re: Outline tree selection elements are all of the same type [message #43387 is a reply to message #42947] Thu, 07 May 2009 15:20 Go to previous message
Eclipse UserFriend
Thank you very much, Sebastian!
Previous Topic:[Xtext] Workflow Errorwhen importing existing ecore meta-model
Next Topic:[Announce] TMF XTEXT 0.7.0M7 is available
Goto Forum:
  


Current Time: Tue Jul 15 08:42:53 EDT 2025

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

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

Back to the top