package test.client;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.form.ValuesManager;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.widgets.tab.TabSet;

public class TestIso implements EntryPoint {

	public void onModuleLoad() {

		final ValuesManager mainVm = new ValuesManager();

 		final DataSource ds = TestDS.getInstance();

		ds.fetchData(null, new DSCallback() {
			@Override
			public void execute(DSResponse response, Object rawData,
					DSRequest request) {
				if (response.getTotalRows() > 0) {
					
					mainVm.editRecord(response.getData()[0]);
					
				}else{
						SC.warn("No records received");
				}

			}

		});

		TabSet tabSet = new TabSet();

		final AForm mainForm = new AForm();
		mainForm.setDataSource(ds);
		mainForm.setHeight(100);

		final CForm commentForm = new CForm();
		commentForm.setDataSource(ds);

		Tab subTab = new Tab();
		
		subTab.setPane(commentForm);
		
		tabSet.addTab(subTab);
		tabSet.setHeight100();
		tabSet.setHeight100();
		
		mainVm.setDataSource(ds);

		mainVm.addMember(mainForm);
		mainVm.addMember(commentForm);

		VLayout layout = new VLayout();
		layout.setMembersMargin(10);
		layout.setHeight100();
		layout.setWidth100();
		layout.addMember(mainForm);
		layout.addMember(tabSet);
		
		layout.draw();


	}

}