@@ -103,7 +103,8 @@ public class SwingSearchBar extends JTextField {
103
103
private static final String DEFAULT_MESSAGE = "Click here to search" ;
104
104
private static final Color ACTIVE_FONT_COLOR = new Color (0 , 0 , 0 );
105
105
private static final Color INACTIVE_FONT_COLOR = new Color (150 , 150 , 150 );
106
- private static final Color SELECTED_RESULT_COLOR = new Color (70 , 152 , 251 );
106
+ private static final Color SELECTED_RESULT_COLOR = new Color (186 , 218 , 255 );
107
+ private static final String CONTEXT_COLOR = "#8C745E" ;
107
108
private static final int ICON_SIZE = 16 ;
108
109
private static final int PAD = 5 ;
109
110
@@ -348,8 +349,14 @@ public SwingSearchPanel(final Context context) {
348
349
349
350
final Container parent = getParent ();
350
351
352
+ String resultSizeStr = "" ;
353
+ final int resCount = ((SearchResultHeader ) value ).resultCount ();
354
+ if (resCount > resultLimit ) {
355
+ resultSizeStr += " <span style='color: " + CONTEXT_COLOR + ";'>(" + resultLimit + "/" + resCount + ")" ;
356
+ }
357
+
351
358
final JCheckBox headerBox = //
352
- new JCheckBox (searcher .title (), searchService .enabled (searcher ));
359
+ new JCheckBox ("<html>" + searcher .title () + resultSizeStr , searchService .enabled (searcher ));
353
360
headerBox .setFont (smaller (headerBox .getFont (), 2 ));
354
361
if (parent != null ) headerBox .setBackground (parent .getBackground ());
355
362
headerCheckboxes .put (searcher .getClass (), headerBox );
@@ -373,9 +380,10 @@ public SwingSearchPanel(final Context context) {
373
380
item .setBorder (new EmptyBorder (1 , PAD , 0 , PAD ));
374
381
item .add (icon (value .iconPath ()));
375
382
item .add (Box .createHorizontalStrut (3 ));
376
- final JTextArea name = new JTextArea ();
377
- name .setText (value .identifier ());
378
- name .setEditable (false );
383
+ final JLabel name = new JLabel ();
384
+ Font f = name .getFont ();
385
+ name .setFont (f .deriveFont (f .getStyle () & ~Font .BOLD ));
386
+ name .setText ("<html>" + value .identifier () + " <span style='color: " + CONTEXT_COLOR + ";'>" + value .context () + "</span>" );
379
387
name .setBackground (null );
380
388
item .add (name );
381
389
item .setBackground (isSelected ? SELECTED_RESULT_COLOR : list .getBackground ());
@@ -642,8 +650,10 @@ private void rebuild() {
642
650
643
651
if (completeResults == null ) continue ;
644
652
653
+ int resultCount = completeResults .size ();
654
+
645
655
// Add section header.
646
- listModel .addElement (new SearchResultHeader (searcher ));
656
+ listModel .addElement (new SearchResultHeader (searcher , resultCount ));
647
657
648
658
if (completeResults .isEmpty ()) continue ;
649
659
@@ -809,9 +819,15 @@ public void keyPressed(final KeyEvent e) {
809
819
private class SearchResultHeader implements SearchResult {
810
820
811
821
private final Searcher searcher ;
822
+ private final int resultCount ;
812
823
813
- public SearchResultHeader (final Searcher searcher ) {
824
+ public SearchResultHeader (final Searcher searcher , int resultCount ) {
814
825
this .searcher = searcher ;
826
+ this .resultCount = resultCount ;
827
+ }
828
+
829
+ public int resultCount () {
830
+ return resultCount ;
815
831
}
816
832
817
833
public Searcher searcher () {
0 commit comments