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.ext.widgets.common.client.common;
 
 import  com.github.gwtbootstrap.client.ui.Form;
 import  com.google.gwt.user.client.DOM;
 import  com.google.gwt.user.client.ui.Composite;
 import  com.google.gwt.user.client.ui.FlexTable;
 import  com.google.gwt.user.client.ui.HTML;
 import  com.google.gwt.user.client.ui.HasHorizontalAlignment;
 import  com.google.gwt.user.client.ui.HasVerticalAlignment;
 import  com.google.gwt.user.client.ui.HorizontalPanel;
 import  com.google.gwt.user.client.ui.Image;
 import  com.google.gwt.user.client.ui.Label;
 import  com.google.gwt.user.client.ui.VerticalPanel;
 import  com.google.gwt.user.client.ui.Widget;

Uses ext forms to do a prettier layout.
 
 public class PrettyFormLayout extends Composite {
 
     private VerticalPanel layout = new VerticalPanel();
     private FlexTable currentTable;
     private String sectionName;
 
     public PrettyFormLayout() {
         .setWidth( "100%" );
         initWidget(  );
     }
 
     public void startSection() {
         this. = new FlexTable();
     }
 
     public void startSectionString title ) {
         startSection();
         this. = title;
     }
 
     public void clear() {
         this..clear();
     }
 
     public void addHeader( Image img,
                            String name,
                            Image edit ) {
         HorizontalPanel h = new HorizontalPanel();
         h.add( img );
         h.add( new HTML( " " ) );
         h.add( new Label( name ) );
         if ( edit != null ) {
             h.add( edit );
         }
 
         Form f = newFormnull );
 
         f.add( h );
         .add( f );
     }
 
     public void addHeader( Image img,
                            Widget content ) {
         HorizontalPanel h = new HorizontalPanel();
         h.add( img );
         h.add( new HTML( " " ) );
         h.add( content );
         Form f = newFormnull );
         f.add( h );
         .add( f );
     }
 
     private Form newFormfinal String hdr ) {
         Form fp = new Form();
         fp.setWidth( "100%" );
         fp.addStyleName( "guvnor-FormPanel" );
         if ( hdr != null ) {
             fp.setTitle( hdr );
         }
         return fp;
     }
 
     public void endSection() {
         Form f = newFormthis. );
 
        f.add( this. );
        this..add( f );
        this. = null;
    }
    public void addRowfinal Widget widget ) {
        //TODO ARIA: what to do with widget has no visible label?
        int row = .getRowCount();
        .setWidget( row,
                                0,
                                widget );
        .getFlexCellFormatter().setColSpan( row,
                                                        0,
                                                        2 );
    }
    public int addAttributeString lbl,
                             final Widget categories ) {
        String id = DOM.createUniqueId();
        categories.getElement().setAttribute( "aria-labelledby"id );
        categories.getElement().setAttribute( "aria-required", String.valueOftrue ) );
        categories.getElement().setTabIndex( 0 );
        int row = .getRowCount();
        Label label = new Label( lbl );
        label.getElement().setAttribute( "id"id );
        .setWidget( row,
                                0,
                                label );
        .setWidget( row,
                                1,
                                categories );
        .getFlexCellFormatter().setHorizontalAlignment( row,
                                                                    0,
                                                                    HasHorizontalAlignment.ALIGN_RIGHT );
        .getFlexCellFormatter().setVerticalAlignment( row,
                                                                  0,
                                                                  HasVerticalAlignment.ALIGN_TOP );
        return row;
    }
    public void removeRowint row ) {
        .removeRow( row );
    }
New to GrepCode? Check out our FAQ X