package com.evolute.siprp.client.panels.utils.dialog;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiFactory;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Widget;

public class CDialogBox extends DialogBox 
{

	private static CDialogBoxUiBinder uiBinder = GWT.create( CDialogBoxUiBinder.class );
	interface CDialogBoxUiBinder extends UiBinder< Widget, CDialogBox > { }

	@UiField Button btnClose;
	@UiField ErrorMsgs msgs;
	
	private String[] errorMsgs;
	
	public CDialogBox( String[] errorMsg ) 
	{		
		this( "Erro ...", errorMsg );
	}

	public CDialogBox( String title, String[] errorMsg )
	{
		this.errorMsgs = errorMsg;
		setWidget( uiBinder.createAndBindUi( this ) );
		
		this.setText( title );
		btnClose.setText( "Fechar" );

		this.setAnimationEnabled( true );
		this.setGlassEnabled( true );

		this.setAutoHideEnabled( true );
		btnClose.setFocus( true );
	}
	
	@UiFactory ErrorMsgs makeErrorMsgs() 
	{
		return new ErrorMsgs( errorMsgs );
	}
	
	@UiHandler( "btnClose" )
	void onClick( ClickEvent e ) 
	{
		this.hide();
	}

}
