/// <summary> /// Accepts drop of a tree node, in a drag & drop operation /// </summary> /// <param name="SourceNode"></param> public override void AcceptDrop(BaseTreeNode SourceNode) { base.AcceptDrop(SourceNode); if (SourceNode is VariableTreeNode) { VariableTreeNode variableTreeNode = SourceNode as VariableTreeNode; DataDictionary.Variables.Variable variable = variableTreeNode.Item; variableTreeNode.Delete(); AddVariable(variable); } else if (SourceNode is SpecificationView.ParagraphTreeNode) { SpecificationView.ParagraphTreeNode node = SourceNode as SpecificationView.ParagraphTreeNode; DataDictionary.Specification.Paragraph paragaph = node.Item; DataDictionary.Variables.Variable variable = (DataDictionary.Variables.Variable)DataDictionary.Generated.acceptor.getFactory().createVariable(); variable.Name = paragaph.Name; DataDictionary.ReqRef reqRef = (DataDictionary.ReqRef)DataDictionary.Generated.acceptor.getFactory().createReqRef(); reqRef.Name = paragaph.FullId; variable.appendRequirements(reqRef); AddVariable(variable); } }
/// <summary> /// Adds a variable in the corresponding namespace /// </summary> /// <param name="variable"></param> public VariableTreeNode AddVariable(DataDictionary.Variables.Variable variable) { // Ensure that variables always have a type if (variable.Type == null) { variable.Type = variable.EFSSystem.BoolType; } Item.appendVariables(variable); VariableTreeNode retVal = new VariableTreeNode(variable, new HashSet <DataDictionary.Types.Type>()); Nodes.Add(retVal); SortSubNodes(); return(retVal); }
/// <summary> /// Called when the drop operation is performed on this text box /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void DragDropHandler(object sender, DragEventArgs e) { if (e.Data.GetDataPresent("WindowsForms10PersistentObject", false)) { BaseTreeNode SourceNode = (BaseTreeNode)e.Data.GetData("WindowsForms10PersistentObject"); if (SourceNode != null) { DataDictionaryView.VariableTreeNode variableNode = SourceNode as DataDictionaryView.VariableTreeNode; if (variableNode != null) { StringBuilder text = new StringBuilder(); text.Append(StripUseless(SourceNode.Model.FullName, EnclosingForm.Selected) + " <- "); DataDictionary.Variables.Variable variable = variableNode.Item; DataDictionary.Types.Structure structure = variable.Type as DataDictionary.Types.Structure; if (structure != null) { text.Append(StripUseless(structure.FullName, EnclosingForm.Selected) + "{\n"); bool first = true; foreach (DataDictionary.Types.StructureElement element in structure.Elements) { if (!first) { text.Append(",\n"); } insertElement(element, text, 4); first = false; } text.Append("}\n"); } else { text.Append(variable.DefaultValue.FullName); } SelectedText = text.ToString(); } else { SelectedText = StripUseless(SourceNode.Model.FullName, EnclosingForm.Selected); } } } }
/// <summary> /// Accepts drop of a tree node, in a drag & drop operation /// </summary> /// <param name="sourceNode"></param> public override void AcceptDrop(BaseTreeNode sourceNode) { base.AcceptDrop(sourceNode); if (sourceNode is VariableTreeNode) { VariableTreeNode variableTreeNode = sourceNode as VariableTreeNode; Variable variable = variableTreeNode.Item; variableTreeNode.Delete(); Item.appendVariables(variable); } else if (sourceNode is ParagraphTreeNode) { ParagraphTreeNode node = sourceNode as ParagraphTreeNode; Paragraph paragraph = node.Item; Variable variable = Variable.CreateDefault(Item.Variables); Item.appendVariables(variable); variable.FindOrCreateReqRef(paragraph); } }