/// <summary>
 /// Adds to an issue some detailed and variable information (such as comments)
 /// </summary>
 /// <param name="issue">The <c>Issue</c> entity to add information to</param>
 public void AddDetailedInfoToIssue(Issue issue) {
     try {
         issue.Comments = Provider.GetIssueComments(issue.Key);
     } catch (Exception ex) {
         ExceptionManager.PublishException(ex);
     }
 }
 private void grdIssues_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e){
     selectedIssue = null;
     foreach (DataGridViewRow row in grdIssues.Rows){
         row.Cells[0].Value = false; 
         row.Tag = issueList[row.Index];
     }
 }
 /// <summary>
 /// Adds a comment to an Issue
 /// </summary>
 /// <param name="issue">The <c>Issue</c> entity to which the comment will be added</param>
 /// <param name="comment">The text of the comment to be added</param>
 public void AddCommentToIssue(Issue issue, string comment) {
     try {
         IssueComment issueComment = new IssueComment(JiraConfigurationHelper.GetUserName(), DateTime.Now, comment);
         this.Provider.AddCommentToIssue(issue.Key, issueComment);
     }
     catch (Exception ex){
         ExceptionManager.PublishException(ex);
     }
 }
        /// <summary>
        /// Creates a new instance of the Dialog Form and assigns values to all its controls
        /// </summary>
        /// <param name="issue">The <c>Issue</c> entity whose are going to be displayed</param>
        public IssueDetailsDialog(Issue issue) {
            
            InitializeComponent();
            //TODO: Improve visualization of issue details
            
            this.lblIssueKey.Text += issue.Key;
            
            this.lblIssueType.Text = issue.Type;
            this.pictureIssueType.Image = IconHelper.GetIssueTypeIcon(issue.Type);

            this.lblIssueStatus.Text = issue.Status;
            this.pictureIssueStatus.Image = IconHelper.GetIssueStatusIcon(issue.Status);

            this.lblIssuePriority.Text = issue.Priority;
            this.pictureIssuePriority.Image = IconHelper.GetIssuePriorityIcon(issue.Priority);

            this.lblReporter.Text = issue.Reporter;

            this.lblOriginalEstimate.Text = issue.OriginalEstimate;

            this.lblRemainingEstimate.Text = issue.RemainingEstimate;

            this.lblTimeSpent.Text = issue.TimeSpent;
            
            this.lblUpdated.Text += issue.Updated;

            this.lblCreated.Text += issue.Created;

            this.lblDueDate.Text += issue.DueDate;
            
            this.lblIssueSummary.Text = issue.Summary;

            this.txtIssueDescription.Text = issue.Description;

            this.lblIssueLink.Text = issue.Link;

            this.lblIssueComments.Text = issue.Comments.Count + " Comments:";
            foreach (IssueComment comment in issue.Comments) {
              this.pnlComments.Controls.Add(new IssueCommentControl(comment));
            }
            if (issue.AffectsVersions !=null){
                foreach (String affectVersion in issue.AffectsVersions) {
                    this.lblAffectVersions.Text += affectVersion + " - ";
                }
            }
            if (issue.FixVersions != null) {
                foreach (String fixVersion in issue.FixVersions) {
                    this.lblFixVersions.Text += fixVersion + " - ";
                }
            }
        }
 /// <summary>
 /// Creates a new instance of the Dialog Form and assigns values to all its controls
 /// </summary>
 /// <param name="issue">The <c>Issue</c> entity whose are going to be displayed</param>
 public IssueDetailDialog(Issue issue) {
     
     InitializeComponent();
     //TODO: Improve visualization of issue details
     
     this.lblIssueKey.Text += issue.Key;
     this.lblIssueTitle.Text += issue.Title;
     this.lblIssueType.Text += issue.Type;
     this.lblIssueSummary.Text += issue.Summary;
     foreach (IssueComment comment in issue.Comments) {
         this.lblIssueComments.Text += comment.Text;
         this.lblIssueComments.Text += "\n";
     }
 }
 private void grdIssues_CellContentClick(object sender, DataGridViewCellEventArgs e){
     // Update the status bar when the cell value changes.
     if (e.ColumnIndex == 0){
         // Force the update of the value for the checkbox column.
         // Without this, the value doens't get updated until you move off from the cell.
         foreach(DataGridViewRow r in grdIssues.Rows) {
             if (r.Index == e.RowIndex) {
                 r.Cells[0].Value = !(bool)r.Cells[0].EditedFormattedValue;
             }else {
                 r.Cells[0].Value = false;   
             }
         }
         if ((bool)grdIssues.Rows[e.RowIndex].Cells[0].Value){
             selectedIssue = (Issue)grdIssues.Rows[e.RowIndex].Tag;
         }
         else {
             selectedIssue = null;
         }
     }       
 }
        /// <summary>
        /// Marks an Issue as "Resolved"
        /// </summary>
        /// <param name="issue">The <c>Issue</c> entity to resolve</param>
        /// <param name="resolution">The resolution to assing to the issue</param>
        /// <param name="comment">An Optional Comment to add to the issue when resolving it</param>
        public void ResolveIssue(Issue issue, KeyValuePair<string, string> resolution, string comment) {
            try {
                if (!CanPerformWorkflowAction(issue,JiraWorkflowAction.RESOLVE)) {
                    throw new FunctionalException("The \"Resolve\" action is not valid for this issue.");
                }

                List<string> fixVersions = this.Provider.GetVersionsIdsFromVersionNames(issue.FixVersions);
                List<string> affectsVersions = this.Provider.GetVersionsIdsFromVersionNames(issue.AffectsVersions);

                this.Provider.ProgressWorkflowForResolution(((int)JiraWorkflowAction.RESOLVE).ToString(),issue.Key, resolution.Key, 
                    comment, fixVersions.ToArray(), affectsVersions.ToArray());

                //For now it's necesarry to add the resolution comment on another different step, after de progression of
                //the workflow action. For more information see http://jira.atlassian.com/browse/JRA-11278
                if (!comment.Equals(String.Empty)) {
                    this.AddCommentToIssue(issue, comment);
                }
            }
            catch (Exception ex){
                ExceptionManager.PublishException(ex);
            }
        }
 /// <summary>
 /// Stops the work progress of an Issue
 /// </summary>
 /// <param name="issue">The <c>Issue</c> whose progress is being stopped</param>
 public void StopIssueProgress(Issue selectedIssue){
     try{
         if (!CanPerformWorkflowAction(selectedIssue, JiraWorkflowAction.STOP_PROGRESS)){
             throw new FunctionalException("The \"Stop Progress\" action is not valid for this issue.");
         }
         this.Provider.StopIssueProgress(selectedIssue.Key);
     }catch (Exception ex){
         ExceptionManager.PublishException(ex);
     }
 }
 /// <summary>
 /// This method allows the user to log work done on an issue.
 /// </summary>
 /// <param name="issue">The selected issue to log work to</param>
 /// <param name="workDone">A string representing the ammount of work done as entered by the user</param>
 public void LogWorkDone(Issue issue, string workDone, string workDescription) {
     try{
         Provider.LogWorkDone(issue.Id,workDone, workDescription);
     }
     catch (Exception ex){
         ExceptionManager.PublishException(ex);
     }
     
 }
 /// <summary>
 /// Indicates where a given workflow action is valid for a specific issue
 /// </summary>
 /// <param name="issue">The <c>Issue</c> entity to resolve</param>
 private bool CanPerformWorkflowAction(Issue issue, JiraWorkflowAction action ){
     List<int> availableActions = this.Provider.GetAvailableActions(issue.Key);
     if (availableActions.Contains((int)action)){
         return true;
     }
     return false;
 }
 internal void HandleStopIssueProgressRequest(Issue selectedIssue) {
     if (selectedIssue != null){
         try {
             this.Proxy.StopIssueProgress(selectedIssue);
             RefreshIssues();
         }
         catch (Exception e){
             this.HandleException(e);
         }
     }
     else{
         DisplayErrorMessage("There's no Issue selected", "Error stopping progress on an Issue");
     }
 }
 /// <summary>
 /// Handles the user request to indicates that he/she has started to work on an issue
 /// </summary>
 /// <param name="selectedIssue">The <c>Issue</c> entity whose progress is being marked as started</param>
 public void HandleStartIssueProgressRequest(Issue selectedIssue){
     if (selectedIssue != null){
         try{
             this.Proxy.StartIssueProgress(selectedIssue);
             selectedIssue.Status = "In Progress";
             this.MainToolbar.RefreshIssuesToShow();
         }
         catch (Exception e){
             this.HandleException(e);
         }
     }
     else{
         DisplayErrorMessage("There's no Issue selected", "Error starting progress on an Issue");
     }
 }
 /// <summary>
 /// Handles user request to log work done for an Issue
 /// </summary>
 /// <param name="selectedIssue">The issue that the user wants to log work on</param>
 public void HandleLogWorkDoneRequest(Issue selectedIssue) {
     if (selectedIssue != null){
         try{
             LogWorkDoneDialog dialog = new LogWorkDoneDialog(selectedIssue);
             if (dialog.ShowDialog()==DialogResult.OK && dialog.WorkDone != String.Empty) {
                 Proxy.LogWorkDone(selectedIssue, dialog.WorkDone, dialog.WorkDescription);
             }
             dialog.Dispose();
         }
         catch (Exception e){
             this.HandleException(e);
         }
     }
     else{
         DisplayErrorMessage("There's no Issue selected", "Error logging work done");
     }
 }
 /// <summary>
 /// Handles the user request to close an issue
 /// </summary>
 /// <param name="selectedIssue">The <c>Issue</c> entity to close</param>
 internal void HandleCloseIssueRequest(Issue selectedIssue) {
     if (selectedIssue != null) {
         try {
             ResolveIssueDialog resolveIssueDialog = new ResolveIssueDialog(this.Proxy.GetAllResolutions());
             if (resolveIssueDialog.ShowDialog() == DialogResult.OK) {
                 this.Proxy.CloseIssue(selectedIssue, resolveIssueDialog.selectedResolution, resolveIssueDialog.ResolutionComment);
                 this.unresolvedIssuesCache.Remove(selectedIssue);
                 this.MainToolbar.RefreshIssuesToShow();
             }
             resolveIssueDialog.Dispose();
         } catch (Exception e) {
             this.HandleException(e);
         }
     } else {
         DisplayErrorMessage("There's no Issue selected", "Error closing an Issue");
     }
 }
 /// <summary>
 /// Handles the user request to add a comment to an Issue
 /// </summary>
 /// <param name="selectedIssue">The <c>Issue</c> entity to which the comment will be added</param>
 internal void HandleAddCommentToIssueRequest(Issue selectedIssue){
     if (selectedIssue != null){
         try{
             IssueCommentDialog dialog = new IssueCommentDialog();
             dialog.ShowDialog();
             string commentText = dialog.Comment;
             if (dialog.Comment != String.Empty)
                 Proxy.AddCommentToIssue(selectedIssue, commentText);
             else
                 DisplayErrorMessage("No text has been entered","Adding a Comment");
             dialog.Dispose();
         }
         catch (Exception e){
             this.HandleException(e);
         }
     }
     else{
         DisplayErrorMessage("There's no Issue selected", "Error adding a commento to an Issue");
     }
 }
 /// <summary>
 /// Displays a Dialog containing detailed information about an Issue
 /// </summary>
 /// <param name="issue">The <c>Issue</c> whose details are going to be shown</param>
 private void DisplayFullIssueDetail(Issue issue) {
     IssueDetailsDialog dialog = new IssueDetailsDialog(issue);
     dialog.ShowDialog();
 }
 /// <summary>
 /// Default constructor that initialize the UI components of the form.
 /// </summary>
 public LogWorkDoneDialog(Issue issue){
     InitializeComponent();
     this.lblOriginalEstimate.Text += issue.OriginalEstimate;
     this.lblRemainingEstimate.Text += issue.RemainingEstimate;
     this.lblTimeSpent.Text += issue.TimeSpent;
 }
 /// <summary>
 /// Handles the request to show all the details for a selected issue in the main toolbar
 /// </summary>
 /// <param name="selectedIssue">The <c>Issue</c> whose details are going to be shown</param>
 internal void HandleFullIssueDetailRequest(Issue selectedIssue) {
     if (selectedIssue != null)
     {
         try {
             //Since the issues shown in the main window only have basic info, we need to ask for the other stuff to the Proxy.
             Proxy.AddDetailedInfoToIssue(selectedIssue);
             this.DisplayFullIssueDetail(selectedIssue);    
         } catch (Exception e) {
             this.HandleException(e);
         }
     }else{
       DisplayErrorMessage("There's no Issue selected", "Error Displaying Details for an Issue");
   }
 }