|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.fr.design.gui.itree.filetree; |
|
|
|
|
|
|
|
|
|
import com.fr.base.FRContext; |
|
|
|
|
import com.fr.base.extension.FileExtension; |
|
|
|
|
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; |
|
|
|
|
import com.fr.file.filetree.FileNode; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
@ -22,7 +23,6 @@ public class TemplateFileTree extends EnvFileTree {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TemplateFileTree() { |
|
|
|
|
|
|
|
|
|
super(ProjectConstants.REPORTLETS_NAME, null, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -30,7 +30,6 @@ public class TemplateFileTree extends EnvFileTree {
|
|
|
|
|
* 选中reportPath |
|
|
|
|
*/ |
|
|
|
|
public void setSelectedTemplatePath(String templatePath) { |
|
|
|
|
|
|
|
|
|
this.selectPath(templatePath); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -38,7 +37,6 @@ public class TemplateFileTree extends EnvFileTree {
|
|
|
|
|
* 返回选中的Template的路径 |
|
|
|
|
*/ |
|
|
|
|
public String getSelectedTemplatePath() { |
|
|
|
|
|
|
|
|
|
FileNode fn = this.getSelectedFileNode(); |
|
|
|
|
if (fn != null && !fn.isDirectory()) { |
|
|
|
|
String envPath = fn.getEnvPath(); |
|
|
|
@ -52,7 +50,6 @@ public class TemplateFileTree extends EnvFileTree {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String[] getSelectedTemplatePaths() { |
|
|
|
|
|
|
|
|
|
TreePath[] selectedTreePaths = this.getSelectionPaths(); |
|
|
|
|
if (ArrayUtils.isEmpty(selectedTreePaths)) { |
|
|
|
|
return ArrayUtils.EMPTY_STRING_ARRAY; |
|
|
|
@ -103,6 +100,11 @@ public class TemplateFileTree extends EnvFileTree {
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public FileNode[] listFile(String path) throws Exception { |
|
|
|
|
return FRContext.getFileNodes().list( |
|
|
|
|
path, |
|
|
|
|
new FileExtension[]{FileExtension.CPT, FileExtension.FRM, FileExtension.CHT,FileExtension.XLS,FileExtension.XLSX}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
* 改变Env后,根据构造函数时设置的RootPaths,重新加载 |
|
|
|
@ -136,7 +138,6 @@ public class TemplateFileTree extends EnvFileTree {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode treeNode) { |
|
|
|
|
|
|
|
|
|
FileNode[] fn_array = listFileNodes(treeNode); |
|
|
|
|
|
|
|
|
|
return fileNodeArray2TreeNodeArray(fn_array); |
|
|
|
@ -146,7 +147,6 @@ public class TemplateFileTree extends EnvFileTree {
|
|
|
|
|
* 把FileNode[]转成ExpandMutableTreeNode[] |
|
|
|
|
*/ |
|
|
|
|
private ExpandMutableTreeNode[] fileNodeArray2TreeNodeArray(FileNode[] fileNodes) { |
|
|
|
|
|
|
|
|
|
ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[fileNodes.length]; |
|
|
|
|
for (int i = 0; i < res.length; i++) { |
|
|
|
|
FileNode fn = fileNodes[i]; |
|
|
|
@ -161,16 +161,26 @@ public class TemplateFileTree extends EnvFileTree {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private FileNode[] listFileNodes(String filePath) { |
|
|
|
|
|
|
|
|
|
FileNode[] fileNodes = null; |
|
|
|
|
try { |
|
|
|
|
fileNodes = FRContext.getFileNodes().list(filePath, filter); |
|
|
|
|
fileNodes = listFile(filePath); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
if (fileNodes == null) { |
|
|
|
|
fileNodes = new FileNode[0]; |
|
|
|
|
} |
|
|
|
|
// 用FileNodeFilter过滤一下
|
|
|
|
|
if (filter != null) { |
|
|
|
|
List<FileNode> list = new ArrayList<FileNode>(); |
|
|
|
|
for (FileNode fileNode : fileNodes) { |
|
|
|
|
if (filter.accept(fileNode)) { |
|
|
|
|
list.add(fileNode); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileNodes = list.toArray(new FileNode[list.size()]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Arrays.sort(fileNodes, new FileNodeComparator()); |
|
|
|
|
|
|
|
|
@ -181,7 +191,6 @@ public class TemplateFileTree extends EnvFileTree {
|
|
|
|
|
* 求当前TreeNode下所有的FileNode. |
|
|
|
|
*/ |
|
|
|
|
private FileNode[] listFileNodes(ExpandMutableTreeNode currentTreeNode) { |
|
|
|
|
|
|
|
|
|
if (currentTreeNode == null) { |
|
|
|
|
return new FileNode[0]; |
|
|
|
|
} |
|
|
|
|