/**
 * 
 */
package com.ghost277.smartgwt.testcases.client.hoverTest;

import com.ghost277.smartgwt.testcases.client.common.CountryData;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.RowHoverEvent;
import com.smartgwt.client.widgets.grid.events.RowHoverHandler;

/**
 * @author Papazafeiropoulos Giorgos
 *
 */
public class LIstGridHoverIssue implements EntryPoint {

	private static String hoverText = "My not so small hover text that shouldn't wrap around, but it does!!!";
	/**
	 * 
	 */
	public LIstGridHoverIssue() {
		// TODO Auto-generated constructor stub
	}

	/* (non-Javadoc)
	 * @see com.google.gwt.core.client.EntryPoint#onModuleLoad()
	 */
	@Override
	public void onModuleLoad() {
		Canvas canvas = new Canvas();

		final ListGrid countryGrid = new ListGrid();
		countryGrid.setWidth(500);
		countryGrid.setHeight(224);
		countryGrid.setShowAllRecords(true);
		countryGrid.setAlternateRecordStyles(true);
		countryGrid.setCanHover(true);
		countryGrid.setHoverWrap(false);

		ListGridField nameField = new ListGridField("countryName", "Country");
		ListGridField continentField = new ListGridField("continent", "Continent");
		ListGridField countryCodeField = new ListGridField("countryCode", "Country Code");

		countryGrid.setFields(nameField, continentField, countryCodeField);

		countryGrid.setCanResizeFields(true);
		countryGrid.setData(CountryData.getRecords());
		

		countryGrid.addRowHoverHandler(new RowHoverHandler() {
			
			@Override
			public void onRowHover(RowHoverEvent event) {
				countryGrid.setHoverCustomizer(new HoverCustomizer() {
					
					@Override
					public String hoverHTML(Object value, ListGridRecord record, int rowNum,
							int colNum) {
						GWT.log("On Hover!");
						return hoverText;
					}
				});
				
			}
		});
		
		canvas.addChild(countryGrid);

		
		
		
		canvas.draw();

	}

}
