package com.app.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.widgets.tree.TreeGrid;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class SmartGwtTest implements EntryPoint {
  /**
   * The message displayed to the user when the server cannot be reached or
   * returns an error.
   */
  private static final String SERVER_ERROR = "An error occurred while "
      + "attempting to contact the server. Please check your network "
      + "connection and try again.";

  /**
   * Create a remote service proxy to talk to the server-side Greeting service.
   */
  private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);

  /**
   * This is the entry point method.
   */
  public void onModuleLoad() {
    final LocalDataTreeSample localDataTreeSample = new LocalDataTreeSample();
    final TreeGrid treeGrid= localDataTreeSample.getTreeGrid();
    //final SideNavTree navTreeGrid = new SideNavTree();
    
    // Add the nameField and sendButton to the RootPanel
    // Use RootPanel.get() to get the entire body element
    RootPanel.get("nameFieldContainer").add(treeGrid);
    //RootPanel.get("nameFieldContainer").add(navTreeGrid);
    

    // Create a handler for the sendButton and nameField
    class MyHandler implements ClickHandler, KeyUpHandler {
      /**
       * Fired when the user clicks on the sendButton.
       */
      public void onClick(ClickEvent event) {
        //sendNameToServer();
      }

      /**
       * Fired when the user types in the nameField.
       */
      public void onKeyUp(KeyUpEvent event) {
        if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
          //sendNameToServer();
        }
      }      
    }

    // Add a handler to send the name to the server
    MyHandler handler = new MyHandler();
    //treeGrid.addCickHandler(handler);
  }
}
