From 59d93de4733b1fd3775449d7f59239af5203107f Mon Sep 17 00:00:00 2001 From: galactica Date: Tue, 31 Dec 2024 16:09:57 +0200 Subject: [PATCH 1/4] fix update scan btn status --- .../CxExtension/Toolbar/BranchesCombobox.cs | 10 ++++++++-- .../CxExtension/Toolbar/CxToolbar.cs | 12 ++++++------ .../CxExtension/Toolbar/ProjectsCombobox.cs | 9 +++++++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs b/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs index 6022979..4a7d031 100644 --- a/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs +++ b/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs @@ -97,7 +97,12 @@ public async Task LoadBranchesAsync(string projectId) /// public void OnChangeBranch(object sender, SelectionChangedEventArgs e) { - if (!(sender is ComboBox branchesCombo) || branchesCombo.SelectedItem == null || branchesCombo.SelectedIndex == -1) return; + //cxToolbar.ScanStartButton.IsEnabled = false; + if (!(sender is ComboBox branchesCombo) || branchesCombo.SelectedItem == null || branchesCombo.SelectedIndex == -1) + { + cxToolbar.EnableScanButtonByCombos(); + return; + } ResetFilteringState(branchesCombo.SelectedItem as ComboBoxItem); @@ -106,6 +111,7 @@ public void OnChangeBranch(object sender, SelectionChangedEventArgs e) cxToolbar.EnableCombos(false); cxToolbar.ScansCombo.Text = string.IsNullOrEmpty(CxToolbar.currentScanId) ? CxConstants.TOOLBAR_LOADING_SCANS : CxToolbar.currentScanId; cxToolbar.ResultsTreePanel.ClearAll(); + //cxToolbar.ScanStartButton.IsEnabled = true; string projectId = ((cxToolbar.ProjectsCombo.SelectedItem as ComboBoxItem).Tag as Project).Id; @@ -118,7 +124,7 @@ public void OnChangeBranch(object sender, SelectionChangedEventArgs e) _ = scansCombobox.LoadScansAsync(projectId, selectedBranch); - cxToolbar.ScanButtonByCombos(); + cxToolbar.EnableScanButtonByCombos(); } protected override void ResetOthersComboBoxesAndResults() { diff --git a/ast-visual-studio-extension/CxExtension/Toolbar/CxToolbar.cs b/ast-visual-studio-extension/CxExtension/Toolbar/CxToolbar.cs index 70c6814..1de5a54 100644 --- a/ast-visual-studio-extension/CxExtension/Toolbar/CxToolbar.cs +++ b/ast-visual-studio-extension/CxExtension/Toolbar/CxToolbar.cs @@ -163,7 +163,7 @@ public void Init() control.IsChecked = readOnlyStore.GetBoolean(SettingsUtils.groupByCollection, groupBy.ToString(), SettingsUtils.groupByDefaultValues[groupBy]); } - ScanButtonByCombos(); + EnableScanButtonByCombos(); _ = IdeScansEnabledAsync(); @@ -311,11 +311,11 @@ private static async Task ASTProjectMatchesWorkspaceProjectAsync(EnvDTE.DT return false; } - public void ScanButtonByCombos() + public void EnableScanButtonByCombos() { - var projectId = SettingsUtils.GetToolbarValue(Package, SettingsUtils.projectIdProperty); - var branch = SettingsUtils.GetToolbarValue(Package, SettingsUtils.branchProperty); - ScanStartButton.IsEnabled = !(string.IsNullOrEmpty(projectId) || string.IsNullOrEmpty(branch)); + var isProject = ProjectsCombo?.SelectedItem != null && ProjectsCombo.SelectedIndex != -1; + var isBranch = BranchesCombo?.SelectedItem != null && BranchesCombo.SelectedIndex != -1; + ScanStartButton.IsEnabled = isProject && isBranch; } private async Task IdeScansEnabledAsync() @@ -410,7 +410,7 @@ private async Task PollScanStartedAsync() var scanId = SettingsUtils.GetToolbarValue(Package, SettingsUtils.createdScanIdProperty); if (string.IsNullOrWhiteSpace(scanId)) { - ScanStartButton.IsEnabled = true; + EnableScanButtonByCombos(); return; }; var options = default(TaskHandlerOptions); diff --git a/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs b/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs index 3be40db..f6ae5b1 100644 --- a/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs +++ b/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs @@ -142,8 +142,13 @@ private async Task LoadProjectsComboboxAsync() /// public void OnChangeProject(object sender, SelectionChangedEventArgs e) { + //cxToolbar.ScanStartButton.IsEnabled = false; ComboBox projectsCombo = cxToolbar.ProjectsCombo; - if (projectsCombo == null || projectsCombo.SelectedItem == null || projectsCombo.SelectedIndex == -1) return; + if (projectsCombo == null || projectsCombo.SelectedItem == null || projectsCombo.SelectedIndex == -1) + { + cxToolbar.EnableScanButtonByCombos(); + return; + } ResetFilteringState(projectsCombo.SelectedItem as ComboBoxItem); @@ -168,7 +173,7 @@ public void OnChangeProject(object sender, SelectionChangedEventArgs e) _ = branchesCombobox.LoadBranchesAsync(selectedProject); - cxToolbar.ScanButtonByCombos(); + cxToolbar.EnableScanButtonByCombos(); } protected override void ResetOthersComboBoxesAndResults() From 00baa5a8facfd39631d2aacb515431d13669f893 Mon Sep 17 00:00:00 2001 From: galactica Date: Tue, 31 Dec 2024 16:16:17 +0200 Subject: [PATCH 2/4] fix --- .../CxExtension/Toolbar/BranchesCombobox.cs | 1 - .../CxExtension/Toolbar/ProjectsCombobox.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs b/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs index 4a7d031..5466023 100644 --- a/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs +++ b/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs @@ -111,7 +111,6 @@ public void OnChangeBranch(object sender, SelectionChangedEventArgs e) cxToolbar.EnableCombos(false); cxToolbar.ScansCombo.Text = string.IsNullOrEmpty(CxToolbar.currentScanId) ? CxConstants.TOOLBAR_LOADING_SCANS : CxToolbar.currentScanId; cxToolbar.ResultsTreePanel.ClearAll(); - //cxToolbar.ScanStartButton.IsEnabled = true; string projectId = ((cxToolbar.ProjectsCombo.SelectedItem as ComboBoxItem).Tag as Project).Id; diff --git a/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs b/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs index f6ae5b1..7c94d66 100644 --- a/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs +++ b/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs @@ -142,7 +142,6 @@ private async Task LoadProjectsComboboxAsync() /// public void OnChangeProject(object sender, SelectionChangedEventArgs e) { - //cxToolbar.ScanStartButton.IsEnabled = false; ComboBox projectsCombo = cxToolbar.ProjectsCombo; if (projectsCombo == null || projectsCombo.SelectedItem == null || projectsCombo.SelectedIndex == -1) { From f593884a0f202ecbabed2ddefd238dd654f6db8b Mon Sep 17 00:00:00 2001 From: galactica Date: Tue, 31 Dec 2024 16:22:24 +0200 Subject: [PATCH 3/4] delete comment --- .../CxExtension/Toolbar/BranchesCombobox.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs b/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs index 5466023..92d9097 100644 --- a/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs +++ b/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs @@ -97,7 +97,6 @@ public async Task LoadBranchesAsync(string projectId) /// public void OnChangeBranch(object sender, SelectionChangedEventArgs e) { - //cxToolbar.ScanStartButton.IsEnabled = false; if (!(sender is ComboBox branchesCombo) || branchesCombo.SelectedItem == null || branchesCombo.SelectedIndex == -1) { cxToolbar.EnableScanButtonByCombos(); From 0f01b6f52dc4d0f8430d55590b5b261b73c8c281 Mon Sep 17 00:00:00 2001 From: galactica Date: Tue, 31 Dec 2024 16:32:18 +0200 Subject: [PATCH 4/4] fix name --- .../CxExtension/Toolbar/BranchesCombobox.cs | 4 ++-- .../CxExtension/Toolbar/CxToolbar.cs | 6 +++--- .../CxExtension/Toolbar/ProjectsCombobox.cs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs b/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs index 92d9097..5acdb3e 100644 --- a/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs +++ b/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs @@ -99,7 +99,7 @@ public void OnChangeBranch(object sender, SelectionChangedEventArgs e) { if (!(sender is ComboBox branchesCombo) || branchesCombo.SelectedItem == null || branchesCombo.SelectedIndex == -1) { - cxToolbar.EnableScanButtonByCombos(); + cxToolbar.CheckScanButtonStateByCombos(); return; } @@ -122,7 +122,7 @@ public void OnChangeBranch(object sender, SelectionChangedEventArgs e) _ = scansCombobox.LoadScansAsync(projectId, selectedBranch); - cxToolbar.EnableScanButtonByCombos(); + cxToolbar.CheckScanButtonStateByCombos(); } protected override void ResetOthersComboBoxesAndResults() { diff --git a/ast-visual-studio-extension/CxExtension/Toolbar/CxToolbar.cs b/ast-visual-studio-extension/CxExtension/Toolbar/CxToolbar.cs index 1de5a54..d7b7713 100644 --- a/ast-visual-studio-extension/CxExtension/Toolbar/CxToolbar.cs +++ b/ast-visual-studio-extension/CxExtension/Toolbar/CxToolbar.cs @@ -163,7 +163,7 @@ public void Init() control.IsChecked = readOnlyStore.GetBoolean(SettingsUtils.groupByCollection, groupBy.ToString(), SettingsUtils.groupByDefaultValues[groupBy]); } - EnableScanButtonByCombos(); + CheckScanButtonStateByCombos(); _ = IdeScansEnabledAsync(); @@ -311,7 +311,7 @@ private static async Task ASTProjectMatchesWorkspaceProjectAsync(EnvDTE.DT return false; } - public void EnableScanButtonByCombos() + public void CheckScanButtonStateByCombos() { var isProject = ProjectsCombo?.SelectedItem != null && ProjectsCombo.SelectedIndex != -1; var isBranch = BranchesCombo?.SelectedItem != null && BranchesCombo.SelectedIndex != -1; @@ -410,7 +410,7 @@ private async Task PollScanStartedAsync() var scanId = SettingsUtils.GetToolbarValue(Package, SettingsUtils.createdScanIdProperty); if (string.IsNullOrWhiteSpace(scanId)) { - EnableScanButtonByCombos(); + CheckScanButtonStateByCombos(); return; }; var options = default(TaskHandlerOptions); diff --git a/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs b/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs index 7c94d66..dcb7220 100644 --- a/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs +++ b/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs @@ -145,7 +145,7 @@ public void OnChangeProject(object sender, SelectionChangedEventArgs e) ComboBox projectsCombo = cxToolbar.ProjectsCombo; if (projectsCombo == null || projectsCombo.SelectedItem == null || projectsCombo.SelectedIndex == -1) { - cxToolbar.EnableScanButtonByCombos(); + cxToolbar.CheckScanButtonStateByCombos(); return; } @@ -172,7 +172,7 @@ public void OnChangeProject(object sender, SelectionChangedEventArgs e) _ = branchesCombobox.LoadBranchesAsync(selectedProject); - cxToolbar.EnableScanButtonByCombos(); + cxToolbar.CheckScanButtonStateByCombos(); } protected override void ResetOthersComboBoxesAndResults()