gt: 		fieldsPanel = new ContentPanel();
context: /**
   * 
   */
  package org.sigmah.client.page.project.dashboard;
  
  import java.util.ArrayList;
  import java.util.Date;
  
  import org.sigmah.client.i18n.I18N;
  import org.sigmah.client.icon.IconImageBundle;
  
  
  import com.extjs.gxt.ui.client.Style;
  import com.extjs.gxt.ui.client.event.BaseEvent;
  import com.extjs.gxt.ui.client.event.Events;
  import com.extjs.gxt.ui.client.event.Listener;
  import com.extjs.gxt.ui.client.util.Margins;
  import com.extjs.gxt.ui.client.widget.ContentPanel;
  import com.extjs.gxt.ui.client.widget.HorizontalPanel;
  import com.extjs.gxt.ui.client.widget.Label;
  import com.extjs.gxt.ui.client.widget.MessageBox;
  import com.extjs.gxt.ui.client.widget.Window;
  import com.extjs.gxt.ui.client.widget.button.Button;
  import com.extjs.gxt.ui.client.widget.form.DateField;
  import com.extjs.gxt.ui.client.widget.form.Field;
  import com.extjs.gxt.ui.client.widget.form.LabelField;
  import com.extjs.gxt.ui.client.widget.form.NumberField;
  import com.extjs.gxt.ui.client.widget.form.TextField;
  import com.extjs.gxt.ui.client.widget.layout.FitLayout;
  import com.extjs.gxt.ui.client.widget.layout.HBoxLayout;
  import com.extjs.gxt.ui.client.widget.layout.HBoxLayoutData;
  import com.extjs.gxt.ui.client.widget.layout.TableData;
  import com.extjs.gxt.ui.client.widget.layout.VBoxLayout;
  import com.extjs.gxt.ui.client.widget.layout.VBoxLayout.VBoxLayoutAlign;
  import com.extjs.gxt.ui.client.widget.layout.VBoxLayoutData;
  
  /**
   * A pop-up form window for the edit of reminders and monitored points.
   * It is almost the same as {@link org.sigmah.client.page.project.logframe.FormWindow}
   * But it adds a deletion link.
   * 
   * @author HUZHE
   *
   */
  public class EditFormWindow {
  	
  	
  	/**
  	 * Listen the form completion.
  	 * 
  	 * @author tmi
  	 * 
  	 */
  	public static interface FormSubmitListener {
  
  		/**
  		 * Method called when the form is correctly filled (values can be
  		 * <code>null</code> if the null input is allowed for some fields). The
  		 * values are returned in the same order in which fields have been
  		 * added.
  		 * 
  		 * @param values
  		 *            The input values.
  		 */
  		public void formSubmitted(Object... values);
  		
  		
  		/**
  		 * Method called when the uses just click the delete button to remove
  		 * the model object.
  		 */
  		public void deleteModelObject();
  
  	}
  
  	/**
  	 * Manages a field displayed by this window.
  	 * 
  	 * @author tmi
  	 * 
  	 */
  	private static final class FieldWrapper {
  
  		/**
  		 * The form field.
  		 */
  		private final Field<?> field;
  
  		/**
  		 * If the field allows blank value.
  		 */
  		private final boolean allowBlank;
  
  		public FieldWrapper(Field<?> field, boolean allowBlank) {
  			this.field = field;
  			this.allowBlank = allowBlank;
  		}
  	}
  
  	/**
  	 * Combobox preferred height.
  	 */
  	private static final int FIELD_HEIGHT = 32;
  
  	/**
  	 * Listeners.
  	 */
  	private final ArrayList<FormSubmitListener> listeners;
  
  	/**
  	 * The pop-up window.
  	 */
  	private Window window;
  
  	/**
  	 * The form title.
  	 */
  	private Label titleLabel;
  
  	/**
  	 * The vertical panel to display fields.
  	 */
  	private ContentPanel fieldsPanel;
  
  	/**
  	 * List of all fields.
  	 */
  	private final ArrayList<FieldWrapper> fields;
  		
  
  	/**
  	 * Initialize the window.
  	 */
  	public EditFormWindow() {
  		listeners = new ArrayList<FormSubmitListener>();
  		fields = new ArrayList<FieldWrapper>();
  		
  	}
  
  	/**
  	 * Adds a listener.
  	 * 
  	 * @param l
  	 *            The new listener.
  	 */
  	public void addFormSubmitListener(FormSubmitListener l) {
  
  		if (l == null) {
  			return;
  		}
  
  		listeners.add(l);
  	}
  
  	/**
  	 * Removes a listener.
  	 * 
  	 * @param l
  	 *            The old listener.
  	 */
  	public void removeFormSubmitListener(FormSubmitListener l) {
  
  		if (l == null) {
  			return;
  		}
  
  		listeners.remove(l);
  	}
  
  	/**
  	 * Informs the listeners that the form has been filled.
  	 * 
  	 * @param values
  	 *            The input values.
  	 */
  	protected void fireFormSubmitted(Object... values) {
  		for (final FormSubmitListener l : listeners) {
  			l.formSubmitted(values);
  		}
  	}
  	
  	/**
  	 * Informs the listeners that users has pressed the delete button.
  	 * 
  	 */
  	protected void fireDeletion() {
  		for (final FormSubmitListener l : listeners) {
  			l.deleteModelObject();
  		}
  	}
  	
  
  	/**
  	 * Builds the pop-up window.
  	 */
  	private void init() {
  
  		// Build the form label.
  		titleLabel = new Label();
  
  		// Builds the submit button.
  		final Button selectButton = new Button(
  				I18N.CONSTANTS.formWindowSubmitAction(),IconImageBundle.ICONS.save());
  		selectButton.addListener(Events.OnClick, new Listener<BaseEvent>() {
  
  			@Override
  			public void handleEvent(BaseEvent be) {
  
  				final ArrayList<Object> values = new ArrayList<Object>();
  
  				// Retrieves each value.
  				for (final FieldWrapper field : fields) {
  
  					final Object value = field.field.getValue();
  
  					// Checks if null value is allowed for this field.
  					if (!field.allowBlank && value == null) {
  						MessageBox.alert(I18N.CONSTANTS
  								.formWindowFieldsUnfilled(), I18N.CONSTANTS
  								.formWindowFieldsUnfilledDetails(), null);
  						return;
  					}
  
  					values.add(value);
  				}
  
  				fireFormSubmitted(values.toArray(new Object[values.size()]));
  
  				// Closes the window.
  				window.hide();
  			}
  		});
  		
  		final Button deleteButton = new Button(I18N.CONSTANTS.formWindowDeleteAction(),IconImageBundle.ICONS.remove());
  		
  		deleteButton.addListener(Events.OnClick, new Listener<BaseEvent>(){
  
  			@Override
  			public void handleEvent(BaseEvent be) {
  				
  				fireDeletion();
  				
  				//Closes the window
  				window.hide();
  				
  			}
  			
  		});
  
  		// Builds the fields panel.
  