Browse Source

REPORT-8926 【10.0一轮回归】设计器默认的工作目录名称有问题

fix
master
ju 7 years ago
parent
commit
7af4028dff
  1. 31
      designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  2. 7
      designer-base/src/com/fr/file/FILEChooserPane.java

31
designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java

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

7
designer-base/src/com/fr/file/FILEChooserPane.java

@ -33,6 +33,7 @@ import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
@ -548,7 +549,7 @@ public class FILEChooserPane extends BasicPane {
String[] fileSuffix_local = LocalFileNodes.FILE_TYPE; String[] fileSuffix_local = LocalFileNodes.FILE_TYPE;
EnumSet<FileExtension> fileExtensions = EnumSet.of(FileExtension.CPT, FileExtension.CPTX, FileExtension.FRM, FileExtension.FRMX, FileExtension.CHT); EnumSet<FileExtension> fileExtensions = EnumSet.of(FileExtension.CPT, FileExtension.CPTX, FileExtension.FRM, FileExtension.FRMX, FileExtension.CHT);
if (type == JFileChooser.OPEN_DIALOG) { if (type == JFileChooser.OPEN_DIALOG) {
if (FRContext.getFileNodes().isSupportLocalFileOperate()) { //本地连接 if (WorkContext.getCurrent().isLocal()) { //本地连接
this.addChooseFILEFilter(new ChooseFileFilter(fileSuffix_local, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"}))); this.addChooseFILEFilter(new ChooseFileFilter(fileSuffix_local, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"})));
} else { } else {
this.addChooseFILEFilter(new ChooseFileFilter(fileExtensions, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"}))); this.addChooseFILEFilter(new ChooseFileFilter(fileExtensions, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"})));
@ -569,7 +570,7 @@ public class FILEChooserPane extends BasicPane {
} }
// 添加 xls 文件类型过滤 kt // 添加 xls 文件类型过滤 kt
if (FRContext.getFileNodes().isSupportLocalFileOperate()) { //本地连接 if (WorkContext.getCurrent().isLocal()) { //本地连接
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLS, Inter.getLocText("Import-Excel_Source"))); this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLS, Inter.getLocText("Import-Excel_Source")));
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLSX, Inter.getLocText("Import-Excel2007_Source"))); this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLSX, Inter.getLocText("Import-Excel2007_Source")));
} }
@ -592,7 +593,7 @@ public class FILEChooserPane extends BasicPane {
for (FILEFilter aFilterList : filterList) { for (FILEFilter aFilterList : filterList) {
defaultComboBoxModel.addElement(aFilterList); defaultComboBoxModel.addElement(aFilterList);
} }
if (FRContext.getFileNodes().isSupportLocalFileOperate()) { //本地连接 if (WorkContext.getCurrent().isLocal()) { //本地连接
if (!showWebReport) { if (!showWebReport) {
defaultComboBoxModel.addElement(Inter.getLocText("FR-Utils-App_AllFiles") + "(*.*)"); defaultComboBoxModel.addElement(Inter.getLocText("FR-Utils-App_AllFiles") + "(*.*)");
} }

Loading…
Cancel
Save