Example #1
0
        protected override void OnActivated(EventArgs e)
        {
            base.OnActivated(e);

            // apply current connector selection when dialog is first activated
            if (firstActivated)
            {
                firstActivated = false;
                IAnkhIssueService iService = Context.GetService <IAnkhIssueService>();
                if (iService != null)
                {
                    IssueRepositorySettings solutionSettings = CurrentSolutionSettings;
                    if (solutionSettings != null)
                    {
                        IssueRepositoryConnector selectConnector;
                        if (iService.TryGetConnector(solutionSettings.ConnectorName, out selectConnector))
                        {
                            if (selectConnector != null)
                            {
                                connectorComboBox.SelectedItem = selectConnector;
                                return;
                            }
                        }
                    }
                }
                connectorComboBox.SelectedIndex = 0;
            }
        }
Example #2
0
        private void PopulateConnectors()
        {
            BindingList <IssueRepositoryConnector> dataSource = new BindingList <IssueRepositoryConnector>();

            dataSource.Add(new DummyConnector());
            if (Context != null)
            {
                IAnkhIssueService iService = Context.GetService <IAnkhIssueService>();
                if (iService != null)
                {
                    IssueRepositorySettings currentSettings = CurrentSolutionSettings;

                    ICollection <IssueRepositoryConnector> connectors = iService.Connectors;
                    if (connectors != null)
                    {
                        foreach (IssueRepositoryConnector connector in connectors)
                        {
                            dataSource.Add(connector);
                        }
                    }
                }
            }
            connectorComboBox.DataSource    = dataSource;
            connectorComboBox.DisplayMember = "Name";
        }
Example #3
0
        public void OnExecute(CommandEventArgs e)
        {
            if (_issueService == null)
            {
                _issueService = e.Context.GetService <IAnkhIssueService>();
            }

            if (_issueService == null)
            {
                return;
            }

            TextMarker marker;

            switch (e.Command)
            {
            case AnkhCommand.PcLogEditorOpenIssue:
                if (TryGetMarker(e, true, out marker))
                {
                    _issueService.OpenIssue(marker.Value);
                }
                break;

            case AnkhCommand.PcLogEditorOpenRevision:
                if (TryGetMarker(e, false, out marker))
                {
                    _issueService.OpenRevision(marker.Value);
                }
                break;
            }
        }
        public void OnUpdate(CommandUpdateEventArgs e)
        {
            IAnkhIssueService service = null;
            SvnItem           item    = null;

            e.Enabled = true &&
                        (item = GetRoot(e)) != null &&
                        item.IsVersioned && // ensure solution (project root) is versioned
                        (service = e.GetService <IAnkhIssueService>()) != null &&
                        service.Connectors != null &&
                        service.Connectors.Count > 0;
        }
