/* ApplyFilter.java

{{IS_NOTE
	Purpose:
		
	Description:
		
	History:
		2013/8/5 , Created by dennis
}}IS_NOTE

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

{{IS_RIGHT
}}IS_RIGHT
*/
package org.zkoss.zssex.ui.impl.ua;

import org.zkoss.zss.api.Ranges;
import org.zkoss.zss.api.SheetOperationUtil;
import org.zkoss.zss.api.model.Book;
import org.zkoss.zss.api.model.Book.BookType;
import org.zkoss.zss.api.model.Sheet;
import org.zkoss.zss.ui.UserActionContext;
import org.zkoss.zss.ui.impl.ua.AbstractProtectedHandler;
/**
 * 
 * @author dennis
 *
 */
public class ReapplyFilterHandler extends AbstractProtectedHandler {
	private static final long serialVersionUID = -7214631280245726763L;
	@Override
	public boolean isEnabled(Book book, Sheet sheet) {
		return book!=null && sheet!=null && !sheet.isProtected() && book.getType()!=BookType.XLS;
	}
	@Override
	protected boolean processAction(UserActionContext ctx) {
		SheetOperationUtil.applyAutoFilter(Ranges.range(ctx.getSheet(), ctx.getSelection())); //ZSS-988
		ctx.clearClipboard();
		return true;
	}

}
