Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.uberfire.client.common;
 
 import java.util.List;
 
The GWT StackPanel is not working as we want. So doing a custom one.
 
 public class LazyStackPanel extends Composite
         implements
 
     private FlexTable flexTable = new FlexTable();
     private int       rowIndex  = 0;
 
     public LazyStackPanel() {
 
         initWidget );
 
         .setStyleName"guvnor-lazyStackPanel" );
 
 
             public void onSelectionSelectionEvent<LazyStackPanelRowevent ) {
                 LazyStackPanelRow row = event.getSelectedItem();
                 if ( row.isExpanded() ) {
                     row.compress();
                 } else {
                     row.expand();
                 }
             }
         } );
     }

    
Add a new (collapsed) element to the stack.

Parameters:
headerText
contentLoad
 
     public void addString headerText,
                      LoadContentCommand contentLoad ) {
         this.addheaderText,
                   contentLoad,
                   false );
     }
 
     public void addString headerText,
                      LoadContentCommand contentLoad,
                      boolean expanded ) {
         LazyStackPanelHeader header = new LazyStackPanelHeaderheaderText );
         addheader,
              contentLoad,
              expanded );
     }
 
     public void addString headerText,
                      ImageResource icon,
                      LoadContentCommand contentLoad ) {
         LazyStackPanelHeader header = new LazyStackPanelHeaderheaderText,
                                                                 icon );
         addheader,
              contentLoad,
              false );
     }

    
Add a new (collapsed) element to the stack.

Parameters:
header
contentLoad
 
    public void addAbstractLazyStackPanelHeader header,
                     LoadContentCommand contentLoad ) {
        this.addheader,
                  contentLoad,
                  false );
    }
    public void addAbstractLazyStackPanelHeader header,
                     LoadContentCommand contentLoad,
                     boolean expanded ) {
        final LazyStackPanelRow row = new LazyStackPanelRowheader,
                                                             contentLoad );
        header.addOpenHandlernew OpenHandler<AbstractLazyStackPanelHeader>() {
            public void onOpenOpenEvent<AbstractLazyStackPanelHeaderevent ) {
                selectRowrow );
            }
        } );
            public void onClosecom.google.gwt.event.logical.shared.CloseEvent<AbstractLazyStackPanelHeaderevent ) {
                selectRowrow );
            }
        } );
        addHeaderRowrow );
        addContentRowrow.getContentPanel() );
        if ( expanded ) {
            header.expand();
        }
    }
    private void addHeaderRowfinal LazyStackPanelRow row ) {
        .setWidget,
                             0,
                             row );
                                                       0,
                                                       "guvnor-LazyStackPanel-row-header" );
        ++;
    }
    private void addContentRowfinal SimplePanel panel ) {
        .setWidget++,
                             0,
                             panel );
    }
    private void selectRowLazyStackPanelRow row ) {
        SelectionEvent.firethis,
                             row );
    }
    @Override
        return addHandlerhandler,
                           SelectionEvent.getType() );
    }
    public void swapint firstIndex,
                      int secondIndex ) {
        // Every list item is made of the header and content row.
        // So we have twice as many rows.
        firstIndex = firstIndex * 2;
        secondIndex = secondIndex * 2;
        Widget firstHeader = .getWidgetfirstIndex,
                                                  0 );
        Widget firstContent = .getWidgetfirstIndex + 1,
                                                   0 );
        Widget secondHeader = .getWidgetsecondIndex,
                                                   0 );
        Widget secondContent = .getWidgetsecondIndex + 1,
                                                    0 );
        .setWidgetfirstIndex,
                             0,
                             secondHeader );
        .setWidgetfirstIndex + 1,
                             0,
                             secondContent );
        .setWidgetsecondIndex,
                             0,
                             firstHeader );
        .setWidgetsecondIndex + 1,
                             0,
                             firstContent );
    }
        Iterator<Widgetiterator = .iterator();
        while ( iterator.hasNext() ) {
            Widget widget = (Widgetiterator.next();
            if ( widget instanceof LazyStackPanelRow ) {
                result.add( ( (LazyStackPanelRowwidget ).getHeader() );
            }
        }
        return result.iterator();
    }
    public void removeint index ) {
        index = index * 2;
        .removeRowindex + 1 );
        .removeRowindex );
    }
    public void clean() {
        .removeAllRows();
         = 0;
    }
New to GrepCode? Check out our FAQ X