/* 
	Purpose:
		
	Description:
		
	History:
		2014/12/28, Created by JerryChen

Copyright (C) 2014 Potix Corporation. All Rights Reserved.

*/
package org.zkoss.zssex.ui.dialog.impl;

import java.util.Map;

import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zss.ui.Spreadsheet;
import org.zkoss.zul.Window;
/**
 * 
 * @author JerryChen
 *
 */
public class RefocusDialogCtrlBase extends DialogCtrlBase{
	private static final long serialVersionUID = 8442229443605058405L;
	protected final static String ARG_SPREADSHEET = "spreadsheet";
	Spreadsheet spreadsheet;

	@Override
	public void doAfterCompose(Window comp) throws Exception {
		super.doAfterCompose(comp);
		Map<?,?> arg = Executions.getCurrent().getArg();
		spreadsheet = (Spreadsheet) arg.get(ARG_SPREADSHEET);
	}

	@Override
	// ZSS-851: spreadsheet should be refocus after detaching dialog.
	protected void detach() {
		super.detach();
		if(spreadsheet != null)
			Clients.evalJavaScript("jq('#" + spreadsheet.getUuid() + "').zk.$().focus(true);");
	}
	
	
}