Example #5
0
        public void OnExecute(CommandEventArgs e)
        {
            if (_issueService == null)
                _issueService = e.Context.GetService<IAnkhIssueService>();

            if (_issueService == null)
                return;

            switch (e.Command)
            {
                case AnkhCommand.LogOpenIssue:
                    {
                        ISvnLogItem selectedLog = EnumTools.GetSingle(e.Selection.GetSelection<ISvnLogItem>());
                        if (selectedLog == null)
                            return;

                        string issueid = null;
                        IEnumerable<IssueMarker> issues = selectedLog.Issues;
                        if (!EnumTools.IsEmpty<IssueMarker>(issues))
                        {
                            using (Ankh.UI.IssueTracker.IssueSelector dlg = new Ankh.UI.IssueTracker.IssueSelector())
                            {
                                dlg.Context = e.Context;
                                dlg.LoadIssues(issues);
                                if (!dlg.IsSingleIssue(out issueid))
                                {
                                    if (dlg.ShowDialog(e.Context) == System.Windows.Forms.DialogResult.OK)
                                    {
                                        issueid = dlg.SelectedIssue;
                                    }
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(issueid)) { _issueService.OpenIssue(issueid); }
                    }

                    break;
                case AnkhCommand.PcLogEditorOpenIssue:
                    IssueMarker marker;

                    if (TryGetIssue(e, out marker))
                    {
                        _issueService.OpenIssue(marker.Value);
                    }
                    break;
            }
        }
Example #6
0
        public void OnExecute(CommandEventArgs e)
        {
            if (_issueService == null)
            {
                _issueService = e.Context.GetService <IAnkhIssueService>();
            }

            if (_issueService == null)
            {
                return;
            }


            ISvnLogItem selectedLog = EnumTools.GetSingle(e.Selection.GetSelection <ISvnLogItem>());

            if (selectedLog == null)
            {
                return;
            }

            string issueid = null;
            IEnumerable <TextMarker> issues = selectedLog.Issues;

            if (!EnumTools.IsEmpty <TextMarker>(issues))
            {
                using (Ankh.UI.IssueTracker.IssueSelector dlg = new Ankh.UI.IssueTracker.IssueSelector())
                {
                    dlg.Context = e.Context;
                    dlg.LoadIssues(issues);
                    if (!dlg.IsSingleIssue(out issueid))
                    {
                        if (dlg.ShowDialog(e.Context) == System.Windows.Forms.DialogResult.OK)
                        {
                            issueid = dlg.SelectedIssue;
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(issueid))
            {
                _issueService.OpenIssue(issueid);
            }
        }
Example #7
0
        bool TryGetIssue(BaseCommandEventArgs e, out IssueMarker value)
        {
            value = null;
            IVsTextView tv = ((ISelectionContextEx)e.Selection).ActiveFrameTextView;

            if (tv == null)
            {
                LogMessageEditor editor = e.Selection.GetActiveControl<LogMessageEditor>();

                if (editor == null)
                    return false;

                tv = ((IAnkhHasVsTextView)editor).TextView;
            }

            int x, y;
            if (!ErrorHandler.Succeeded(tv.GetCaretPos(out y, out x)))
                return false;

            IVsTextLines lines;
            if (!ErrorHandler.Succeeded(tv.GetBuffer(out lines)))
                return false;

            string text, pre = null, post = null;

            text = GetLine(lines, y);

            if (string.IsNullOrEmpty(text))
                return false;

            string combined = null;
            int start = 0;
            if (y > 0)
            {
                pre = GetLine(lines, y - 1);
                combined = pre + '\n';
                start = combined.Length;
            }

            combined += text;

            post = GetLine(lines, y + 1);

            if (!string.IsNullOrEmpty(post))
                combined += '\n' + post;
            if ((y > 0) && !ErrorHandler.Succeeded(tv.GetTextStream(y - 1, 0, y, 0, out pre)))
                return false;

            if (!ErrorHandler.Succeeded(tv.GetTextStream(y + 1, 0, y + 2, 0, out post)))
                post = null;

            if (!string.IsNullOrEmpty(pre))
            {
                combined = pre.TrimEnd('\r', '\n') + '\n';
                start = combined.Length;
            }

            combined += text;

            if (!string.IsNullOrEmpty(post))
            {
                post = post.TrimEnd('\r', '\n');
                combined += '\n' + post;
            }

            if (_issueService == null)
                _issueService = e.GetService<IAnkhIssueService>();

            IEnumerable<IssueMarker> markers;

            int posToCheck = x + start;

            if (!_issueService.TryGetIssues(combined, out markers))
                return false;

            foreach (IssueMarker im in markers)
            {
                if (im.Index > posToCheck)
                    break;

                if (im.Index + im.Length >= posToCheck)
                {
                    value = im;
                    return true;
                }
            }

            return false;
        }
Example #8
0
        bool TryGetMarker(BaseCommandEventArgs e, bool issue, out TextMarker value)
        {
            value = null;
            IVsTextView tv = ((ISelectionContextEx)e.Selection).ActiveFrameTextView;

            if (tv == null)
            {
                LogMessageEditor editor = e.Selection.GetActiveControl <LogMessageEditor>();

                if (editor == null)
                {
                    return(false);
                }

                tv = ((IAnkhHasVsTextView)editor).TextView;
            }

            int x, y;

            if (!VSErr.Succeeded(tv.GetCaretPos(out y, out x)))
            {
                return(false);
            }

            IVsTextLines lines;

            if (!VSErr.Succeeded(tv.GetBuffer(out lines)))
            {
                return(false);
            }

            string text, pre = null, post = null;

            text = GetLine(lines, y);

            if (string.IsNullOrEmpty(text))
            {
                return(false);
            }

            string combined = null;
            int    start    = 0;

            if (y > 0)
            {
                pre      = GetLine(lines, y - 1);
                combined = pre + '\n';
                start    = combined.Length;
            }

            combined += text;

            post = GetLine(lines, y + 1);

            if (!string.IsNullOrEmpty(post))
            {
                combined += '\n' + post;
            }

            if (_issueService == null)
            {
                _issueService = e.GetService <IAnkhIssueService>();
            }

            IEnumerable <TextMarker> markers;

            int posToCheck = x + start;

            if (issue)
            {
                if (!_issueService.TryGetIssues(combined, out markers))
                {
                    return(false);
                }
            }
            else
            {
                if (!_issueService.TryGetRevisions(combined, out markers))
                {
                    return(false);
                }
            }

            foreach (TextMarker im in markers)
            {
                if (im.Index > posToCheck)
                {
                    break;
                }

                if (im.Index + im.Length >= posToCheck)
                {
                    value = im;
                    return(true);
                }
            }

            return(false);
        }