package com.archway.test.client;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.core.DataClass;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.types.TopOperatorAppearance;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.IPickTreeItem;
import com.smartgwt.client.widgets.layout.VStack;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class GridNestedFilterBulderSample implements EntryPoint {

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		/* Create static data for displaying Operands in filterbuilder */
		DataClass[] ddData = new DataClass[4];
		ddData[0] = new DataClass();
		ddData[0].setAttribute("type", "TX");
		ddData[0].setAttribute("name", "UserName");
		ddData[0].setAttribute("title", "UserName");
		ddData[0].setAttribute("strOperandId", "1");
		ddData[0].setAttribute("strParentOperandId", "");

		ddData[1] = new DataClass();
		ddData[1].setAttribute("type", "TX");
		ddData[1].setAttribute("name", "UserAddress");
		ddData[1].setAttribute("title", "UserAddress");
		ddData[1].setAttribute("strOperandId", "2");
		ddData[1].setAttribute("strParentOperandId", "");

		ddData[2] = new DataClass();
		ddData[2].setAttribute("type", "DT");
		ddData[2].setAttribute("name", "BirthDate");
		ddData[2].setAttribute("title", "BirthDate");
		ddData[2].setAttribute("strOperandId", "3");
		ddData[2].setAttribute("strParentOperandId", "");
		
		ddData[3] = new DataClass();
		ddData[3].setAttribute("type", "TX");
		ddData[3].setAttribute("name", "ChildName");
		ddData[3].setAttribute("title", "ChildName");
		ddData[3].setAttribute("strOperandId", "4");
		ddData[3].setAttribute("strParentOperandId", "1");

		/* Set the data source to filterbuilder */
		final FWFilterBuilder filterBuilder = new FWFilterBuilder();
		DataSource filterBuilderDS = DataSource.get("FSFilterBuilder");
		filterBuilderDS.setTestData(ddData);

		final DataSource FBDataSource = DataSource.get("FSFilterBuilder");
		filterBuilder.setFieldDataSource(FBDataSource);
		filterBuilder.setTopOperatorAppearance(TopOperatorAppearance.INLINE);
		filterBuilder.setShowRemoveButton(false);
		filterBuilder.setShowAddButton(false);
		filterBuilder.setShowSubClauseButton(false);
		filterBuilder.setShowSelectionCheckbox(true);
		filterBuilder.setWidth100();
		filterBuilder.setHeight("*");

		VStack vStack = new VStack(10);
		vStack.addMember(filterBuilder);
		vStack.draw();

	}
}
