Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Customizing Outline View(Customizing Outline View)
Customizing Outline View [message #1011258] Tue, 19 February 2013 02:35 Go to next message
Ankit Agarwal is currently offline Ankit Agarwal
Messages: 33
Registered: March 2012
Member
Hi,

I have a file opened in Editor whose contents i want to show on my outline view, i dont want to show all the contents though.
My file looks like

import abcd.x
import abcde.x

String hello;
int a;

public int add(int a){
int c = 10;
return a+c;
}
}

Right now my outline view displays everything that is there inside the method add in a tree format. But i only want to show any variable defined in it (like int c).
My OutlineTreeProvider looks like :

Class MyOutlineTreeProvider extends DefaultOutlineTreeProvider {

protected void _createChildren(DocumentRootNode parentNode,Model modelElement) {
for (EObject element : modelElement.getImports()) {
createNode(parentNode, element);
}

for (EObject element : modelElement.getVardecls()) {
createNode(parentNode, element);
}
for (EObject element : modelElement.getMethods()) {
createNode(parentNode, element);
}
}

Now how do i eliminate other information from inside the Method in outline view.
I tried the method mentioned in http://www.eclipse.org/Xtext/documentation.html#outline, but could not get it working

[Updated on: Tue, 19 February 2013 02:42]

Report message to a moderator

Re: Customizing Outline View [message #1011262 is a reply to message #1011258] Tue, 19 February 2013 02:44 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan Koehnlein
Messages: 655
Registered: July 2009
Senior Member
How about overriding

_isLeaf(WhatEverTypeYourMethodIs method) {
return true;
}

Am 19.02.13 08:35, schrieb Ankit Agarwal:
> Hi,
>
> I have a file opened in Editor whose contents i want to show on my
> outline view, i dont want to show all the contents though.
> My file looks like
>
> import abcd.x
> import abcde.x
>
> Class Demo
> {
> String hello;
> int a;
>
> public int add(int a){
> int c = 10;
> return a+c;
> }
> }
>
> Right now my outline view displays everything that is there inside the
> method add in a tree format. But i only want to show any variable
> defined in it (like int c).
> My OutlineTreeProvider looks like :
>
> Class MyOutlineTreeProvider extends DefaultOutlineTreeProvider {
>
> protected void _createChildren(DocumentRootNode parentNode,Model
> modelElement) {
> for (EObject element : modelElement.getImports()) {
> createNode(parentNode, element);
> }
>
> for (EObject element : modelElement.getVardecls()) {
> createNode(parentNode, element);
> }
> for (EObject element : modelElement.getMethods()) {
> createNode(parentNode, element);
> }
> }
> }
>
> Now how do i eliminate other information from inside the Method in
> outline view.
> I tried the method mentioned in
> http://www.eclipse.org/Xtext/documentation.html#outline, but could not
> get it working


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Customizing Outline View [message #1011279 is a reply to message #1011262] Tue, 19 February 2013 03:17 Go to previous messageGo to next message
Ankit Agarwal is currently offline Ankit Agarwal
Messages: 33
Registered: March 2012
Member
This will make my method as leaf node, but i want to add any variable defined inside the method as children of method in the outline view, but nothing else from method should appear.
Re: Customizing Outline View [message #1011301 is a reply to message #1011279] Tue, 19 February 2013 04:13 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan Koehnlein
Messages: 655
Registered: July 2009
Senior Member
Oh, I got you wrong. You have to override

_createChildren(IOutlineNode parentNode, MethodType myMethod) {
// call createNode for the elements you wan to show
}


Am 19.02.13 09:17, schrieb Ankit Agarwal:
> This will make my method as leaf node, but i want to add any variable
> defined inside the method as children of method in the outline view, but
> nothing else from method should appear.

--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Customizing Outline View [message #1011350 is a reply to message #1011301] Tue, 19 February 2013 06:31 Go to previous message
Ankit Agarwal is currently offline Ankit Agarwal
Messages: 33
Registered: March 2012
Member
i tried with this, but the execution is not even coming in this method
Previous Topic:Cross referencing - Fake Resource Set
Next Topic:Duplicate declarations with cross reference
Goto Forum:
  


Current Time: Sat Apr 19 13:13:12 EDT 2014

Powered by FUDForum. Page generated in 0.03383 seconds