View Javadoc

1   /*
2    * DataSourceAddAction.java
3    * Created on 10 Апрель 2006 г., 11:41
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 ObjectSourceAddAction extends AbstractAction {
20      
21      public ActionState getActionState(ActionContainer targetObject) 
22          throws Exception 
23      {
24          ObjectSource ds = (ObjectSource)targetObject;
25          return new ActionStateImpl(
26                       ds.getMode() != Mode.EDIT 
27                    && !ds.isReadOnly()
28                  , true);
29      }
30  
31      public Object execute(ActionContainer targetObject) throws Exception {
32          ObjectSource ds = (ObjectSource)targetObject;
33          ds.createNewRow();
34          return null;
35      }
36      
37  }