package com.gwtplayer.client.entrypoint;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.widgets.Button;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.plugins.Flashlet;

public class StudioPlayerEntryPoint implements EntryPoint {

  private Button previewButton;
  
  private Flashlet previewFlashlet;
  
  private Window previewWindow;
  
  private Flashlet previewWindowFlashlet;

  /**
   * On load method for studio player. This is where
   * the application starts.
   */
  public void onModuleLoad() {

    VLayout mainLayout = new VLayout();
    mainLayout.setSize("500px", "400px");
    
    previewButton = new Button("Preview");
    previewButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        previewWindow.show();
      }
    });
    mainLayout.addMember(previewButton);
    
    // create preview flashlet on main
    // root pane.
    //
    previewFlashlet = new Flashlet();
    previewFlashlet.setSize("100%", "100%");
    previewFlashlet.setSrc("CellRenderers_sample.swf");
    //previewFlashlet.setCanSelectText(true);
    
    mainLayout.addMember(previewFlashlet);

    // create dialog window.
    //
    previewWindow = new Window();
    previewWindow.setIsModal(true);
    previewWindow.setShowModalMask(true);
    previewWindow.setTitle("Preview");
    previewWindow.setWidth(500);
    previewWindow.setHeight(400);
    previewWindow.hide();

    // create preview window flashlet
    //
    previewWindowFlashlet = new Flashlet();
    previewWindowFlashlet.setSize("100%", "100%");
    previewWindowFlashlet.setSrc("VideoCapture.swf");
    //previewWindowFlashlet.setCanSelectText(true);
    previewWindow.addItem(previewWindowFlashlet);

    // add main layout to root pane.
    //
    RootPanel.get().add(mainLayout);
  }

}
