예제 #1
0
        /// <summary>
        /// Add child node to the parent at the given position. Both TreeView and document are added implicitly.
        /// </summary>
        /// <param name="parentNode">DatasetNode, StructNode, or UnionNode</param>
        /// <param name="childNode">Any data node</param>
        /// <param name="at">Position to insert the child</param>
        /// <returns></returns>
        private void addChildNode(DataNode parentNode, DataNode childNode, int at)
        {
            ComplexNode dataNode = null;

            if (parentNode.getDataNode().GetType().Equals(typeof(DefineTypeNode)))
            {
                dataNode = ((DefineTypeNode)parentNode.getDataNode()).getBaseType();
            }
            else
            {
                dataNode = (ComplexNode)parentNode.getDataNode();
            }
            dataNode.insertChild(childNode.getDataNode(), at);
            parentNode.Nodes.Insert(at, childNode);
        }
예제 #2
0
        /// <summary>
        /// Add a dim node to array node or another dim node, if one is available, it is replaced.
        /// </summary>
        /// <remarks>If parent node is the ArrayNode or DefineTypeNode of ArrayNode, then
        /// the new DimNode will replace the original DimNode which is then indented (demoted as the grandchild.
        /// If the parent node is a DimNode, then its child node is replaced and degraded, or if no child node
        /// exists, the new node is added as the child.</remarks>
        /// <param name="parentNode"></param>
        /// <param name="at"></param>
        public void addDimNode(DataNode parentNode, int at)
        {
            AbstractNode dNode = parentNode.getDataNode();

            if (dNode.GetType().Equals(typeof(DefineTypeNode)))
            {
                dNode = ((DefineTypeNode)dNode).getBaseType();
            }
            FormDim      formDim = new FormDim();
            DialogResult r       = formDim.ShowDialog(view_);

            if (r == DialogResult.OK)
            {
                string  sdname  = formDim.DimName;
                string  scount  = formDim.DimCount;
                DimNode dimNode = new DimNode(sdname, scount);
                ((ComplexNode)dNode).insertChild(dimNode, 0);                   //at irrelevant for array and dim node
                DataNode d   = new DataNode(dimNode);
                DataNode old = (DataNode)parentNode.LastNode;
                if (old != null)
                {
                    parentNode.Nodes.Remove(old);
                    d.Nodes.Add(old);
                }
                parentNode.Nodes.Add(d);
                parentNode.ExpandAll();
            }
        }
예제 #3
0
        /// <summary>
        /// Delete a selected node.
        /// </summary>
        /// <remarks>
        /// definitions and dataset: nop
        /// primitive:	delete
        /// complex:	delete
        /// useType:	delete
        /// case:		delete
        /// dim:		delete
        /// </remarks>
        /// <param name="theNode"></param>
        public void deleteNode(DataNode theNode)
        {
            DataNode parentNode = (DataNode)theNode.Parent;

            if (parentNode.getDataNode().isComplex())
            {
                ComplexNode aNode = (ComplexNode)parentNode.getDataNode();
                aNode.removeChild(parentNode.Nodes.IndexOf(theNode));
                if (theNode.getDataNode().GetType().Equals(typeof(DimNode)))
                {
                    //promote its child node if any
                    DataNode childNode = (DataNode)theNode.FirstNode;
                    parentNode.Nodes.Remove(theNode);
                    if (childNode != null)
                    {
                        parentNode.Nodes.Add(childNode);
                    }
                }
                else
                {
                    parentNode.Nodes.Remove(theNode);
                }
            }
        }
예제 #4
0
 /// <summary>
 /// Add child node to the parent at the given position. Both TreeView and document are added implicitly.
 /// </summary>
 /// <param name="parentNode">DatasetNode, StructNode, or UnionNode</param>
 /// <param name="childNode">Any data node</param>
 /// <param name="at">Position to insert the child</param>
 /// <returns></returns>
 private void addChildNode(DataNode parentNode, DataNode childNode, int at)
 {
     ComplexNode dataNode = null;
     if (parentNode.getDataNode().GetType().Equals(typeof(DefineTypeNode)))
     {
         dataNode = ((DefineTypeNode)parentNode.getDataNode()).getBaseType();
     }
     else
     {
         dataNode = (ComplexNode)parentNode.getDataNode();
     }
     dataNode.insertChild(childNode.getDataNode(), at);
     parentNode.Nodes.Insert(at, childNode);
 }
예제 #5
0
 /// <summary>
 /// Delete a selected node.
 /// </summary>
 /// <remarks>
 /// definitions and dataset: nop
 /// primitive:	delete
 /// complex:	delete
 /// useType:	delete
 /// case:		delete
 /// dim:		delete
 /// </remarks>
 /// <param name="theNode"></param>
 public void deleteNode(DataNode theNode)
 {
     DataNode parentNode = (DataNode)theNode.Parent;
     if (parentNode.getDataNode().isComplex())
     {
         ComplexNode aNode = (ComplexNode)parentNode.getDataNode();
         aNode.removeChild(parentNode.Nodes.IndexOf(theNode));
         if (theNode.getDataNode().GetType().Equals(typeof(DimNode)))
         {
             //promote its child node if any
             DataNode childNode = (DataNode)theNode.FirstNode;
             parentNode.Nodes.Remove(theNode);
             if (childNode != null)
             {
                 parentNode.Nodes.Add(childNode);
             }
         }
         else
         {
             parentNode.Nodes.Remove(theNode);
         }
     }
 }
예제 #6
0
 /// <summary>
 /// Add a dim node to array node or another dim node, if one is available, it is replaced.
 /// </summary>
 /// <remarks>If parent node is the ArrayNode or DefineTypeNode of ArrayNode, then
 /// the new DimNode will replace the original DimNode which is then indented (demoted as the grandchild.
 /// If the parent node is a DimNode, then its child node is replaced and degraded, or if no child node
 /// exists, the new node is added as the child.</remarks>
 /// <param name="parentNode"></param>
 /// <param name="at"></param>
 public void addDimNode(DataNode parentNode, int at)
 {
     AbstractNode dNode = parentNode.getDataNode();
     if (dNode.GetType().Equals(typeof(DefineTypeNode)))
     {
         dNode = ((DefineTypeNode)dNode).getBaseType();
     }
     FormDim formDim = new FormDim();
     DialogResult r = formDim.ShowDialog(view_);
     if (r == DialogResult.OK)
     {
         string sdname = formDim.DimName;
         string scount = formDim.DimCount;
         DimNode dimNode = new DimNode(sdname, scount);
         ((ComplexNode)dNode).insertChild(dimNode, 0);	//at irrelevant for array and dim node
         DataNode d = new DataNode(dimNode);
         DataNode old = (DataNode)parentNode.LastNode;
         if (old != null)
         {
             parentNode.Nodes.Remove(old);
             d.Nodes.Add(old);
         }
         parentNode.Nodes.Add(d);
         parentNode.ExpandAll();
     }
 }