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);
            }
        }
        public async Task InitializeEditor()
        {
            var rootNode = store.GetFirstNode();

            if (rootNode == null)
            {
                return;
            }

            var baseDocument = baseEditor.DocumentContext.AnalysisDocument;
            var baseText     = await baseDocument.GetTextAsync();

            int offset = 0;

            var diffService = baseEditor.DocumentContext.RoslynWorkspace.Services.GetService <IDocumentTextDifferencingService> ();

            foreach (var operation in operations)
            {
                if (!(operation is ApplyChangesOperation ac))
                {
                    continue;
                }

                var changedDocument = ac.ChangedSolution.GetDocument(baseDocument.Id);
                var newText         = await changedDocument.GetTextAsync();

                var diff = await diffService.GetTextChangesAsync(baseDocument, changedDocument, CancellationToken.None);

                foreach (var change in diff)
                {
                    var node = rootNode.Clone();

                    var span = GetChangeSpan(newText, change, offset);

                    var newSubText = newText.GetSubText(span).ToString().Replace(Environment.NewLine, "…").Trim();

                    var operationNode = node.AddChild();
                    operationNode.SetValues(nodeCheck, CheckBoxState.On, nodeLabel, newSubText, nodeEditor, change, nodeOffset, offset);

                    offset += change.NewText.Length - change.Span.Length;
                }
            }

            treeView.ExpandAll();
        }
Exemple #3
0
        TreeNavigator SearchNode(string name)
        {
            TreeNavigator navigator = store.GetFirstNode();

            if (navigator.CurrentPosition == null)
            {
                return(null);
            }

            do
            {
                if (name == navigator.GetValue(nameCol))
                {
                    return(navigator);
                }
            } while (navigator.MoveNext());

            return(null);
        }
        void BuildQueryView()
        {
            queryStore.Clear();
            foreach (var server in TFSVersionControlService.Instance.Servers)
            {
                var node = queryStore.AddNode().SetValue(titleField, server.Name);
                foreach (var pc in server.ProjectCollections)
                {
                    node.AddChild().SetValue(titleField, pc.Name);
                    var workItemManager = new WorkItemManager(pc);
                    foreach (var projectInfo in pc.Projects.OrderBy(x => x.Name))
                    {
                        var workItemProject = workItemManager.GetByGuid(projectInfo.Guid);
                        if (workItemProject == null)
                        {
                            continue;
                        }

                        node.AddChild().SetValue(titleField, projectInfo.Name);

                        var privateQueries = workItemManager.GetMyQueries(workItemProject);
                        if (privateQueries.Any())
                        {
                            node.AddChild().SetValue(titleField, "My Queries");
                            foreach (var query in privateQueries)
                            {
                                node.AddChild().SetValue(titleField, query.QueryName).SetValue(queryField, query);
                                node.MoveToParent();
                            }
                            node.MoveToParent();
                        }
                        var publicQueries = workItemManager.GetPublicQueries(workItemProject);
                        if (publicQueries.Any())
                        {
                            node.AddChild().SetValue(titleField, "Public");
                            foreach (var query in publicQueries)
                            {
                                node.AddChild().SetValue(titleField, query.QueryName).SetValue(queryField, query);
                                node.MoveToParent();
                            }
                            node.MoveToParent();
                        }
                        node.MoveToParent();
                    }
                    queryView.ExpandRow(node.CurrentPosition, true);
                }
            }
            var cursor = queryStore.GetFirstNode();

            if (cursor.MoveToChild()) //Move to Project Collections
            {
                queryView.ExpandToRow(cursor.CurrentPosition);
            }
        }
        public CodeIssuePadControl()
        {
            var buttonRow = new HBox();

            runButton.Clicked += StartAnalyzation;
            buttonRow.PackStart(runButton);

            cancelButton.Clicked  += StopAnalyzation;
            cancelButton.Sensitive = false;
            buttonRow.PackStart(cancelButton);

            var groupingProvider = new CategoryGroupingProvider {
                Next = new ProviderGroupingProvider()
            };

            rootGroup = new IssueGroup(groupingProvider, "root group");
            var groupingProviderControl = new GroupingProviderChainControl(rootGroup, groupingProviders);

            buttonRow.PackStart(groupingProviderControl);

            PackStart(buttonRow);

            store               = new TreeStore(textField, nodeField);
            view.DataSource     = store;
            view.HeadersVisible = false;
            view.Columns.Add("Name", textField);
            view.SelectionMode = SelectionMode.Multiple;

            view.RowActivated   += OnRowActivated;
            view.RowExpanding   += OnRowExpanding;
            view.ButtonPressed  += HandleButtonPressed;
            view.ButtonReleased += HandleButtonReleased;
            PackStart(view, true);

            IIssueTreeNode node = rootGroup;

            node.ChildrenInvalidated += (sender, group) => {
                Application.Invoke(delegate {
                    ClearSiblingNodes(store.GetFirstNode());
                    store.Clear();
                    SyncStateToUi(runner.State);
                    foreach (var child in ((IIssueTreeNode)rootGroup).Children)
                    {
                        var navigator = store.AddNode();
                        SetNode(navigator, child);
                        SyncNode(navigator);
                    }
                });
            };
            node.ChildAdded += HandleRootChildAdded;

            runner.IssueSink             = rootGroup;
            runner.AnalysisStateChanged += HandleAnalysisStateChanged;
        }
