Skip to content

Commit 72be7a1

Browse files
Fix: Truncate long custom state names in filter menu (AST-137779) (#246)
* Fix AST-137779: Truncate long custom state names in filter menu and triage combo Custom states with very long names caused the state filter dropdown menu to expand across the entire screen. Fix truncates display text to 50 chars (with trailing "...") in both the state filter MenuItem and the triage state ComboViewer LabelProvider. The full state name is still used internally for filtering and triage submission. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * Fix AST-137779: Guard against null getResults() in cxProjectMatchesWorkspaceProject Results.getResults() can return null when no results have been loaded yet (e.g. fresh IDE session before any scan is imported). The prior check only guarded against a null Results object, causing an NPE on the first click of the Start Scan button and preventing scans from running. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 0260961 commit 72be7a1

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,13 @@ private void createResultViewPanel(Composite resultsComposite) {
627627
combo_1.setLayoutData(gd_combo_1);
628628

629629
triageStateComboViewer = new ComboViewer(triageView, SWT.READ_ONLY);
630+
triageStateComboViewer.setLabelProvider(new LabelProvider() {
631+
@Override
632+
public String getText(Object element) {
633+
String s = element instanceof String ? (String) element : super.getText(element);
634+
return s.length() > 50 ? s.substring(0, 47) + "..." : s;
635+
}
636+
});
630637
Combo combo_2 = triageStateComboViewer.getCombo();
631638
combo_2.setEnabled(true);
632639
combo_2.setData(PluginConstants.DATA_ID_KEY, PluginConstants.TRIAGE_STATE_COMBO_ID);

checkmarx-ast-eclipse-plugin/src/com/checkmarx/eclipse/views/actions/ActionFilterStatePreference.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public Menu getMenu(final Control parent) {
8989

9090
for (String customState : customStates) {
9191
MenuItem item = new MenuItem(menu, SWT.CHECK);
92-
item.setText(customState);
92+
item.setText(truncate(customState));
9393
item.setSelection(FilterState.isCustomStateSelected(customState));
9494
item.addSelectionListener(new SelectionAdapter() {
9595
@Override
@@ -127,4 +127,8 @@ public void widgetSelected(SelectionEvent e) {
127127
public Menu getMenu(final Menu parent) {
128128
return null;
129129
}
130+
131+
private static String truncate(String text) {
132+
return text.length() > 50 ? text.substring(0, 47) + "..." : text;
133+
}
130134
}

checkmarx-ast-eclipse-plugin/src/com/checkmarx/eclipse/views/actions/ActionStartScan.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private String getCurrentGitBranch() {
220220
*/
221221
private boolean cxProjectMatchesWorkspaceProject() {
222222
Results results = DataProvider.getInstance().getCurrentResults();
223-
boolean noResultsInScan = results == null || results.getResults().isEmpty();
223+
boolean noResultsInScan = results == null || results.getResults() == null || results.getResults().isEmpty();
224224
boolean noFilesInWorkspace = ResourcesPlugin.getWorkspace().getRoot().getProjects().length == 0;
225225

226226
if (noResultsInScan || noFilesInWorkspace) {

0 commit comments

Comments
 (0)