2020import javax .swing .SwingUtilities ;
2121
2222import burp .api .montoya .MontoyaApi ;
23+ import burp .api .montoya .core .HighlightColor ;
2324import burp .api .montoya .http .message .HttpRequestResponse ;
2425import burp .api .montoya .http .message .requests .HttpRequest ;
2526import burp .api .montoya .http .message .responses .HttpResponse ;
2627import burp .api .montoya .scanner .AuditConfiguration ;
2728import burp .api .montoya .scanner .BuiltInAuditConfiguration ;
29+ import burp .api .montoya .ui .swing .SwingUtils ;
2830import swurg .gui .components .tables .models .ParserTableModel ;
2931import swurg .gui .components .tables .renderers .CustomTableCellRenderer ;
3032
3133public class ParserContextMenu extends JPopupMenu {
3234
3335 private final MontoyaApi montoyaApi ;
36+ private final SwingUtils swingUtils ;
3437
3538 private final JTable table ;
3639
3740 public ParserContextMenu (MontoyaApi montoyaApi , JTable table ) {
3841 this .montoyaApi = montoyaApi ;
42+ this .swingUtils = montoyaApi .userInterface ().swingUtils ();
43+
3944 this .table = table ;
4045
4146 initComponents ();
@@ -205,9 +210,12 @@ private JMenuItem createSendToComparerMenuItem() {
205210 private JMenu createHighlightMenu () {
206211 JMenu highlightMenu = new JMenu ("Highlight" );
207212
208- Arrays .asList (null , Color .RED , Color .ORANGE , Color .YELLOW , Color .GREEN , Color .BLUE ,
209- Color .MAGENTA , Color .PINK , Color .GRAY )
210- .forEach (color -> highlightMenu .add (createHighlightMenuItem (color )));
213+ Arrays .stream (HighlightColor .values ())
214+ .forEach (highlightColor -> {
215+ Color color = (highlightColor .compareTo (HighlightColor .NONE ) == 0 ) ? null
216+ : this .swingUtils .colorForHighLight (highlightColor );
217+ highlightMenu .add (createHighlightMenuItem (color ));
218+ });
211219
212220 return highlightMenu ;
213221 }
@@ -222,9 +230,7 @@ private JMenuItem createHighlightMenuItem(Color color) {
222230 CustomTableCellRenderer renderer = (CustomTableCellRenderer ) table .getDefaultRenderer (Object .class );
223231
224232 menuItem .addActionListener (e -> processSelectedRows (index -> {
225- SwingUtilities .invokeLater (() -> {
226- renderer .setRowHighlightColor (index , color );
227- });
233+ SwingUtilities .invokeLater (() -> renderer .setRowHighlightColor (index , color ));
228234 }));
229235
230236 return menuItem ;
0 commit comments