Browse Source

Merge pull request #1663 in BA/design from ~RINOUX/design:feature/10.0 to feature/10.0

* commit '60771b1b19031511558ff9e7d7e0a6439ef8e7ca':
  DEC-156 资源文件调用接口调整
  DEC-156 资源文件调用接口调整
master
superman 7 years ago
parent
commit
b547dd459d
  1. 3
      designer/src/com/fr/design/module/DesignerModule.java
  2. 10
      designer_base/src/com/fr/design/file/TemplateTreePane.java
  3. 10
      designer_base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  4. 76
      designer_base/src/com/fr/env/RemoteEnv.java

3
designer/src/com/fr/design/module/DesignerModule.java

@ -53,6 +53,7 @@ import com.fr.general.ModuleContext;
import com.fr.general.xml.GeneralXMLTools; import com.fr.general.xml.GeneralXMLTools;
import com.fr.io.importer.Excel2007ReportImporter; import com.fr.io.importer.Excel2007ReportImporter;
import com.fr.io.importer.ExcelReportImporter; import com.fr.io.importer.ExcelReportImporter;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.quickeditor.cellquick.CellBiasTextPainterEditor; import com.fr.quickeditor.cellquick.CellBiasTextPainterEditor;
import com.fr.quickeditor.cellquick.CellDSColumnEditor; import com.fr.quickeditor.cellquick.CellDSColumnEditor;
@ -348,7 +349,7 @@ public class DesignerModule extends DesignModule {
namestyle.clear(); namestyle.clear();
String checkStr = StringUtils.EMPTY; String checkStr = StringUtils.EMPTY;
try { try {
checkStr = IOUtils.inputStream2String(file.asInputStream()); checkStr = ResourceIOUtils.inputStream2String(file.asInputStream());
tpl.readStream(file.asInputStream()); tpl.readStream(file.asInputStream());
} catch (Exception exp) { } catch (Exception exp) {
String errorMessage = StringUtils.EMPTY; String errorMessage = StringUtils.EMPTY;

10
designer_base/src/com/fr/design/file/TemplateTreePane.java

@ -26,7 +26,11 @@ import com.sun.jna.platform.FileUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -139,7 +143,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
public void openContainerFolder() { public void openContainerFolder() {
FileNode fn = TemplateTreePane.this.reportletsTree.getSelectedFileNode(); FileNode fn = TemplateTreePane.this.reportletsTree.getSelectedFileNode();
LocalEnv localEnv = (LocalEnv) FRContext.getCurrentEnv(); LocalEnv localEnv = (LocalEnv) FRContext.getCurrentEnv();
String filePath = StableUtils.pathJoin(new String[]{localEnv.path, fn.getEnvPath()}); String filePath = StableUtils.pathJoin(localEnv.path, fn.getEnvPath());
filePath = filePath.substring(0, filePath.lastIndexOf(CoreConstants.SEPARATOR)); filePath = filePath.substring(0, filePath.lastIndexOf(CoreConstants.SEPARATOR));
try { try {
Desktop.getDesktop().open(new File(filePath)); Desktop.getDesktop().open(new File(filePath));
@ -315,6 +319,8 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (fileUtils.hasTrash()) { if (fileUtils.hasTrash()) {
try { try {
fileUtils.moveToTrash(new File[]{new File(StableUtils.pathJoin(nodeFile.getEnvPath(), nodeFile.getPath()))}); fileUtils.moveToTrash(new File[]{new File(StableUtils.pathJoin(nodeFile.getEnvPath(), nodeFile.getPath()))});
//todo 走下这个流程,否则集群下其它节点无法同步删除
//FRContext.getCurrentEnv().deleteFile(nodeFile.getPath());
} catch (IOException e) { } catch (IOException e) {
FRLogger.getLogger().info(e.getMessage()); FRLogger.getLogger().info(e.getMessage());
FRContext.getCurrentEnv().deleteFile(nodeFile.getPath()); FRContext.getCurrentEnv().deleteFile(nodeFile.getPath());

10
designer_base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -28,6 +28,7 @@ import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
@ -382,8 +383,8 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
return; return;
} }
final FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(new String[]{ProjectConstants.REPORTLETS_NAME, reportPath}), false)); final FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath), false));
final String path = StableUtils.pathJoin(new String[]{nodeFile.getEnvPath(), nodeFile.getPath()}); final String path = nodeFile.getPath();
oldName = nodeFile.getName(); oldName = nodeFile.getName();
suffix = oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length()); suffix = oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, ""); oldName = oldName.replaceAll(suffix, "");
@ -476,8 +477,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
String newPath = path.replace(nodeFile.getName(), userInput + suffix); String newPath = path.replace(nodeFile.getName(), userInput + suffix);
renameTemplateInMemory(nodeFile, userInput + suffix, oldName + suffix); renameTemplateInMemory(nodeFile, userInput + suffix, oldName + suffix);
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldPath, newPath.replaceAll("/", "\\\\")); DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldPath, newPath.replaceAll("/", "\\\\"));
File newFile = new File(newPath);
new File(path).renameTo(newFile); //模版重命名
ResourceIOUtils.renameTo(path, newPath);
selectedOperation.refresh(); selectedOperation.refresh();
DesignerContext.getDesignerFrame().setTitle(); DesignerContext.getDesignerFrame().setTitle();
jd.dispose(); jd.dispose();

76
designer_base/src/com/fr/env/RemoteEnv.java vendored

