Beispiel #1
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();
        }
Beispiel #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);
                }
            }
        }
Beispiel #3
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);
     }
 }
Beispiel #4
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);
         }
     }
 }
Beispiel #5
0
 /// <summary>
 /// LookUp referencing node in the tree
 /// </summary>
 private void ACTION_LookUpNode()
 {
     if (CONTEXT_LIST_VIEW_ITEM == null)
     {
         SHOW_NodeInTree(CONTEXT_XML_NODE);
     }
     else
     {
         VXmlReference r = (VXmlReference)cont.GetNode(VSLib.ConvertStringToLong(CONTEXT_LIST_VIEW_ITEM.SubItems[0].Text));
         SHOW_NodeInTree(r.ReferenceNode);
     }
 }
Beispiel #6
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);
        }
Beispiel #7
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();
        }
Beispiel #8
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();
        }
Beispiel #9
0
        /// <summary>
        /// Download content (content node type only)
        /// </summary>
        private void ACTION_DownloadContent()
        {
            SaveFileDialog sd = new SaveFileDialog();

            sd.Filter           = "All files (*.*)|*.*";
            sd.FilterIndex      = 1;
            sd.RestoreDirectory = true;
            VXmlContent c = (VXmlContent)((CONTEXT_LIST_VIEW_ITEM == null) ? CONTEXT_XML_NODE : cont.GetNode(VSLib.ConvertStringToLong(CONTEXT_LIST_VIEW_ITEM.SubItems[0].Text)));

            string s = c.filename;

            sd.FileName = (s == "") ? "NewFileName" : s;

            if (sd.ShowDialog() == DialogResult.OK)
            {
                c.Download(sd.FileName);
            }
        }
Beispiel #10
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();
                }
            }
        }
Beispiel #11
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);
                }
            }
        }
Beispiel #12
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);
            }
        }
Beispiel #13
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;
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// View XML
        /// </summary>
        private void ACTION_ViewXML()
        {
            VXmlNode n = cont.GetNode(VSLib.ConvertStringToLong(tvCat.SelectedNode.Name));

            VSUICommonFunctions.DisplayText(n.Name, n.Xml);
        }
Beispiel #15
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            short node_type = 0;

            string V = "";
            string N = "";

            for (int i = 0; i < n_type.Length; i++)
            {
                if (n_type[i] == cbNodeType.Text)
                {
                    node_type = n_type_code[i];
                    break;
                }
            }

            RC = 0;
            g.Read();
            N = g.GetValue("name");
            V = g.GetValue("value");

            if ((N == "") & DEFX.BR_NODE_NEED_NAME(node_type))
            {
                MessageBox.Show("Name field is not defined", "Error");
            }
            else if ((node_type == DEFX.NODE_TYPE_CONTENT) &
                     ((g.GetValue("file") == "") | (g.GetValue("title") == "")))
            {
                MessageBox.Show("File name or Title not defined", "Error");
            }
            else
            {
                VXmlNode node = CONT.GetNode(VSLib.ConvertStringToLong(TN.Name));
                try
                {
                    if (node_type == DEFX.NODE_TYPE_CONTENT)
                    {
                        VXmlContent c = node.CreateContent(g.GetValue("file"));
                    }
                    else if (node_type == DEFX.NODE_TYPE_CATALOG)
                    {
                        VXmlCatalog cat    = (VXmlCatalog)CONT.GetNode(node.Id);
                        VXmlCatalog newcat = cat.CreateCatalog(g.GetValue("name"));
                        if (V != "")
                        {
                            newcat.Value = V;
                        }
                    }
                    else if (node_type == DEFX.NODE_TYPE_DOCUMENT)
                    {
                        VXmlCatalog  cat = (VXmlCatalog)CONT.GetNode(node.Id);
                        VXmlDocument d   = cat.CreateDocument(N);
                        if (V != "")
                        {
                            d.Value = V;
                        }
                    }
                    else if (node_type == DEFX.NODE_TYPE_ATTRIBUTE)
                    {
                        node.SetAttribute(N, V);
                    }
                    else if (node_type == DEFX.NODE_TYPE_COMMENT)
                    {
                        node.CreateComment(V);
                    }
                    else if (node_type == DEFX.NODE_TYPE_TEXT)
                    {
                        node.CreateTextNode(V);
                    }
                    else if (node_type == DEFX.NODE_TYPE_TAG)
                    {
                        node.SetTag(V.Trim());
                    }
                    else if (node_type == DEFX.NODE_TYPE_ELEMENT)
                    {
                        VXmlElement el = node.CreateElement(N, V);
                    }
                    else
                    {
                        MessageBox.Show("Invalid node type '" + DEFX.GET_NODETYPE(node_type) + "'", "Error");
                        RC = 1;
                    }
                }
                catch (VXmlException ex)
                {
                    MessageBox.Show(ex.Message, "Error");
                    RC = 1;
                }
                if (RC == 0)
                {
                    this.Close();
                }
            }
        }