@ -48,13 +48,14 @@ public class ITReplaceMainDialog extends UIDialog {
private static boolean matched = false ;
private static boolean matched = false ;
private static volatile ITReplaceMainDialog instance = null ;
private static volatile ITReplaceMainDialog instance = null ;
private static String templateID ;
private static String templateID ;
private static String templateName ;
private ITReplaceNorthPanel northPane ;
private ITReplaceNorthPanel northPane ;
private ITReplaceSouthPanel southPanel ;
private ITReplaceSouthPanel southPanel ;
private ITReplaceWestPanel westPanel ;
private ITReplaceWestPanel westPanel ;
private boolean searchFlag ;
private boolean searchFlag ;
private String searchStr ;
private String searchStr ;
private static final int FIRST_ROW = 0 ;
private static final int FIRST_ROW = 0 ;
public static int selectCount = 0 ;
public static int selectCount = 0 ;
public ITReplaceMainDialog ( ) {
public ITReplaceMainDialog ( ) {
super ( DesignerContext . getDesignerFrame ( ) ) ;
super ( DesignerContext . getDesignerFrame ( ) ) ;
@ -165,8 +166,9 @@ public class ITReplaceMainDialog extends UIDialog {
String searchStr = ( ( UITextField ) ( northPane . getFindInputCombobox ( ) . getEditor ( ) . getEditorComponent ( ) ) ) . getText ( ) ;
String searchStr = ( ( UITextField ) ( northPane . getFindInputCombobox ( ) . getEditor ( ) . getEditorComponent ( ) ) ) . getText ( ) ;
String replaceStr = ( ( UITextField ) ( northPane . getReplaceInputCombobox ( ) . getEditor ( ) . getEditorComponent ( ) ) ) . getText ( ) ;
String replaceStr = ( ( UITextField ) ( northPane . getReplaceInputCombobox ( ) . getEditor ( ) . getEditorComponent ( ) ) ) . getText ( ) ;
//替换内容为空需要触发搜索
//替换内容为空需要触发搜索
if ( StringUtils . equals ( getSearchStr ( ) , searchStr ) & & StringUtils . isNotEmpty ( replaceStr ) ) {
if ( isITReplaceValid ( ) & & checkTemplateChanged ( searchResultList ) ) {
if ( isITReplaceValid ( ) & & checkTemplateChanged ( searchResultList ) ) {
if ( StringUtils . equals ( getSearchStr ( ) , searchStr ) & & StringUtils . isNotEmpty ( replaceStr ) ) {
HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) . fireTargetModified ( true ) ;
for ( Info info : searchResultList ) {
for ( Info info : searchResultList ) {
if ( info . getContent ( ) . isSelected ( ) ) {
if ( info . getContent ( ) . isSelected ( ) ) {
info . setValue ( info , searchStr , replaceStr , info . getContent ( ) . getOperatorArray ( ) ) ;
info . setValue ( info , searchStr , replaceStr , info . getContent ( ) . getOperatorArray ( ) ) ;
@ -175,29 +177,26 @@ public class ITReplaceMainDialog extends UIDialog {
southPanel . getTableEditorPane ( ) . update ( ) ;
southPanel . getTableEditorPane ( ) . update ( ) ;
northPane . refreshReplaceInputComboBoxItems ( ) ;
northPane . refreshReplaceInputComboBoxItems ( ) ;
ITTableEditorPane . getEditTable ( ) . repaint ( ) ;
ITTableEditorPane . getEditTable ( ) . repaint ( ) ;
HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) . fireTargetModified ( true ) ;
setSearchFlag ( false ) ;
setSearchFlag ( false ) ;
search ( ) ;
} else {
Object [ ] options = new Object [ ] { Toolkit . i18nText ( "Fine-Design_Replace_Search_Again" ) , Toolkit . i18nText ( "Fine-Design_Basic_Cancel" ) } ;
int optionSelected = FineJOptionPane . showOptionDialog (
ITReplaceMainDialog . this ,
Toolkit . i18nText ( "Fine-Design_Replace_Message" ) ,
Toolkit . i18nText ( "Fine-Design_Basic_Tool_Tips" ) ,
JOptionPane . YES_NO_CANCEL_OPTION ,
JOptionPane . ERROR_MESSAGE ,
null ,
// 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框)
options ,
options [ 0 ]
) ;
//如果选择了重新查找,则再查找一遍
if ( optionSelected = = 0 ) {
search ( ) ;
}
}
}
} else {
search ( ) ;
search ( ) ;
} else {
Object [ ] options = new Object [ ] { Toolkit . i18nText ( "Fine-Design_Replace_Search_Again" ) , Toolkit . i18nText ( "Fine-Design_Basic_Cancel" ) } ;
int optionSelected = FineJOptionPane . showOptionDialog (
ITReplaceMainDialog . this ,
Toolkit . i18nText ( "Fine-Design_Replace_Message" ) ,
Toolkit . i18nText ( "Fine-Design_Basic_Tool_Tips" ) ,
JOptionPane . YES_NO_CANCEL_OPTION ,
JOptionPane . ERROR_MESSAGE ,
null ,
// 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框)
options ,
options [ 0 ]
) ;
//如果选择了重新查找,则再查找一遍
if ( optionSelected = = 0 ) {
search ( ) ;
}
}
}
@ -220,7 +219,8 @@ public class ITReplaceMainDialog extends UIDialog {
* /
* /
public boolean isITReplaceValid ( ) {
public boolean isITReplaceValid ( ) {
if ( JTemplate . isValid ( HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) ) ) {
if ( JTemplate . isValid ( HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) ) ) {
return StringUtils . equals ( HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) . getTarget ( ) . getTemplateID ( ) , templateID ) ;
return StringUtils . equals ( HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) . getTarget ( ) . getTemplateID ( ) , templateID )
& & StringUtils . equals ( HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) . getTemplateName ( ) , templateName ) ;
} else {
} else {
return false ;
return false ;
}
}
@ -288,6 +288,7 @@ public class ITReplaceMainDialog extends UIDialog {
if ( JTemplate . isValid ( HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) ) ) {
if ( JTemplate . isValid ( HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) ) ) {
JTemplate jTemplate = HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) ;
JTemplate jTemplate = HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) ;
templateID = HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) . getTarget ( ) . getTemplateID ( ) ;
templateID = HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) . getTarget ( ) . getTemplateID ( ) ;
templateName = HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) . getTemplateName ( ) ;
itTableEditor . clear ( ) ;
itTableEditor . clear ( ) ;
String searchStr = ( ( UITextField ) ( northPane . getFindInputCombobox ( ) . getEditor ( ) . getEditorComponent ( ) ) ) . getText ( ) ;
String searchStr = ( ( UITextField ) ( northPane . getFindInputCombobox ( ) . getEditor ( ) . getEditorComponent ( ) ) ) . getText ( ) ;
//更新搜索内容
//更新搜索内容
@ -310,12 +311,12 @@ public class ITReplaceMainDialog extends UIDialog {
setSearchFlag ( true ) ;
setSearchFlag ( true ) ;
selectCount = searchResultList . size ( ) ;
selectCount = searchResultList . size ( ) ;
//如果有结果,默认选中第一行
//如果有结果,默认选中第一行
if ( searchResultList . size ( ) > 0 ) {
if ( searchResultList . size ( ) > 0 ) {
getEditTable ( ) . addRowSelectionInterval ( FIRST_ROW , FIRST_ROW ) ;
getEditTable ( ) . addRowSelectionInterval ( FIRST_ROW , FIRST_ROW ) ;
}
}
//更新替换按钮可用性
//更新替换按钮可用性
if ( StringUtils . isEmpty ( searchStr ) | | searchResultList . size ( ) = = 0 ) {
if ( StringUtils . isEmpty ( searchStr ) | | searchResultList . size ( ) = = 0 ) {
northPane . getReplaceButton ( ) . setEnabled ( false ) ;
northPane . getReplaceButton ( ) . setEnabled ( false ) ;
} else {
} else {
northPane . getReplaceButton ( ) . setEnabled ( true ) ;
northPane . getReplaceButton ( ) . setEnabled ( true ) ;