@ -31,6 +31,7 @@ import com.fr.file.DatasourceManagerProvider;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.*; import com.fr.general.*;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
@ -39,6 +40,7 @@ import com.fr.regist.License;
import com.fr.share.ShareConstants; import com.fr.share.ShareConstants;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.Filter;
import com.fr.stable.JavaCompileInfo; import com.fr.stable.JavaCompileInfo;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -1481,16 +1483,11 @@ public class RemoteEnv extends AbstractEnv {
* @param path 制定路径,是基于报表目录下resource文件夹路径 * @param path 制定路径,是基于报表目录下resource文件夹路径
* @return 读到的文件 * @return 读到的文件
*/ */
public File[] readPathSvgFiles(String path) { public String[] readPathSvgFiles(String path) {
String cataloguePath = StableUtils.pathJoin(new String[]{CacheManager.getProviderInstance().getCacheDirectory().getPath(), SvgProvider.SERVER, path}); String cataloguePath = StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getPath(), SvgProvider.SERVER, path);
//检查缓存文件保存的目录下serversvgs文件夹是否存在 ,先用来暂存服务器读过来的svg文件
File catalogue = new File(cataloguePath);
if (!catalogue.exists()) {
catalogue.mkdirs();
}
ArrayList<File> fileArray = new ArrayList<>(); ArrayList<String> fileArray = new ArrayList<>();
try { try {
HashMap<String, String> para = new HashMap<String, String>(); HashMap<String, String> para = new HashMap<String, String>();
para.put("op", "fr_remote_design"); para.put("op", "fr_remote_design");
@ -1506,17 +1503,17 @@ public class RemoteEnv extends AbstractEnv {
JSONObject jsonObject = (JSONObject) ja.get(i); JSONObject jsonObject = (JSONObject) ja.get(i);
String svgFileName = (String) jsonObject.get("svgfileName"); String svgFileName = (String) jsonObject.get("svgfileName");
String svgfileContent = (String) jsonObject.get("svgfileContent"); String svgfileContent = (String) jsonObject.get("svgfileContent");
File file = new File(StableUtils.pathJoin(new String[]{cataloguePath, svgFileName}));
String file = StableUtils.pathJoin(cataloguePath, svgFileName);
InputStream in = new ByteArrayInputStream(svgfileContent.getBytes(EncodeConstants.ENCODING_UTF_8)); InputStream in = new ByteArrayInputStream(svgfileContent.getBytes(EncodeConstants.ENCODING_UTF_8));
FileOutputStream out = new FileOutputStream(file); ResourceIOUtils.write(file, in);
IOUtils.copyBinaryTo(in, out);
fileArray.add(file); fileArray.add(file);
} }
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage()); FRContext.getLogger().error(e.getMessage());
} }
return fileArray.toArray(new File[fileArray.size()]); return fileArray.toArray(new String[fileArray.size()]);
} }
@ -2098,14 +2095,12 @@ public class RemoteEnv extends AbstractEnv {
public void pluginServiceStart(String serviceID){ public void pluginServiceStart(String serviceID){
} }
@Override @Override
public File[] loadREUFile() throws Exception { public String[] loadREUFile() throws Exception {
File target = new File(CacheManager.getProviderInstance().getCacheDirectory(), ResourceIOUtils.delete(StableUtils.pathJoin(
ShareConstants.DIR_SHARE_CACHE); CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath(),
StableUtils.deleteFile(target); ShareConstants.DIR_SHARE_CACHE));
StableUtils.mkdirs(target);
File cacheDir = null; String zipFilePath = null;
File zip = null;
OutputStream out = null;
try { try {
HashMap<String, String> para = new HashMap<String, String>(); HashMap<String, String> para = new HashMap<String, String>();
para.put("op", "fr_remote_design"); para.put("op", "fr_remote_design");
@ -2114,34 +2109,35 @@ public class RemoteEnv extends AbstractEnv {
para.put("currentUsername", this.getUser()); para.put("currentUsername", this.getUser());
HttpClient client = createHttpMethod(para); HttpClient client = createHttpMethod(para);
InputStream input = client.getResponseStream();//拿到服务端传过来的整个共享文件夹的压缩文件的文件流 //拿到服务端传过来的整个共享文件夹的压缩文件的文件流
zip = new File(StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath()), "share.zip"); InputStream input = client.getResponseStream();
cacheDir = new File(StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath()), ShareConstants.DIR_SHARE_CACHE);
StableUtils.deleteFile(cacheDir); zipFilePath = StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath(), "share.zip");
StableUtils.mkdirs(cacheDir); String cacheDir = StableUtils.pathJoin(CacheManager.getProviderInstance().getCacheDirectory().getAbsolutePath(), ShareConstants.DIR_SHARE_CACHE);
StableUtils.makesureFileExist(zip);
out = new FileOutputStream(zip); ResourceIOUtils.write(zipFilePath, input);
IOUtils.copyBinaryTo(input, out);//放到本地缓存目录下 ResourceIOUtils.unzip(zipFilePath, cacheDir, EncodeConstants.ENCODING_GBK);
IOUtils.unzip(zip, cacheDir.getAbsolutePath(), EncodeConstants.ENCODING_GBK);//先解压到临时目录 List<String> files = ResourceIOUtils.listWithFullPath(cacheDir, new Filter<String>() {
if (cacheDir.exists() && cacheDir.isDirectory()) { @Override
return cacheDir.listFiles(new FilenameFilter() { public boolean accept(String s) {
public boolean accept(File file, String s) { return s.endsWith(ProjectConstants.REU);
return s.endsWith("reu");
} }
}); });
}
return files.toArray(new String[files.size()]);
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage()); FRContext.getLogger().error(e.getMessage());
} finally { } finally {
if (out != null) {
out.flush(); if (zipFilePath != null) {
out.close(); ResourceIOUtils.delete(zipFilePath);
} }
StableUtils.deleteFile(zip);
} }
return new File[0];
return new String[0];
} }
@Override @Override

Loading…
Cancel
Save