View Javadoc

1   /*
2    * DataSourceCancelEditAction.java
3     * Created on 7 Апрель 2006 г., 15:49
4    */
5   
6   package org.weda.store.actions;
7   
8   import org.weda.action.ActionContainer;
9   import org.weda.action.ActionState;
10  import org.weda.store.ObjectSource;
11  import org.weda.store.ObjectSource.Mode;
12  import org.weda.action.impl.AbstractAction;
13  import org.weda.action.impl.ActionStateImpl;
14  
15  /**
16   *
17   * @author Mikhail Titov
18   */
19  public class ObjectSourceCancelEditAction extends AbstractAction {
20      
21      public ActionState getActionState(ActionContainer targetObject) 
22          throws Exception 
23      {
24          ObjectSource ds = (ObjectSource)targetObject;
25          return new ActionStateImpl(ds.getMode()==Mode.EDIT, true);
26      }
27  
28      public Object execute(ActionContainer targetObject) throws Exception {
29          ObjectSource ds = (ObjectSource)targetObject;
30          ds.cancelModification();
31          return null;
32      }
33      
34  }