Exemple #6
0
        public void FillTreeView()
        {
            _treeStore.Clear();
            var versionControl = this.projectCollection.GetService <RepositoryService>();
            var items          = versionControl.QueryItems(new ItemSpec(VersionControlPath.RootFolder, RecursionType.Full), VersionSpec.Latest, DeletedState.NonDeleted, ItemType.Folder, false);
            var root           = ItemSetToHierarchItemConverter.Convert(items);
            var node           = _treeStore.AddNode().SetValue(_name, root.Name).SetValue(_path, root.ServerPath);

            AddChilds(node, root.Children);
            var topNode = _treeStore.GetFirstNode();

            treeView.ExpandRow(topNode.CurrentPosition, false);
        }
Exemple #7
0
        private void ExpandServers()
        {
            var node = _treeStore.GetFirstNode();

            if (node.CurrentPosition == null)
            {
                return;
            }
            _treeView.ExpandRow(node.CurrentPosition, false);
            while (node.MoveNext())
            {
                _treeView.ExpandRow(node.CurrentPosition, false);
            }
        }
        void SelectBestMatchForCaret()
        {
            if (suppressChangeEvent || lastSourceText == null)
            {
                SetPropertyGridValue(null);
                return;
            }

            var roslynSnapshot = lastSourceText.FindCorrespondingEditorTextSnapshot();

            if (roslynSnapshot == null)
            {
                SetPropertyGridValue(null);
                return;
            }
            var point = editorTracker.TextView.Caret.Position.BufferPosition.TranslateTo(roslynSnapshot, PointTrackingMode.Positive);

            var node         = store.GetFirstNode();
            var firstNodePos = node.CurrentPosition;

            while (true)
            {
                var span = node.GetValue(spanField);
                if (span.Contains(point.Position))
                {
                    if (!node.MoveToChild())
                    {
                        break;
                    }
                    continue;
                }
                if (!node.MoveNext())
                {
                    break;
                }
            }

            suppressChangeEvent = true;
            try {
                treeView.CollapseRow(firstNodePos);
                treeView.ExpandToRow(node.CurrentPosition);
                treeView.ScrollToRow(node.CurrentPosition);
                treeView.SelectRow(node.CurrentPosition);
                SetPropertyGridValue(node.GetValue(nodeField));
            } finally {
                suppressChangeEvent = false;
            }
        }
