Browse Source

Pull request #10595: REPORT-82745 二次新建模板计数异常

Merge in DESIGN/design from ~DESTINY.LIN/design:final/11.0 to final/11.0

* commit 'fbc891f1a74b79f66a3dd44cc56efde4809b8dc5':
  REPORT-82745 二次新建模板计数异常
new-design
Destiny.Lin-林锦龙 2 years ago
parent
commit
52fc481ad3
  1. 27
      designer-base/src/main/java/com/fr/design/mainframe/JTemplateNameHelper.java

27
designer-base/src/main/java/com/fr/design/mainframe/JTemplateNameHelper.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.stable.StringUtils;
@ -19,8 +20,6 @@ public class JTemplateNameHelper {
private static final int PREFIX_NUM = 3000;
private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复
public static String newTemplateNameByIndex(String prefix) {
// 用于获取左侧模板的文件名,如左侧已包含"WorkBook1.cpt, WorkBook12.cpt, WorkBook177.cpt"
// 那么新建的文件名将被命名为"WorkBook178.cpt",即取最大数+1
@ -37,13 +36,33 @@ public class JTemplateNameHelper {
reportNum.add(index);
}
}
//把当前编辑面板的模板名也加进来判断
addHistoryTemplateName2List(reportNum, prefix);
Collections.sort(reportNum);
BigInteger idx = reportNum.size() > 0 ? reportNum.get(reportNum.size() - 1).add(BigInteger.valueOf(1)) : BigInteger.valueOf(1);
idx = idx.add(BigInteger.valueOf(currentIndex));
currentIndex++;
return prefix + idx;
}
/**
* 将当前打开的模板列表的模板名处理一下加进来以便于获取左侧模板文件名与当前模板列表的最大值
*
* @param reportNum 存储后缀的列表
* @param prefix 前缀
*/
private static void addHistoryTemplateName2List(List<BigInteger> reportNum, String prefix) {
int len = HistoryTemplateListCache.getInstance().getHistoryCount();
for (int i = 0; i < len; i++) {
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().get(i);
if (jTemplate != null) {
String templateName = jTemplate.getTemplateName();
BigInteger index = getFileNameIndex(prefix, templateName);
if (index != null) {
reportNum.add(index);
}
}
}
}
/**
* @return java.lang.Integer WorkBook11.cpt则返回11如果没有找到index返回null
* @Description 返回文件名中的index

Loading…
Cancel
Save