Outline tree selection elements are all of the same type [message #42916] |
Tue, 05 May 2009 13:52  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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.
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03604 seconds