Example #1
0
        /**
         * Execute an action on this History.
         *
         * Normally the history will be updated so that the action can be undone
         * or redone. The exact way how the action affects the history depends
         * on its HistoryOperation.
         *
         * If the action has been executed already, this operation will fail.
         *
         * When an action is executed successfully, the redoable list of actions
         * is cleared.
         *
         * Events Cleared, Changed and ActionExecuted may result from this call.
         *
         * @param action Action to execute in this History instance. If a null
         *		value is passed, the function will return FAILURE.
         *
         * @return Result from executing the action.
         */
        public bool ExecuteAction( ICommand action, object param )
        {
            if ( action == null )
            {
                return false;
            }

            if ( action.Executed )
            {
                return false;
            }

            bool result = (action as Play.Studio.Core.Command.ICommand).ExecuteWithResult(param);

            if ( result == true )
            {
                m_redoableActions.Clear();

                if ( action.HasHistoryOperation( CommandHistoryOperation.CLEAR_ON_SUCCESS ) )
                {
                    // We clear before than checking store on success, so that they
                    // aren't mutually exclusive.
                    Clear();
                }

                if ( action.HasHistoryOperation( CommandHistoryOperation.STORE_ON_SUCCESS ) )
                {
                    m_undoableActions.Add( action );
                    OnChange();
                }
            }

            OnActionExecuted( action, result );

            return result;
        }