package customformitem.client;

import java.util.Date;
import java.util.HashMap;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.core.KeyIdentifier;
import com.smartgwt.client.util.KeyCallback;
import com.smartgwt.client.util.Page;
import com.smartgwt.client.util.SC;

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

    
    private GeneralPage page = null;
    
    /**
     * This is the entry point method.
     */
    public void onModuleLoad() {
        KeyIdentifier debugKey = new KeyIdentifier();
        debugKey.setCtrlKey(true);
        debugKey.setKeyName("E");

        Page.registerKey(debugKey, new KeyCallback() {
            public void execute(String keyName) {
                SC.showConsole();
            }
        });

        GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler(){
            @Override
            public void onUncaughtException(Throwable e) {
                Date date = new Date();
                DateTimeFormat sdf = DateTimeFormat.getFormat("MM/dd/yyyy HH:mm:ss");
                System.err.println(sdf.format(date)+" Uncaught Exception intercepted ");
                e.printStackTrace();
            }
        });
        

        DeferredCommand.addCommand( 
                        new Command() {
                           public void execute() {
                               page = new GeneralPage();
                               CustomItemPanel p = new CustomItemPanel();
                               page.setContentArea(p, new HashMap());
                               page.init();
                               RootPanel.get().add(page);
                           }
                        } );
    }

}
