|
|
|
@ -183,7 +183,19 @@ public class SaveSomeTemplatePane extends BasicPane {
|
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public boolean showSavePane(@Nullable MultiTemplateTabPane.CloseCondition option, boolean judgeJTemplateMustSave) { |
|
|
|
|
initAndPopulate(option, judgeJTemplateMustSave); |
|
|
|
|
return showSavePane(option, judgeJTemplateMustSave, false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 显示保存模板提醒面板 |
|
|
|
|
* |
|
|
|
|
* @param option 具体关闭操作 |
|
|
|
|
* @param judgeJTemplateMustSave 模板是否必须保存 |
|
|
|
|
* @param judgeSameTabType 是否只包含当前编辑的模板类型 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public boolean showSavePane(@Nullable MultiTemplateTabPane.CloseCondition option, boolean judgeJTemplateMustSave, boolean judgeSameTabType) { |
|
|
|
|
initAndPopulate(option, judgeJTemplateMustSave, judgeSameTabType); |
|
|
|
|
//如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目
|
|
|
|
|
if (!unSavedTemplate.isEmpty()) { |
|
|
|
|
dialog.setVisible(true); |
|
|
|
@ -197,13 +209,16 @@ public class SaveSomeTemplatePane extends BasicPane {
|
|
|
|
|
return HistoryTemplateListPane.getInstance().getHistoryList(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initAndPopulate(@Nullable MultiTemplateTabPane.CloseCondition option, boolean judgeJTemplateMustSave) { |
|
|
|
|
private void initAndPopulate(@Nullable MultiTemplateTabPane.CloseCondition option, boolean judgeJTemplateMustSave, boolean judgeSameTabType) { |
|
|
|
|
java.util.List<JTemplate<?, ?>> opendedTemplate = getOpenedTemplatesToProcess(); |
|
|
|
|
JTemplate<?, ?> currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
int currentIndex = opendedTemplate.indexOf(currentTemplate); |
|
|
|
|
for (int i = 0; i < opendedTemplate.size(); i++) { |
|
|
|
|
//满足关闭条件的才继续判断文件是否发生了改动
|
|
|
|
|
boolean needClose = option == null || option.shouldClose(opendedTemplate.get(i), currentIndex, i); |
|
|
|
|
if (judgeSameTabType) { |
|
|
|
|
needClose &= ComparatorUtils.equals(opendedTemplate.get(i).getTemplateTabOperatorType(), currentTemplate.getTemplateTabOperatorType()); |
|
|
|
|
} |
|
|
|
|
if (needClose && isneedToAdd(opendedTemplate.get(i), currentTemplate)) { |
|
|
|
|
unSavedTemplate.add(opendedTemplate.get(i)); |
|
|
|
|
} |
|
|
|
|