From 17e390b25f353511c593b4e1eabd47ae7fd22380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Ace=C3=B1olaza?= Date: Wed, 6 May 2015 13:24:37 -0300 Subject: [PATCH] Fixed priority mappings and save process --- .../Entities/BaseEntity.cs | 7 +- .../Entities/BaseServiceEntity.cs | 7 +- .../Entities/JiraFilter.cs | 14 +- .../Entities/JiraPriorityMapping.cs | 1 + .../Entities/JiraServiceEntity.cs | 126 +++++++++---- .../Entities/Mapping.cs | 14 +- .../Entities/NullableInt.cs | 16 +- .../Entities/ProxyConnectionSettings.cs | 35 +++- .../Entities/TimerEntity.cs | 7 +- .../Entities/VersionOneSettings.cs | 28 ++- .../Entities/WorkitemWriterEntity.cs | 7 +- .../UI/Controllers/JiraController.cs | 45 +++-- .../UI/Controls/JiraPageControl.cs | 175 +++++++++++------- .../UI/Interfaces/IConfigurationController.cs | 8 +- .../UI/Interfaces/IJiraPageView.cs | 7 +- 15 files changed, 340 insertions(+), 157 deletions(-) diff --git a/VersionOne.ServiceHost.ConfigurationTool/Entities/BaseEntity.cs b/VersionOne.ServiceHost.ConfigurationTool/Entities/BaseEntity.cs index 946086f..7b5f8bc 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/Entities/BaseEntity.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/Entities/BaseEntity.cs @@ -21,8 +21,11 @@ public virtual bool Disabled get { return disabled; } set { - disabled = value; - NotifyPropertyChanged(); + if (disabled != value) + { + disabled = value; + NotifyPropertyChanged(); + } } } diff --git a/VersionOne.ServiceHost.ConfigurationTool/Entities/BaseServiceEntity.cs b/VersionOne.ServiceHost.ConfigurationTool/Entities/BaseServiceEntity.cs index 7163a3e..e32240f 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/Entities/BaseServiceEntity.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/Entities/BaseServiceEntity.cs @@ -18,8 +18,11 @@ public TimerEntity Timer get { return timer; } set { - timer = value; - NotifyPropertyChanged(); + if (timer != value) + { + timer = value; + NotifyPropertyChanged(); + } } } diff --git a/VersionOne.ServiceHost.ConfigurationTool/Entities/JiraFilter.cs b/VersionOne.ServiceHost.ConfigurationTool/Entities/JiraFilter.cs index 7abec57..cb0fc49 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/Entities/JiraFilter.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/Entities/JiraFilter.cs @@ -19,8 +19,11 @@ public string Id get { return id; } set { - id = value; - NotifyPropertyChanged(); + if (id != value) + { + id = value; + NotifyPropertyChanged(); + } } } @@ -31,8 +34,11 @@ public override bool Disabled get { return disabled; } set { - disabled = value; - NotifyPropertyChanged(); + if (disabled != value) + { + disabled = value; + NotifyPropertyChanged(); + } } } diff --git a/VersionOne.ServiceHost.ConfigurationTool/Entities/JiraPriorityMapping.cs b/VersionOne.ServiceHost.ConfigurationTool/Entities/JiraPriorityMapping.cs index f8ec891..ee31030 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/Entities/JiraPriorityMapping.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/Entities/JiraPriorityMapping.cs @@ -19,6 +19,7 @@ public JiraPriorityMapping() [XmlElement("JIRAPriority")] public Mapping JiraPriority { get; set; } + [XmlElement("VersionOnePriority")] public Mapping VersionOnePriority { get; set; } [XmlIgnore] diff --git a/VersionOne.ServiceHost.ConfigurationTool/Entities/JiraServiceEntity.cs b/VersionOne.ServiceHost.ConfigurationTool/Entities/JiraServiceEntity.cs index 21f58d5..308d115 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/Entities/JiraServiceEntity.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/Entities/JiraServiceEntity.cs @@ -80,8 +80,11 @@ public string Url get { return url; } set { - url = value; - NotifyPropertyChanged(); + if (url != value) + { + url = value; + NotifyPropertyChanged(); + } } } @@ -92,8 +95,11 @@ public string UserName get { return userName; } set { - userName = value; - NotifyPropertyChanged(); + if (userName != value) + { + userName = value; + NotifyPropertyChanged(); + } } } @@ -104,8 +110,11 @@ public string Password get { return password; } set { - password = value; - NotifyPropertyChanged(); + if (password != value) + { + password = value; + NotifyPropertyChanged(); + } } } @@ -117,8 +126,11 @@ public ObservableCollection ProjectMappings get { return projectMappings; } set { - projectMappings = value; - NotifyPropertyChanged(); + if (projectMappings != value) + { + projectMappings = value; + NotifyPropertyChanged(); + } } } @@ -130,8 +142,11 @@ public ObservableCollection PriorityMappings get { return priorityMappings; } set { - priorityMappings = value; - NotifyPropertyChanged(); + if (priorityMappings != value) + { + priorityMappings = value; + NotifyPropertyChanged(); + } } } @@ -142,8 +157,11 @@ public JiraFilter CreateDefectFilter get { return createDefectFilter; } set { - createDefectFilter = value; - NotifyPropertyChanged(); + if (createDefectFilter != value) + { + createDefectFilter = value; + NotifyPropertyChanged(); + } } } @@ -154,8 +172,11 @@ public JiraFilter CreateStoryFilter get { return createStoryFilter; } set { - createStoryFilter = value; - NotifyPropertyChanged(); + if (createStoryFilter != value) + { + createStoryFilter = value; + NotifyPropertyChanged(); + } } } @@ -165,8 +186,11 @@ public string CreateFieldId get { return createFieldId; } set { - createFieldId = value; - NotifyPropertyChanged(); + if (createFieldId != value) + { + createFieldId = value; + NotifyPropertyChanged(); + } } } @@ -176,8 +200,11 @@ public string CreateFieldValue get { return createFieldValue; } set { - createFieldValue = value; - NotifyPropertyChanged(); + if (createFieldValue != value) + { + createFieldValue = value; + NotifyPropertyChanged(); + } } } @@ -187,8 +214,11 @@ public string CloseFieldId get { return closeFieldId; } set { - closeFieldId = value; - NotifyPropertyChanged(); + if (closeFieldId != value) + { + closeFieldId = value; + NotifyPropertyChanged(); + } } } @@ -198,8 +228,11 @@ public string CloseFieldValue get { return closeFieldValue; } set { - closeFieldValue = value; - NotifyPropertyChanged(); + if (closeFieldValue != value) + { + closeFieldValue = value; + NotifyPropertyChanged(); + } } } @@ -209,8 +242,11 @@ public NullableInt ProgressWorkflow get { return progressWorkflow; } set { - progressWorkflow = value; - NotifyPropertyChanged(); + if (progressWorkflow != value) + { + progressWorkflow = value; + NotifyPropertyChanged(); + } } } @@ -220,8 +256,11 @@ public NullableInt ProgressWorkflowClosed get { return progressWorkflowClosed; } set { - progressWorkflowClosed = value; - NotifyPropertyChanged(); + if (progressWorkflowClosed != value) + { + progressWorkflowClosed = value; + NotifyPropertyChanged(); + } } } @@ -231,8 +270,11 @@ public string AssigneeStateChanged get { return assigneeStateChanged; } set { - assigneeStateChanged = value; - NotifyPropertyChanged(); + if (assigneeStateChanged != value) + { + assigneeStateChanged = value; + NotifyPropertyChanged(); + } } } @@ -245,8 +287,11 @@ public string UrlTemplate get { return urlTemplate; } set { - urlTemplate = value; - NotifyPropertyChanged(); + if (urlTemplate != value) + { + urlTemplate = value; + NotifyPropertyChanged(); + } } } @@ -256,8 +301,11 @@ public string UrlTitle get { return urlTitle; } set { - urlTitle = value; - NotifyPropertyChanged(); + if (urlTitle != value) + { + urlTitle = value; + NotifyPropertyChanged(); + } } } @@ -269,8 +317,11 @@ public string SourceName get { return sourceName; } set { - sourceName = value; - NotifyPropertyChanged(); + if (sourceName != value) + { + sourceName = value; + NotifyPropertyChanged(); + } } } @@ -281,8 +332,11 @@ public string LinkField get { return linkField; } set { - linkField = value; - NotifyPropertyChanged(); + if (linkField != value) + { + linkField = value; + NotifyPropertyChanged(); + } } } diff --git a/VersionOne.ServiceHost.ConfigurationTool/Entities/Mapping.cs b/VersionOne.ServiceHost.ConfigurationTool/Entities/Mapping.cs index e26be4c..2337a44 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/Entities/Mapping.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/Entities/Mapping.cs @@ -13,8 +13,11 @@ public string Id get { return id; } set { - id = value; - NotifyPropertyChanged(); + if (id != value) + { + id = value; + NotifyPropertyChanged(); + } } } @@ -24,8 +27,11 @@ public string Name get { return name; } set { - name = value; - NotifyPropertyChanged(); + if (name != value) + { + name = value; + NotifyPropertyChanged(); + } } } } diff --git a/VersionOne.ServiceHost.ConfigurationTool/Entities/NullableInt.cs b/VersionOne.ServiceHost.ConfigurationTool/Entities/NullableInt.cs index 94cc7b8..3f58ee6 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/Entities/NullableInt.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/Entities/NullableInt.cs @@ -6,8 +6,21 @@ public class NullableInt : BaseEntity { public const string StringValueProperty = "StringValue"; + private int? numberValue; + [XmlIgnore] - public int? NumberValue { get; set; } + public int? NumberValue + { + get { return numberValue; } + set + { + if (numberValue != value) + { + numberValue = value; + NotifyPropertyChanged(); + } + } + } [XmlText] public string StringValue @@ -20,7 +33,6 @@ public string StringValue NumberValue = parsedValue; else NumberValue = null; - NotifyPropertyChanged(); } } diff --git a/VersionOne.ServiceHost.ConfigurationTool/Entities/ProxyConnectionSettings.cs b/VersionOne.ServiceHost.ConfigurationTool/Entities/ProxyConnectionSettings.cs index 75ddc40..7634bc9 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/Entities/ProxyConnectionSettings.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/Entities/ProxyConnectionSettings.cs @@ -31,8 +31,11 @@ public bool Enabled get { return enabled; } set { - enabled = value; - NotifyPropertyChanged(); + if (enabled != value) + { + enabled = value; + NotifyPropertyChanged(); + } } } @@ -49,8 +52,11 @@ public string Uri get { return uri; } set { - uri = value; - NotifyPropertyChanged(); + if (uri != value) + { + uri = value; + NotifyPropertyChanged(); + } } } @@ -59,8 +65,11 @@ public string UserName get { return userName; } set { - userName = value; - NotifyPropertyChanged(); + if (userName != value) + { + userName = value; + NotifyPropertyChanged(); + } } } @@ -69,8 +78,11 @@ public string Password get { return password; } set { - password = value; - NotifyPropertyChanged(); + if (password != value) + { + password = value; + NotifyPropertyChanged(); + } } } @@ -79,8 +91,11 @@ public string Domain get { return domain; } set { - domain = value; - NotifyPropertyChanged(); + if (domain != value) + { + domain = value; + NotifyPropertyChanged(); + } } } diff --git a/VersionOne.ServiceHost.ConfigurationTool/Entities/TimerEntity.cs b/VersionOne.ServiceHost.ConfigurationTool/Entities/TimerEntity.cs index b22506f..b8f3c2c 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/Entities/TimerEntity.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/Entities/TimerEntity.cs @@ -27,8 +27,11 @@ public long TimeoutMilliseconds get { return timeoutMilliseconds; } set { - timeoutMilliseconds = Math.Max(value, minimumTimerIntervalMillis); - NotifyPropertyChanged(); + if (timeoutMilliseconds != value) + { + timeoutMilliseconds = Math.Max(value, minimumTimerIntervalMillis); + NotifyPropertyChanged(); + } } } diff --git a/VersionOne.ServiceHost.ConfigurationTool/Entities/VersionOneSettings.cs b/VersionOne.ServiceHost.ConfigurationTool/Entities/VersionOneSettings.cs index 8179aa7..6fec4c9 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/Entities/VersionOneSettings.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/Entities/VersionOneSettings.cs @@ -48,8 +48,11 @@ public string ApplicationUrl get { return applicationUrl; } set { - applicationUrl = value; - NotifyPropertyChanged(); + if (applicationUrl != value) + { + applicationUrl = value; + NotifyPropertyChanged(); + } } } @@ -59,8 +62,11 @@ public string AccessToken get { return accessToken; } set { - accessToken = value; - NotifyPropertyChanged(); + if (accessToken != value) + { + accessToken = value; + NotifyPropertyChanged(); + } } } @@ -70,8 +76,11 @@ public string Username get { return username; } set { - username = value; - NotifyPropertyChanged(); + if (username != value) + { + username = value; + NotifyPropertyChanged(); + } } } @@ -81,8 +90,11 @@ public string Password get { return password; } set { - password = value; - NotifyPropertyChanged(); + if (password != value) + { + password = value; + NotifyPropertyChanged(); + } } } diff --git a/VersionOne.ServiceHost.ConfigurationTool/Entities/WorkitemWriterEntity.cs b/VersionOne.ServiceHost.ConfigurationTool/Entities/WorkitemWriterEntity.cs index 871bbcd..e02ae0a 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/Entities/WorkitemWriterEntity.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/Entities/WorkitemWriterEntity.cs @@ -22,8 +22,11 @@ public string ExternalIdFieldName get { return externalIdFieldName; } set { - externalIdFieldName = value; - NotifyPropertyChanged(); + if (externalIdFieldName != value) + { + externalIdFieldName = value; + NotifyPropertyChanged(); + } } } diff --git a/VersionOne.ServiceHost.ConfigurationTool/UI/Controllers/JiraController.cs b/VersionOne.ServiceHost.ConfigurationTool/UI/Controllers/JiraController.cs index 6ff7ec2..686d26c 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/UI/Controllers/JiraController.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/UI/Controllers/JiraController.cs @@ -3,37 +3,47 @@ using VersionOne.ServiceHost.ConfigurationTool.Entities; using VersionOne.ServiceHost.ConfigurationTool.UI.Interfaces; -namespace VersionOne.ServiceHost.ConfigurationTool.UI.Controllers { - public class JiraController : BasePageController { +namespace VersionOne.ServiceHost.ConfigurationTool.UI.Controllers +{ + public class JiraController : BasePageController + { public JiraController(JiraServiceEntity model, IFacade facade) : base(model, facade) { } - public override void PrepareView() { + public override void PrepareView() + { View.ValidationRequested += View_ValidationRequested; View.ControlValidationTriggered += View_ControlValidationTriggered; - - try { + + try + { View.AvailableSources = Facade.GetSourceList(); View.ProjectWrapperList = Facade.GetProjectWrapperList(); View.VersionOnePriorities = Facade.GetVersionOnePriorities(); base.PrepareView(); - } catch (BusinessException ex) { + } + catch (BusinessException ex) + { View.DisplayError(ex.Message); - } + } } - private void View_ControlValidationTriggered(object sender, EventArgs e) { + private void View_ControlValidationTriggered(object sender, EventArgs e) + { var results = Facade.ValidateEntity(Model); var generalTabValid = true; var mappingTabValid = true; - foreach(var result in results) { + foreach (var result in results) + { var targetType = result.Target.GetType(); - if(targetType == typeof(JiraServiceEntity) || targetType == typeof(JiraFilter)) { + if (targetType == typeof(JiraServiceEntity) || targetType == typeof(JiraFilter)) + { generalTabValid = false; } - if(targetType == typeof(JiraProjectMapping) || targetType == typeof(JiraPriorityMapping)) { + if (targetType == typeof(JiraProjectMapping) || targetType == typeof(JiraPriorityMapping)) + { mappingTabValid = false; } } @@ -42,16 +52,21 @@ private void View_ControlValidationTriggered(object sender, EventArgs e) { View.SetMappingTabValidity(mappingTabValid); } - private void View_ValidationRequested(object sender, EventArgs e) { - try { + private void View_ValidationRequested(object sender, EventArgs e) + { + try + { var result = Facade.ValidateConnection(Model); View.SetValidationResult(result); - if(result) { + if (result) + { var jiraPriorities = Facade.GetJiraPriorities(Model.Url, Model.UserName, Model.Password); View.UpdateJiraPriorities(jiraPriorities); } - } catch (AssemblyLoadException ex) { + } + catch (AssemblyLoadException ex) + { FormController.FailApplication(ex.Message); } } diff --git a/VersionOne.ServiceHost.ConfigurationTool/UI/Controls/JiraPageControl.cs b/VersionOne.ServiceHost.ConfigurationTool/UI/Controls/JiraPageControl.cs index 5b2f3da..6a4ca1c 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/UI/Controls/JiraPageControl.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/UI/Controls/JiraPageControl.cs @@ -8,13 +8,14 @@ using VersionOne.ServiceHost.ConfigurationTool.UI.Interfaces; using VersionOne.ServiceHost.ConfigurationTool.BZ; -namespace VersionOne.ServiceHost.ConfigurationTool.UI.Controls { - public partial class JiraPageControl : /*UserControl { //*/BasePageControl, IJiraPageView { - private IList jiraPriorities; - +namespace VersionOne.ServiceHost.ConfigurationTool.UI.Controls +{ + public partial class JiraPageControl : /*UserControl { //*/BasePageControl, IJiraPageView + { public event EventHandler ValidationRequested; - public JiraPageControl() { + public JiraPageControl() + { InitializeComponent(); grdProjectMappings.AutoGenerateColumns = false; grdPriorityMappings.AutoGenerateColumns = false; @@ -25,16 +26,8 @@ public JiraPageControl() { btnDeleteProjectMapping.Click += btnDeleteProjectMapping_Click; btnDeletePriorityMapping.Click += btnDeletePriorityMapping_Click; - grdProjectMappings.UserDeletingRow += delegate(object sender, DataGridViewRowCancelEventArgs e) { - if(!ConfirmDelete()) { - e.Cancel = true; - } - }; - grdPriorityMappings.UserDeletingRow += delegate(object sender, DataGridViewRowCancelEventArgs e) { - if(!ConfirmDelete()) { - e.Cancel = true; - } - }; + grdProjectMappings.UserDeletingRow += grdProjectMappings_OnUserDeletingRow; + grdPriorityMappings.UserDeletingRow += grdProjectMappings_OnUserDeletingRow; grdProjectMappings.DataError += grdProjectMappings_DataError; grdPriorityMappings.DataError += grdPriorityMappings_DataError; @@ -58,38 +51,57 @@ public JiraPageControl() { chkStoryFilterDisabled.CheckStateChanged += chkStoryFilterEnabled_CheckStateChanged; } - private void chkStoryFilterEnabled_CheckStateChanged(object sender, EventArgs e) { + private void grdProjectMappings_OnUserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) + { + if (!ConfirmDelete()) + { + e.Cancel = true; + } + } + + private void chkStoryFilterEnabled_CheckStateChanged(object sender, EventArgs e) + { SwitchStoryFilterEnableState(); } - private void chkDefectFilterEnabled_CheckStateChanged(object sender, EventArgs e) { + private void chkDefectFilterEnabled_CheckStateChanged(object sender, EventArgs e) + { SwitchDefectFilterEnableState(); } - private void bsPriorityMappings_CurrentItemChanged(object sender, EventArgs e) { - var current = (JiraPriorityMapping) bsPriorityMappings.Current; - - if(current == null) { + private void bsPriorityMappings_CurrentItemChanged(object sender, EventArgs e) + { + var current = (JiraPriorityMapping)bsPriorityMappings.Current; + if (current == null) + { return; } - var currentId = current.JiraPriorityId; - var sourceName = (jiraPriorities.Where(item => item.Value == currentId).Select(item=> item.Name).FirstOrDefault()) ?? string.Empty; + var currentVersionOnePriorityId = current.VersionOnePriorityId; + var currentVersionOnePriorityName = (VersionOnePriorities.Where(item => item.Value == currentVersionOnePriorityId).Select(item => item.Name).FirstOrDefault()) ?? string.Empty; + if (!string.IsNullOrEmpty(currentVersionOnePriorityName) && current.VersionOnePriorityName != currentVersionOnePriorityName) + { + current.VersionOnePriorityName = currentVersionOnePriorityName; + } - if(!string.IsNullOrEmpty(sourceName) && current.JiraPriorityName != sourceName) { - current.JiraPriorityName = sourceName; + var currentJiraPriorityId = current.JiraPriorityId; + var currentJiraPriorityName = (JiraPriorities.Where(item => item.Value == currentJiraPriorityId).Select(item => item.Name).FirstOrDefault()) ?? string.Empty; + if (!string.IsNullOrEmpty(currentJiraPriorityName) && current.JiraPriorityName != currentJiraPriorityName) + { + current.JiraPriorityName = currentJiraPriorityName; } } - public override void DataBind() { + public override void DataBind() + { AddControlBinding(chkDisabled, Model, BaseEntity.DisabledProperty); AddControlBinding(txtUrl, Model, JiraServiceEntity.UrlProperty); AddControlBinding(txtPassword, Model, JiraServiceEntity.PasswordProperty); AddControlBinding(txtUserName, Model, JiraServiceEntity.UserNameProperty); AddControlBinding(txtCreateDefectFilterId, Model.CreateDefectFilter, JiraFilter.IdProperty); - AddControlBinding(chkDefectFilterDisabled, Model.CreateDefectFilter, JiraFilter.DisabledProperty); + AddControlBinding(chkDefectFilterDisabled, Model.CreateDefectFilter, BaseEntity.DisabledProperty); AddControlBinding(txtCreateStoryFilterId, Model.CreateStoryFilter, JiraFilter.IdProperty); - AddControlBinding(chkStoryFilterDisabled, Model.CreateStoryFilter, JiraFilter.DisabledProperty); + AddControlBinding(chkStoryFilterDisabled, Model.CreateStoryFilter, BaseEntity.DisabledProperty); AddControlBinding(txtJiraUrlTitle, Model, JiraServiceEntity.UrlTitleProperty); AddControlBinding(txtJiraUrlTempl, Model, JiraServiceEntity.UrlTemplateProperty); AddSimpleComboboxBinding(cboSourceFieldValue, Model, JiraServiceEntity.SourceNameProperty); @@ -115,35 +127,46 @@ public override void DataBind() { InvokeValidationTriggered(); } - private void BindPriorityMappingsGrid() { + // HACK: needed because we can't get priorities from Jira until user validates connection + private static IList GetJiraPriorityList(IEnumerable mappings) + { + return mappings.Select(mapping => new ListValue(mapping.JiraPriorityName, mapping.JiraPriorityId)).ToList(); + } + + private void BindPriorityMappingsGrid() + { BindVersionOnePriorityColumn(); - jiraPriorities = CreateDataSourceFromMappings(Model.PriorityMappings); + JiraPriorities = GetJiraPriorityList(Model.PriorityMappings); BindJiraPriorityColumn(); bsPriorityMappings.DataSource = Model.PriorityMappings; grdPriorityMappings.DataSource = bsPriorityMappings; } - private void BindProjectMappingsGrid() { + private void BindProjectMappingsGrid() + { BindProjectColumn(); bsProjectMappings.DataSource = Model.ProjectMappings; grdProjectMappings.DataSource = bsProjectMappings; } - private void SwitchStoryFilterEnableState() { + private void SwitchStoryFilterEnableState() + { txtCreateStoryFilterId.Enabled = !chkStoryFilterDisabled.Checked; } - private void SwitchDefectFilterEnableState() { + private void SwitchDefectFilterEnableState() + { txtCreateDefectFilterId.Enabled = !chkDefectFilterDisabled.Checked; } - private void BindHelpStrings() { + private void BindHelpStrings() + { AddHelpSupport(lblMinutes, Model.Timer, TimerEntity.TimerProperty); AddHelpSupport(chkDisabled, Model, BaseEntity.DisabledProperty); AddHelpSupport(txtCreateDefectFilterId, Model.CreateDefectFilter, JiraFilter.IdProperty); - AddHelpSupport(chkDefectFilterDisabled, Model.CreateDefectFilter, JiraFilter.DisabledProperty); + AddHelpSupport(chkDefectFilterDisabled, Model.CreateDefectFilter, BaseEntity.DisabledProperty); AddHelpSupport(txtCreateStoryFilterId, Model.CreateStoryFilter, JiraFilter.IdProperty); - AddHelpSupport(chkStoryFilterDisabled, Model.CreateStoryFilter, JiraFilter.DisabledProperty); + AddHelpSupport(chkStoryFilterDisabled, Model.CreateStoryFilter, BaseEntity.DisabledProperty); AddHelpSupport(txtDefectLinkFieldId, Model, JiraServiceEntity.LinkFieldProperty); AddHelpSupport(txtJiraUrlTempl, Model, JiraServiceEntity.UrlTemplateProperty); AddHelpSupport(cboSourceFieldValue, Model, JiraServiceEntity.SourceNameProperty); @@ -158,81 +181,98 @@ private void BindHelpStrings() { AddHelpSupport(txtProgressWorkflowClosed, Model, JiraServiceEntity.ProgressWorkflowClosedProperty); } - private static IList CreateDataSourceFromMappings(IEnumerable mappings) { - return mappings.Select(mapping => new ListValue(mapping.JiraPriorityName, mapping.JiraPriorityId)).ToList(); - } - - private void BindProjectColumn() { + private void BindProjectColumn() + { colVersionOneProject.DisplayMember = "DisplayName"; colVersionOneProject.ValueMember = "Token"; colVersionOneProject.DataSource = ProjectWrapperList; } - private void BindVersionOnePriorityColumn() { + private void BindVersionOnePriorityColumn() + { colVersionOnePriority.DisplayMember = "Name"; colVersionOnePriority.ValueMember = "Value"; colVersionOnePriority.DataSource = VersionOnePriorities; } - private void BindJiraPriorityColumn() { + private void BindJiraPriorityColumn() + { colJiraPriority.DisplayMember = "Name"; colJiraPriority.ValueMember = "Value"; - colJiraPriority.DataSource = jiraPriorities; + colJiraPriority.DataSource = JiraPriorities; } - private void btnVerifyJiraConnection_Click(object sender, EventArgs e) { - if(ValidationRequested != null) { + private void btnVerifyJiraConnection_Click(object sender, EventArgs e) + { + if (ValidationRequested != null) + { ValidationRequested(this, EventArgs.Empty); } } - private void btnDeleteProjectMapping_Click(object sender, EventArgs e) { - if(grdProjectMappings.SelectedRows.Count > 0 && ConfirmDelete()) { + private void btnDeleteProjectMapping_Click(object sender, EventArgs e) + { + if (grdProjectMappings.SelectedRows.Count > 0 && ConfirmDelete()) + { bsProjectMappings.Remove(grdProjectMappings.SelectedRows[0].DataBoundItem); } } - private void btnDeletePriorityMapping_Click(object sender, EventArgs e) { - if(grdPriorityMappings.SelectedRows.Count > 0 && ConfirmDelete()) { + private void btnDeletePriorityMapping_Click(object sender, EventArgs e) + { + if (grdPriorityMappings.SelectedRows.Count > 0 && ConfirmDelete()) + { bsPriorityMappings.Remove(grdPriorityMappings.SelectedRows[0].DataBoundItem); } } - private void grdProjectMappings_DataError(object sender, DataGridViewDataErrorEventArgs e) { - if(ProjectWrapperList != null && ProjectWrapperList.Count > 0) { + private void grdProjectMappings_DataError(object sender, DataGridViewDataErrorEventArgs e) + { + if (ProjectWrapperList != null && ProjectWrapperList.Count > 0) + { grdProjectMappings.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = ProjectWrapperList[0].Token; } e.ThrowException = false; } - private void grdPriorityMappings_DataError(object sender, DataGridViewDataErrorEventArgs e) { + private void grdPriorityMappings_DataError(object sender, DataGridViewDataErrorEventArgs e) + { var column = grdPriorityMappings.Columns[e.ColumnIndex]; - if(column == colVersionOnePriority) { + if (column == colVersionOnePriority) + { SetDefaultValue(VersionOnePriorities, e.RowIndex, e.ColumnIndex); - } else if(column == colJiraPriority) { - SetDefaultValue(jiraPriorities, e.RowIndex, e.ColumnIndex); + } + else if (column == colJiraPriority) + { + SetDefaultValue(JiraPriorities, e.RowIndex, e.ColumnIndex); } e.ThrowException = false; } - private void SetDefaultValue(IList dataSource, int rowIndex, int columnIndex) { - if(dataSource != null && dataSource.Count > 0) { + private void SetDefaultValue(IList dataSource, int rowIndex, int columnIndex) + { + if (dataSource != null && dataSource.Count > 0) + { grdPriorityMappings.Rows[rowIndex].Cells[columnIndex].Value = dataSource[0].Value; } } - public void SetValidationResult(bool validationSuccessful) { + public void SetValidationResult(bool validationSuccessful) + { lblConnectionValidation.Visible = true; - if(validationSuccessful) { + if (validationSuccessful) + { lblConnectionValidation.ForeColor = Color.Green; lblConnectionValidation.Text = Resources.ConnectionValidMessage + Environment.NewLine + Resources.CheckPriorityMappingsMessage; - } else { + } + else + { lblConnectionValidation.ForeColor = Color.Red; lblConnectionValidation.Text = Resources.ConnectionInvalidMessage; } @@ -244,16 +284,21 @@ public void SetValidationResult(bool validationSuccessful) { public IList VersionOnePriorities { get; set; } - public void SetGeneralTabValidity(bool isValid) { + public IList JiraPriorities { get; set; } + + public void SetGeneralTabValidity(bool isValid) + { TabHighlighter.SetTabPageValidationMark(tpSettings, isValid); } - public void SetMappingTabValidity(bool isValid) { + public void SetMappingTabValidity(bool isValid) + { TabHighlighter.SetTabPageValidationMark(tpMappings, isValid); } - public void UpdateJiraPriorities(IList priorities) { - jiraPriorities = priorities; + public void UpdateJiraPriorities(IList priorities) + { + JiraPriorities = priorities; BindJiraPriorityColumn(); } } diff --git a/VersionOne.ServiceHost.ConfigurationTool/UI/Interfaces/IConfigurationController.cs b/VersionOne.ServiceHost.ConfigurationTool/UI/Interfaces/IConfigurationController.cs index e3f7215..1d035a7 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/UI/Interfaces/IConfigurationController.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/UI/Interfaces/IConfigurationController.cs @@ -1,12 +1,14 @@ -namespace VersionOne.ServiceHost.ConfigurationTool.UI.Interfaces { - public interface IConfigurationController : ISettingsProvider { +namespace VersionOne.ServiceHost.ConfigurationTool.UI.Interfaces +{ + public interface IConfigurationController : ISettingsProvider + { string ApplicationVersion { get; } void RegisterView(IConfigurationView configurationView); IConfigurationView View { get; } - string CurrentFileName { get;} + string CurrentFileName { get; } void PrepareView(); void ShowPage(string pageKey); diff --git a/VersionOne.ServiceHost.ConfigurationTool/UI/Interfaces/IJiraPageView.cs b/VersionOne.ServiceHost.ConfigurationTool/UI/Interfaces/IJiraPageView.cs index 4378f4e..960ad68 100644 --- a/VersionOne.ServiceHost.ConfigurationTool/UI/Interfaces/IJiraPageView.cs +++ b/VersionOne.ServiceHost.ConfigurationTool/UI/Interfaces/IJiraPageView.cs @@ -4,13 +4,16 @@ using VersionOne.ServiceHost.ConfigurationTool.Entities; using VersionOne.ServiceHost.ConfigurationTool.BZ; -namespace VersionOne.ServiceHost.ConfigurationTool.UI.Interfaces { - public interface IJiraPageView : IPageView { +namespace VersionOne.ServiceHost.ConfigurationTool.UI.Interfaces +{ + public interface IJiraPageView : IPageView + { event EventHandler ValidationRequested; void SetValidationResult(bool validationSuccessful); IEnumerable AvailableSources { get; set; } IList ProjectWrapperList { get; set; } IList VersionOnePriorities { get; set; } + IList JiraPriorities { get; set; } void SetGeneralTabValidity(bool isValid); void SetMappingTabValidity(bool isValid); void UpdateJiraPriorities(IList jiraPriorities);