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> /// Adds a new rule to the model /// </summary> /// <param name="rule"></param> /// <returns></returns> public RuleTreeNode AddRule(DataDictionary.Rules.Rule rule) { RuleTreeNode retVal = new DataDictionaryView.RuleTreeNode(rule); Item.appendRules(rule); Nodes.Add(retVal); SortSubNodes(); return(retVal); }
/// <summary> /// Handles drop event /// </summary> /// <param name="SourceNode"></param> public override void AcceptDrop(BaseTreeNode SourceNode) { if (SourceNode is ShortcutTreeNode) { ShortcutTreeNode shortcut = SourceNode as ShortcutTreeNode; if (shortcut.Item.Dictionary == Item.Dictionary) { DataDictionary.Shortcuts.Shortcut otherShortcut = (DataDictionary.Shortcuts.Shortcut)DataDictionary.Generated.acceptor.getFactory().createShortcut(); shortcut.Item.copyTo(otherShortcut); createShortcut(otherShortcut); shortcut.Delete(); } } else if (SourceNode is ShortcutFolderTreeNode) { ShortcutFolderTreeNode folder = SourceNode as ShortcutFolderTreeNode; if (folder.Item.Dictionary == Item.Dictionary) { DataDictionary.Shortcuts.ShortcutFolder otherFolder = (DataDictionary.Shortcuts.ShortcutFolder)DataDictionary.Generated.acceptor.getFactory().createShortcutFolder(); folder.Item.copyTo(otherFolder); createFolder(otherFolder); folder.Delete(); } } else if (SourceNode is DataDictionaryView.RuleTreeNode) { DataDictionaryView.RuleTreeNode rule = SourceNode as DataDictionaryView.RuleTreeNode; if (rule.Item.Dictionary == Item.Dictionary) { DataDictionary.Shortcuts.Shortcut shortcut = (DataDictionary.Shortcuts.Shortcut)DataDictionary.Generated.acceptor.getFactory().createShortcut(); shortcut.CopyFrom(rule.Item); createShortcut(shortcut); } } else if (SourceNode is DataDictionaryView.FunctionTreeNode) { DataDictionaryView.FunctionTreeNode function = SourceNode as DataDictionaryView.FunctionTreeNode; if (function.Item.Dictionary == Item.Dictionary) { DataDictionary.Shortcuts.Shortcut shortcut = (DataDictionary.Shortcuts.Shortcut)DataDictionary.Generated.acceptor.getFactory().createShortcut(); shortcut.CopyFrom(function.Item); createShortcut(shortcut); } } else if (SourceNode is DataDictionaryView.ProcedureTreeNode) { DataDictionaryView.ProcedureTreeNode procedure = SourceNode as DataDictionaryView.ProcedureTreeNode; if (procedure.Item.Dictionary == Item.Dictionary) { DataDictionary.Shortcuts.Shortcut shortcut = (DataDictionary.Shortcuts.Shortcut)DataDictionary.Generated.acceptor.getFactory().createShortcut(); shortcut.CopyFrom(procedure.Item); createShortcut(shortcut); } } else if (SourceNode is DataDictionaryView.VariableTreeNode) { DataDictionaryView.VariableTreeNode variable = SourceNode as DataDictionaryView.VariableTreeNode; if (variable.Item.Dictionary == Item.Dictionary) { DataDictionary.Shortcuts.Shortcut shortcut = (DataDictionary.Shortcuts.Shortcut)DataDictionary.Generated.acceptor.getFactory().createShortcut(); shortcut.CopyFrom(variable.Item); createShortcut(shortcut); } } }