Exemple #9
0
        internal void FillData(List <Sample> samples)
        {
            _samplesStore.Clear();

            foreach (var sample in samples)
            {
                var row = _samplesStore.AddNode();
                row.SetValue(_nameField, sample.Name);
                row.SetValue(_sampleField, sample);
            }

            var firstNode = _samplesStore.GetFirstNode();

            if (firstNode != null)
            {
                _samplesView.SelectRow(firstNode.CurrentPosition);
            }
        }
        void SyncStateToUi(AnalysisState state)
        {
            // Update the top row
            string text = null;

            switch (state)
            {
            case AnalysisState.Running:
                text = "Running...";
                break;

            case AnalysisState.Cancelled:
                text = string.Format("Found issues: {0} (Cancelled)", rootGroup.IssueCount);
                break;

            case AnalysisState.Error:
                text = string.Format("Found issues: {0} (Failed)", rootGroup.IssueCount);
                break;

            case AnalysisState.Completed:
                text = string.Format("Found issues: {0}", rootGroup.IssueCount);
                break;
            }

            if (text != null)
            {
                var topRow = store.GetFirstNode();
                // Weird way to check if the store was empty during the call above.
                // Might not be portable...
                if (topRow.CurrentPosition == null)
                {
                    topRow = store.AddNode();
                }
                topRow.SetValue(textField, text);
            }

            // Set button sensitivity
            bool running = state == AnalysisState.Running;

            runButton.Sensitive    = !running;
            cancelButton.Sensitive = running;
        }
Exemple #11
0
        void UpdateStore(List <IMappingTagSpan <ITag> > tags)
        {
            if (activeTags.Count == tags.Count && tags.All(t => activeTags.Contains(t)))
            {
                Console.WriteLine("up to date");
                return;
            }
            activeTags.Clear();
            foreach (var t in tags)
            {
                activeTags.Add(t);
            }

            var textView = editorTracker.TextView;

            store.Clear();

            if (tags.Count == 0)
            {
                return;
            }

            foreach (var mappingTag in tags)
            {
                var span = mappingTag.Span;
                var nav  = store.AddNode().SetValues(
                    tagNameMarkupField, GetTagMarkup(mappingTag.Tag),
                    spanField, $"[{GetPosition (span.Start)}-{GetPosition (span.End)}]",
                    tagField, mappingTag.Tag
                    );
            }

            treeView.SelectRow(store.GetFirstNode().CurrentPosition);

            string GetPosition(IMappingPoint mp)
            {
                var p = mp.GetPoint(textView.TextBuffer, PositionAffinity.Predecessor);

                return(p.HasValue ? p.Value.Position.ToString() : "?");
            }
        }
