private void addTransitionMenuItem_Click(object sender, EventArgs e) { if (StateMachine.States.Count > 1) { DataDictionary.ObjectFactory factory = (DataDictionary.ObjectFactory)DataDictionary.Generated.acceptor.getFactory(); DataDictionary.Rules.Rule rule = (DataDictionary.Rules.Rule)factory.createRule(); rule.Name = "Rule" + (StateMachine.Rules.Count + 1); DataDictionary.Rules.RuleCondition ruleCondition = (DataDictionary.Rules.RuleCondition)factory.createRuleCondition(); ruleCondition.Name = "RuleCondition" + (rule.RuleConditions.Count + 1); rule.appendConditions(ruleCondition); DataDictionary.Rules.Action action = (DataDictionary.Rules.Action)factory.createAction(); action.Expression = "THIS <- " + ((State)StateMachine.States[1]).LiteralName; ruleCondition.appendActions(action); if (MDIWindow.DataDictionaryWindow != null) { DataDictionaryView.StateTreeNode stateNode = MDIWindow.DataDictionaryWindow.FindNode((State)StateMachine.States[0]) as DataDictionaryView.StateTreeNode; DataDictionaryView.RuleTreeNode ruleNode = stateNode.Rules.AddRule(rule); } StateContainerPanel.RefreshControl(); StateContainerPanel.Refresh(); TransitionControl control = StateContainerPanel.getTransitionControl(ruleCondition); Select(control); } }
/// <summary> /// Duplicates this model element /// </summary> /// <returns></returns> public RuleCondition duplicate() { RuleCondition retVal = (RuleCondition)Generated.acceptor.getFactory().createRuleCondition(); retVal.Name = Name; foreach (PreCondition preCondition in PreConditions) { PreCondition newPreCondition = preCondition.duplicate(); retVal.appendPreConditions(newPreCondition); } foreach (Action action in Actions) { Action newAction = action.duplicate(); retVal.appendActions(newAction); } return(retVal); }