void LoadModes()
        {
            storeModes.Clear();
            var  currentMode  = SelectedExecutionMode;
            bool nodeSelected = false;
            var  ctx          = new CommandExecutionContext(item, h => item.CanExecute(new ExecutionContext(h, null, IdeApp.Workspace.ActiveExecutionTarget), IdeApp.Workspace.ActiveConfiguration, SelectedConfiguration));

            foreach (var modeSet in Runtime.ProcessService.GetExecutionModes())
            {
                TreeNavigator setNode = null;
                foreach (var mode in modeSet.ExecutionModes)
                {
                    if (ctx.CanExecute(mode.ExecutionHandler))
                    {
                        if (setNode == null)
                        {
                            setNode = storeModes.AddNode();
                            setNode.SetValue(modeNameField, modeSet.Name);
                            setNode.SetValue(modeField, mode);
                            setNode.SetValue(modeSetField, modeSet);
                            if (mode.Id == currentMode?.Id)
                            {
                                treeModes.SelectRow(setNode.CurrentPosition);
                                nodeSelected = true;
                            }
                        }
                        var node = storeModes.AddNode(setNode.CurrentPosition);
                        node.SetValue(modeNameField, mode.Name);
                        node.SetValue(modeField, mode);
                        node.SetValue(modeSetField, modeSet);
                        if (!nodeSelected && mode.Id == currentMode?.Id)
                        {
                            treeModes.SelectRow(node.CurrentPosition);
                            nodeSelected = true;
                        }
                    }
                }
                // If the mode only has one child, remove it, we don't need to show it
                if (setNode != null && setNode.MoveToChild())
                {
                    var pos = setNode.Clone();
                    if (!setNode.MoveNext())
                    {
                        pos.Remove();
                    }
                }
            }
            if (!nodeSelected && storeModes.GetFirstNode()?.CurrentPosition != null)
            {
                treeModes.SelectRow(storeModes.GetFirstNode().CurrentPosition);
            }
        }
        void UpdateNextChildrenOffset(TreeNavigator node, CheckBoxState newCheck)
        {
            var iter   = node.Clone();
            var change = node.GetValue(nodeEditor);
            var diff   = change.NewText.Length - change.Span.Length;

            if (newCheck == CheckBoxState.Off)
            {
                diff = -diff;
            }

            while (iter.MoveNext())
            {
                var currentOffset = iter.GetValue(nodeOffset);
                iter.SetValue(nodeOffset, currentOffset + diff);
            }
        }
Example #3
0
        private bool GetItem(TreeNavigator root, string text, out TreeNavigator item)
        {
            var nav = root.Clone();

            if (nav.MoveToChild())
            {
                do
                {
                    if (nav.GetValue(_dataText) == text)
                    {
                        item = nav;
                        return(true);
                    }
                }while (nav.MoveNext());
            }

            item = _treeRoot;
            return(false);
        }
