Beispiel #1
0
  /**
   * Executes the action. Should be overridden by sub-class to define stuffs to execute. If the
   * status of the action differs than CREATED or EXECUTED and if the action cannot be done (canDo),
   * the action is not executed.
   *
   * @since 0.1
   * @return True if the execution is successful. False otherwise.
   */
  public boolean doIt() {
    final boolean ok;

    if ((status == ActionStatus.CREATED || status == ActionStatus.EXECUTED) && canDo()) {
      ok = true;
      doActionBody();
      status = ActionStatus.EXECUTED;
      ActionsRegistry.INSTANCE.onActionExecuted(this);
    } else ok = false;

    return ok;
  }
Beispiel #2
0
 /**
  * Sets the action to "done".
  *
  * @since 0.1
  */
 public void done() {
   if (status == ActionStatus.CREATED || status == ActionStatus.EXECUTED) {
     status = ActionStatus.DONE;
     ActionsRegistry.INSTANCE.onActionDone(this);
   }
 }