Skip to main content


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 07:35 Go to next message
Ankit Agarwal is currently offline Ankit AgarwalFriend
Messages: 35
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 07:42]

Report message to a moderator

Re: Customizing Outline View [message #1011262 is a reply to message #1011258] Tue, 19 February 2013 07:44 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Customizing Outline View [message #1011279 is a reply to message #1011262] Tue, 19 February 2013 08:17 Go to previous messageGo to next message
Ankit Agarwal is currently offline Ankit AgarwalFriend
Messages: 35
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 09:13 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Customizing Outline View [message #1011350 is a reply to message #1011301] Tue, 19 February 2013 11:31 Go to previous message
Ankit Agarwal is currently offline Ankit AgarwalFriend
Messages: 35
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: Fri Mar 29 06:59:10 GMT 2024

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

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

Back to the top