Example #4
0
        int BuildTree(TreeNavigator currentPosition, ExtensionNodeDescriptionCollection nodes, int currentDepth, ref int count)
        {
            int maxDepth = currentDepth;

            // TODO: insertbefore/after

            foreach (ExtensionNodeDescription node in nodes)
            {
                count++;
                var pos = currentPosition.Clone().AddChild();

                var label = GetLabelForNode(node);
                pos.SetValue(labelField, label);

                var childDepth = BuildTree(pos, node.ChildNodes, currentDepth + 1, ref count);
                maxDepth = Math.Max(maxDepth, childDepth);
            }

            return(maxDepth);
        }
        int BuildTree(TreeNavigator currentPosition, IEnumerable <AddinNode> addins, HashSet <AddinNode> visited, int currentDepth)
        {
            int maxDepth = currentDepth;

            foreach (var addinNode in addins)
            {
                if (!visited.Add(addinNode))
                {
                    continue;
                }

                var node = currentPosition.Clone().AddChild();
                node.SetValue(labelField, addinNode.Label);

                var childDepth = BuildTree(node, addinNode.Children, visited, currentDepth + 1);
                maxDepth = Math.Max(maxDepth, childDepth);
            }

            return(maxDepth);
        }
        void UpdateRootFromChild(TreeNavigator childNode, CheckBoxState newCheck)
        {
            var rootNode = childNode.Clone();

            rootNode.MoveToParent();

            var iter = rootNode.Clone();

            iter.MoveToChild();

            bool hasFalse = false;
            bool hasTrue  = false;

            do
            {
                var value = iter.GetValue(nodeCheck) == CheckBoxState.On;

                hasTrue  |= value;
                hasFalse |= !value;
            } while (iter.MoveNext());

            bool isMixed = hasFalse && hasTrue;

            if (isMixed)
            {
                rootNode.SetValue(nodeCheck, CheckBoxState.Mixed);
            }
            else
            {
                if (hasTrue)
                {
                    rootNode.SetValue(nodeCheck, CheckBoxState.On);
                }
                else                 // hasFalse
                {
                    rootNode.SetValue(nodeCheck, CheckBoxState.Off);
                }
            }
        }
Example #7
0
        public void SetExists(TreeNavigator titem, bool exists)
        {
            var item = titem.GetValue(_dataTag) as IProjectItem;

            if (item is PipelineProject)
            {
                return;
            }

            if (item is DirectoryItem)
            {
                var fex = exists;
                var nav = titem.Clone();

                if (nav.MoveToChild())
                {
                    do
                    {
                        if (!(titem.GetValue(_dataTag) as IProjectItem).Exists)
                        {
                            fex = false;
                        }
                    }while (nav.MoveNext());
                }

                titem.SetValue(_dataImage, Global.GetXwtDirectoryIcon(fex));
            }
            else
            {
                titem.SetValue(_dataImage, Global.GetXwtFileIcon(PipelineController.Instance.GetFullPath(item.OriginalPath), exists));
            }

            if (titem.MoveToParent())
            {
                SetExists(titem, exists);
            }
        }
Example #8
0
        private TreeNavigator GetorAddItem(TreeNavigator root, IProjectItem item)
        {
            var          nav    = root.Clone();
            var          folder = item is DirectoryItem;
            TreePosition pos    = null;
            TreePosition child  = null;

            if (nav.MoveToChild())
            {
                child = nav.CurrentPosition;

                do
                {
                    if (nav.GetValue(_dataText).ToString() == item.Name)
                    {
                        return(nav);
                    }

                    if (nav.GetValue(_dataTag) is DirectoryItem)
                    {
                        if (folder && string.Compare(nav.GetValue(_dataText), item.Name) < 0 || !folder)
                        {
                            pos = nav.CurrentPosition;
                        }
                    }
                    else if (!folder && nav.GetValue(_dataTag) is ContentItem)
                    {
                        if (string.Compare(nav.GetValue(_dataText), item.Name) < 0)
                        {
                            pos = nav.CurrentPosition;
                        }
                    }
                }while (nav.MoveNext());
            }

            TreeNavigator ret;

            if (pos == null)
            {
                if (child == null)
                {
                    ret = _treeStore.AddNode(root.CurrentPosition);
                }
                else
                {
                    ret = _treeStore.InsertNodeBefore(child);
                }
            }
            else
            {
                ret = _treeStore.InsertNodeAfter(pos);
            }

            if (item is DirectoryItem)
            {
                ret.SetValue(_dataImage, Global.GetXwtDirectoryIcon(item.Exists));
            }
            else
            {
                ret.SetValue(_dataImage, Global.GetXwtFileIcon(PipelineController.Instance.GetFullPath(item.OriginalPath), item.Exists));
            }

            ret.SetValue(_dataText, item.Name);
            ret.SetValue(_dataTag, item);

            return(ret);
        }