public IUndoableEdit ApplyStateToChildren() { if (stateObject == null) { return(null); } CompoundEdit ce = new CompoundEdit(); if (stateObject.GetChildrenObjectStates() == null) { return(ce); } foreach (IStateObject o in stateObject.GetChildrenObjectStates()) { StateObjectManager rlc = new StateObjectManager(o); ce.AddEdit(rlc.ChangeState(stateObject.CurrentState)); } return(ce); }
public IUndoableEdit ChangeState(State newState) { CompoundEdit ce = new CompoundEdit(); if ((stateObject == null)) { return(ce); } //check if the new state can apply to the statebean if (stateObject.GetParentObjectStates() != null) { foreach (IStateObject parentStateObject in stateObject.GetParentObjectStates()) { if (CompareState(parentStateObject.CurrentState, newState) < 0) { throw new Exception("The state cannot change, contains a greater state as a parent"); } } } if (stateObject.GetChildrenObjectStates() == null) { return(ce); } foreach (IStateObject o in stateObject.GetChildrenObjectStates()) { if (o is Combination && stateObject is EquivalenceClass && newState != State.POSITIVE) { ce.AddEdit(PropagateStateChangeInCombination((Combination)o, (EquivalenceClass)stateObject)); } else { StateObjectManager rlc = new StateObjectManager(o); ce.AddEdit(rlc.ChangeState(newState)); } } ce.AddEdit(EditFactory.instance.CreateChangeStateEdit(stateObject, newState)); stateObject.CurrentState = newState; return(ce); }
public IUndoableEdit ApplyState(IStateObject stateObject, State newState) { StateObjectManager sto = new StateObjectManager(stateObject); return(sto.ChangeState(newState)); }