Browse Source

Merge pull request #114 in DESIGN/design from ~RICHIE/design:feature/10.0 to feature/10.0

* commit '1cc349fb27fc3ec3f907aac70553f902c5d742ca':
  无JIRA任务 去掉env中大部分无用的接口,并用Operator中的方法替代(部分)
master
superman 6 years ago
parent
commit
daf1ad952b
  1. 26
      designer-base/src/com/fr/design/actions/file/LocalePane.java
  2. 31
      designer-base/src/com/fr/design/file/TemplateTreePane.java
  3. 14
      designer-base/src/com/fr/design/formula/JavaEditorPane.java
  4. 25
      designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java
  5. 2
      designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  6. 81
      designer-base/src/com/fr/env/RemoteEnv.java
  7. 37
      designer-base/src/com/fr/file/FileNodeFILE.java
  8. 16
      designer-chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java
  9. 8
      designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java
  10. 4
      designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java

26
designer-base/src/com/fr/design/actions/file/LocalePane.java

@ -15,6 +15,7 @@ import com.fr.general.GeneralUtils;
import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils;
import com.fr.stable.bridge.StableFactory;
import com.fr.stable.project.ProjectConstants;
@ -24,6 +25,7 @@ import javax.swing.event.DocumentListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableRowSorter;
import java.awt.*;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
@ -183,7 +185,7 @@ public class LocalePane extends BasicPane {
if (env == null) {
return;
}
FileNode[] fileNodes = env.listFile(ProjectConstants.LOCALE_NAME);
FileNode[] fileNodes = env.getFileOperator().list(ProjectConstants.LOCALE_NAME);
if (ArrayUtils.getLength(fileNodes) == 0) {
return;
}
@ -194,7 +196,7 @@ public class LocalePane extends BasicPane {
for (FileNode fileNode : fileNodes) {
String fileName = fileNode.getName();
if (fileName.endsWith(".properties")) {
InputStream in = env.readBean(fileName, ProjectConstants.LOCALE_NAME);
InputStream in = new ByteArrayInputStream(env.getFileOperator().read(StableUtils.pathJoin(ProjectConstants.LOCALE_NAME, fileName)));
Properties properties = new Properties();
properties.load(in);
keys.addAll(properties.stringPropertyNames());
@ -234,16 +236,16 @@ public class LocalePane extends BasicPane {
properties.setProperty(GeneralUtils.objectToString(customTableModel.getValueAt(j, 0)), GeneralUtils.objectToString(customTableModel.getValueAt(j, i)));
}
OutputStream out = null;
try {
out = env.writeBean(PREFIX + fileName + ".properties", ProjectConstants.LOCALE_NAME);
properties.store(out, null);
out.flush();
out.close();
} catch (Exception e) {
FineLoggerFactory.getLogger().info(e.getMessage());
}
// OutputStream out = null;
// try {
// out = env.writeBean(PREFIX + fileName + ".properties", ProjectConstants.LOCALE_NAME);
// properties.store(out, null);
//
// out.flush();
// out.close();
// } catch (Exception e) {
// FineLoggerFactory.getLogger().info(e.getMessage());
// }
}
}

31
designer-base/src/com/fr/design/file/TemplateTreePane.java

@ -4,13 +4,13 @@
package com.fr.design.file;
import com.fr.base.FRContext;
import com.fr.base.io.FileAssistUtils;
import com.fr.dav.LocalEnv;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.env.RemoteEnv;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.file.filetree.IOFileNodeFilter;
@ -21,7 +21,6 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.sun.jna.platform.FileUtils;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
@ -32,7 +31,6 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
public class TemplateTreePane extends JPanel implements FileOperations {
@ -181,8 +179,8 @@ public class TemplateTreePane extends JPanel implements FileOperations {
break;
}
if (nodeFile.exists()) {
String path = StableUtils.pathJoin(new String[]{nodeFile.getEnvPath(), nodeFile.getPath()});
moveToTrash(nodeFile);
String path = StableUtils.pathJoin(nodeFile.getEnvPath(), nodeFile.getPath());
FileAssistUtils.moveToTrash(path);
deleteHistory(path.replaceAll("/", "\\\\"));
} else {
JOptionPane.showMessageDialog(this, Inter.getLocText("Warning-Template_Do_Not_Exsit"), ProductConstants.PRODUCT_NAME,
@ -282,27 +280,4 @@ public class TemplateTreePane extends JPanel implements FileOperations {
}
}
}
/**
* 文件回收
*
* @param nodeFile 节点文件
*/
private void moveToTrash(FileNodeFILE nodeFile) {
FileUtils fileUtils = FileUtils.getInstance();
if (fileUtils.hasTrash()) {
try {
fileUtils.moveToTrash(new File[]{new File(StableUtils.pathJoin(nodeFile.getEnvPath(), nodeFile.getPath()))});
//todo 走下这个流程,否则集群下其它节点无法同步删除
FRContext.getCurrentEnv().deleteFile(nodeFile.getPath());
} catch (IOException e) {
FineLoggerFactory.getLogger().info(e.getMessage());
FRContext.getCurrentEnv().deleteFile(nodeFile.getPath());
}
} else {
FineLoggerFactory.getLogger().info("No Trash Available");
FRContext.getCurrentEnv().deleteFile(nodeFile.getPath());
}
}
}

14
designer-base/src/com/fr/design/formula/JavaEditorPane.java

@ -9,8 +9,8 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EncodeConstants;
import com.fr.stable.JavaCompileInfo;
import com.fr.stable.StableUtils;
@ -21,7 +21,9 @@ import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.concurrent.ExecutionException;
@ -111,7 +113,7 @@ public class JavaEditorPane extends BasicPane {
private InputStream getJavaSourceInputStream() {
String javaPath = getJavaPath();
try {
return FRContext.getCurrentEnv().readBean(javaPath, ProjectConstants.CLASSES_NAME);
return new ByteArrayInputStream(FRContext.getCurrentEnv().getFileOperator().read(StableUtils.pathJoin(ProjectConstants.CLASSES_NAME, javaPath)));
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
@ -154,11 +156,7 @@ public class JavaEditorPane extends BasicPane {
return;
}
try {
OutputStream out = FRContext.getCurrentEnv().writeBean(getJavaPath(), ProjectConstants.CLASSES_NAME);
Writer writer = new BufferedWriter(new OutputStreamWriter(out, EncodeConstants.ENCODING_UTF_8));
writer.write(text);
writer.flush();
writer.close();
FRContext.getCurrentEnv().getFileOperator().write(text.getBytes(EncodeConstants.ENCODING_UTF_8), ProjectConstants.CLASSES_NAME, getJavaPath());
JOptionPane.showMessageDialog(null, Inter.getLocText(new String[]{"Save", "Successfully"}) + "!");
fireSaveActionListener();
} catch (Exception e) {

25
designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java

@ -1,19 +1,9 @@
package com.fr.design.gui.itree.filetree;
import java.awt.*;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.gui.itree.refreshabletree.RefreshableJTree;
import com.fr.file.filetree.FileNode;
@ -23,6 +13,15 @@ import com.fr.general.Inter;
import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import javax.swing.*;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
/*
* 文件结构树.
*/
@ -192,7 +191,7 @@ public class EnvFileTree extends RefreshableJTree {
FileNode[] res_fns = null;
try {
res_fns = env == null ? new FileNode[0] : env.listFile(filePath);
res_fns = env == null ? new FileNode[0] : env.getFileOperator().list(filePath);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}

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

@ -104,7 +104,7 @@ public class TemplateFileTree extends EnvFileTree {
}
public FileNode[] listFile(String path) throws Exception {
return FRContext.getCurrentEnv().getFileOperator().list("reportlets", path);
return FRContext.getCurrentEnv().getFileOperator().list(path);
}
/*

81
designer-base/src/com/fr/env/RemoteEnv.java vendored

@ -315,16 +315,6 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
* @throws Exception e
*/
/**
* 返回描述该运行环境的名字
*
* @return 描述环境名字的字符串
*/
@Override
public String getEnvDescription() {
return Inter.getLocText("Env-Remote_Server");
}
public class Bytes2ServerOutputStream extends OutputStream {
private ByteArrayOutputStream out = new ByteArrayOutputStream();
private HashMap<String, String> nameValuePairs;
@ -690,26 +680,6 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
return true;
}
/**
* 读取文件
*
* @param beanPath 文件名
* @param prefix 当前Env下得工程分类如reportletslib等
* @return InputStream 输入流
*/
@Override
public InputStream readBean(String beanPath, String prefix)
throws Exception {
refreshHttpSProperty();
HashMap<String, String> para = new HashMap<>();
para.put("op", "fs_remote_design");
para.put("cmd", "design_open");
para.put(RemoteDeziConstants.PREFXI, prefix);
para.put("resource", beanPath);
return filterInputStream(RemoteEnvUtils.simulateRPCByHttpGet(para, false, this));
}
/**
* 写文件
*
@ -783,25 +753,6 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
}
/**
* 输出日志信息
*
* @throws Exception e
*/
@Override
public void printLogMessage() throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
HashMap<String, String> para = new HashMap<>();
para.put("op", "fr_remote_design");
para.put("cmd", "get_log_message");
InputStream input = postBytes2ServerB(out.toByteArray(), para);
if (input == null) {
return;
}
LogRecordTime[] records = LogUtils.readXMLLogRecords(input);
}
@Override
public String[] getSupportedTypes() {
return FILE_TYPE;
@ -839,12 +790,6 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
}
@Override
public InputStream getDataSourceInputStream(String filePath) throws Exception {
return readBean(filePath, "datasource");
}
@Override
public ArrayList getAllRole4Privilege(boolean isFS) {
refreshHttpSProperty();
@ -910,32 +855,6 @@ public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAut
return info;
}
@Override
public String pluginServiceAction(String serviceID, String req) throws Exception {
refreshHttpSProperty();
HashMap<String, String> para = new HashMap<>();
para.put("op", "fr_remote_design");
para.put("cmd", "design_get_plugin_service_data");
para.put("serviceID", serviceID);
para.put("req", req);
//jim :加上user,远程设计点击预览时传递用户角色信息
InputStream inputStream = filterInputStream(
RemoteEnvUtils.simulateRPCByHttpPost(para, false, this)
);
return IOUtils.inputStream2String(inputStream);
}
/**
* 远程不启动使用虚拟服务
* <p>
*
* @param serviceID serviceID
*/
@Override
public void pluginServiceStart(String serviceID) {
}
@Override
public String[] loadREUFile() {
refreshHttpSProperty();

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

@ -8,12 +8,14 @@ import com.fr.design.gui.itree.filetree.FileTreeIcon;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
@ -166,7 +168,7 @@ public class FileNodeFILE implements FILE {
return res_array;
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return new FILE[0];
}
}
@ -178,18 +180,10 @@ public class FileNodeFILE implements FILE {
* @return 返回文件节点
*/
private FileNode[] listFile(String rootFilePath) {
if (ComparatorUtils.equals(envPath, FRContext.getCurrentEnv().getWebReportPath())) {
try {
return FRContext.getCurrentEnv().listReportPathFile(rootFilePath);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
} else {
try {
return FRContext.getCurrentEnv().listFile(rootFilePath);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
try {
return FRContext.getCurrentEnv().getFileOperator().list(rootFilePath);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return new FileNode[0];
}
@ -206,11 +200,9 @@ public class FileNodeFILE implements FILE {
}
try {
return FRContext.getCurrentEnv().createFolder(StableUtils.pathJoin(new String[]{
node.getEnvPath(), name
}));
return FRContext.getCurrentEnv().getFileOperator().createFolder(StableUtils.pathJoin(node.getEnvPath(), name));
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
}
}
@ -248,7 +240,7 @@ public class FileNodeFILE implements FILE {
}
try {
return FRContext.getCurrentEnv().fileExists(node.getEnvPath());
return FRContext.getCurrentEnv().getFileOperator().isExists(node.getEnvPath());
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
return false;
@ -275,9 +267,9 @@ public class FileNodeFILE implements FILE {
}
try {
return FRContext.getCurrentEnv().createFile(node.getEnvPath());
return FRContext.getCurrentEnv().getFileOperator().createFile(node.getEnvPath());
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
}
}
@ -299,10 +291,7 @@ public class FileNodeFILE implements FILE {
return null;
}
InputStream in = FRContext.getCurrentEnv().readBean(
envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1),
ProjectConstants.REPORTLETS_NAME
);
InputStream in = new ByteArrayInputStream(FRContext.getCurrentEnv().getFileOperator().read(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1))));
return envPath.endsWith(".cpt") || envPath.endsWith(".frm")
? XMLEncryptUtils.decodeInputStream(in) : in;

16
designer-chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java

@ -340,13 +340,13 @@ public class MapGroupExtensionPane extends BasicPane implements UIObserver {
return;
}
try{//提醒名字已存在
if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin(
new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),newName+SvgProvider.EXTENSION}))){
if(FRContext.getCurrentEnv().getFileOperator().isExists(StableUtils.pathJoin(
MapSvgXMLHelper.relativeDefaultMapPath(),newName+SvgProvider.EXTENSION))){
showRenameWaring(newName);
return;
}
if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin(
new String[]{MapSvgXMLHelper.relativeCustomMapPath(), newName + SvgProvider.EXTENSION}))){
if(FRContext.getCurrentEnv().getFileOperator().isExists(StableUtils.pathJoin(
MapSvgXMLHelper.relativeCustomMapPath(), newName + SvgProvider.EXTENSION))){
showRenameWaring(newName);
return;
}
@ -361,10 +361,10 @@ public class MapGroupExtensionPane extends BasicPane implements UIObserver {
groupExtensionPane.setValueAtCurrentSelectIndex(newName);
fireStateChange();
saveMapInfo(newName);
FRContext.getCurrentEnv().deleteFile(
StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),oldName+SvgProvider.EXTENSION}));
FRContext.getCurrentEnv().deleteFile(
StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeCustomMapPath(),oldName+SvgProvider.EXTENSION}));
FRContext.getCurrentEnv().getFileOperator().delete(
StableUtils.pathJoin(MapSvgXMLHelper.relativeDefaultMapPath(),oldName+SvgProvider.EXTENSION));
FRContext.getCurrentEnv().getFileOperator().delete(
StableUtils.pathJoin(MapSvgXMLHelper.relativeCustomMapPath(),oldName+SvgProvider.EXTENSION));
refresh();
}catch (Exception exp){
FineLoggerFactory.getLogger().error(exp.getMessage());

8
designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java

@ -12,13 +12,15 @@ import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.general.Inter;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -149,7 +151,7 @@ public class FileSearchManager implements AlphaFineSearchProvider {
*/
private void searchFileContent(Env env, String searchText, FileNode node, boolean isAlreadyContain, boolean needMore) {
try {
InputStream inputStream = env.readBean(node.getEnvPath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1), ProjectConstants.REPORTLETS_NAME);
InputStream inputStream = new ByteArrayInputStream(env.getFileOperator().read(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, node.getEnvPath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1))));
InputStreamReader isr = new InputStreamReader(inputStream, "UTF-8");
BufferedReader reader = new BufferedReader(isr);
String line;
@ -232,7 +234,7 @@ public class FileSearchManager implements AlphaFineSearchProvider {
* @throws Exception
*/
private void listAll(Env env, String rootFilePath, List<FileNode> nodeList, boolean recurse) throws Exception {
FileNode[] fns = env.listFile(rootFilePath);
FileNode[] fns = env.getFileOperator().list(rootFilePath);
for (int i = 0; i < fns.length; i++) {
FileNode fileNode = fns[i];
if (fileNode.isDirectory()) {

4
designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java

@ -8,6 +8,7 @@ import com.fr.design.DesignerEnvManager;
import com.fr.general.FRLogManager;
import com.fr.general.Inter;
import com.fr.general.LogDuration;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.stable.xml.XMLPrintWriter;
@ -18,6 +19,7 @@ import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.web.core.SessionDealWith;
import com.fr.web.core.SessionIDInfor;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
/**
@ -132,7 +134,7 @@ public class ErrorInfoLogAppender extends AppenderSkeleton {
}
};
try {
file.readStream(FRContext.getCurrentEnv().readBean(bookPath, ProjectConstants.REPORTLETS_NAME));
file.readStream(new ByteArrayInputStream(FRContext.getCurrentEnv().getFileOperator().read(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, bookPath))));
return file.getTemplateID();
} catch (Exception ignore) {
}

Loading…
Cancel
Save