From 6310f05bebe62d57977db3a7de8efb0f20fa04a3 Mon Sep 17 00:00:00 2001 From: Aniket Shinde Date: Fri, 17 Apr 2026 11:30:58 +0530 Subject: [PATCH] AST-101305: Disable Branch and Scan dropdown when no project is selected - Add FocusListener to project combo viewer - When user clears project and clicks outside, branch combo is disabled - Resets currentProjectId to empty when project field is cleared - Preserves existing behavior for all other scenarios Co-Authored-By: Claude Haiku 4.5 --- .../eclipse/views/CheckmarxView.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/checkmarx-ast-eclipse-plugin/src/com/checkmarx/eclipse/views/CheckmarxView.java b/checkmarx-ast-eclipse-plugin/src/com/checkmarx/eclipse/views/CheckmarxView.java index 43c16a4..7a78108 100644 --- a/checkmarx-ast-eclipse-plugin/src/com/checkmarx/eclipse/views/CheckmarxView.java +++ b/checkmarx-ast-eclipse-plugin/src/com/checkmarx/eclipse/views/CheckmarxView.java @@ -41,6 +41,8 @@ import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; @@ -904,7 +906,26 @@ protected IStatus run(IProgressMonitor monitor) { debounceTimer.schedule(pendingSearchTask, DEBOUNCE_DELAY_MS); } - }); + }); + + // Add FocusListener to disable branch combo when project is cleared and focus lost + projectComboViewer.getCombo().addFocusListener(new FocusListener() { + @Override + public void focusLost(FocusEvent e) { + // When user clicks outside project combo, check if project is empty + String enteredProject = projectComboViewer.getCombo().getText().trim(); + // If project field is empty or contains only the placeholder text, disable branch combo + if (enteredProject.isEmpty() || enteredProject.equals(PROJECT_COMBO_VIEWER_TEXT)) { + currentProjectId = PluginConstants.EMPTY_STRING; + PluginUtils.enableComboViewer(branchComboViewer, false); + } + } + + @Override + public void focusGained(FocusEvent e) { + // No action needed on focus gain + } + }); } /**