Browse Source

Merge pull request #140 in DESIGN/design from ~JU/design:feature/10.0 to feature/10.0

* commit 'f6048da455029ed36c338e5882a53c2de9ad20e6':
  REPORT-8881 com.fr.file.FileNodeFILE#listFiles有问题
master
ju 7 years ago
parent
commit
b44fd56c70
  1. 4
      designer-base/src/com/fr/design/extra/WebViewDlgHelper.java
  2. 2
      designer-base/src/com/fr/file/FILEChooserPane.java
  3. 4
      designer-base/src/com/fr/file/FILEFactory.java
  4. 38
      designer-base/src/com/fr/file/FileNodeFILE.java

4
designer-base/src/com/fr/design/extra/WebViewDlgHelper.java

@ -44,7 +44,7 @@ public class WebViewDlgHelper {
private static final String LATEST = "latest";
private static final String SHOP_SCRIPTS = "shop_scripts";
private static final int VERSION_8 = 8;
private static String installHome = FRContext.getCommonOperator().getWebReportPath();
private static String installHome = FRContext.getCommonOperator().getWebRootPath();
private static final String MAIN_JS_PATH = "/scripts/plugin.html";
private static final String ENV_VERSION = "ENV_VERSION";
@ -52,7 +52,7 @@ public class WebViewDlgHelper {
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@Override
public void envChanged() {
installHome = FRContext.getCommonOperator().getWebReportPath();
installHome = FRContext.getCommonOperator().getWebRootPath();
}
});
}

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

