Ejemplo n.º 1
0
/// <summary>
/// Build a MetaTreeNodeList containing just queries or data table objects from a list of node names (MruList or Favorites)
/// </summary>
/// <param name="nodeNameList"></param>
/// <returns></returns>

        List <MetaTreeNode> BuildMetaTreeNodeList(List <string> nodeNameList)
        {
            List <MetaTreeNode> nodes = new List <MetaTreeNode>();
            int li = 0;

            while (li < nodeNameList.Count)
            {
                string nodeName = nodeNameList[li];
                if (String.IsNullOrEmpty(nodeName))
                {
                    nodeNameList.RemoveAt(li);
                    continue;
                }

                MetaTreeNode node = MainMenu.GetMetaTreeNode(nodeName);
                if (node != null)
                {
                    li++;
                    if (node.Type == MetaTreeNodeType.Query || MetaTreeNode.IsDataTableNodeType(node.Type))
                    {
                        nodes.Add(node);
                    }

                    else
                    {
                        continue;
                    }
                }

                else                           // remove from list if can't find
                {
                    nodeNameList.RemoveAt(li); // remove from list if not in db
                }
            }

            return(nodes);
        }
Ejemplo n.º 2
0
        private void ContentsTree_Click(object sender, EventArgs e)
        {
            MouseEventArgs me = e as MouseEventArgs;

            if (me == null)
            {
                return;
            }
            TreeListHitInfo hi = QbContentsTreeCtl.TreeList.CalcHitInfo(me.Location);

            if (hi == null || hi.Node == null)
            {
                QbContentsTreeCtl.TreeList.OptionsSelection.MultiSelect = false;
                return;
            }

            MetaTreeNode currentNode = QbContentsTreeCtl.GetMetaTreeNode(hi.Node);

            if (currentNode == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(currentNode.Target))
            {
                DisableMultiselect(hi.Node);
                return;
            }

            // support multiple selections until we find otherwise
            QbContentsTreeCtl.TreeList.OptionsSelection.MultiSelect = true;
            CurrentContentsMetaTreeNodes = QbContentsTreeCtl.GetCurrentSelectedNodes();

            if (CurrentContentsMetaTreeNodes.Count() > 1)
            {
                // process multiple nodes
                bool enabled = false;

                // If the user selected all Data Objects than we will allow muliselect
                if (MetaTreeNode.IsDataTableNodeType(currentNode.Type))
                {
                    foreach (MetaTreeNode node in CurrentContentsMetaTreeNodes)
                    {
                        if (node == currentNode)
                        {
                            break;
                        }
                        enabled = MetaTreeNode.IsDataTableNodeType(node.Type);
                        if (!enabled)
                        {
                            break;
                        }
                    }
                }

                // If the Data Object check above failed, enable multiselect if we have all User Objects that are leafe nodes (no folders).
                if (!enabled && MetaTreeNode.IsUserObjectNodeType(currentNode.Type) && MetaTreeNode.IsLeafNodeType(currentNode.Type))
                {
                    foreach (MetaTreeNode node in CurrentContentsMetaTreeNodes)
                    {
                        if (node == currentNode)
                        {
                            break;
                        }
                        enabled = MetaTreeNode.IsUserObjectNodeType(node.Type) &&
                                  MetaTreeNode.IsLeafNodeType(node.Type);
                        if (!enabled)
                        {
                            break;
                        }
                    }
                }

                // Invalid combination of nodes, disable multiselect.
                if (!enabled)
                {
                    DisableMultiselect(hi.Node);
                    //MessageBox.Show("Multiselection is supported only for the following combinations\r\n\u2022 Lists, Queries, Annotation Tables, Calc Fields (Cut, Copy, Paste, Delete)\r\n\u2022 Data Tables, Anotation Tables, Calc Fields (Add to a Query)");
                }
            }
            else
            {
                //process single node
                if ((currentNode.Type == MetaTreeNodeType.Url || currentNode.Type == MetaTreeNodeType.Action) &&
                    CurrentContentsTreeMouseDownEvent.Button != MouseButtons.Right)
                {
                    ExecuteNodeAction(currentNode);                     // if url send command on 1st click
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// DoQuickSearchAndDisplayOfContentsTree
        /// </summary>
        /// <param name="inputString"></param>

        public void DoQuickSearchAndDisplayOfContentsTree(
            string inputString)
        {
            int maxNodes = 10;

            MatchingContentsNodes =             // find the first set of matching nodes
                                    ContentsTree.FindNodesBySubstringQuick(inputString, maxNodes);

            if (ListControl.ImageList == null)             // be sure we have the images
            {
                ListControl.ImageList = Bitmaps.Bitmaps16x16;
            }

            if (MatchingContentsNodes.Count > 0)
            {
                HashSet <string> allowedMts = ClientState.UserInfo.RestrictedViewAllowedMetaTables;

                ListControl.Items.Clear();
                foreach (MetaTreeNode mtn0 in MatchingContentsNodes)
                {
                    if (allowedMts != null && MetaTreeNode.IsDataTableNodeType(mtn0.Type))                     // see if datatable (metatable) allowed for user
                    {
                        string mtName = mtn0.Target.Trim().ToUpper();
                        if (!allowedMts.Contains(mtName))
                        {
                            continue;
                        }
                    }

                    ImageListBoxItem lbi = new ImageListBoxItem();
                    lbi.ImageIndex = mtn0.GetImageIndex();
                    int i1 = mtn0.Label.IndexOf(inputString, StringComparison.OrdinalIgnoreCase);
                    if (i1 >= 0)
                    {
                        lbi.Value = mtn0.Label;
                    }
                    else
                    {
                        lbi.Value = mtn0.Target + " - " + mtn0.Label;
                    }
                    ListControl.Items.Add(lbi);
                }

                if (MatchingContentsNodes.Count >= maxNodes)                 // show elipsis if only showing partial results
                {
                    ImageListBoxItem lbi = new ImageListBoxItem();
                    lbi.Value = "...";
                    ListControl.Items.Add(lbi);
                }

                ListControl.Location = new Point(0, 0);
                Size = ListControl.Size;
                ListControl.Visible    = true;
                StructurePanel.Visible = false;
                Visible = true;
                RenderId++;
                ListControl.BringToFront();
                return;
            }

            else
            {
                HideQuickSearchPopup();              // nothing found
            }
            return;
        }
Ejemplo n.º 4
0
        static void FilterNodeForUser(
            MetaTreeNode node,
            HashSet <string> allowedMts,
            Dictionary <string, MetaTreeNode> nodes)
        {
            MetaTreeNode[] children = node.Nodes.ToArray();
            for (int ci = 0; ci < children.Length; ci++)
            {
                MetaTreeNode child = children[ci];

                if (MetaTreeNode.IsDataTableNodeType(child.Type))                 // see if metatable allowed
                {
                    string mtName = child.Target.Trim().ToUpper();
                    if (allowedMts.Contains(mtName))
                    {
                        continue;
                    }

                    else
                    {
                        node.Nodes.Remove(child);
                    }
                }

                else if (!child.IsFolderType)                      // non-metatable leaf node
                {
                    string nodeName = child.Name.Trim().ToUpper(); // see if node name in included list
                    if (allowedMts.Contains(nodeName))
                    {
                        continue;
                    }

                    else
                    {
                        node.Nodes.Remove(child);
                    }
                }

                else if (child.IsFolderType)                 // folder node
                {
                    FilterNodeForUser(child, allowedMts, nodes);

                    bool removeChild = true;                     // remove the folder if only standard two tables in folder

                    foreach (MetaTreeNode ccNode in child.Nodes)
                    {
                        if (Lex.Eq(ccNode.Target, "<standardTable1>") && Lex.Ne(child.Name, "<standardTable1>"))
                        {
                        }

                        else if (Lex.Eq(ccNode.Target, "<standardTable2>") && Lex.Ne(child.Name, "<standardTable2>"))
                        {
                        }

                        else
                        {
                            removeChild = false;                          // keep the child
                        }
                    }

                    if (removeChild)
                    {
                        node.Nodes.Remove(child);
                        if (nodes.ContainsKey(child.Name))
                        {
                            nodes.Remove(child.Name);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Filter Restricted Metatable nodes that should be hidden from the user
        /// </summary>
        /// <param name="node"></param>
        /// <param name="blockedMts"></param>
        /// <param name="nodes"></param>
        static void FilterRestrictedMetatableNodeForUser(
            MetaTreeNode node,
            HashSet <string> blockedMts,
            Dictionary <string, MetaTreeNode> nodes)
        {
            MetaTreeNode[] children = node.Nodes.ToArray();
            for (int ci = 0; ci < children.Length; ci++)
            {
                MetaTreeNode child = children[ci];

                if (MetaTreeNode.IsDataTableNodeType(child.Type))                 // see if metatable allowed
                {
                    string mtName = child.Target.Trim().ToUpper();

                    if (blockedMts != null && !blockedMts.Contains(mtName))
                    {
                        continue;
                    }

                    else
                    {
                        node.Nodes.Remove(child);

                        if (nodes.ContainsKey(mtName))
                        {
                            nodes.Remove(mtName);
                        }
                    }
                }

                else if (!child.IsFolderType)                      // non-metatable leaf node
                {
                    string nodeName = child.Name.Trim().ToUpper(); // see if node name in included list
                    if ((blockedMts != null && !blockedMts.Contains(nodeName)))
                    {
                        continue;
                    }

                    else
                    {
                        node.Nodes.Remove(child);

                        if (nodes.ContainsKey(child.Name))
                        {
                            nodes.Remove(child.Name);
                        }
                    }
                }

                else if (child.IsFolderType)                 // folder node
                {
                    FilterRestrictedMetatableNodeForUser(child, blockedMts, nodes);

                    if (!blockedMts.Contains(child.Name))
                    {
                        continue;
                    }
                    else
                    {
                        node.Nodes.Remove(child);
                        if (nodes.ContainsKey(child.Name))
                        {
                            nodes.Remove(child.Name);
                        }
                    }
                }
            }
        }