private void getComments(JToken cmts, JToken rendered) { if (cmts == null) { return; } var list = rendered != null ? rendered["comments"] : cmts["comments"]; var cmtTimes = new Dictionary <int, DateTime>(); foreach (var cmt in cmts["comments"]) { cmtTimes[cmt["id"].Value <int>()] = DateTime.Parse(cmt["created"].Value <string>(), CultureInfo.InvariantCulture); } foreach (var comment in list) { var id = comment["id"].Value <int>(); comments.Add(new Comment { Body = comment["body"].Value <string>(), Author = comment["author"] != null && comment["author"]["displayName"] != null ? comment["author"]["displayName"].Value <string>() : "Unknown", Created = JiraIssueUtils.getJiraFormattedTimeString(cmtTimes[id]) }); } }
public override List <string> getValues() { return(FieldValid ? new List <string> { JiraIssueUtils.addSpacesToTimeSpec(trackingBox.Text.Trim()) } : new List <string>()); }
public List <string> getFieldValues(string field, JiraIssue issue, object rawIssueObject) { string value = JiraIssueUtils.getRawIssueObjectPropertyValue <string>(rawIssueObject, "environment"); return(value != null ? new List <string> { value } : null); }
public override List <string> getValues() { return(picker.Checked ? new List <string> { Field.FieldDefinition == null ? JiraIssueUtils.getShortDateStringFromDateTime(serverLanguage, picker.Value) : JiraIssueUtils.getShortRestDateStringFromDateTime(picker.Value) } : new List <string>()); }
private static void addMenuItems(ToolStrip menu, string key, bool showKey) { ToolStripMenuItem item1 = new ToolStripMenuItem("Open " + (showKey ? key + " " : "") + "in IDE", Resources.open_in_ide); item1.Click += (s, e) => JiraIssueUtils.openInIde(key); menu.Items.Add(item1); ToolStripMenuItem item2 = new ToolStripMenuItem("View " + (showKey ? key + " " : "") + "in the Browser", Resources.view_in_browser); item2.Click += (s, e) => JiraIssueUtils.launchBrowser(key); menu.Items.Add(item2); }
private static void addMenuItems(ItemsControl menu, string key, bool displayKey) { MenuItem item1 = new MenuItem { Header = "Open" + (displayKey ? " " + key : "") + " in IDE", Icon = getImagePath(Resources.open_in_ide) }; item1.Click += (s, e) => JiraIssueUtils.openInIde(key); menu.Items.Add(item1); MenuItem item2 = new MenuItem { Header = "View" + (displayKey ? " " + key : "") + " in the Browser", Icon = getImagePath(Resources.view_in_browser) }; item2.Click += (s, e) => JiraIssueUtils.launchBrowser(key); menu.Items.Add(item2); }
public List <string> getFieldValues(string field, JiraIssue issue, object rawIssueObject) { var issueToken = rawIssueObject as JToken; if (issueToken != null) { var value = JiraIssueUtils.getRawIssueObjectPropertyValue <object>(rawIssueObject, field); if (value == null || (value is JToken && !(value as JToken).HasValues)) { return(null); } var arr = value as JArray; return(arr != null?arr.Select(el => el.ToString()).ToList() : new List <string> { value.ToString() }); } var customFieldValues = JiraIssueUtils.getRawIssueObjectPropertyValueArray <object>(rawIssueObject, "customFieldValues"); if (customFieldValues == null || customFieldValues.Length == 0) { return(null); } foreach (var customFieldValue in customFieldValues) { var property = customFieldValue.GetType().GetProperty("customfieldId"); if (property == null) { continue; } var fieldId = property.GetValue(customFieldValue, null) as string; if (fieldId == null || !fieldId.Equals(field)) { continue; } property = customFieldValue.GetType().GetProperty("values"); if (property == null) { continue; } var values = property.GetValue(customFieldValue, null) as object[]; return((from val in values select val.ToString()).ToList()); } return(null); }
public List <string> getFieldValues(string field, JiraIssue issue, object rawIssueObject) { DateTime?dueDate = JiraIssueUtils.getRawIssueObjectPropertyValue <DateTime?>(rawIssueObject, "duedate"); if (!dueDate.HasValue) { return(new List <string>()); } string dateString = JiraIssueUtils.getShortDateStringFromDateTime(issue.ServerLanguage, dueDate.Value); List <string> result = new List <string> { dateString }; return(result); }
public List <string> getFieldValues(string field, JiraIssue issue, object rawIssueObject) { object[] value = JiraIssueUtils.getRawIssueObjectPropertyValueArray <object>(rawIssueObject, "fixVersions"); if (value == null || value.Length == 0) { return(null); } if (rawIssueObject is JToken) { return(value.Select(v => v as JToken).Select(vt => vt["id"].Value <string>()).ToList()); } return((from v in value.ToList() let prop = v.GetType().GetProperty("id") where prop != null select(string) prop.GetValue(v, null)).ToList()); }
public override int ExecMarkerCommand(IVsTextMarker pMarker, int iItem) { switch (iItem) { case 0: JiraIssueUtils.openInIde(issueKey); return(VSConstants.S_OK); case 1: JiraIssueUtils.launchBrowser(issueKey); return(VSConstants.S_OK); case (int)MarkerCommandValues.mcvBodyDoubleClickCommand: JiraIssueUtils.openInIde(issueKey); return(VSConstants.S_OK); default: return(VSConstants.S_OK); } }
private void getAttachments(XPathNavigator nav) { XPathExpression expr = nav.Compile("attachment"); XPathNodeIterator it = nav.Select(expr); if (!nav.MoveToFirstChild()) { return; } while (it.MoveNext()) { JiraAttachment a = new JiraAttachment( int.Parse(XPathUtils.getAttributeSafely(it.Current, "id", "0")), XPathUtils.getAttributeSafely(it.Current, "name", "none"), JiraIssueUtils.getDateTimeFromJiraTimeString(ServerLanguage, XPathUtils.getAttributeSafely(it.Current, "created", "none")), XPathUtils.getAttributeSafely(it.Current, "author", "none"), int.Parse(XPathUtils.getAttributeSafely(it.Current, "size", "0"))); attachments.Add(a); } nav.MoveToParent(); }
private void fillFields() { List <JiraField> unsupportedFields = new List <JiraField>(); foreach (JiraField field in fields) { JiraFieldEditorProvider editor = null; switch (JiraActionFieldType.getFieldTypeForField(field)) { case JiraActionFieldType.WidgetType.SUMMARY: editor = new TextLineFieldEditorProvider(field, field.Values.IsNullOrEmpty() ? "" : field.Values[0], fieldValid); break; case JiraActionFieldType.WidgetType.DESCRIPTION: editor = new TextAreaFieldEditorProvider(SmartJiraServerFacade.Instance, issue, field, field.Values.IsNullOrEmpty() ? "" : field.Values[0], fieldValid); break; case JiraActionFieldType.WidgetType.ENVIRONMENT: editor = new TextAreaFieldEditorProvider(SmartJiraServerFacade.Instance, issue, field, field.Values.IsNullOrEmpty() ? "" : field.Values[0], fieldValid); break; case JiraActionFieldType.WidgetType.ISSUE_TYPE: editor = new NamedEntityComboEditorProvider(issue.Server, field, issue.IssueTypeId, issue.IsSubtask ? subtaskIssueTypes : issueTypes, fieldValid); break; case JiraActionFieldType.WidgetType.VERSIONS: editor = new NamedEntityListFieldEditorProvider(field, issue.Versions, versions, fieldValid); break; case JiraActionFieldType.WidgetType.FIX_VERSIONS: editor = new NamedEntityListFieldEditorProvider(field, issue.FixVersions, versions, fieldValid); break; case JiraActionFieldType.WidgetType.ASSIGNEE: editor = new UserFieldEditorProvider(issue.Server, field, field.Values.IsNullOrEmpty() ? "" : field.Values[0], fieldValid); break; case JiraActionFieldType.WidgetType.REPORTER: editor = new UserFieldEditorProvider(issue.Server, field, field.Values.IsNullOrEmpty() ? "" : field.Values[0], fieldValid); break; case JiraActionFieldType.WidgetType.DUE_DATE: editor = new DateFieldEditorProvider(issue.ServerLanguage, field, field.Values.IsNullOrEmpty() ? (DateTime?)null : JiraIssueUtils.getDateTimeFromShortString(issue.ServerLanguage, field.Values[0]), fieldValid); break; case JiraActionFieldType.WidgetType.COMPONENTS: editor = new NamedEntityListFieldEditorProvider(field, issue.Components, comps, fieldValid); break; case JiraActionFieldType.WidgetType.RESOLUTION: SortedDictionary <int, JiraNamedEntity> resolutions = JiraServerCache.Instance.getResolutions(issue.Server); editor = new ResolutionEditorProvider(issue.Server, field, issue.ResolutionId, resolutions != null ? resolutions.Values : null, fieldValid); break; case JiraActionFieldType.WidgetType.PRIORITY: editor = new NamedEntityComboEditorProvider(issue.Server, field, issue.PriorityId, JiraServerCache.Instance.getPriorities(issue.Server), fieldValid); break; case JiraActionFieldType.WidgetType.TIMETRACKING: editor = new TimeTrackingEditorProvider(field, field.Values.IsNullOrEmpty() ? "" : field.Values[0], fieldValid); break; // ReSharper disable RedundantCaseLabel case JiraActionFieldType.WidgetType.SECURITY: case JiraActionFieldType.WidgetType.UNSUPPORTED: // ReSharper restore RedundantCaseLabel default: if (!JiraActionFieldType.isTimeField(field)) { unsupportedFields.Add(field); } break; } if (editor == null) { continue; } addLabel(editor.getFieldLabel(issue, field)); editor.Widget.Location = new Point(FIELD_X_POS, verticalPosition); editor.Widget.TabIndex = tabIndex++; panelContent.Controls.Add(editor.Widget); verticalPosition += editor.VerticalSkip + MARGIN / 2; editors.Add(editor); } if (unsupportedFields.Count == 0) { return; } StringBuilder sb = new StringBuilder(); sb.Append("Unsupported fields (existing values copied): "); foreach (var field in unsupportedFields) { sb.Append(field.Name).Append(", "); } textUnsupported = new TextBox { Multiline = true, BorderStyle = BorderStyle.None, ReadOnly = true, WordWrap = true, Text = sb.ToString().Substring(0, sb.Length - 2), }; }
public JiraIssue(JiraServer server, string serverLanguage, XPathNavigator nav) { Server = server; ServerLanguage = serverLanguage; nav.MoveToFirstChild(); do { switch (nav.Name) { case "key": Key = nav.Value; Id = XPathUtils.getAttributeSafely(nav, "id", UNKNOWN); ProjectKey = Key.Substring(0, Key.LastIndexOf('-')); break; case "parent": ParentKey = nav.Value; break; case "subtasks": getSubtasks(nav); break; case "summary": Summary = nav.Value; break; case "attachments": getAttachments(nav); break; case "status": Status = nav.Value; StatusIconUrl = XPathUtils.getAttributeSafely(nav, "iconUrl", null); StatusId = XPathUtils.getAttributeSafely(nav, "id", UNKNOWN); break; case "priority": Priority = nav.Value; PriorityIconUrl = XPathUtils.getAttributeSafely(nav, "iconUrl", null); PriorityId = XPathUtils.getAttributeSafely(nav, "id", UNKNOWN); break; case "description": Description = nav.Value; break; case "type": IssueType = nav.Value; IssueTypeIconUrl = XPathUtils.getAttributeSafely(nav, "iconUrl", null); IssueTypeId = XPathUtils.getAttributeSafely(nav, "id", UNKNOWN); break; case "assignee": Assignee = XPathUtils.getAttributeSafely(nav, "username", "Unknown"); string assigneName = nav.Value; JiraServerCache.Instance.getUsers(server).putUser(new JiraUser(Assignee, assigneName)); break; case "reporter": Reporter = XPathUtils.getAttributeSafely(nav, "username", "Unknown"); string reporterName = nav.Value; JiraServerCache.Instance.getUsers(server).putUser(new JiraUser(Reporter, reporterName)); break; case "created": CreationDate = JiraIssueUtils.getDateTimeFromJiraTimeString(serverLanguage, nav.Value); break; case "updated": UpdateDate = JiraIssueUtils.getDateTimeFromJiraTimeString(serverLanguage, nav.Value); break; case "resolution": Resolution = nav.Value; ResolutionId = XPathUtils.getAttributeSafely(nav, "id", UNKNOWN); break; case "timeestimate": RemainingEstimate = nav.Value; RemainingEstimateInSeconds = XPathUtils.getAttributeSafely(nav, "seconds", UNKNOWN); break; case "timeoriginalestimate": OriginalEstimate = nav.Value; OriginalEstimateInSeconds = XPathUtils.getAttributeSafely(nav, "seconds", UNKNOWN); break; case "timespent": TimeSpent = nav.Value; TimeSpentInSeconds = XPathUtils.getAttributeSafely(nav, "seconds", UNKNOWN); break; case "version": versions.Add(nav.Value); break; case "fixVersion": fixVersions.Add(nav.Value); break; case "component": components.Add(nav.Value); break; case "comments": getComments(nav); break; case "environment": Environment = nav.Value; break; case "issuelinks": getIssueLinks(nav); break; default: break; } } while (nav.MoveToNext()); if (Key == null || Summary == null) { throw new InvalidDataException(); } }
private void logWorkAndUpdateRemainingManually() { facade.logWorkAndUpdateRemainingManually( issue, JiraIssueUtils.addSpacesToTimeSpec(textTimeSpent.Text.Trim()), getStartTime(), JiraIssueUtils.addSpacesToTimeSpec(textRemainingEstimate.Text.Trim()), textComment.Text.Trim()); }
private void logWorkAndLeaveRemainingUnchanged() { facade.logWorkAndLeaveRemainingUnchanged( issue, JiraIssueUtils.addSpacesToTimeSpec(textTimeSpent.Text.Trim()), getStartTime(), textComment.Text.Trim()); }
private void logWorkAndAutoUpdateRemaining() { facade.logWorkAndAutoUpdateRemaining( issue, JiraIssueUtils.addSpacesToTimeSpec(textTimeSpent.Text.Trim()), getStartTime(), textComment.Text.Trim()); }
public void Invoke() { JiraIssueUtils.openInIde(issueKey); }
private void createEditorWidget(IEnumerable <JiraNamedEntity> versions, IEnumerable <JiraNamedEntity> comps, object rawIssueObject) { PlvsLogger.log("FieldEditor.createEditorWidget()"); switch (JiraActionFieldType.getFieldTypeForFieldId(fieldId)) { case JiraActionFieldType.WidgetType.SUMMARY: editorProvider = new TextLineFieldEditorProvider(field, issue.Summary, fieldValid); break; case JiraActionFieldType.WidgetType.DESCRIPTION: string descr = JiraIssueUtils.getRawIssueObjectPropertyValue <string>(rawIssueObject, "description") ?? ""; editorProvider = new TextAreaFieldEditorProvider(facade, issue, field, descr, fieldValid); break; case JiraActionFieldType.WidgetType.ENVIRONMENT: string env = JiraIssueUtils.getRawIssueObjectPropertyValue <string>(rawIssueObject, "environment") ?? ""; editorProvider = new TextAreaFieldEditorProvider(facade, issue, field, env, fieldValid); break; case JiraActionFieldType.WidgetType.VERSIONS: editorProvider = new NamedEntityListFieldEditorProvider(field, issue.Versions, versions, fieldValid); break; case JiraActionFieldType.WidgetType.FIX_VERSIONS: editorProvider = new NamedEntityListFieldEditorProvider(field, issue.FixVersions, versions, fieldValid); break; case JiraActionFieldType.WidgetType.ASSIGNEE: editorProvider = new UserFieldEditorProvider(issue.Server, field, field.Values.IsNullOrEmpty() ? "" : field.Values[0], fieldValid, true); break; case JiraActionFieldType.WidgetType.COMPONENTS: editorProvider = new NamedEntityListFieldEditorProvider(field, issue.Components, comps, fieldValid); break; case JiraActionFieldType.WidgetType.PRIORITY: editorProvider = new NamedEntityComboEditorProvider(issue.Server, field, issue.PriorityId, JiraServerCache.Instance.getPriorities(issue.Server), fieldValid); break; case JiraActionFieldType.WidgetType.TIMETRACKING: List <JiraField> fields = JiraActionFieldType.fillFieldValues(issue, rawIssueObject, new List <JiraField> { field }); editorProvider = new TimeTrackingEditorProvider(field, fields[0].Values[0], fieldValid); break; default: MessageBox.Show("Unsupported field type selected for editing", Constants.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); break; } buttonCancel.Enabled = true; buttonOk.Enabled = editorProvider != null ? editorProvider.FieldValid : false; if (editorProvider != null) { addEditorWidget(editorProvider); } }
public JiraAttachmentListViewItem(JiraIssue issue, JiraAttachment att) : base(new [] { att.Name, att.Author, att.Size.ToString(), JiraIssueUtils.getShortDateStringFromDateTime(issue.ServerLanguage, att.Created) }) { this.issue = issue; Attachment = att; }
public void Invoke() { JiraIssueUtils.launchBrowser(issueKey); }