Exemple #12
0
        public TreeViewCellBounds()
        {
            MinHeight = 120;
            MinWidth  = 100;

            container = new VBox();
            TreeView  = new TreeView();
            TreeStore = new TreeStore(triState, check, text, desc);
            TreeView.GridLinesVisible = GridLines.Both;

            TreeView.Columns.Add("TriCheck", triState);
            TreeView.Columns.Add("Check", check);
            TreeView.Columns.Add("Item", text);
            TreeView.Columns.Add("Desc", desc, check, text);

            TreeView.DataSource = TreeStore;

            TreeStore.AddNode().SetValue(text, "One").SetValue(desc, "First").SetValue(triState, CheckBoxState.Mixed);
            TreeStore.AddNode().SetValue(text, "Two").SetValue(desc, "Second").AddChild()
            .SetValue(text, "Sub two").SetValue(desc, "Sub second");
            TreeStore.AddNode().SetValue(text, "Three").SetValue(desc, "Third").AddChild()
            .SetValue(text, "Sub three").SetValue(desc, "Sub third");

            TreeView.ExpandAll();


            TreeView.SelectionChanged += (sender, e) => UpdateTracker(TreeView.SelectedRow);
            TreeView.MouseMoved       += (sender, e) => UpdateTracker(TreeView.GetRowAtPosition(e.X, e.Y));

            drawer = new TreeTrackingCanvas(this);

            container.PackStart(TreeView, true);
            container.PackStart(drawer);
            AddChild(container);

            if (currentRow == null)
            {
                currentRow = TreeStore.GetFirstNode();
            }
        }
		public CodeIssuePadControl ()
		{
			var buttonRow = new HBox();
			runButton.Image = ImageService.GetIcon (Ide.Gui.Stock.Execute, IconSize.Menu);
			runButton.Clicked += StartAnalyzation;
			buttonRow.PackStart (runButton);

			cancelButton.Image = ImageService.GetIcon (Ide.Gui.Stock.Stop, IconSize.Menu);
			cancelButton.Clicked += StopAnalyzation;
			cancelButton.Sensitive = false;
			buttonRow.PackStart (cancelButton);
			var groupingProvider = new CategoryGroupingProvider {
				Next = new ProviderGroupingProvider()
			};
			rootGroup = new IssueGroup (groupingProvider, "root group");
			var groupingProviderControl = new GroupingProviderChainControl (rootGroup, groupingProviders);
			buttonRow.PackStart (groupingProviderControl);
			
			PackStart (buttonRow);

			store = new TreeStore (textField, nodeField);
			view.DataSource = store;
			view.HeadersVisible = false;
			view.Columns.Add ("Name", textField);
			view.SelectionMode = SelectionMode.Multiple;

			view.RowActivated += OnRowActivated;
			view.RowExpanding += OnRowExpanding;
			view.ButtonPressed += HandleButtonPressed;
			view.ButtonReleased += HandleButtonReleased;
			PackStart (view, true);
			
			IIssueTreeNode node = rootGroup;
			node.ChildrenInvalidated += (sender, group) => {
				Application.Invoke (delegate {
					ClearSiblingNodes (store.GetFirstNode ());
					store.Clear ();
					foreach(var child in ((IIssueTreeNode)rootGroup).Children) {
						var navigator = store.AddNode ();
						SetNode (navigator, child);
						SyncNode (navigator);
					}
				});
			};
			node.ChildAdded += HandleRootChildAdded;

			IdeApp.Workspace.LastWorkspaceItemClosed += HandleLastWorkspaceItemClosed;
		}
Exemple #14
0
		public TreeViewCellBounds ()
		{
			MinHeight = 120;
			MinWidth = 100;

			container = new VBox ();
			TreeView = new TreeView ();
			TreeStore = new TreeStore (triState, check, text, desc);
			TreeView.GridLinesVisible = GridLines.Both;

			TreeView.Columns.Add ("TriCheck", triState);
			TreeView.Columns.Add ("Check", check);
			TreeView.Columns.Add ("Item", text);
			TreeView.Columns.Add ("Desc", desc, check, text);

			TreeView.DataSource = TreeStore;

			TreeStore.AddNode ().SetValue (text, "One").SetValue (desc, "First").SetValue (triState, CheckBoxState.Mixed);
			TreeStore.AddNode ().SetValue (text, "Two").SetValue (desc, "Second").AddChild ()
				.SetValue (text, "Sub two").SetValue (desc, "Sub second");
			TreeStore.AddNode ().SetValue (text, "Three").SetValue (desc, "Third").AddChild ()
				.SetValue (text, "Sub three").SetValue (desc, "Sub third");

			TreeView.ExpandAll ();


			TreeView.SelectionChanged += (sender, e) => UpdateTracker (TreeView.SelectedRow);
			TreeView.MouseMoved += (sender, e) => UpdateTracker (TreeView.GetRowAtPosition (e.X, e.Y));

			drawer = new TreeTrackingCanvas (this);

			container.PackStart (TreeView, true);
			container.PackStart (drawer);
			AddChild (container);

			if (currentRow == null)
				currentRow = TreeStore.GetFirstNode ();
		}