1 package org.weda.store.actions; 2 3 import org.weda.action.Action; 4 import org.weda.action.ActionContainer; 5 import org.weda.action.ActionState; 6 import org.weda.store.ObjectSource; 7 import org.weda.store.QueryFilterElement; 8 import org.weda.store.QueryFilterElement.ExpressionType; 9 import org.weda.action.impl.AbstractAction; 10 import org.weda.action.impl.ActionStateImpl; 11 12 /**Цель: почистить текщие шаблоны поиска в {@link org.weda.store.ObjectSource} 13 * 14 * @author Mikhail Titov 15 */ 16 public class ObjectSourceResetSearchPatternsAction extends AbstractAction { 17 18 public ActionState getActionState(ActionContainer targetObject) 19 throws Exception 20 { 21 ObjectSource ds = (ObjectSource)targetObject; 22 boolean canClear = false; 23 for (QueryFilterElement element: 24 ds.getQueryFilter().getFilterElements()) 25 { 26 if (element.getExpressionType()!=ExpressionType.EMPTY){ 27 canClear=true; 28 break; 29 } 30 } 31 return new ActionStateImpl( 32 ds.getSelectedObjectSet()==null, canClear); 33 } 34 35 public Object execute(ActionContainer targetObject) throws Exception { 36 ((ObjectSource)targetObject).getQueryFilter().clearFiltersExpressions(); 37 return null; 38 } 39 40 41 }