@@ -136,18 +136,15 @@ public void actionPerformed(ActionEvent e) {
136136 if ((e .getModifiers () & java .awt .event .InputEvent .BUTTON1_MASK ) == java .awt .event .InputEvent .BUTTON1_MASK ) {
137137 final Object object = AutoCompleteJComboBox .this .getEditor ().getItem ();
138138 /* Let us be extra paranoid. */
139- if (object instanceof ResultType ) {
140- // From Yahoo! Ajax result.
141- ResultType lastEnteredResult = (ResultType )object ;
142- AutoCompleteJComboBox .this .resultSubject .notify (AutoCompleteJComboBox .this , lastEnteredResult );
139+ if (object instanceof DispType ) {
140+ DispType lastEnteredDisp = (DispType )object ;
141+ AutoCompleteJComboBox .this .dispSubject .notify (AutoCompleteJComboBox .this , lastEnteredDisp );
143142 } else if (object instanceof StockInfo ) {
144143 // From our offline database.
145144 StockInfo lastEnteredStockInfo = (StockInfo )object ;
146145 AutoCompleteJComboBox .this .stockInfoSubject .notify (AutoCompleteJComboBox .this , lastEnteredStockInfo );
147146 } else {
148- assert (object instanceof MatchType );
149- MatchType lastEnteredMatch = (MatchType )object ;
150- AutoCompleteJComboBox .this .matchSubject .notify (AutoCompleteJComboBox .this , lastEnteredMatch );
147+ assert (false );
151148 }
152149
153150 SwingUtilities .invokeLater (new Runnable () {
@@ -354,31 +351,24 @@ public void keyReleased(KeyEvent e) {
354351 busySubject .notify (AutoCompleteJComboBox .this , false );
355352
356353 StockInfo lastEnteredStockInfo = null ;
357- ResultType lastEnteredResultType = null ;
358- MatchType lastEnteredMatchType = null ;
354+ DispType lastEnteredDispType = null ;
359355
360356 if (AutoCompleteJComboBox .this .getItemCount () > 0 ) {
361357 int index = AutoCompleteJComboBox .this .getSelectedIndex ();
362358 if (index == -1 ) {
363359 Object object = AutoCompleteJComboBox .this .getItemAt (0 );
364360 if (object instanceof StockInfo ) {
365361 lastEnteredStockInfo = (StockInfo )object ;
366- } else if (object instanceof ResultType ) {
367- lastEnteredResultType = (ResultType )object ;
368- } else {
369- assert (object instanceof MatchType );
370- lastEnteredMatchType = (MatchType )object ;
362+ } else if (object instanceof DispType ) {
363+ lastEnteredDispType = (DispType )object ;
371364 }
372365 }
373366 else {
374367 Object object = AutoCompleteJComboBox .this .getItemAt (index );
375368 if (object instanceof StockInfo ) {
376369 lastEnteredStockInfo = (StockInfo )object ;
377- } else if (object instanceof ResultType ) {
378- lastEnteredResultType = (ResultType )object ;
379- } else {
380- assert (object instanceof MatchType );
381- lastEnteredMatchType = (MatchType )object ;
370+ } else if (object instanceof DispType ) {
371+ lastEnteredDispType = (DispType )object ;
382372 }
383373 }
384374 }
@@ -403,10 +393,8 @@ public void keyReleased(KeyEvent e) {
403393 AutoCompleteJComboBox .this .removeAllItems ();
404394 if (lastEnteredStockInfo != null ) {
405395 AutoCompleteJComboBox .this .stockInfoSubject .notify (AutoCompleteJComboBox .this , lastEnteredStockInfo );
406- } else if (lastEnteredResultType != null ) {
407- AutoCompleteJComboBox .this .resultSubject .notify (AutoCompleteJComboBox .this , lastEnteredResultType );
408- } else if (lastEnteredMatchType != null ) {
409- AutoCompleteJComboBox .this .matchSubject .notify (AutoCompleteJComboBox .this , lastEnteredMatchType );
396+ } else if (lastEnteredDispType != null ) {
397+ AutoCompleteJComboBox .this .dispSubject .notify (AutoCompleteJComboBox .this , lastEnteredDispType );
410398 } else {
411399 // Do nothing.
412400 }
@@ -559,7 +547,7 @@ public void update(final AjaxGoogleSearchEngineMonitor subject, MatchSetType arg
559547 if (arg .Match .isEmpty ()) {
560548 StockInfo stockInfo = ajaxStockInfoSearchEngine .search (arg .Query );
561549 if (stockInfo != null ) {
562- MatchType matchType = new MatchType (stockInfo .code .toString (), stockInfo .symbol .toString (), null , null );
550+ MatchType matchType = new MatchType (stockInfo .code .toString (). toUpperCase () , stockInfo .symbol .toString (), null , null );
563551 List <MatchType > matchTypes = new ArrayList <>();
564552 matchTypes .add (matchType );
565553 MatchSetType matchSetType = MatchSetType .newInstance (arg .Query , matchTypes );
@@ -652,7 +640,7 @@ public void update(final AjaxYahooSearchEngineMonitor subject, ResultSetType arg
652640 if (arg .Result .isEmpty ()) {
653641 StockInfo stockInfo = ajaxStockInfoSearchEngine .search (arg .Query );
654642 if (stockInfo != null ) {
655- ResultType resultType = new ResultType (stockInfo .code .toString (), stockInfo .symbol .toString ());
643+ ResultType resultType = new ResultType (stockInfo .code .toString (). toUpperCase () , stockInfo .symbol .toString ());
656644 List <ResultType > resultTypes = new ArrayList <>();
657645 resultTypes .add (resultType );
658646 // Overwrite!
@@ -736,8 +724,7 @@ public void _update(AjaxYahooSearchEngineMonitor subject, ResultSetType arg) {
736724 };
737725 }
738726
739- private final SubjectEx <AutoCompleteJComboBox , ResultType > resultSubject = new SubjectEx <AutoCompleteJComboBox , ResultType >();
740- private final SubjectEx <AutoCompleteJComboBox , MatchType > matchSubject = new SubjectEx <AutoCompleteJComboBox , MatchType >();
727+ private final SubjectEx <AutoCompleteJComboBox , DispType > dispSubject = new SubjectEx <AutoCompleteJComboBox , DispType >();
741728 private final SubjectEx <AutoCompleteJComboBox , StockInfo > stockInfoSubject = new SubjectEx <AutoCompleteJComboBox , StockInfo >();
742729 private final SubjectEx <AutoCompleteJComboBox , Boolean > busySubject = new SubjectEx <AutoCompleteJComboBox , Boolean >();
743730
@@ -755,12 +742,8 @@ public void attachStockInfoObserver(Observer<AutoCompleteJComboBox, StockInfo> o
755742 *
756743 * @param observer an observer to listen to ResultType available event
757744 */
758- public void attachResultObserver (Observer <AutoCompleteJComboBox , ResultType > observer ) {
759- resultSubject .attach (observer );
760- }
761-
762- public void attachMatchObserver (Observer <AutoCompleteJComboBox , MatchType > observer ) {
763- matchSubject .attach (observer );
745+ public void attachDispObserver (Observer <AutoCompleteJComboBox , DispType > observer ) {
746+ dispSubject .attach (observer );
764747 }
765748
766749 /**
@@ -779,8 +762,7 @@ public void dettachAll() {
779762 // For offline database feature.
780763 stockInfoSubject .dettachAll ();
781764 // For online database feature.
782- resultSubject .dettachAll ();
783- matchSubject .dettachAll ();
765+ dispSubject .dettachAll ();
784766 busySubject .dettachAll ();
785767 }
786768
@@ -845,7 +827,7 @@ public int compare(StockInfo o1, StockInfo o2) {
845827 private List <String > codeExtensionSortingOption = java .util .Collections .emptyList ();
846828
847829 private final ListCellRenderer offlineModeCellRenderer = new StockInfoCellRenderer ();
848- private final ListCellRenderer onlineModeCellRenderer = new MatchSetOrResultSetCellRenderer ();
830+ private final ListCellRenderer onlineModeCellRenderer = new DispTypeCellRenderer ();
849831 private final ListCellRenderer oldListCellRenderer ;
850832 private ListCellRenderer currentListCellRenderer ;
851833
0 commit comments