Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Customizing the outline
Customizing the outline [message #912290] Thu, 13 September 2012 05:19 Go to next message
Eclipse UserFriend
How can a customize the outline??

I need it to get something like this with this objects:


if
AbstractElements
else if
AbstractElements


Object:

IfExp:
block=CondBlock ('else' blocks+=CondBlock)* ('else' defaultBlock=Block)?;

CondBlock:
name='if' cond=TerminalBoolExpression action=Block;

Block:
{Block}
name='{'
sta+=AbstractElement*
'}';


But what I get something like this:

if
unnamed
AbstractElement
unnamed



Someone can help me??


Thanks a lot
Re: Customizing the outline [message #912378 is a reply to message #912290] Thu, 13 September 2012 09:02 Go to previous messageGo to next message
Eclipse UserFriend
I would not use the special member "name" for this.
It might be simpler to just customize the LabelProvider class.

For example to change the label of a conditional block you can try:
    String text(CondBlock ele) {
        return "If";
      }


I usually override the doGetText to get some more verbose defaults during development:
    @Override
    protected Object doGetText(Object element) {
            Object text = super.doGetText(element);
            String prefix = "";
            if(element instanceof EObject) {
                EObject e = (EObject) element;
                if(e.eContainingFeature()!=null) {
                    prefix = prefix + e.eContainingFeature().getName() + "="; 
                }
            }
            prefix = prefix + element.getClass().getSimpleName().replaceFirst("Impl$", "");
            if(text != null && text instanceof String) {
                return prefix +":"+text;
            } else {
                return prefix;
            }
    }


This is just meant as a starting point.
Re: Customizing the outline [message #912823 is a reply to message #912378] Fri, 14 September 2012 04:54 Go to previous messageGo to next message
Eclipse UserFriend
Hi Jens,

Where should I override doGetText() ? I tried to override in DefaultOutlineTreeProvider, but it does not work.
Re: Customizing the outline [message #912827 is a reply to message #912823] Fri, 14 September 2012 05:03 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

as said before the labels are ususally done in the Labelprovider - but not by overriding doGetText

String text(CondBlock ele) {
        return "If";
      }


you may find the dogettext in DefaultEObjectLabelProvider (superclass of MydslLabelProvider)

~Christian
Re: Customizing the outline [message #912845 is a reply to message #912827] Fri, 14 September 2012 05:28 Go to previous messageGo to next message
Eclipse UserFriend
Maybe it was a little misleading to suggest the override of doGetText. It is not required in this case.
I meant this only as developing aid. I used this in several projects for a quick check of the results. I know there are other ways doing that, too.
Re: Customizing the outline [message #920840 is a reply to message #912845] Sun, 23 September 2012 10:07 Go to previous messageGo to next message
Eclipse UserFriend
The text() method works, but I want to delete some nodes of the outline, but adding the children of this node to his parent.

I want just this:

if
element
if
element

But the blocks and the IfExp appears in my outline.

Any idea.
Re: Customizing the outline [message #920855 is a reply to message #920840] Sun, 23 September 2012 10:22 Go to previous message
Eclipse UserFriend
Hi there are a lot of topics on the outline already the . Have a look
at the YourDslOutlineTreeProvider and adapt the code.

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Previous Topic:Quickfix All
Next Topic:Python inspire language in Xtext?
Goto Forum:
  


Current Time: Sat Jul 05 09:07:56 EDT 2025

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

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

Back to the top