package com.firebet.test.client;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.ValuesManager;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
import com.smartgwt.client.widgets.form.fields.FileItem;
import com.smartgwt.client.widgets.form.fields.HiddenItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import com.smartgwt.client.widgets.layout.VLayout;

/**
 * Title:        Test<br>
 * Description:  Sandbox for testing stuff<br>
 */
public class Test implements EntryPoint {

    /**
     * {@inheritDoc}
     */
    @Override
    public void onModuleLoad() {
        
        SC.showConsole();

        final ValuesManager vm = new ValuesManager();
        vm.setDataSource( DataSource.get("testDS") );
        
        DynamicForm form1 = new DynamicForm();
        form1.setValuesManager( vm );
        
        DynamicForm form2 = new DynamicForm();
        form2.setValuesManager( vm );
        
        DynamicForm form3 = new DynamicForm();
        form3.setValuesManager( vm );

        HiddenItem pk = new HiddenItem("pk");
        FileItem file = new FileItem("file", "File");
        TextItem name = new TextItem("name", "Name");
        TextItem emailAddress = new TextItem("emailAddress", "Email");
        TextItem address = new TextItem("address", "Address");
        ButtonItem submit = new ButtonItem("Upload");
        submit.addClickHandler( new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                
                vm.submit();
            }
            
        });
        
        form1.setFields( pk, file, name, submit );
        form2.setFields( emailAddress );
        form3.setFields( address );
        
        VLayout canvas = new VLayout();
        canvas.addMember( form1 );
        canvas.addMember( form2 );
        canvas.addMember( form3 );
        canvas.show();
    }
}