@ -146,6 +146,8 @@ public class AlphaFineFrame extends JFrame {
private UILabel clearLabel ;
private JPanel tabPane ;
private CellType selectedType ;
private String beforeSearchStr = StringUtils . EMPTY ;
@ -365,7 +367,7 @@ public class AlphaFineFrame extends JFrame {
labelPane . add ( labelContentPane ) ;
labelPane . setPreferredSize ( new Dimension ( AlphaFineConstants . FULL_SIZE . width , 30 ) ) ;
JPanel tabPane = new JPanel ( new FlowLayout ( FlowLayout . LEFT , 20 , 10 ) ) ;
tabPane = new JPanel ( new FlowLayout ( FlowLayout . LEFT , 20 , 10 ) ) ;
tabPane . setBackground ( Color . WHITE ) ;
List < SelectedLabel > selectedLabelList = createSelectedLabelList ( ) ;
selectedType = selectedLabelList . get ( 0 ) . getCellType ( ) ;
@ -624,6 +626,7 @@ public class AlphaFineFrame extends JFrame {
clearLabel . setVisible ( true ) ;
SearchTooltipPopup . getInstance ( ) . show ( searchTextFieldWrapperPane ) ;
}
tabPane . repaint ( ) ;
} ) ;
timer . start ( ) ;
@ -644,28 +647,58 @@ public class AlphaFineFrame extends JFrame {
beforeSearchStr = StringUtils . EMPTY ;
return ;
}
String lowerCaseSearchText = preProcessSearchText ( searchTextField . getText ( ) . toLowerCase ( ) ) ;
if ( DesignerEnvManager . getEnvManager ( ) . getAlphaFineConfigManager ( ) . isNeedSegmentationCheckbox ( ) ) {
//是高级搜索
if ( searchTextField . getText ( ) . toLowerCase ( ) . startsWith ( ADVANCED_SEARCH_MARK ) ) {
segmentationResult = SegmentationManager . getInstance ( ) . startSegmentation ( getStoreText ( searchTextField . getText ( ) . toLowerCase ( ) ) ) ;
}
//是普通搜索
else {
segmentationResult = SegmentationManager . getInstance ( ) . startSegmentation ( searchTextField . getText ( ) . toLowerCase ( ) ) ;
}
dealSegmentationSearch ( lowerCaseSearchText ) ;
} else {
if ( StringUtils . isEmpty ( getRealSearchText ( searchTextField . getText ( ) ) ) ) {
segmentationResult = null ;
} else {
segmentationResult = new String [ ] { getRealSearchText ( searchTextField . getText ( ) ) } ;
}
dealNormalSearch ( ) ;
}
DesignerEnvManager . getEnvManager ( ) . getAlphaFineConfigManager ( ) . getHistorySearch ( ) . push ( searchTextField . getText ( ) ) ;
doSearch ( searchTextField . getText ( ) . toLowerCase ( ) ) ;
doSearch ( lowerCaseSearchText ) ;
beforeSearchStr = searchTextField . getText ( ) ;
SearchTooltipPopup . getInstance ( ) . hide ( ) ;
}
/ * *
* 普通搜索
* /
private void dealNormalSearch ( ) {
String searchText = preProcessSearchText ( searchTextField . getText ( ) ) ;
if ( StringUtils . isEmpty ( getRealSearchText ( searchText ) ) ) {
segmentationResult = null ;
} else {
segmentationResult = new String [ ] { getRealSearchText ( searchText ) } ;
}
}
/ * *
* 分词搜索
* /
private void dealSegmentationSearch ( String lowerCaseSearchText ) {
//是高级搜索
if ( searchTextField . getText ( ) . toLowerCase ( ) . startsWith ( ADVANCED_SEARCH_MARK ) ) {
segmentationResult = SegmentationManager . getInstance ( ) . startSegmentation ( getStoreText ( lowerCaseSearchText ) ) ;
}
//是普通搜索
else {
segmentationResult = SegmentationManager . getInstance ( ) . startSegmentation ( lowerCaseSearchText ) ;
}
}
/ * *
* 文本预处理 限制长度
*
* @param text
* @return
* /
private String preProcessSearchText ( String text ) {
if ( text . length ( ) > AlphaFineConstants . LEN_LIMIT ) {
return text . substring ( 0 , AlphaFineConstants . LEN_LIMIT ) ;
} else {
return text ;
}
}
private void dealWithSearchResult ( ) {
final AlphaCellModel model = searchResultList . getSelectedValue ( ) ;
if ( model ! = null ) {
@ -717,7 +750,7 @@ public class AlphaFineFrame extends JFrame {
*
* /
private void reSearch ( ) {
String text = this . searchTextField . getText ( ) . toLowerCase ( ) ;
String text = preProcessSearchText ( this . searchTextField . getText ( ) . toLowerCase ( ) ) ;
if ( StringUtils . isEmpty ( text ) ) {
return ;
}