Skip to content

Commit 6310f05

Browse files
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 <noreply@anthropic.com>
1 parent 1b94a50 commit 6310f05

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

checkmarx-ast-eclipse-plugin/src/com/checkmarx/eclipse/views/CheckmarxView.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
import org.eclipse.swt.custom.CLabel;
4242
import org.eclipse.swt.custom.ScrolledComposite;
4343
import org.eclipse.swt.custom.StyledText;
44+
import org.eclipse.swt.events.FocusEvent;
45+
import org.eclipse.swt.events.FocusListener;
4446
import org.eclipse.swt.events.SelectionAdapter;
4547
import org.eclipse.swt.events.SelectionEvent;
4648
import org.eclipse.swt.events.SelectionListener;
@@ -904,7 +906,26 @@ protected IStatus run(IProgressMonitor monitor) {
904906
debounceTimer.schedule(pendingSearchTask, DEBOUNCE_DELAY_MS);
905907

906908
}
907-
});
909+
});
910+
911+
// Add FocusListener to disable branch combo when project is cleared and focus lost
912+
projectComboViewer.getCombo().addFocusListener(new FocusListener() {
913+
@Override
914+
public void focusLost(FocusEvent e) {
915+
// When user clicks outside project combo, check if project is empty
916+
String enteredProject = projectComboViewer.getCombo().getText().trim();
917+
// If project field is empty or contains only the placeholder text, disable branch combo
918+
if (enteredProject.isEmpty() || enteredProject.equals(PROJECT_COMBO_VIEWER_TEXT)) {
919+
currentProjectId = PluginConstants.EMPTY_STRING;
920+
PluginUtils.enableComboViewer(branchComboViewer, false);
921+
}
922+
}
923+
924+
@Override
925+
public void focusGained(FocusEvent e) {
926+
// No action needed on focus gain
927+
}
928+
});
908929

909930
}
910931
/**

0 commit comments

Comments
 (0)