From bf17d9f018d850a4b0e7f3726bf2e9c408fa7f7e Mon Sep 17 00:00:00 2001 From: ju Date: Fri, 29 Jun 2018 17:11:51 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-9314=20=E3=80=9010.0=E4=B8=80?= =?UTF-8?q?=E8=BD=AE=E5=9B=9E=E5=BD=92=E3=80=91=E6=A8=A1=E6=9D=BF=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BAexcel=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B9=9F=E6=97=A0=E6=B3=95=E6=89=93=E5=BC=80=EF=BC=8C?= =?UTF-8?q?9.0=E5=8F=AF=E4=BB=A5=20=E5=90=8E=E9=9D=A2=E6=9C=89=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/itree/filetree/TemplateFileTree.java | 87 ++++++++++--------- 1 file changed, 47 insertions(+), 40 deletions(-) diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java index aeb3756e6..aaf57a90a 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java @@ -20,36 +20,40 @@ import java.util.List; * 显示Env下的reportlets目录下面的所有cpt文件 */ public class TemplateFileTree extends EnvFileTree { - - + + public TemplateFileTree() { + super(ProjectConstants.REPORTLETS_NAME, null, null); } - + /* * 选中reportPath */ public void setSelectedTemplatePath(String templatePath) { + this.selectPath(templatePath); } - + /** * 返回选中的Template的路径 */ public String getSelectedTemplatePath() { + FileNode fn = this.getSelectedFileNode(); if (fn != null && !fn.isDirectory()) { String envPath = fn.getEnvPath(); - + if (envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { return envPath.substring(ProjectConstants.REPORTLETS_NAME.length()); } } - + return null; } - + public String[] getSelectedTemplatePaths() { + TreePath[] selectedTreePaths = this.getSelectionPaths(); if (ArrayUtils.isEmpty(selectedTreePaths)) { return ArrayUtils.EMPTY_STRING_ARRAY; @@ -68,13 +72,13 @@ public class TemplateFileTree extends EnvFileTree { } } } - - + + return selectedPathList.toArray(new String[0]); } - + public TreePath getNextMatch(String prefix, int startingRow, Position.Bias bias) { - + int max = getRowCount(); if (prefix == null) { throw new IllegalArgumentException(); @@ -89,9 +93,9 @@ public class TemplateFileTree extends EnvFileTree { do { TreePath path = getPathForRow(row); String text = convertValueToText( - path.getLastPathComponent(), isRowSelected(row), - isExpanded(row), true, row, false); - + path.getLastPathComponent(), isRowSelected(row), + isExpanded(row), true, row, false); + if (text.toUpperCase().startsWith(prefix)) { return path; } @@ -99,24 +103,23 @@ public class TemplateFileTree extends EnvFileTree { } while (row != startingRow); return null; } - + public FileNode[] listFile(String path) throws Exception { - return FRContext.getFileNodes().list( - path, - new FileExtension[]{FileExtension.CPT, FileExtension.FRM, FileExtension.CPTX, FileExtension.FRMX}); + + return FRContext.getFileNodes().list(path); } - + /* * 改变Env后,根据构造函数时设置的RootPaths,重新加载 */ public void refreshEnv() { - + DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.getModel(); ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); rootTreeNode.removeAllChildren(); - + FileNode[] fns; - + // 如果rootPaths是null的话列出所有文件 if (subPathes == null) { fns = listFileNodes(this.treeRootPath); @@ -127,26 +130,28 @@ public class TemplateFileTree extends EnvFileTree { fns[i] = new FileNode(StableUtils.pathJoin(this.treeRootPath, subPathes[i]), true); } } - + ExpandMutableTreeNode[] subTreeNodes = fileNodeArray2TreeNodeArray(fns); - + for (ExpandMutableTreeNode node : subTreeNodes) { rootTreeNode.add(node); } - + defaultTreeModel.reload(rootTreeNode); } - + protected ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode treeNode) { + FileNode[] fn_array = listFileNodes(treeNode); - + return fileNodeArray2TreeNodeArray(fn_array); } - + /* * 把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]; @@ -155,12 +160,13 @@ public class TemplateFileTree extends EnvFileTree { res[i].add(new ExpandMutableTreeNode()); } } - + return res; } - - + + private FileNode[] listFileNodes(String filePath) { + FileNode[] fileNodes = null; try { fileNodes = listFile(filePath); @@ -178,31 +184,32 @@ public class TemplateFileTree extends EnvFileTree { list.add(fileNode); } } - + fileNodes = list.toArray(new FileNode[list.size()]); } - + Arrays.sort(fileNodes, new FileNodeComparator()); - + return fileNodes; } - + /* * 求当前TreeNode下所有的FileNode. */ private FileNode[] listFileNodes(ExpandMutableTreeNode currentTreeNode) { + if (currentTreeNode == null) { return new FileNode[0]; } - + Object object = currentTreeNode.getUserObject(); - + if (object instanceof FileNode) { return this.listFileNodes(((FileNode) object).getEnvPath()); } - + return new FileNode[0]; } - - + + } \ No newline at end of file From 3113f41292ec293a73e6a3980c60444901ae24f1 Mon Sep 17 00:00:00 2001 From: ju Date: Fri, 29 Jun 2018 17:20:13 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-8926=20=E3=80=9010.0=E4=B8=80?= =?UTF-8?q?=E8=BD=AE=E5=9B=9E=E5=BD=92=E3=80=91=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=9A=84=E5=B7=A5=E4=BD=9C=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E6=9C=89=E9=97=AE=E9=A2=98=20=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E6=94=BE=E5=88=B0basic=E5=90=AF=E5=8A=A8=E5=AE=8C?= =?UTF-8?q?=E6=88=90=EF=BC=8C=E5=88=87=E7=8E=AF=E5=A2=83=E4=B9=8B=E5=89=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/start/module/DesignerWorkspaceProvider.java | 4 +++- .../src/com/fr/start/module/PreStartActivator.java | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/com/fr/start/module/DesignerWorkspaceProvider.java index beb45fe98..3a2229229 100644 --- a/designer-realize/src/com/fr/start/module/DesignerWorkspaceProvider.java +++ b/designer-realize/src/com/fr/start/module/DesignerWorkspaceProvider.java @@ -14,7 +14,9 @@ public class DesignerWorkspaceProvider extends Activator { @Override public void start() { - + //检查环境 + DesignerEnvManager.checkNameEnvMap(); + String[] args = getModule().upFindSingleton(StartupArgs.class).get(); if (args != null) { for (String arg : args) { diff --git a/designer-realize/src/com/fr/start/module/PreStartActivator.java b/designer-realize/src/com/fr/start/module/PreStartActivator.java index 36a993bff..38f8c1c20 100644 --- a/designer-realize/src/com/fr/start/module/PreStartActivator.java +++ b/designer-realize/src/com/fr/start/module/PreStartActivator.java @@ -65,7 +65,6 @@ public class PreStartActivator extends Activator { private void initLanguage() { //这两句的位置不能随便调换,因为会影响语言切换的问题 FRContext.setLanguage(DesignerEnvManager.getEnvManager(false).getLanguage()); - DesignerEnvManager.checkNameEnvMap(); } @Override From 4741f1d0509d239b6654099e301a526623eaf573 Mon Sep 17 00:00:00 2001 From: ju Date: Fri, 29 Jun 2018 17:36:38 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-8926=20=E3=80=9010.0=E4=B8=80?= =?UTF-8?q?=E8=BD=AE=E5=9B=9E=E5=BD=92=E3=80=91=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=9A=84=E5=B7=A5=E4=BD=9C=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E6=9C=89=E9=97=AE=E9=A2=98=20=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E6=94=BE=E5=88=B0basic=E5=90=AF=E5=8A=A8=E5=AE=8C?= =?UTF-8?q?=E6=88=90=EF=BC=8C=E5=88=87=E7=8E=AF=E5=A2=83=E4=B9=8B=E5=89=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/itree/filetree/TemplateFileTree.java | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java index aaf57a90a..bef992fd4 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java @@ -1,7 +1,6 @@ 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; @@ -104,10 +103,6 @@ public class TemplateFileTree extends EnvFileTree { return null; } - public FileNode[] listFile(String path) throws Exception { - - return FRContext.getFileNodes().list(path); - } /* * 改变Env后,根据构造函数时设置的RootPaths,重新加载 @@ -169,24 +164,13 @@ public class TemplateFileTree extends EnvFileTree { FileNode[] fileNodes = null; try { - fileNodes = listFile(filePath); + fileNodes = FRContext.getFileNodes().list(filePath, filter); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } if (fileNodes == null) { fileNodes = new FileNode[0]; } - // 用FileNodeFilter过滤一下 - if (filter != null) { - List list = new ArrayList(); - for (FileNode fileNode : fileNodes) { - if (filter.accept(fileNode)) { - list.add(fileNode); - } - } - - fileNodes = list.toArray(new FileNode[list.size()]); - } Arrays.sort(fileNodes, new FileNodeComparator()); From 7af4028dff646edd312033f9635f4705efec52e5 Mon Sep 17 00:00:00 2001 From: ju Date: Fri, 29 Jun 2018 19:35:27 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-8926=20=E3=80=9010.0=E4=B8=80?= =?UTF-8?q?=E8=BD=AE=E5=9B=9E=E5=BD=92=E3=80=91=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=9A=84=E5=B7=A5=E4=BD=9C=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E6=9C=89=E9=97=AE=E9=A2=98=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/itree/filetree/TemplateFileTree.java | 99 ++++++++++--------- .../src/com/fr/file/FILEChooserPane.java | 7 +- 2 files changed, 58 insertions(+), 48 deletions(-) diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java index bef992fd4..0f61f40c3 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java @@ -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; @@ -19,40 +20,36 @@ import java.util.List; * 显示Env下的reportlets目录下面的所有cpt文件 */ public class TemplateFileTree extends EnvFileTree { - - + + public TemplateFileTree() { - super(ProjectConstants.REPORTLETS_NAME, null, null); } - + /* * 选中reportPath */ public void setSelectedTemplatePath(String templatePath) { - this.selectPath(templatePath); } - + /** * 返回选中的Template的路径 */ public String getSelectedTemplatePath() { - FileNode fn = this.getSelectedFileNode(); if (fn != null && !fn.isDirectory()) { String envPath = fn.getEnvPath(); - + if (envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { return envPath.substring(ProjectConstants.REPORTLETS_NAME.length()); } } - + return null; } - + public String[] getSelectedTemplatePaths() { - TreePath[] selectedTreePaths = this.getSelectionPaths(); if (ArrayUtils.isEmpty(selectedTreePaths)) { return ArrayUtils.EMPTY_STRING_ARRAY; @@ -71,13 +68,13 @@ public class TemplateFileTree extends EnvFileTree { } } } - - + + return selectedPathList.toArray(new String[0]); } - + public TreePath getNextMatch(String prefix, int startingRow, Position.Bias bias) { - + int max = getRowCount(); if (prefix == null) { throw new IllegalArgumentException(); @@ -92,9 +89,9 @@ public class TemplateFileTree extends EnvFileTree { do { TreePath path = getPathForRow(row); String text = convertValueToText( - path.getLastPathComponent(), isRowSelected(row), - isExpanded(row), true, row, false); - + path.getLastPathComponent(), isRowSelected(row), + isExpanded(row), true, row, false); + if (text.toUpperCase().startsWith(prefix)) { return path; } @@ -102,19 +99,24 @@ public class TemplateFileTree extends EnvFileTree { } while (row != startingRow); 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,重新加载 */ public void refreshEnv() { - + DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.getModel(); ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); rootTreeNode.removeAllChildren(); - + FileNode[] fns; - + // 如果rootPaths是null的话列出所有文件 if (subPathes == null) { fns = listFileNodes(this.treeRootPath); @@ -125,28 +127,26 @@ public class TemplateFileTree extends EnvFileTree { fns[i] = new FileNode(StableUtils.pathJoin(this.treeRootPath, subPathes[i]), true); } } - + ExpandMutableTreeNode[] subTreeNodes = fileNodeArray2TreeNodeArray(fns); - + for (ExpandMutableTreeNode node : subTreeNodes) { rootTreeNode.add(node); } - + defaultTreeModel.reload(rootTreeNode); } - + protected ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode treeNode) { - FileNode[] fn_array = listFileNodes(treeNode); - + return fileNodeArray2TreeNodeArray(fn_array); } - + /* * 把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]; @@ -155,45 +155,54 @@ public class TemplateFileTree extends EnvFileTree { res[i].add(new ExpandMutableTreeNode()); } } - + return res; } - - + + 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 list = new ArrayList(); + for (FileNode fileNode : fileNodes) { + if (filter.accept(fileNode)) { + list.add(fileNode); + } + } + + fileNodes = list.toArray(new FileNode[list.size()]); + } + Arrays.sort(fileNodes, new FileNodeComparator()); - + return fileNodes; } - + /* * 求当前TreeNode下所有的FileNode. */ private FileNode[] listFileNodes(ExpandMutableTreeNode currentTreeNode) { - if (currentTreeNode == null) { return new FileNode[0]; } - + Object object = currentTreeNode.getUserObject(); - + if (object instanceof FileNode) { return this.listFileNodes(((FileNode) object).getEnvPath()); } - + return new FileNode[0]; } - - + + } \ No newline at end of file diff --git a/designer-base/src/com/fr/file/FILEChooserPane.java b/designer-base/src/com/fr/file/FILEChooserPane.java index 3d350c27d..975459653 100644 --- a/designer-base/src/com/fr/file/FILEChooserPane.java +++ b/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.StringUtils; import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.WorkContext; import javax.swing.*; import javax.swing.event.ListSelectionEvent; @@ -548,7 +549,7 @@ public class FILEChooserPane extends BasicPane { String[] fileSuffix_local = LocalFileNodes.FILE_TYPE; EnumSet fileExtensions = EnumSet.of(FileExtension.CPT, FileExtension.CPTX, FileExtension.FRM, FileExtension.FRMX, FileExtension.CHT); 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"}))); } else { 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 - if (FRContext.getFileNodes().isSupportLocalFileOperate()) { //本地连接 + if (WorkContext.getCurrent().isLocal()) { //本地连接 this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLS, Inter.getLocText("Import-Excel_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) { defaultComboBoxModel.addElement(aFilterList); } - if (FRContext.getFileNodes().isSupportLocalFileOperate()) { //本地连接 + if (WorkContext.getCurrent().isLocal()) { //本地连接 if (!showWebReport) { defaultComboBoxModel.addElement(Inter.getLocText("FR-Utils-App_AllFiles") + "(*.*)"); }