Exemple #1
0
        /// <summary>
        /// Create new reference
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public VXmlReference CreateReference(VXmlNode n)
        {
            if (!DEFX.BR_NODE_REFERENCE(n.NodeTypeCode))
            {
                throw new VXmlException(VXmlException.E0004_INVALID_NODE_TYPE_CODE, ": " + n.NodeType + " (Create Reference)");
            }

            // Check if this object is already in child node or reference

            VXmlNodeCollection refs = this.get_child_nodes_of_type(DEFX.NODE_TYPE_REFERENCE);

            //Check if ref already exists
            foreach (VXmlReference rf in refs)
            {
                if (rf.ReferenceId == n.Id)
                {
                    return(rf);
                }
            }

            VXmlReference r = (VXmlReference)create_node(DEFX.NODE_TYPE_REFERENCE, n.Name);

            r.set_reference_node(n);

            root_catalog.index_reference.Insert(n.ID, r.Id);          // Add index

            return(r);
        }
Exemple #2
0
        /// <summary>
        /// Check In Node
        /// </summary>
        private void ACTION_CheckInNode()
        {
            VXmlNode new_node = null;
            string   fname    = VSUICommonFunctions.SelectFile(DEFX.KEY_SNAP, "Select snap file for check-in", "Snap files (*." + DEFX.XML_EXPORT_FILE_TYPE + ")|*." + DEFX.XML_EXPORT_FILE_TYPE);

            if (fname != "")
            {
                VXmlNode n     = cont.GetNode(VSLib.ConvertStringToLong(tvCat.SelectedNode.Name));
                bool     state = true;
                tsNode.Text = "Checking in " + fname + " ...";

                Application.DoEvents();

                cont.Begin();
                try
                {
                    new_node = n.ChargeIn(fname);
                }
                catch (VXmlException e1)
                {
                    state = false;
                    MessageBox.Show(e1.Message, "Error", MessageBoxButtons.OK);
                }
                cont.Commit();
                if (state)
                {
                    SHOW_NodeInTree(new_node);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Rename node
        /// </summary>
        private void ACTION_RenameNode()
        {
            VXmlNode n = (CONTEXT_LIST_VIEW_ITEM == null) ? CONTEXT_XML_NODE : cont.GetNode(VSLib.ConvertStringToLong(CONTEXT_LIST_VIEW_ITEM.SubItems[0].Text));

            string res = VSUILib.VSUICommonFunctions.InputBox("Rename node", "New name", value: n.Name, numeric: false);

            if (res == VSUILib.VSUICommonFunctions.CANCELLED)
            {
                return;
            }
            cont.Begin();
            try
            {
                n.Name = res;
            }
            catch (VXmlException e1)
            {
                MessageBox.Show(e1.Message, "Rename node error");
                cont.RollBack();
                return;
            }
            cont.Commit();

            if (CONTEXT_LIST_VIEW_ITEM == null)
            {
                ACTION_SetTreeNodeName(CONTEXT_TREE_NODE, n);
            }
            else
            {
                ACTION_SetListItemName(CONTEXT_LIST_VIEW_ITEM, n);
            }
        }
Exemple #4
0
        public void Init(VXmlCatalog dc, TreeNode tn)
        {
            g = new VSUIPanel(pnMain, "1");
            g.Load(Properties.Resources.CreateNode);

            CONT      = dc;
            TN        = tn;
            this.Text = "Create child node for " + tn.Text;
            cbNodeType.Items.Clear();

            PARENT      = CONT.GetNode(VSLib.ConvertStringToLong(tn.Name));
            n_type_code = DEFX.BR_CHILD_VALID_TYPE_CODES(PARENT.NodeTypeCode);
            n_type      = DEFX.BR_CREATE_VALID_TYPES(PARENT.NodeTypeCode);


            for (int i = 0; i < n_type.Length; i++)
            {
                if (n_type_code[i] != DEFX.NODE_TYPE_REFERENCE)
                {
                    cbNodeType.Items.Add(n_type[i]);
                }
            }

            g.AddControl("type", cbNodeType);
            g.AddControl("select", btnSelectFile);
            g.AddControl("ok", btnCreate);
            g.AddControl("cancel", btnCancel);

            g.Display();
        }
Exemple #5
0
        /// <summary>
        /// Show VXml node in the TV-tree
        /// </summary>
        /// <param name="n"></param>
        private void SHOW_NodeInTree(VXmlNode n)
        {
            // Build path
            List <long> l = new List <long>();

            l.Add(n.Id);
            VXmlNode node = n.ParentNode;

            while (node != null)
            {
                l.Add(node.Id);
                node = node.ParentNode;
            }
            TreeNode t = tvCat.Nodes[0];          //Root (document container)

            SELECT_Node(show_list: false, t: t);
            //Rebuild tree
            for (int i = (l.Count - 1); i >= 0; i--)
            {
                if (i > 0)
                {
                    t = t.FirstNode;
                    string val = l[i - 1].ToString();
                    while (t.Name != val)
                    {
                        t = t.NextNode;
                    }
                    SELECT_Node(show_list: false, t: t);
                }
            }
            tvCat.Select();
            SELECT_Node(show_list: true, t: t);
            tvCat.SelectedNode = t;
            t.Expand();
        }
Exemple #6
0
 /// <summary>
 /// Initialize collection by the array of ids
 /// </summary>
 /// <param name="_node"></param>
 /// <param name="_nodeids"></param>
 public VXmlNodeCollectionEnum(VXmlNode _node, long[] _nodeids)
 {
     node     = _node;
     node_ids = _nodeids;
     //if (node_ids.Length > 0)
     //    pos = 0;
 }
Exemple #7
0
 private void lbResult_DoubleClick(object sender, EventArgs e)
 {
     if (lbResult.SelectedItem != null)
     {
         string   s = (string)lbResult.SelectedItem;
         VXmlNode n = cont.GetNode(VSLib.ConvertStringToLong(s.Substring(4, 8)));
         SHOW_NodeInTree(n);
     }
 }
Exemple #8
0
 /// <summary>
 /// Constructor "Open"
 /// </summary>
 /// <param name="node"></param>
 internal VXmlDummy(VXmlNode node, short type, string name)
 {
     BASE_NODE    = node;
     BASE_OBJECT  = node.OBJ;
     field_type   = type;
     field_name   = name;
     field_value  = "";
     field_prefix = DEFX.NODE_TYPE_INTERNAL_FIELD_PREFIX[type - 100];
 }
Exemple #9
0
 private string UTIL_PrepareName(VXmlNode c)
 {
     if (c.NodeTypeCode == DEFX.NODE_TYPE_REFERENCE)
     {
         return((c.IsChargedOut ? ">> " : "") + "~" + ((VXmlReference)c).ReferenceNode.Name);
     }
     else
     {
         return((c.IsChargedOut ? ">> " : "") + c.Name);
     }
 }
Exemple #10
0
 private void lbResult_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.Enter)
     {
         if (lbResult.SelectedItem != null)
         {
             string   s = (string)lbResult.SelectedItem;
             VXmlNode n = cont.GetNode(VSLib.ConvertStringToLong(s.Substring(4, 8)));
             SHOW_NodeInTree(n);
         }
     }
 }
Exemple #11
0
 /// <summary>
 /// Set Tree node name
 /// </summary>
 /// <param name="tn"></param>
 /// <param name="c"></param>
 private void ACTION_SetListItemName(ListViewItem ln, VXmlNode c)
 {
     ln.SubItems[2].Text = UTIL_PrepareName(c);
     for (int i = 0; i < CONTEXT_TREE_NODE.Nodes.Count; i++)
     {
         if (CONTEXT_TREE_NODE.Nodes[i].Name == c.ID)
         {
             ACTION_SetTreeNodeName(CONTEXT_TREE_NODE.Nodes[i], c);
             break;
         }
     }
 }
Exemple #12
0
        public VXmlNodeCollection(VXmlNode _node, long[] _nodeids)
        {
            node = _node;

            node_ids = new List <long>(256);
            if (_nodeids != null)
            {
                for (int i = 0; i < _nodeids.Length; i++)
                {
                    node_ids.Add(_nodeids[i]);
                }
            }
        }
Exemple #13
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="node"></param>
        internal VXmlDummyCollection(VXmlNode node, string type, string prefix)
        {
            // Save base objects
            BASE_NODE   = node;
            BASE_OBJECT = node.OBJ;
            field_type  = type;

            // Get fields list
            object_fields = BASE_OBJECT.GetFields(type + prefix);

            for (int i = 0; i < object_fields.Length; i++)
            {
                object_fields[i] = object_fields[i].Remove(0, 1);
            }
        }
Exemple #14
0
 /// <summary>
 /// Close XML storage
 /// </summary>
 private void ACTION_CloseStorage()
 {
     if (OPENED)
     {
         pnQuery.Visible = false;
         tvCat.Nodes.Clear();
         lvDetails.Clear();
         cont.Close();
         OPENED      = false;
         ROOT        = "";
         tsNode.Text = "";
         SHOW_Buttons();
         CONTEXT_TREE_NODE = null;
         CONTEXT_XML_NODE  = null;
     }
 }
Exemple #15
0
        /// <summary>
        /// Copy node name to clipboard
        /// </summary>
        private void ACTION_CopyToClipboard()
        {
            VXmlNode n = null;
            string   s = "";

            if (CONTEXT_LIST_VIEW_ITEM != null)
            {
                s = lvDetails.SelectedItems[0].SubItems[0].Text;
                n = cont.GetNode(VSLib.ConvertStringToLong(s));
            }
            else
            {
                n = CONTEXT_XML_NODE;
            }
            Clipboard.SetText(n.Name);
        }
Exemple #16
0
        /// <summary>
        /// Get id by name
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        protected long get_node_by_name(string name)
        {
            if (node_ids == null)
            {
                return(0);
            }

            for (int i = 0; i < node_ids.Count; i++)
            {
                VXmlNode n = node.GetNode(node_ids[i]);
                if (VSLib.Compare(name, n.Name))
                {
                    return(n.Id);
                }
            }
            return(0);
        }
Exemple #17
0
        // Build full path
        private string build_path()
        {
            if (CONTEXT_XML_NODE == null)
            {
                return("");
            }

            string path = "/" + CONTEXT_XML_NODE.Name;

            VXmlNode n = CONTEXT_XML_NODE.ParentNode;

            while (n != null)
            {
                path = "/" + n.Name + path;
                n    = n.ParentNode;
            }
            return(path);
        }
Exemple #18
0
        /// <summary>
        /// Load XML
        /// </summary>
        private void ACTION_LoadXML()
        {
            string fname = VSUICommonFunctions.SelectFile(DEFX.KEY_LOAD_XML, "Select XML file for load", "XML files (*.xml" + ")|*.xml");

            if (fname != "")
            {
                VXmlNode n = cont.GetNode(VSLib.ConvertStringToLong(tvCat.SelectedNode.Name));
                tsNode.Text = "Loading " + fname + " ...";
                Application.DoEvents();
                Cursor.Current = Cursors.WaitCursor;
                cont.Begin();
                string rc = "";
                try
                {
                    if (n.NodeTypeCode == DEFX.NODE_TYPE_DOCUMENT)
                    {
                        VXmlDocument d = (VXmlDocument )cont.GetNode(n.Id);
                        rc = d.Load(fname);
                    }
                    else
                    {
                        rc = n.Load(fname);
                    }
                }
                catch (VXmlException e1)
                {
                    rc = e1.Message;
                }

                if (rc == "")
                {
                    cont.Commit();
                    SHOW_NodeInTree(n);
                }
                else
                {
                    cont.RollBack();
                    MessageBox.Show(rc, "Load error", MessageBoxButtons.OK);
                }
            }
            Cursor.Current = Cursors.Default;
            SELECT_Node();
        }
Exemple #19
0
        /// <summary>
        /// Load child node(s) from file
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public new string Load(string file, VXmlNode parent = null)
        {
            string s     = "";
            string error = "";

            try
            {
                s = File.ReadAllText(file, Encoding.Default);
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            if (error != "")
            {
                return(VXmlException.GetMessage(VXmlException.E0025_XML_FILE_ERROR_CODE) + ": " + error);
            }

            //return LoadXml(s, Path.GetFileName(file), parent);
            return(load_xml_data(s, Path.GetFileNameWithoutExtension(file), file, parent));
        }
Exemple #20
0
        /// <summary>
        /// Set Tree node name
        /// </summary>
        /// <param name="tn"></param>
        /// <param name="c"></param>
        private void ACTION_SetTreeNodeName(TreeNode tn, VXmlNode c)
        {
            string   s      = "";
            string   nodeid = c.ID;
            VXmlNode n      = null;

            if (c.NodeTypeCode == DEFX.NODE_TYPE_REFERENCE)
            {
                n       = ((VXmlReference)c).ReferenceNode;
                nodeid += "~" + n.ID;
            }
            else
            {
                n = c;
            }

            tn.Text = UTIL_PrepareName(c);


            s =
                "Id='" + nodeid + "'\r" + "\n" +
                "Type='" + n.NodeType + "'\r" + "\n" +
                "Name='" + n.Name + "'\r" + "\n" +
                "Value='" + n.Value + "'";

            if (c.GUID != "")
            {
                s += "\r" + "\n" + "GUID=" + c.GUID;
            }

            if (c.NodeTypeCode == DEFX.NODE_TYPE_CONTENT)
            {
                VXmlContent ct = (VXmlContent)cont.GetNode(c.Id);
                s += "\r" + "\n" +
                     "File name='" + ct.filename + "'" + "\r" + "\n" +
                     "Size='" + ct.Length.ToString("#,0;(#,0)") + " bytes";
            }

            tn.ToolTipText = s;
        }
Exemple #21
0
        /// <summary>
        /// Display next level of the child nodes - recursively
        /// </summary>
        /// <param name="parent"></param>
        private void SHOW_Childs()
        {
            VXmlNode           node;
            TreeNodeCollection tc;

            Cursor.Current = Cursors.WaitCursor;

            tvCat.BeginUpdate();

            if (CONTEXT_TREE_NODE == null)
            {
                node                       = cont;
                CONTEXT_XML_NODE           = cont;
                CONTEXT_TREE_NODE          = tvCat.Nodes.Add(node.ID, UTIL_PrepareName(node));
                CONTEXT_TREE_NODE.ImageKey = node.NodeType;
                ACTION_SetTreeNodeName(CONTEXT_TREE_NODE, node);
                tc = CONTEXT_TREE_NODE.Nodes;
                tvCat.SelectedNode = CONTEXT_TREE_NODE;
            }
            else
            {
                tc   = CONTEXT_TREE_NODE.Nodes;
                node = CONTEXT_XML_NODE;
            }
            tc.Clear();

            if ((node.NodeTypeCode != DEFX.NODE_TYPE_ATTRIBUTE) & (node.NodeTypeCode != DEFX.NODE_TYPE_COMMENT) & (node.NodeTypeCode != DEFX.NODE_TYPE_TEXT))
            {
                VXmlNodeCollection cn = node.AllChildNodes;
                for (int i = 0; i < cn.Count; i++)
                {
                    VXmlNode c  = cn[i];
                    TreeNode tn = tc.Add(c.ID, UTIL_PrepareName(c));
                    tn.ImageKey = (c.NodeTypeCode == DEFX.NODE_TYPE_REFERENCE) ? ((VXmlReference)c).ReferenceNode.NodeType : c.NodeType;
                    ACTION_SetTreeNodeName(tn, c);
                }
            }
            tvCat.EndUpdate();
            Cursor.Current = Cursors.Default;
        }
Exemple #22
0
        private void SELECT_Node(bool show_list = true, TreeNode t = null)
        {
            TreeNode tn = (t == null) ? tvCat.SelectedNode : t;

            if (tn != null)
            {
                CONTEXT_TREE_NODE = tn;

                CONTEXT_XML_NODE = cont.GetNode(VSLib.ConvertStringToLong(CONTEXT_TREE_NODE.Name));
                if (CONTEXT_XML_NODE.NodeTypeCode == DEFX.NODE_TYPE_REFERENCE)
                {
                    CONTEXT_REF_NODE = (VXmlReference)CONTEXT_XML_NODE;
                    CONTEXT_XML_NODE = cont.GetNode(CONTEXT_REF_NODE.ReferenceId);
                }
                else
                {
                    CONTEXT_REF_NODE = null;
                }

                if (CONTEXT_TREE_NODE.FirstNode == null)
                {
                    SHOW_Childs();
                }

                if (show_list)
                {
                    SHOW_NodeList();
                }
                MENU_NODE_SELECTED_TYPE = "";
                MENU_NODE_SELECTED_NAME = "";
            }
            else
            {
                tsNode.Text = "";
            }
            build_path();
        }
Exemple #23
0
        /// <summary>
        /// Search (XQL)
        /// </summary>
        private void ACTION_SearchNode()
        {
            VXmlNode n  = null;
            string   st = mnuSearchTextBox.Text.Trim();

            if (st.Length > 0)
            {
                if (tsSearchType.Text == "ID")
                {
                    int  nv        = 0;
                    bool IsNumeric = int.TryParse(st, out nv);
                    if (IsNumeric & (nv > 0))
                    {
                        n = cont.GetNode((long)nv);

                        if (n != null)
                        {
                            SHOW_NodeInTree(n);
                        }
                        else
                        {
                            MessageBox.Show("Node is not found, ID=" + nv.ToString(), "Lookup node", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid node ID in request", "Lookup node", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    decimal d = 0;

                    if (CONTEXT_LIST_VIEW_ITEM == null)
                    {
                        n = CONTEXT_XML_NODE;
                    }
                    else
                    {
                        n = cont.GetNode(VSLib.ConvertStringToLong(CONTEXT_LIST_VIEW_ITEM.SubItems[0].Text));
                    }

                    if (n.NodeTypeCode == DEFX.NODE_TYPE_REFERENCE)
                    {
                        n = ((VXmlReference)n).ReferenceNode;
                    }

                    //n = CONTEXT_XML_NODE; // cont.GetNode(VSLib.ConvertStringToLong(tvCat.SelectedNode.Name));

                    VXmlNodeCollection l = null;
                    try
                    {
                        lbResult.Items.Clear();
                        pnQuery.Visible  = true;
                        tsNodeCount.Text = "Running query...";
                        Application.DoEvents();
                        Cursor.Current = Cursors.WaitCursor;
                        long l_start = DateTime.Now.Ticks;
                        l = n.SelectNodes(st);
                        long l_end = DateTime.Now.Ticks;
                        d = l_end - l_start;
                    }
                    catch (VXmlException e1)
                    {
                        MessageBox.Show(e1.Message, "Error", MessageBoxButtons.OK);
                    }

                    if (l != null)
                    {
                        tsNodeCount.Text = "Selected " + l.Count.ToString() + " nodes in " + (d / 10000000).ToString("F") + " seconds";
                        Application.DoEvents();
                        Cursor.Current = Cursors.WaitCursor;
                        lbResult.BeginUpdate();
                        for (int i = 0; i < l.Count; i++)
                        {
                            lbResult.Items.Add("<Id:" + l[i].Id.ToString("D8") + "><Name:" + l[i].Name + "><Type:" + l[i].NodeType + ">");
                        }
                        lbResult.EndUpdate();
                    }
                    else
                    {
                        tsNodeCount.Text = "";
                    }
                    Cursor.Current  = Cursors.Default;
                    pnQuery.Visible = true;
                    mnuHide.Visible = true;
                    SHOW_Buttons();
                }
            }
        }
Exemple #24
0
        /// <summary>
        /// Delete Node and all subtree
        /// </summary>
        private void ACTION_DeleteNode()
        {
            string nm = (CONTEXT_LIST_VIEW_ITEM == null) ? CONTEXT_TREE_NODE.Text : (CONTEXT_LIST_VIEW_ITEM.SubItems[1].Text + " {" + CONTEXT_LIST_VIEW_ITEM.SubItems[2].Text + "}");

            if (MessageBox.Show("Do you want to proceed and delete node '" + nm + "'?", "Delete node", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                if (CONTEXT_LIST_VIEW_ITEM == null)
                {
                    VXmlNode NodeToDelete = cont.GetNode(VSLib.ConvertStringToLong(CONTEXT_TREE_NODE.Name));
                    VXmlNode pnode        = NodeToDelete.ParentNode;
                    if (CONTEXT_REF_NODE == null)
                    {
                        if (pnode == null)
                        {
                            if (MessageBox.Show("You are about to delete root node." + "\r\n" +
                                                "Storage will be closed in this case after deletion." + "\r\n" +
                                                "Do you want to proceed?", "Delete node", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
                            {
                                return;
                            }
                        }
                    }

                    tsNode.Text = "Deleting node ...";
                    Application.DoEvents();
                    Cursor.Current = Cursors.WaitCursor;
                    cont.Begin();
                    try
                    {
                        if (CONTEXT_LIST_VIEW_ITEM != null)
                        {
                            string rid = NodeToDelete.ID;
                            NodeToDelete.Remove();
                            CONTEXT_LIST_VIEW_ITEM.Remove();
                            for (int i = 0; i < CONTEXT_TREE_NODE.Nodes.Count; i++)
                            {
                                if (CONTEXT_TREE_NODE.Nodes[i].Name == rid)
                                {
                                    CONTEXT_TREE_NODE.Nodes[i].Remove();
                                    break;
                                }
                            }
                        }
                        else
                        {
                            if (CONTEXT_REF_NODE == null)
                            {
                                CONTEXT_XML_NODE.Remove();
                                if (pnode == null)
                                {
                                    Cursor.Current = Cursors.Default;
                                    ACTION_CloseStorage();
                                    return;
                                }
                            }
                            else
                            {
                                CONTEXT_REF_NODE.Remove();
                            }

                            tvCat.SelectedNode = CONTEXT_TREE_NODE.Parent;
                            CONTEXT_TREE_NODE.Remove();
                        }
                    }
                    catch (VXmlException e1)
                    {
                        MessageBox.Show(e1.Message, "Error", MessageBoxButtons.OK);
                    }
                    cont.Commit();
                    tsNode.Text = "";
                    SELECT_Node();
                    Cursor.Current = Cursors.Default;
                }
                else
                {
                    if (MENU_NODE_SELECTED_TYPE == DEFX.GET_NODETYPE(DEFX.NODE_TYPE_ATTRIBUTE))
                    {
                        CONTEXT_XML_NODE.RemoveAttribute(MENU_NODE_SELECTED_NAME);
                    }
                    else if (MENU_NODE_SELECTED_TYPE == DEFX.GET_NODETYPE(DEFX.NODE_TYPE_COMMENT))
                    {
                        CONTEXT_XML_NODE.RemoveComment(MENU_NODE_SELECTED_NAME);
                    }
                    else if (MENU_NODE_SELECTED_TYPE == DEFX.GET_NODETYPE(DEFX.NODE_TYPE_TEXT))
                    {
                        CONTEXT_XML_NODE.RemoveText(MENU_NODE_SELECTED_NAME);
                    }
                    //else // Tag
                    //    CONTEXT_XML_NODE.RemoveTag.RemoveTagByName(MENU_NODE_SELECTED_NAME);

                    SELECT_Node(true, CONTEXT_TREE_NODE);
                }
            }
        }
Exemple #25
0
 public VXmlAttribute(VXmlNode node, string name)
     : base(node, DEFX.NODE_TYPE_ATTRIBUTE, name)
 {
 }
Exemple #26
0
 internal VXmlTagCollection(VXmlNode node)
     : base(node, DEFX.PREFIX_TAG, "*")
 {
 }
Exemple #27
0
        /// <summary>
        /// View XML
        /// </summary>
        private void ACTION_ViewXML()
        {
            VXmlNode n = cont.GetNode(VSLib.ConvertStringToLong(tvCat.SelectedNode.Name));

            VSUICommonFunctions.DisplayText(n.Name, n.Xml);
        }
Exemple #28
0
        /// <summary>
        /// Show/hide buttons and menu items
        /// </summary>
        private void SHOW_Buttons()
        {
            mOpenStorage.Enabled   = mCreateStorage.Enabled = !OPENED;
            mDeleteStorage.Enabled = mCloseStorage.Enabled = OPENED;

            mnuCopyToClip.Enabled = mnuDownloadContent.Visible = mnuSaveXML.Visible = mnuSaveXMLWithContent.Visible = false;
            mnuViewXML.Visible    = mnuLoadXML.Visible = false;

            mnuCreate.Visible = mCreate.Enabled = false;

            mnuDelete.Visible = mDelete.Enabled = false;

            mnuEdit.Visible = mEdit.Enabled = false;

            mnuCheckIn.Visible = mCheckIn.Enabled = false;

            mnuCheckOut.Visible = mCheckOut.Enabled = false;

            mnuSnap.Visible = mSnap.Enabled = false;

            mnuUndoCheckOut.Visible = mUndoCheckOut.Enabled = false;

            mnuRenameNode.Visible = mnuLookUp.Visible = false;

            mnuSearch.Enabled = mnuSearchTextBox.Enabled = false;

            if (OPENED)
            {
                mnuSearch.Enabled = mnuSearchTextBox.Enabled = true;
                if (CONTEXT_LIST_VIEW_ITEM == null)
                {
                    VXmlNode n = cont.GetNode(VSLib.ConvertStringToLong(CONTEXT_TREE_NODE.Name));

                    mnuCheckIn.Visible = mCheckIn.Enabled = (CONTEXT_LIST_VIEW_ITEM == null) & DEFX.BR_CHARGEIN_IS_VALID_TYPE(n.NodeTypeCode);

                    mnuCheckOut.Visible = mSnap.Enabled = mnuSnap.Visible = mCheckOut.Enabled = (CONTEXT_LIST_VIEW_ITEM == null) & (DEFX.BR_CHARGEOUT_IS_VALID_TYPE(n.NodeTypeCode) & (!n.IsChargedOut));

                    mnuUndoCheckOut.Visible = mUndoCheckOut.Enabled = (CONTEXT_LIST_VIEW_ITEM == null) & ((n.IsChargedOut) & (n.GUID != ""));

                    mnuCreate.Visible = mCreate.Enabled = (CONTEXT_LIST_VIEW_ITEM == null) & (!n.IsChargedOut) & (DEFX.BR_CHILD_VALID_TYPE_CODES(n.NodeTypeCode).Length > 0);

                    mnuEdit.Visible = mEdit.Enabled = !n.IsChargedOut;

                    mnuDelete.Visible = mDelete.Enabled = (!n.IsChargedOut);

                    mnuCopyToClip.Enabled = true;

                    mnuDownloadContent.Visible = (n.NodeTypeCode == DEFX.NODE_TYPE_CONTENT);

                    mnuSaveXML.Visible = mnuLoadXML.Visible = mnuSaveXMLWithContent.Visible = mnuViewXML.Visible = (CONTEXT_LIST_VIEW_ITEM == null) & DEFX.BR_XML_IS_VALID_TYPE(n.NodeTypeCode);

                    mnuRenameNode.Visible = DEFX.BR_NODE_RENAME(n.NodeTypeCode);

                    mnuLookUp.Visible = (n.NodeTypeCode == DEFX.NODE_TYPE_REFERENCE);
                }
                else
                {
                    mnuDelete.Visible     = mDelete.Enabled = mnuEdit.Visible = mEdit.Enabled = true;
                    mnuCopyToClip.Enabled = true;
                }
            }
        }
Exemple #29
0
        /// <summary>
        /// Serialize node
        /// </summary>
        /// <param name="node"></param>
        public void Serialize(VXmlNode node, short level)
        {
            Level = level;

            Type    = node.NodeTypeCode;
            Name    = node.Name;
            Value   = node.Value;
            Content = null;

            VXmlContent ct = null;

            if (Type == DEFX.NODE_TYPE_CONTENT)
            {
                ct      = (VXmlContent)node.GetNode(node.Id);
                Content = ct.ContentBytes;
            }

            VXmlAttributeCollection ac = node.Attributes;
            VXmlCommentCollection   cc = node.CommentNodes;
            VXmlTextCollection      tx = node.TextNodes;
            VXmlTagCollection       tt = node.TagNodes;


            byte[] br = new byte[RESERVE_LENGTH];                   // Reserve

            // Fixed part
            IO.Write(-1, level);                                          // +08(2) - level
            IO.Write(-1, Type);                                           // +10(2) - node type
            IO.Write(-1, (short)Name.Length);                             // +12(2) - name length
            IO.Write(-1, (long)Value.Length);                             // +14(8) - value length
            IO.Write(-1, (long)((Content == null) ? 0 : Content.Length)); // +22(8) - content length
            IO.Write(-1, (int)ac.Count);                                  // +30(4)   Number of attrs
            IO.Write(-1, (int)cc.Count);                                  // +34(4)   Number of comments
            IO.Write(-1, (int)tx.Count);                                  // +34(4)   number of text nodes
            IO.Write(-1, (int)tt.Count);                                  // +38(4)   number of tags
            IO.Write(-1, ref br);                                         // +42(16)- reserve

            // Variable part
            IO.Write(-1, node.Name);        // Name

            if (Value.Length > 0)
            {
                IO.Write(-1, Value);        // Value
            }
            if (Content != null)
            {
                IO.Write(-1, ref Content); // Content
            }
            // Write attributes
            for (int i = 0; i < ac.Count; i++)
            {
                IO.Write(-1, (short)ac[i].Name.Length);      // Attr name length
                IO.Write(-1, ac[i].Name);                    // Attr name

                IO.Write(-1, (int)ac[i].Value.Length);       // Attr value length
                IO.Write(-1, ac[i].Value);                   // Attr value
            }

            // Write comments
            for (int i = 0; i < cc.Count; i++)
            {
                IO.Write(-1, (int)cc[i].Value.Length);       // Comment value length
                IO.Write(-1, cc[i].Value);                   // Comment value
            }

            // Write text
            for (int i = 0; i < tx.Count; i++)
            {
                IO.Write(-1, (int)tx[i].Value.Length);       // Text value length
                IO.Write(-1, tx[i].Value);                   // Text value
            }

            // Write tags
            for (int i = 0; i < tt.Count; i++)
            {
                IO.Write(-1, (int)tt[i].Value.Length);       // Tag value length
                IO.Write(-1, tt[i].Value);                   // Tag value
            }
        }
Exemple #30
0
 internal VXmlCommentCollection(VXmlNode node)
     : base(node, DEFX.PREFIX_COMMENT, "*")
 {
 }