package org.jboss.as.console.client.widgets.tree;

import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.TreeItem;

public class GroupItem extends TreeItem {

    public GroupItem(String title) {
        super();

        setText(title);
        getElement().setAttribute("style", "cursor:pointer;");

        HTMLPanel inner = new HTMLPanel("<span>"+title+"</span>")
        {
            {
                sinkEvents(Event.ONKEYDOWN);
                sinkEvents(Event.ONMOUSEDOWN);

            }
            @Override
            public void onBrowserEvent(Event event) {
                GroupItem.this.setState(!GroupItem.this.getState());
                event.preventDefault();
                event.stopPropagation();
            }
        };

        setWidget(inner);
    }

    @Override
    public void setSelected(boolean selected) {
        super.setSelected(selected);

        if(selected)
            addStyleName("tree-section-selected");
        else
            removeStyleName("tree-section-selected");
    }
}

@@ -48,97 +48,8 @@
 e;%0A%0A
-import com.google.gwt.user.client.Event;%0Aimport com.google.gwt.user.client.ui.HTMLPanel;%0A
 impo
@@ -281,218 +281,19 @@
 %22);%0A
-%0A        HTMLPanel inner = new HTMLPanel(%22%3Cspan%3E%22+title+%22%3C/span%3E%22)%0A        %7B%0A            %7B%0A                sinkEvents(Event.ONKEYDOWN);%0A                sinkEvents(Event.ONMOUSEDOWN);%0A%0A        
     %7D%0A
-     
+%0A
     
-   
 @Ove
@@ -298,24 +298,16 @@
 verride%0A
-        
     publ
@@ -318,34 +318,29 @@
 oid 
-onBrowserEvent(Event ev
+setState(boolean op
 en
-t
 ) %7B%0A
@@ -351,317 +351,88 @@
     
-        GroupItem.this.setState(!GroupItem.this.getState());%0A                event.preventDefault();%0A                event.stopPropagation();%0A            %7D%0A        %7D;%0A%0A        setWidget(inner);%0A    %7D%0A%0A    @Override%0A    public void setSelected(boolean selected) %7B%0A        super.setSelected(selected)
+super.setState(open);%0A%0A        String text = open ? %22open %22 : %22close %22
 ;%0A
-%0A
         
 if(s
@@ -431,136 +431,41 @@
     
-if(selected)%0A            addStyleName(%22tree-section-selected%22);%0A        else%0A            removeStyleName(%22tree-section-selected%22
+System.out.println(text+getText()
 );%0A 

simplify lhs group items: activation is handled by owning tree