@ -787,7 +787,7 @@ public class FILEChooserPane extends BasicPane {
if (FILEChooserPane.this.showWebReport) {
// webReportFILE = new FileFILE(new
// File(FRContext.getCommonOperator().getWebReportPath()));
webReportFILE = new FileNodeFILE(FRContext.getCommonOperator().getWebReportPath());
webReportFILE = new FileNodeFILE(FRContext.getCommonOperator().getWebRootPath());
// String webReportPath =
// FRContext.getCommonOperator().getWebReportPath();
// String webReportParentPath = new

4
designer-base/src/com/fr/file/FILEFactory.java

@ -31,7 +31,7 @@ public class FILEFactory {
return new FileNodeFILE(new FileNode(path.substring(envPath.length() + 1), false));
} else if (path.startsWith(WEBREPORT_PREFIX)) {
return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), false),
FRContext.getCommonOperator().getWebReportPath());
FRContext.getCommonOperator().getWebRootPath());
} else if (path.startsWith(FILE_PREFIX)) {
return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length())));
} else {
@ -48,7 +48,7 @@ public class FILEFactory {
return new FileNodeFILE(new FileNode(path.substring(ENV_PREFIX.length()), true));
} else if (path.startsWith(WEBREPORT_PREFIX)) {
return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), true),
FRContext.getCommonOperator().getWebReportPath());
FRContext.getCommonOperator().getWebRootPath());
} else if (path.startsWith(FILE_PREFIX)) {
return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length())));
} else {

38
designer-base/src/com/fr/file/FileNodeFILE.java

@ -22,10 +22,12 @@ import java.io.OutputStream;
public class FileNodeFILE implements FILE {
private FileNode node;
// carl:记录下FILE对应的运行环境,每次创建都设置下当前的运行环境
private String envPath;
public FileNodeFILE(FileNodeFILE parent, String name, boolean isDir) {
FileNode fn = parent.node;
String parentDir;
if (fn.isDirectory()) {
@ -39,16 +41,19 @@ public class FileNodeFILE implements FILE {
}
public FileNodeFILE(FileNode node) {
this.node = node;
this.envPath = WorkContext.getCurrent().getPath();
}
public FileNodeFILE(String envPath) {
this.node = null;
this.envPath = envPath;
}
public FileNodeFILE(FileNode node, String envPath) {
this.node = node;
this.envPath = envPath;
}
@ -59,7 +64,8 @@ public class FileNodeFILE implements FILE {
* @return 返回后缀
*/
public String prefix() {
if (ComparatorUtils.equals(getEnvPath(), FRContext.getCommonOperator().getWebReportPath())) {
if (ComparatorUtils.equals(getEnvPath(), FRContext.getCommonOperator().getWebRootPath())) {
return FILEFactory.WEBREPORT_PREFIX;
}
return FILEFactory.ENV_PREFIX;
@ -69,6 +75,7 @@ public class FileNodeFILE implements FILE {
* @return
*/
public String getEnvPath() {
return this.envPath;
}
@ -78,6 +85,7 @@ public class FileNodeFILE implements FILE {
* @return 是则返回true
*/
public boolean isDirectory() {
return ComparatorUtils.equals(node, null) ? true : node.isDirectory();
}
@ -85,6 +93,7 @@ public class FileNodeFILE implements FILE {
* @return
*/
public String getName() {
if (node == null) {
return null;
}
@ -100,6 +109,7 @@ public class FileNodeFILE implements FILE {
* @return
*/
public Icon getIcon() {
if (node == null) {
return null;
}
@ -115,6 +125,7 @@ public class FileNodeFILE implements FILE {
* @return
*/
public String getPath() {
if (node == null) {
return "";
}
@ -126,6 +137,7 @@ public class FileNodeFILE implements FILE {
* @param path
*/
public void setPath(String path) {
node.setEnvPath(path);
}
@ -133,6 +145,7 @@ public class FileNodeFILE implements FILE {
* @return
*/
public FILE getParent() {
if (node == null) {
return null;
}
@ -146,6 +159,7 @@ public class FileNodeFILE implements FILE {
* @return 文件组
*/
public FILE[] listFiles() {
if (ComparatorUtils.equals(node, null)) {
node = new FileNode(CoreConstants.SEPARATOR, true);
//return new FILE[0];
@ -178,10 +192,16 @@ public class FileNodeFILE implements FILE {
* @return 返回文件节点
*/
private FileNode[] listFile(String rootFilePath) {
try {
if (ComparatorUtils.equals(envPath, FRContext.getCommonOperator().getWebRootPath())) {
return FRContext.getFileNodes().listWebRootFile(rootFilePath);
} else {
return FRContext.getFileNodes().list(rootFilePath);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FRContext.getLogger().error(e.getMessage(), e);
}
return new FileNode[0];
}
@ -193,6 +213,7 @@ public class FileNodeFILE implements FILE {
* @return 创建成功返回true
*/
public boolean createFolder(String name) {
if (ComparatorUtils.equals(node, null) || !node.isDirectory()) {
return false;
}
@ -211,6 +232,7 @@ public class FileNodeFILE implements FILE {
* @return 文件被锁返回true
*/
public boolean isLocked() {
if (node == null) {
return false;
}
@ -229,6 +251,7 @@ public class FileNodeFILE implements FILE {
* @return 文件存在返回 true
*/
public boolean exists() {
if (node == null) {
return false;
}
@ -251,6 +274,7 @@ public class FileNodeFILE implements FILE {
* @return 是报表当前环境返回true
*/
public boolean isCurrentEnv() {
return ComparatorUtils.equals(WorkContext.getCurrent().getPath(), envPath);
}
@ -260,6 +284,7 @@ public class FileNodeFILE implements FILE {
* @return 成功返回true
*/
public boolean mkfile() {
if (node == null) {
return false;
}
@ -279,6 +304,7 @@ public class FileNodeFILE implements FILE {
* @throws Exception
*/
public InputStream asInputStream() throws Exception {
if (node == null) {
return null;
}
@ -302,6 +328,7 @@ public class FileNodeFILE implements FILE {
* @throws Exception
*/
public OutputStream asOutputStream() throws Exception {
if (ComparatorUtils.equals(node, null)) {
return null;
}
@ -323,6 +350,7 @@ public class FileNodeFILE implements FILE {
* @throws Exception
*/
public void closeTemplate() throws Exception {
if (node == null) {
return;
}
@ -343,6 +371,7 @@ public class FileNodeFILE implements FILE {
* @return
*/
public String getEnvFullName() {
return this.node.getEnvPath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1);
}
@ -352,6 +381,7 @@ public class FileNodeFILE implements FILE {
* @return 是则返回true
*/
public boolean isMemFile() {
return false;
}
@ -361,6 +391,7 @@ public class FileNodeFILE implements FILE {
* @return 是则返回true
*/
public boolean isEnvFile() {
return true;
}
@ -371,6 +402,7 @@ public class FileNodeFILE implements FILE {
* @return
*/
public boolean equals(Object obj) {
if (!(obj instanceof FileNodeFILE)) {
return false;
}
@ -384,6 +416,7 @@ public class FileNodeFILE implements FILE {
* @return 返回hash码
*/
public int hashCode() {
int hash = 5;
hash = 61 * hash + (this.node != null ? this.node.hashCode() : 0);
hash = 61 * hash + (this.envPath != null ? this.envPath.hashCode() : 0);
@ -396,6 +429,7 @@ public class FileNodeFILE implements FILE {
* @return String 字符串
*/
public String toString() {
return prefix() + (this.node != null ? this.node.getEnvPath() : "");
}
}
Loading…
Cancel
Save