@ -17,6 +17,7 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.general.ComparatorUtils ;
import com.fr.log.FineLoggerFactory ;
import org.jetbrains.annotations.Nullable ;
import javax.swing.* ;
import javax.swing.border.EmptyBorder ;
@ -162,8 +163,25 @@ public class SaveSomeTemplatePane extends BasicPane {
return showSavePane ( false ) ;
}
/ * *
* 显示保存模板提醒面板
*
* @param judgeJTemplateMustSave 模板是否必须保存
* @return
* /
public boolean showSavePane ( boolean judgeJTemplateMustSave ) {
populate ( judgeJTemplateMustSave ) ;
return showSavePane ( null , judgeJTemplateMustSave ) ;
}
/ * *
* 显示保存模板提醒面板
*
* @param option 具体关闭操作
* @param judgeJTemplateMustSave 模板是否必须保存
* @return
* /
public boolean showSavePane ( @Nullable MultiTemplateTabPane . CloseOption option , boolean judgeJTemplateMustSave ) {
initAndPopulate ( option , judgeJTemplateMustSave ) ;
//如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目
if ( ! unSavedTemplate . isEmpty ( ) ) {
dialog . setVisible ( true ) ;
@ -177,11 +195,14 @@ public class SaveSomeTemplatePane extends BasicPane {
return HistoryTemplateListPane . getInstance ( ) . getHistoryList ( ) ;
}
public void populate ( boolean judgeJTemplateMustSave ) {
private void initAndPopulate ( @Nullable MultiTemplateTabPane . CloseOption option , boolean judgeJTemplateMustSave ) {
java . util . List < JTemplate < ? , ? > > opendedTemplate = getOpenedTemplatesToProcess ( ) ;
JTemplate < ? , ? > currentTemplate = HistoryTemplateListPane . getInstance ( ) . getCurrentEditingTemplate ( ) ;
int currentIndex = opendedTemplate . indexOf ( currentTemplate ) ;
for ( int i = 0 ; i < opendedTemplate . size ( ) ; i + + ) {
if ( isneedToAdd ( opendedTemplate . get ( i ) , currentTemplate ) ) {
//满足关闭条件的才继续判断文件是否发生了改动
boolean needClose = option = = null | | option . shouldClose ( currentIndex , i ) ;
if ( needClose & & isneedToAdd ( opendedTemplate . get ( i ) , currentTemplate ) ) {
unSavedTemplate . add ( opendedTemplate . get ( i ) ) ;
}
}