package com.siemens.ui.client;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.types.FetchMode;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwtee.tools.client.SCEE;

public class SmartGWTUI implements EntryPoint {

  @Override
  public void onModuleLoad() {
    VLayout layout = new VLayout(2);
    
    IButton adminButton = new IButton("Admin Console");
    adminButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        com.smartgwtee.tools.client.SCEE.openDataSourceConsole();
      }
    });

    IButton vbButton = new IButton("VisualBuilder");
    vbButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        SCEE.openVisualBuilder();
      }
    });

    layout.addMember(adminButton);
    layout.addMember(vbButton);
    layout.draw();
  }

  private void drawListGrid() {
    final ListGrid listGrid = new ListGrid();

    listGrid.setWidth(600);
    listGrid.setHeight(200);
    listGrid.setAlternateRecordStyles(true);
    listGrid.setDataSource(DataSource.get("ormDataSource"));
    listGrid.setCanEdit(false);
    listGrid.setCanRemoveRecords(false);
    listGrid.setDataFetchMode(FetchMode.PAGED);
    listGrid.setAutoFetchData(true);
    listGrid.setUseAllDataSourceFields(true);

    // listGrid.fetchData();

    VLayout layout = new VLayout(15);
    layout.addMember(listGrid);

    layout.draw();
  }
}
