Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2010 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.drools.guvnor.client.common;
 
 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;
 import  com.gwtext.client.widgets.form.FormPanel;

Uses ext forms to do a prettier layout.

Author(s):
Michael Neale
 
 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 startSection(String title) {
 		this. = title;
 	}
 
 	public void clear() {
 		this..clear();
 	}
 
 	public void addHeader(String imgString name, Image edit) {
 		HorizontalPanel h = new HorizontalPanel();
         h.add( new Image( img ) );
         h.add( new HTML( " " ) );
         h.add( new Label( name ) );
         if ( edit != null ) h.add( edit );
 
         FormPanel f = newFormnull );
 
         f.add( h );
         .add( f );
 	}
 
 	public void addHeader(String img, Widget content) {
         HorizontalPanel h = new HorizontalPanel();
         h.add( new Image( img ) );
         h.add( new HTML( " " ) );
         h.add( content );
         FormPanel f = newFormnull );
         f.add( h );
         .add( f );
     }
 
 	private FormPanel newForm(final String hdr) {
 		FormPanel fp = new FormPanel();
 		fp.setWidth("100%");
 		fp.setFrame(true);
 		if (hdr != null) {
 			fp.setTitle(hdr);
 		}
 		return fp;
 	}
 
     public void endSection() {
 
 		FormPanel f = newForm(this.);
 
 		f.add(this.);
 
 
		this..add(f);
		this. = null;
	}
	public void addRow(final Widget versionBrowser) {
    	int i = .getRowCount();
    	.setWidget(i, 0, versionBrowser);
    	.getFlexCellFormatter().setColSpan(i, 0, 2);
	}
	public void addAttribute(String lblfinal Widget categories) {
		int i = this..getRowCount();
		.setWidget(i, 0, new Label(lbl));
		.setWidget(i, 1, categories);
		.getFlexCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
		.getFlexCellFormatter().setVerticalAlignment( i, 0, HasVerticalAlignment.ALIGN_TOP );
	}
New to GrepCode? Check out our FAQ X