From 1cc349fb27fc3ec3f907aac70553f902c5d742ca Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 8 Jun 2018 17:40:57 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20?= =?UTF-8?q?=E5=8E=BB=E6=8E=89env=E4=B8=AD=E5=A4=A7=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=97=A0=E7=94=A8=E7=9A=84=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E7=94=A8Operator=E4=B8=AD=E7=9A=84=E6=96=B9=E6=B3=95=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3=EF=BC=88=E9=83=A8=E5=88=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/file/LocalePane.java | 26 +++--- .../com/fr/design/file/TemplateTreePane.java | 31 +------ .../com/fr/design/formula/JavaEditorPane.java | 14 ++-- .../gui/itree/filetree/EnvFileTree.java | 25 +++--- .../gui/itree/filetree/TemplateFileTree.java | 2 +- designer-base/src/com/fr/env/RemoteEnv.java | 81 ------------------- .../src/com/fr/file/FileNodeFILE.java | 37 +++------ .../PlotSeries/MapGroupExtensionPane.java | 16 ++-- .../manager/impl/FileSearchManager.java | 8 +- .../errorinfo/ErrorInfoLogAppender.java | 4 +- 10 files changed, 65 insertions(+), 179 deletions(-) diff --git a/designer-base/src/com/fr/design/actions/file/LocalePane.java b/designer-base/src/com/fr/design/actions/file/LocalePane.java index a5017bf04..898f26370 100644 --- a/designer-base/src/com/fr/design/actions/file/LocalePane.java +++ b/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()); +// } } } diff --git a/designer-base/src/com/fr/design/file/TemplateTreePane.java b/designer-base/src/com/fr/design/file/TemplateTreePane.java index f2fb514f7..21cc6824a 100644 --- a/designer-base/src/com/fr/design/file/TemplateTreePane.java +++ b/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()); - } - } - } \ No newline at end of file diff --git a/designer-base/src/com/fr/design/formula/JavaEditorPane.java b/designer-base/src/com/fr/design/formula/JavaEditorPane.java index a5245d685..10195acbd 100644 --- a/designer-base/src/com/fr/design/formula/JavaEditorPane.java +++ b/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) { diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java index c9077b775..c7a6f4c82 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/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); } 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 32c95f672..0ee011e22 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 @@ -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); } /* diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index eae3d5714..2f6b872e4 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -315,16 +315,6 @@ public class RemoteEnv extends AbstractEnv 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 nameValuePairs; @@ -690,26 +680,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return true; } - /** - * 读取文件 - * - * @param beanPath 文件名 - * @param prefix 当前Env下得工程分类,如reportlets,lib等 - * @return InputStream 输入流 - */ - @Override - public InputStream readBean(String beanPath, String prefix) - throws Exception { - refreshHttpSProperty(); - HashMap 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 implements DesignAut } - /** - * 输出日志信息 - * - * @throws Exception e - */ - @Override - public void printLogMessage() throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - HashMap 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 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 implements DesignAut return info; } - - @Override - public String pluginServiceAction(String serviceID, String req) throws Exception { - refreshHttpSProperty(); - HashMap 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); - } - - /** - * 远程不启动,使用虚拟服务 - *

- * - * @param serviceID serviceID - */ - @Override - public void pluginServiceStart(String serviceID) { - } - @Override public String[] loadREUFile() { refreshHttpSProperty(); diff --git a/designer-base/src/com/fr/file/FileNodeFILE.java b/designer-base/src/com/fr/file/FileNodeFILE.java index 8aeca889b..9105b2041 100644 --- a/designer-base/src/com/fr/file/FileNodeFILE.java +++ b/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; diff --git a/designer-chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java b/designer-chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java index ed2ab0718..409131847 100644 --- a/designer-chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java +++ b/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()); diff --git a/designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java b/designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java index 33c592073..0df9529ca 100644 --- a/designer-realize/src/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java +++ b/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 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()) { diff --git a/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java b/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java index ef2c62730..66fb704d9 100644 --- a/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java +++ b/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) { } From 3c76cc3c04b0b27811c288c733e52b5b0a3bb09c Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 8 Jun 2018 21:23:51 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20?= =?UTF-8?q?=E5=8E=BB=E6=8E=89writeXMLFileManager=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../style/color/ColorSelectConfigManager.java | 12 ----- designer-base/src/com/fr/env/RemoteEnv.java | 47 +------------------ 2 files changed, 1 insertion(+), 58 deletions(-) diff --git a/designer-base/src/com/fr/design/style/color/ColorSelectConfigManager.java b/designer-base/src/com/fr/design/style/color/ColorSelectConfigManager.java index 80e1048b7..812160778 100644 --- a/designer-base/src/com/fr/design/style/color/ColorSelectConfigManager.java +++ b/designer-base/src/com/fr/design/style/color/ColorSelectConfigManager.java @@ -3,7 +3,6 @@ package com.fr.design.style.color; import com.fr.base.FRContext; import com.fr.file.XMLFileManager; import com.fr.general.ComparatorUtils; -import com.fr.log.FineLoggerFactory; import com.fr.general.GeneralContext; import com.fr.stable.EnvChangedListener; import com.fr.stable.xml.XMLPrintWriter; @@ -96,11 +95,6 @@ public class ColorSelectConfigManager extends XMLFileManager implements ColorSel if (colors != null && !colors.isEmpty()) { manager.setColorsToFile(colors); } - try { - FRContext.getCurrentEnv().writeResource(manager); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } } @@ -115,7 +109,6 @@ public class ColorSelectConfigManager extends XMLFileManager implements ColorSel ColorSelectConfigManager manager = new ColorSelectConfigManager(); XMLTools.readInputStreamXML(manager, input); configManager = manager; - FRContext.getCurrentEnv().writeResource(configManager); } @@ -131,11 +124,6 @@ public class ColorSelectConfigManager extends XMLFileManager implements ColorSel } return configManager; } - - - public boolean writeResource() throws Exception { - return FRContext.getCurrentEnv().writeResource(ColorSelectConfigManager.getProviderInstance()); - } public String fileName() { return "recentcolors.xml"; diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index 2f6b872e4..12bf84e3b 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -11,13 +11,13 @@ import com.fr.common.rpc.netty.MessageSendExecutor; import com.fr.common.rpc.netty.RemoteCallClient; import com.fr.core.env.EnvConstants; import com.fr.core.env.EnvContext; -import com.fr.design.env.RemoteEnvConfig; import com.fr.data.TableDataSource; import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.dav.AbstractEnv; import com.fr.dav.DavXMLUtils; import com.fr.design.DesignerEnvManager; +import com.fr.design.env.RemoteEnvConfig; import com.fr.design.mainframe.DesignerContext; import com.fr.file.CacheManager; import com.fr.file.ConnectionConfig; @@ -26,8 +26,6 @@ import com.fr.general.CommonIOUtils; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.general.Inter; -import com.fr.general.LogRecordTime; -import com.fr.general.LogUtils; import com.fr.general.http.HttpToolbox; import com.fr.io.utils.ResourceIOUtils; import com.fr.json.JSONArray; @@ -44,9 +42,7 @@ import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.SvgProvider; -import com.fr.stable.file.XMLFileManagerProvider; import com.fr.stable.project.ProjectConstants; -import com.fr.stable.xml.XMLTools; import com.fr.third.guava.base.Strings; import com.fr.third.guava.collect.ImmutableMap; import com.fr.web.ResourceConstants; @@ -639,47 +635,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return true; } - /** - * 写报表运行环境所需的配置文件 - * - * @param mgr 管理各个资源文件的管理器 - * @return 写入xml成功返回true - * @throws Exception 写入xml错误则抛出此异常 - */ - @Override - public boolean writeResource(XMLFileManagerProvider mgr) throws Exception { - testServerConnection(); - - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "design_save_resource"); - para.put("resource", mgr.fileName()); - para.put("class_name", mgr.getClass().getName()); - para.put("current_uid", this.getUserID()); - para.put("currentUsername", this.getUser()); - - // alex:通过ByteArrayOutputStream将mgr写成字节流 - Bytes2ServerOutputStream out = new Bytes2ServerOutputStream(para); - XMLTools.writeOutputStreamXML(mgr, out); - - try { - String res = stream2String( - filterInputStream( - RemoteEnvUtils.simulateRPCByHttpPost(out.getOut().toByteArray(), out.nameValuePairs, false, this) - ) - ); - if (StringUtils.isNotEmpty(res)) { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Already_exist") + res); - return false; - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - return false; - } - - return true; - } - /** * 写文件 * From 1888af55de60ced48624ba7d61357fa7505825a7 Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 8 Jun 2018 23:32:06 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20?= =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E4=B8=80=E6=B3=A2=E5=88=A0=E5=87=8F=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/file/HistoryTemplateListPane.java | 9 +- .../com/fr/design/file/TemplateTreePane.java | 6 +- .../com/fr/design/formula/JavaEditorPane.java | 2 +- .../gui/itree/filetree/TemplateFileTree.java | 5 +- .../com/fr/design/mainframe/JTemplate.java | 21 ++- .../design/roleAuthority/RoleDataWrapper.java | 2 +- designer-base/src/com/fr/env/RemoteEnv.java | 132 +----------------- .../src/com/fr/file/FILEChooserPane.java | 50 +++---- 8 files changed, 59 insertions(+), 168 deletions(-) diff --git a/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java index 92a27b760..daa851c66 100644 --- a/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -1,5 +1,6 @@ package com.fr.design.file; +import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.dav.LocalEnv; @@ -18,9 +19,11 @@ import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; +import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; +import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; import javax.swing.*; @@ -363,8 +366,10 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C */ public void openContainerFolder() { FileNode fileNode = new FileNode(((JTemplate) list.getSelectedValue()).getEditingFILE().getPath(), false); - LocalEnv localEnv = (LocalEnv) FRContext.getCurrentEnv(); - localEnv.openContainerFolder(fileNode); + Env env = FRContext.getCurrentEnv(); + if (env.isLocalEnv()) { + IOUtils.openWindowsFolder(StableUtils.pathJoin(env.getEnvConfig().getPath(), fileNode.getEnvPath())); + } } /** diff --git a/designer-base/src/com/fr/design/file/TemplateTreePane.java b/designer-base/src/com/fr/design/file/TemplateTreePane.java index 21cc6824a..afb2a006a 100644 --- a/designer-base/src/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/com/fr/design/file/TemplateTreePane.java @@ -3,6 +3,7 @@ */ package com.fr.design.file; +import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.base.io.FileAssistUtils; import com.fr.dav.LocalEnv; @@ -15,6 +16,7 @@ import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; import com.fr.file.filetree.IOFileNodeFilter; import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.log.FineLoggerFactory; import com.fr.stable.CoreConstants; @@ -139,13 +141,13 @@ public class TemplateTreePane extends JPanel implements FileOperations { */ public void openContainerFolder() { FileNode fn = TemplateTreePane.this.reportletsTree.getSelectedFileNode(); - LocalEnv localEnv = (LocalEnv) FRContext.getCurrentEnv(); + Env localEnv = FRContext.getCurrentEnv(); String filePath = StableUtils.pathJoin(localEnv.getPath(), fn.getEnvPath()); filePath = filePath.substring(0, filePath.lastIndexOf(CoreConstants.SEPARATOR)); try { Desktop.getDesktop().open(new File(filePath)); } catch (Exception e) { - localEnv.openContainerFolder(fn); + IOUtils.openWindowsFolder(StableUtils.pathJoin(localEnv.getEnvConfig().getPath(), fn.getEnvPath())); } } diff --git a/designer-base/src/com/fr/design/formula/JavaEditorPane.java b/designer-base/src/com/fr/design/formula/JavaEditorPane.java index 10195acbd..48d3b02d8 100644 --- a/designer-base/src/com/fr/design/formula/JavaEditorPane.java +++ b/designer-base/src/com/fr/design/formula/JavaEditorPane.java @@ -176,7 +176,7 @@ public class JavaEditorPane extends BasicPane { @Override protected JavaCompileInfo doInBackground() throws Exception { Env env = FRContext.getCurrentEnv(); - return env.compilerSourceCode(javaText.getText()); + return env.getCommonOperator().compile(javaText.getText()); } public void done() { 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 0ee011e22..31325dd0f 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 @@ -2,6 +2,7 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.Env; import com.fr.base.FRContext; +import com.fr.base.extension.FileExtension; import com.fr.base.operator.file.FileOperator; import com.fr.core.env.proxy.EnvProxy; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; @@ -104,7 +105,9 @@ public class TemplateFileTree extends EnvFileTree { } public FileNode[] listFile(String path) throws Exception { - return FRContext.getCurrentEnv().getFileOperator().list(path); + return FRContext.getCurrentEnv().getFileOperator().list( + path, + new FileExtension[]{FileExtension.CPT, FileExtension.FRM, FileExtension.CPTX, FileExtension.FRMX}); } /* diff --git a/designer-base/src/com/fr/design/mainframe/JTemplate.java b/designer-base/src/com/fr/design/mainframe/JTemplate.java index df970d1b3..f31fc7491 100644 --- a/designer-base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/com/fr/design/mainframe/JTemplate.java @@ -45,8 +45,8 @@ import com.fr.file.MemFILE; import com.fr.form.ui.NoneWidget; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; -import com.fr.log.FineLoggerFactory; import com.fr.general.Inter; +import com.fr.log.FineLoggerFactory; import com.fr.report.cell.Elem; import com.fr.report.cell.cellattr.CellImage; import com.fr.stable.ArrayUtils; @@ -539,7 +539,14 @@ public abstract class JTemplate> if (!editingFILE.exists()) { return saveAsTemplate(isShowLoc); } - if (!FRContext.getCurrentEnv().hasFileFolderAllow(this.getEditingFILE().getPath())) { + boolean access = false; + + try { + access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(this.getEditingFILE().getPath()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + if (!access) { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_No-Privilege") + "!", Inter.getLocText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE); return false; } @@ -579,18 +586,22 @@ public abstract class JTemplate> int chooseResult = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), this.suffix()); if (isCancelOperation(chooseResult)) { - fileChooser = null; return false; } if (isOkOperation(chooseResult)) { - if (!FRContext.getCurrentEnv().hasFileFolderAllow(fileChooser.getSelectedFILE().getPath()) ) { + boolean access = false; + try { + access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(fileChooser.getSelectedFILE().getPath()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + if (!access) { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_No-Privilege") + "!", Inter.getLocText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE); return false; } editingFILE = fileChooser.getSelectedFILE(); mkNewFile(editingFILE); - fileChooser = null; } return saveNewFile(editingFILE, oldName); diff --git a/designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java b/designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java index 5dc9c2aef..253f6d8c2 100644 --- a/designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java +++ b/designer-base/src/com/fr/design/roleAuthority/RoleDataWrapper.java @@ -1 +1 @@ -package com.fr.design.roleAuthority; import com.fr.base.FRContext; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.loader.ChildrenNodesLoader; import com.fr.general.Inter; import java.util.ArrayList; import java.util.List; /** * 将权限细粒度的角色数据包装一下,区分报表平台管理角色和数据决策系统角色 *

* Author : daisy * Date: 13-8-30 * Time: 下午3:42 */ public class RoleDataWrapper implements ChildrenNodesLoader { List rolelist = new ArrayList(); private String roleTypename = null; public RoleDataWrapper(String roleName) { roleTypename = roleName; } /** * 在此计算并获得与管理类型相对应的 */ private void calculateRoleList() { this.rolelist.addAll(FRContext.getCurrentEnv().getAllRole4Privilege( roleTypename != Inter.getLocText("M_Server-Platform_Manager"))); } //加载所有的角色列表 public ExpandMutableTreeNode[] load() { calculateRoleList(); return this.load(this.rolelist); } //从workbook中读取的角色列表 public ExpandMutableTreeNode[] load(List rolelist) { this.rolelist = rolelist; ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[rolelist.size()]; for (int i = 0; i < res.length; i++) { res[i] = new ExpandMutableTreeNode(rolelist.get(i)); } return res; } public String getRoleTypename(){ return roleTypename; } } \ No newline at end of file +package com.fr.design.roleAuthority; import com.fr.base.FRContext; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.loader.ChildrenNodesLoader; import com.fr.general.Inter; import com.fr.log.FineLoggerFactory; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * 将权限细粒度的角色数据包装一下,区分报表平台管理角色和数据决策系统角色 *

* Author : daisy * Date: 13-8-30 * Time: 下午3:42 */ public class RoleDataWrapper implements ChildrenNodesLoader { private List rolelist = new ArrayList(); private String roleTypename = null; public RoleDataWrapper(String roleName) { roleTypename = roleName; } /** * 在此计算并获得与管理类型相对应的 */ private void calculateRoleList() { try { Collections.addAll(rolelist, FRContext.getCurrentEnv().getOrganizationOperator().getRoleGroup()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } //加载所有的角色列表 public ExpandMutableTreeNode[] load() { calculateRoleList(); return this.load(this.rolelist); } //从workbook中读取的角色列表 public ExpandMutableTreeNode[] load(List rolelist) { this.rolelist = rolelist; ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[rolelist.size()]; for (int i = 0; i < res.length; i++) { res[i] = new ExpandMutableTreeNode(rolelist.get(i)); } return res; } public String getRoleTypename(){ return roleTypename; } } \ No newline at end of file diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index 12bf84e3b..9034d6c36 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -5,6 +5,7 @@ import com.fr.base.TableData; import com.fr.base.operator.common.CommonOperator; import com.fr.base.operator.connect.ConnectOperator; import com.fr.base.operator.file.FileOperator; +import com.fr.base.operator.org.OrganizationOperator; import com.fr.base.remote.RemoteDeziConstants; import com.fr.common.rpc.RemoteCallServerConfig; import com.fr.common.rpc.netty.MessageSendExecutor; @@ -20,8 +21,6 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.env.RemoteEnvConfig; import com.fr.design.mainframe.DesignerContext; import com.fr.file.CacheManager; -import com.fr.file.ConnectionConfig; -import com.fr.file.TableDataConfig; import com.fr.general.CommonIOUtils; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; @@ -37,7 +36,6 @@ import com.fr.share.ShareConstants; import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; import com.fr.stable.Filter; -import com.fr.stable.JavaCompileInfo; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; @@ -56,20 +54,17 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import java.awt.*; -import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import static com.fr.third.guava.base.Preconditions.checkArgument; @@ -126,6 +121,11 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return MessageSendExecutor.getInstance().execute(CommonOperator.class); } + @Override + public OrganizationOperator getOrganizationOperator() throws Exception { + return MessageSendExecutor.getInstance().execute(OrganizationOperator.class); + } + @Override public RemoteEnvConfig getEnvConfig() { return config; @@ -427,45 +427,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); } - /** - * DataSource中去除当前角色没有权限访问的数据源 - */ - @Override - public void removeNoPrivilegeConnection() { - refreshHttpSProperty(); - TableDataConfig dm = TableDataConfig.getInstance(); - - try { - HashMap para = new HashMap<>(); - para.put("op", "fs_remote_design"); - para.put("cmd", "env_get_role"); - para.put("currentUsername", this.getUser()); - para.put("currentPwd", this.getPassword()); - - InputStream input = filterInputStream( - RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) - ); - JSONArray ja = new JSONArray(stream2String(input)); - ArrayList toBeRemoveTDName = new ArrayList<>(); - for (int i = 0; i < ja.length(); i++) { - String toBeRemoveConnName = (String) ((JSONObject) ja.get(i)).get("name"); - ConnectionConfig.getInstance().removeConnection(toBeRemoveConnName); - Iterator it = dm.getTableDatas().keySet().iterator(); - while (it.hasNext()) { - String tdName = (String) it.next(); - TableData td = dm.getTableData(tdName); - td.registerNoPrivilege(toBeRemoveTDName, toBeRemoveConnName, tdName); - } - } - - for (int i = 0; i < toBeRemoveTDName.size(); i++) { - dm.removeTableData(toBeRemoveTDName.get(i)); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - } - @Override public EmbeddedTableData previewTableData(Object tableData, Map parameterMap, int rowCount) throws Exception { return previewTableData(null, tableData, parameterMap, rowCount); @@ -713,63 +674,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return FILE_TYPE; } - - /** - * 判断是否有文件夹权限 - * - * @param path 路径 - * @return 有权限则返回true - */ - @Override - public boolean hasFileFolderAllow(String path) { - refreshHttpSProperty(); - try { - HashMap para = new HashMap<>(); - para.put("op", "fs_remote_design"); - para.put("cmd", "design_filefolder_allow"); - para.put("current_uid", this.getUserID()); - para.put(RemoteDeziConstants.TEMPLATE_PATH, path); - - InputStream input = filterInputStream( - RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) - ); - - if (input == null) { - return false; - } - return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - return false; - } - - } - - @Override - public ArrayList getAllRole4Privilege(boolean isFS) { - refreshHttpSProperty(); - ArrayList allRoleList = new ArrayList<>(); - try { - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "get_all_role"); - para.put("isFS", String.valueOf(isFS)); - - InputStream input = filterInputStream( - RemoteEnvUtils.simulateRPCByHttpGet(para, false, this) - ); - JSONArray ja = new JSONArray(stream2String(input)); - for (int i = 0; i < ja.length(); i++) { - String roleName = (String) ((JSONObject) ja.get(i)).get("name"); - allRoleList.add(roleName); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - return allRoleList; - } - - /** * 获取当前env的build文件路径 */ @@ -786,30 +690,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAut this.buildFilePath = buildFilePath; } - /** - * 编译Java源代码,方便二次开发的进行 - * - * @param sourceText 源代码 - * @return 编译信息,有可能是成功信息,也有可能是出错或者警告信息 - */ - @Override - public JavaCompileInfo compilerSourceCode(String sourceText) throws Exception { - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "design_compile_source_code"); - InputStream in = postBytes2ServerB(sourceText.getBytes(EncodeConstants.ENCODING_UTF_8), para); - BufferedReader br = new BufferedReader(new InputStreamReader(in, EncodeConstants.ENCODING_UTF_8)); - StringBuilder sb = new StringBuilder(); - String line; - while ((line = br.readLine()) != null) { - sb.append(line); - } - JSONObject jo = new JSONObject(sb.toString()); - JavaCompileInfo info = new JavaCompileInfo(); - info.parseJSON(jo); - return info; - } - @Override public String[] loadREUFile() { refreshHttpSProperty(); diff --git a/designer-base/src/com/fr/file/FILEChooserPane.java b/designer-base/src/com/fr/file/FILEChooserPane.java index 3b5f71a60..d5e6d8e55 100644 --- a/designer-base/src/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/com/fr/file/FILEChooserPane.java @@ -1,8 +1,8 @@ package com.fr.file; import com.fr.base.BaseUtils; -import com.fr.base.extension.FileExtension; import com.fr.base.FRContext; +import com.fr.base.extension.FileExtension; import com.fr.dav.LocalEnv; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; @@ -26,6 +26,7 @@ import com.fr.file.filter.FILEFilter; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.Inter; +import com.fr.log.FineLoggerFactory; import com.fr.stable.CoreConstants; import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; @@ -33,38 +34,13 @@ import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; -import javax.swing.AbstractAction; -import javax.swing.AbstractListModel; -import javax.swing.ActionMap; -import javax.swing.BorderFactory; -import javax.swing.DefaultComboBoxModel; -import javax.swing.DefaultListCellRenderer; -import javax.swing.DefaultListModel; -import javax.swing.Icon; -import javax.swing.InputMap; -import javax.swing.JComponent; -import javax.swing.JFileChooser; -import javax.swing.JList; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.KeyStroke; -import javax.swing.ListCellRenderer; -import javax.swing.ListModel; -import javax.swing.ListSelectionModel; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; +import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.filechooser.FileSystemView; import javax.swing.plaf.basic.BasicArrowButton; import javax.swing.plaf.basic.BasicButtonUI; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.Window; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -707,7 +683,14 @@ public class FILEChooserPane extends BasicPane { } returnValue = OK_OPTION; FILE selectedFile = this.getSelectedFILE(); - if (!FRContext.getCurrentEnv().hasFileFolderAllow(selectedFile.getPath())) { + boolean access = false; + + try { + access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(selectedFile.getPath()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + if (!access) { JOptionPane.showMessageDialog(FILEChooserPane.this, Inter.getLocText("FR-App-Privilege_No") + "!", Inter.getLocText("FR-App-File_Message"), JOptionPane.WARNING_MESSAGE); return; } @@ -1418,7 +1401,14 @@ public class FILEChooserPane extends BasicPane { if (currentDirectory == null) { return; } - if (!FRContext.getCurrentEnv().hasFileFolderAllow(currentDirectory.getPath() + "/")) { + + boolean access = false; + try { + access = FRContext.getCurrentEnv().getOrganizationOperator().canAccess(currentDirectory.getPath()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + if (!access) { JOptionPane.showMessageDialog(FILEChooserPane.this, Inter.getLocText("FR-App-Privilege_No") + "!", Inter.getLocText("FR-App-File_Message"), JOptionPane.WARNING_MESSAGE); return; } From 503c7335efaaa605bdb1e8a5b1d113f89408f309 Mon Sep 17 00:00:00 2001 From: richie Date: Sat, 9 Jun 2018 08:01:12 +0800 Subject: [PATCH 04/15] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E4=BA=86=E5=8F=AF=E5=8F=98=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=97=A0=E6=B3=95=E5=BA=8F=E5=88=97=E5=8C=96=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer-base/src/com/fr/design/formula/JavaEditorPane.java | 2 +- designer-base/src/com/fr/env/RemoteEnv.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/designer-base/src/com/fr/design/formula/JavaEditorPane.java b/designer-base/src/com/fr/design/formula/JavaEditorPane.java index 48d3b02d8..946eb58c1 100644 --- a/designer-base/src/com/fr/design/formula/JavaEditorPane.java +++ b/designer-base/src/com/fr/design/formula/JavaEditorPane.java @@ -156,7 +156,7 @@ public class JavaEditorPane extends BasicPane { return; } try { - FRContext.getCurrentEnv().getFileOperator().write(text.getBytes(EncodeConstants.ENCODING_UTF_8), ProjectConstants.CLASSES_NAME, getJavaPath()); + FRContext.getCurrentEnv().getFileOperator().write(text.getBytes(EncodeConstants.ENCODING_UTF_8), StableUtils.pathJoin(ProjectConstants.CLASSES_NAME, getJavaPath())); JOptionPane.showMessageDialog(null, Inter.getLocText(new String[]{"Save", "Successfully"}) + "!"); fireSaveActionListener(); } catch (Exception e) { diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index 9034d6c36..e50da3169 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -5,6 +5,7 @@ import com.fr.base.TableData; import com.fr.base.operator.common.CommonOperator; import com.fr.base.operator.connect.ConnectOperator; import com.fr.base.operator.file.FileOperator; +import com.fr.base.operator.file.SimpleFileOperator; import com.fr.base.operator.org.OrganizationOperator; import com.fr.base.remote.RemoteDeziConstants; import com.fr.common.rpc.RemoteCallServerConfig; @@ -126,6 +127,11 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return MessageSendExecutor.getInstance().execute(OrganizationOperator.class); } + @Override + public SimpleFileOperator getSimpleFileOperator() throws Exception { + return MessageSendExecutor.getInstance().execute(SimpleFileOperator.class); + } + @Override public RemoteEnvConfig getEnvConfig() { return config; From 92af60d32f97a6088324b21cee088496637dc045 Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Mon, 11 Jun 2018 11:32:34 +0800 Subject: [PATCH 05/15] =?UTF-8?q?REPORT-8515=20=E5=90=AF=E5=8A=A8=E9=80=9F?= =?UTF-8?q?=E5=BA=A6=E4=BC=98=E5=8C=96,=20=E8=B5=84=E6=BA=90=E9=A2=84?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/imenu/UIBasicMenuItemUI.java | 53 ++- .../DesignerFrameFileDealerPane.java | 62 ++- .../src/com/fr/start/BaseDesigner.java | 24 +- .../alphafine/component/AlphaFinePane.java | 10 +- .../src/com/fr/start/Designer.java | 46 +- .../src/com/fr/start/ImagePreLoader.java | 406 ++++++++++++++++++ 6 files changed, 551 insertions(+), 50 deletions(-) create mode 100644 designer-realize/src/com/fr/start/ImagePreLoader.java diff --git a/designer-base/src/com/fr/design/gui/imenu/UIBasicMenuItemUI.java b/designer-base/src/com/fr/design/gui/imenu/UIBasicMenuItemUI.java index d8cce0234..8dcb2d806 100644 --- a/designer-base/src/com/fr/design/gui/imenu/UIBasicMenuItemUI.java +++ b/designer-base/src/com/fr/design/gui/imenu/UIBasicMenuItemUI.java @@ -4,20 +4,49 @@ package com.fr.design.gui.imenu; -import com.fr.general.ComparatorUtils; import com.fr.design.utils.ColorRoutines; import com.fr.design.utils.ThemeUtils; +import com.fr.general.ComparatorUtils; -import javax.swing.*; +import javax.swing.AbstractAction; +import javax.swing.ActionMap; +import javax.swing.ButtonModel; +import javax.swing.Icon; +import javax.swing.InputMap; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JComponent; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JRadioButtonMenuItem; +import javax.swing.KeyStroke; +import javax.swing.LookAndFeel; +import javax.swing.MenuElement; +import javax.swing.MenuSelectionManager; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; import javax.swing.event.MenuDragMouseEvent; import javax.swing.event.MenuDragMouseListener; import javax.swing.event.MenuKeyListener; import javax.swing.event.MouseInputListener; -import javax.swing.plaf.*; +import javax.swing.plaf.ActionMapUIResource; +import javax.swing.plaf.ColorUIResource; +import javax.swing.plaf.ComponentInputMapUIResource; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.MenuItemUI; +import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicGraphicsUtils; import javax.swing.plaf.basic.BasicHTML; import javax.swing.text.View; -import java.awt.*; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; @@ -588,7 +617,7 @@ public class UIBasicMenuItemUI extends MenuItemUI { } protected void installDefaults() { - String prefix = getPropertyPrefix(); + final String prefix = getPropertyPrefix(); acceleratorFont = UIManager.getFont("MenuItem.acceleratorFont"); @@ -600,7 +629,7 @@ public class UIBasicMenuItemUI extends MenuItemUI { LookAndFeel.installBorder(menuItem, prefix + ".border"); oldBorderPainted = menuItem.isBorderPainted(); menuItem.setBorderPainted(((Boolean) (UIManager.get(prefix + ".borderPainted"))).booleanValue()); - LookAndFeel.installColorsAndFont(menuItem, prefix + ".background", prefix + ".foreground", prefix + ".font"); + installFont(prefix); // MenuItem specific defaults if (selectionBackground == null || selectionBackground instanceof UIResource) { @@ -637,6 +666,18 @@ public class UIBasicMenuItemUI extends MenuItemUI { defaultIconGap = DEFAULT_ICON_GAP; // Should be from table } + private void installFont(final String prefix) { + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + LookAndFeel.installColorsAndFont(menuItem, prefix + ".background", prefix + ".foreground", prefix + ".font"); + } + }); + thread.setName("UIBasicMenuItemUI"); + thread.setDaemon(true); + thread.start(); + } + protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem b = (JMenuItem) c; diff --git a/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index af03db3fe..6755965bb 100644 --- a/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -10,7 +10,11 @@ import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.tabledata.ResponseDataSourceChange; -import com.fr.design.file.*; +import com.fr.design.file.FileOperations; +import com.fr.design.file.FileToolbarStateChangeListener; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.MutilTempalteTabPane; +import com.fr.design.file.TemplateTreePane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuHighLight; @@ -33,15 +37,23 @@ import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.SwingConstants; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; -import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -129,9 +141,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt public void refreshDockingView() { ToolBarDef toolbarDef = new ToolBarDef(); toolbarDef.addShortCut(openReportAction, refreshTreeAction); - if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) { - toolbarDef.addShortCut(openFolderAction, renameAction); - } + toolbarDef.addShortCut(openFolderAction, renameAction); toolbarDef.addShortCut(delFileAction); Set extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); for (ShortCut shortCut : extraShortCuts){ @@ -256,37 +266,19 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt public void stateChange() { //当前环境为远程环境时 if (FRContext.getCurrentEnv() != null) { - if (!FRContext.getCurrentEnv().isSupportLocalFileOperate()) { - if (selectedOperation.getSelectedTemplatePath() != null) { - openReportAction.setEnabled(true); - } else { - openReportAction.setEnabled(false); - } - FileNode node = TemplateTreePane.getInstance().getTemplateFileTree().getSelectedFileNode(); - if (selectedOperation.getSelectedTemplatePath() != null){ - if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(),node.getLock())){ - delFileAction.setEnabled(false); - } else { - delFileAction.setEnabled(true); - } - } else { - delFileAction.setEnabled(false); - } + //当前环境为本地环境时 + if (selectedOperation.getSelectedTemplatePath() != null) { + openReportAction.setEnabled(true); + renameAction.setEnabled(true); + delFileAction.setEnabled(true); } else { - //当前环境为本地环境时 - if (selectedOperation.getSelectedTemplatePath() != null) { - openReportAction.setEnabled(true); - renameAction.setEnabled(true); - delFileAction.setEnabled(true); - } else { - openReportAction.setEnabled(false); - renameAction.setEnabled(false); - delFileAction.setEnabled(false); - } - openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0); + openReportAction.setEnabled(false); + renameAction.setEnabled(false); + delFileAction.setEnabled(false); } - refreshTreeAction.setEnabled(true); + openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0); } + refreshTreeAction.setEnabled(true); if (containsFolderNums() > 0 && (containsFolderNums() + seletedTemplateNums() > 1)) { refreshActions(); } else if (containsFolderNums() == 0 && seletedTemplateNums() > 1) { diff --git a/designer-base/src/com/fr/start/BaseDesigner.java b/designer-base/src/com/fr/start/BaseDesigner.java index 6648d9c7a..3c5ede5e3 100644 --- a/designer-base/src/com/fr/start/BaseDesigner.java +++ b/designer-base/src/com/fr/start/BaseDesigner.java @@ -11,6 +11,7 @@ import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerStartOpenFileProcessor; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; +import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.utils.DesignUtils; import com.fr.event.EventDispatcher; @@ -48,12 +49,32 @@ public abstract class BaseDesigner extends ToolBarMenuDock { EventDispatcher.fire(ModuleEvent.MajorModuleStarting, InterProviderFactory.getProvider().getLocText("FR-Designer_Initializing")); // 初始化look and feel.这个在预加载之前执行是因为lookAndFeel里的东西,预加载时也要用到 DesignUtils.initLookAndFeel(); - + // 预加载一些耗时的单例面板 + preLoadPane(); + // 初始化Log Handler DesignerEnvManager.loadLogSetting(); createDesignerFrame(); } + private void preLoadPane() { + ExecutorService service = Executors.newCachedThreadPool(); + service.submit(new Runnable() { + @Override + public void run() { + LogMessageBar.getInstance(); + } + }); + + service.submit(new Runnable() { + @Override + public void run() { + HistoryTemplateListPane.getInstance(); + } + }); + service.shutdown(); + } + public void show(final String[] args) { ExecutorService executorService = Executors.newSingleThreadExecutor(); executorService.submit(new Runnable() { @@ -61,6 +82,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { public void run() { collectUserInformation(); showDesignerFrame(args, DesignerContext.getDesignerFrame(), false); + DesignerContext.getDesignerFrame().refreshEnv(); for (int i = 0; !TemplateTreePane.getInstance().getTemplateFileTree().isTemplateShowing() && i < LOAD_TREE_MAXNUM; i++) { TemplateTreePane.getInstance().getTemplateFileTree().refresh(); } diff --git a/designer-realize/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java b/designer-realize/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java index 86ddc8b40..fee8f69b8 100644 --- a/designer-realize/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java +++ b/designer-realize/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java @@ -1,16 +1,18 @@ package com.fr.design.mainframe.alphafine.component; -import com.bulenkov.iconloader.IconLoader; import com.fr.design.actions.help.alphafine.AlphaFineContext; import com.fr.design.actions.help.alphafine.AlphaFineListener; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.alphafine.AlphaFineHelper; -import com.fr.design.utils.ThemeUtils; +import com.fr.general.IOUtils; import com.fr.general.Inter; -import java.awt.*; +import java.awt.AWTEvent; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -28,7 +30,7 @@ public class AlphaFinePane extends BasicPane { setPreferredSize(new Dimension(24, 24)); setLayout(new BorderLayout()); UIButton refreshButton = new UIButton(); - refreshButton.setIcon(IconLoader.getIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png")); + refreshButton.setIcon(IOUtils.readIcon(("/com/fr/design/mainframe/alphafine/images/smallsearch.png"))); refreshButton.setToolTipText(Inter.getLocText("FR-Designer_AlphaFine")); refreshButton.set4ToolbarButton(); refreshButton.setRolloverEnabled(false); diff --git a/designer-realize/src/com/fr/start/Designer.java b/designer-realize/src/com/fr/start/Designer.java index a890bc73c..c877876b8 100644 --- a/designer-realize/src/com/fr/start/Designer.java +++ b/designer-realize/src/com/fr/start/Designer.java @@ -30,6 +30,7 @@ import com.fr.design.mainframe.JWorkBook; import com.fr.design.mainframe.alphafine.component.AlphaFinePane; import com.fr.design.mainframe.bbs.UserInfoLabel; import com.fr.design.mainframe.bbs.UserInfoPane; +import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.MenuDef; @@ -41,6 +42,7 @@ import com.fr.design.utils.concurrent.ThreadFactoryBuilder; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; +import com.fr.general.SiteCenter; import com.fr.module.Module; import com.fr.module.ModuleContext; import com.fr.stable.BuildContext; @@ -52,16 +54,22 @@ import com.fr.stable.xml.XMLTools; import com.fr.start.fx.SplashFx; import com.fr.start.jni.SplashMac; import com.fr.start.module.StartupArgs; -import com.fr.start.server.FineEmbedServer; import com.fr.start.server.ServerTray; -import javax.swing.*; +import javax.swing.JComponent; +import javax.swing.JPanel; import javax.swing.border.MatteBorder; -import java.awt.*; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.util.ArrayList; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; @@ -87,7 +95,7 @@ public class Designer extends BaseDesigner { * @param args 参数 */ public static void main(String[] args) { - + preloadResource(); BuildContext.setBuildFilePath("/com/fr/stable/build.properties"); SplashContext.getInstance().registerSplash(createSplash()); SplashContext.getInstance().show(); @@ -102,6 +110,33 @@ public class Designer extends BaseDesigner { } + private static void preloadResource() { + ExecutorService service = Executors.newCachedThreadPool(); + + service.submit(new Runnable() { + @Override + public void run() { + SiteCenter.getInstance(); + Cursor cursor = UIConstants.CELL_DEFAULT_CURSOR; + } + }); + + service.submit(new Runnable() { + @Override + public void run() { + new ImagePreLoader(); + } + }); + + service.submit(new Runnable() { + @Override + public void run() { + TemplateInfoCollector.getInstance(); + } + }); + service.shutdown(); + } + private static SplashStrategy createSplash() { // 这里可以开接口加载自定义启动画面 if (OperatingSystem.isWindows()) { @@ -498,6 +533,9 @@ public class Designer extends BaseDesigner { collector.collectStopTime(); collector.saveXMLFile(); Env currentEnv = FRContext.getCurrentEnv(); + if (currentEnv == null) { + return; + } currentEnv.doWhenServerShutDown(); } diff --git a/designer-realize/src/com/fr/start/ImagePreLoader.java b/designer-realize/src/com/fr/start/ImagePreLoader.java new file mode 100644 index 000000000..7d020d2f7 --- /dev/null +++ b/designer-realize/src/com/fr/start/ImagePreLoader.java @@ -0,0 +1,406 @@ +package com.fr.start; + +import com.fr.general.IOUtils; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * 在设计器框架加载之前, 先用多个线程把相关的资源文件全部load到缓存中. + */ +public class ImagePreLoader { + + public static final int THRESHOLD = 50; + + public ImagePreLoader() { + ExecutorService service = Executors.newCachedThreadPool(); + + int len = preLoadImages.length; + int start = 0; + for (int i = 0; i < len; i++) { + if (i != 0 && i % THRESHOLD == 0) { + loadImage(start,i, service); + start = i; + } + if (len - i < THRESHOLD) { + loadImage(start, len, service); + break; + } + + } + service.shutdown(); + } + + private void loadImage(final int start, final int end, ExecutorService service) { + service.submit(new Runnable() { + @Override + public void run() { + for (int i = start; i < end; i++) { + IOUtils.readImageWithCache(preLoadImages[i]); + } + } + }); + } + + + private String[] preLoadImages = { + "com/fr/design/images/m_file/formExport.png", + "com/fr/base/images/oem/cpt.png", + "com/fr/design/images/data/store_procedure.png", + "/com/fr/design/images/m_file/preview.png", + "com/fr/base/images/cell/blank.gif", + "com/fr/design/images/data/dock/serverdatabase.png", + "/com/fr/design/images/data/dock/serverclasstabledata.png", + "/com/fr/design/images/data/dock/serverdatatable.png", + "/com/fr/design/images/data/file.png", + "/com/fr/design/images/data/tree.png", + "/com/fr/design/images/buttonicon/minus.png", + "/com/fr/design/images/buttonicon/plus.png", + "/com/fr/design/images/data/multi.png", + "/com/fr/design/images/data/store_procedure.png", + "com/fr/design/images/buttonicon/arrowdown.png", + "com/fr/design/images/buttonicon/arrowup.png", + "com/fr/design/images/buttonicon/yes.png", + "com/fr/design/images/buttonicon/select_item.png", + "com/fr/design/images/buttonicon/prewidget.png", + "com/fr/design/images/buttonicon/editn.png", + "com/fr/design/images/buttonicon/editp.png", + "com/fr/design/images/buttonicon/hiden.png", + "com/fr/design/images/buttonicon/hidep.png", + "com/fr/design/images/buttonicon/viewn.png", + "com/fr/design/images/buttonicon/viewp.png", + "com/fr/design/images/buttonicon/run24.png", + "com/fr/design/images/buttonicon/runs.png", + "com/fr/design/mainframe/alphafine/images/smallsearch.png", + "com/fr/design/images/buttonicon/pageb24.png", + "com/fr/design/images/buttonicon/writeb24.png", + "com/fr/design/images/buttonicon/anab24.png", + "com/fr/design/images/buttonicon/pages.png", + "com/fr/design/images/buttonicon/writes.png", + "com/fr/design/images/buttonicon/anas.png", + "com/fr/design/images/buttonicon/refresh.png", + "com/fr/design/images/gui/color/foreground.png", + "com/fr/design/images/buttonicon/history.png", + "com/fr/design/images/m_file/close.png", + "com/fr/design/images/m_file/edit.png", + "com/fr/design/images/data/search.png", + "com/fr/design/images/data/black_search.png", + "com/fr/design/images/data/source/delete.png", + "com/fr/design/images/control/edit.png", + "com/fr/design/images/control/edit_white.png", + "com/fr/design/images/buttonicon/prevew_down_icon.png", + "com/fr/design/images/m_report/close.png", + "com/fr/design/images/m_report/close_over.png", + "com/fr/design/images/m_report/close_press.png", + "com/fr/design/images/buttonicon/save.png", + "com/fr/design/images/buttonicon/undo.png", + "com/fr/design/images/buttonicon/redo.png", + "com/fr/design/images/buttonicon/additicon_grey.png", + "com/fr/design/images/buttonicon/addicon.png", + "com/fr/design/images/buttonicon/list_normal.png", + "com/fr/design/images/buttonicon/list_pressed.png", + "com/fr/design/images/buttonicon/close_icon.png", + "com/fr/design/images/buttonicon/mouseoverclose icon.png", + "com/fr/design/images/buttonicon/pressclose icon.png", + "com/fr/design/images/buttonicon/open.png", + "com/fr/design/images/m_file/view_folder.png", + "com/fr/design/images/data/source/rename.png", + "com/fr/design/images/buttonicon/minus.png", + "com/fr/design/images/buttonicon/plus.png", + "com/fr/design/images/data/database.png", + "com/fr/design/images/data/source/classTableData.png", + "com/fr/design/images/data/dataTable.png", + "com/fr/design/images/data/multi.png", + "com/fr/design/images/data/file.png", + "com/fr/design/images/data/tree.png", + "com/fr/design/images/control/tab/remove.png", + "com/fr/design/images/m_file/preview.png", + "com/fr/design/images/m_web/connection.png", + "com/fr/design/images/control/addPopup.png", + "com/fr/design/images/buttonicon/propertiestab/cellelement_normal.png", + "com/fr/design/images/buttonicon/propertiestab/cellattr_normal.png", + "com/fr/design/images/buttonicon/propertiestab/floatelement_normal.png", + "com/fr/design/images/buttonicon/propertiestab/widgetsettings_normal.png", + "com/fr/design/images/buttonicon/propertiestab/conditionattr_normal.png", + "com/fr/design/images/buttonicon/propertiestab/hyperlink_normal.png", + "com/fr/design/images/buttonicon/propertiestab/widgetlib_normal.png", + "com/fr/design/images/buttonicon/propertiestab/authorityedit_normal.png", + "com/fr/design/images/buttonicon/propertiestab/configuredroles_normal.png", + "com/fr/design/images/buttonicon/propertiestab/cellelement_selected.png", + "com/fr/design/images/log/selectedall.png", + "com/fr/design/images/m_edit/copy.png", + "com/fr/design/images/log/clear.png", + "com/fr/design/images/log/clear.png", + "com/fr/design/images/log/selectedall.png", + "com/fr/design/images/log/setting.png", + "com/fr/design/images/buttonicon/newcpts.png", + "com/fr/base/images/oem/logo.png", + "com/fr/design/images/data/bind/localconnect.png", + "com/fr/design/images/gui/tab_add_normal.png", + "com/fr/design/images/m_help/demo.png", + "com/fr/design/images/gui/tab_add_hover.png", + "com/fr/design/images/gui/tab_add_click.png", + "com/fr/design/images/gui/tab_delete.png", + "com/fr/design/images/bbs.png", + "com/fr/design/images/video.png", + "com/fr/design/images/help.png", + "com/fr/design/images/questions.png", + "com/fr/design/images/update.png", + "com/fr/design/images/need.png", + "com/fr/design/images/bug.png", + "com/fr/design/images/signature.png", + "com/fr/design/images/m_file/switch.png", + "com/fr/design/images/gui/blank.gif", + "com/fr/design/images/gui/folder.png", + "com/fr/design/images/gui/javaFile.gif", + "com/fr/design/images/gui/classFile.gif", + "com/fr/design/images/gui/jspFile.gif", + "com/fr/design/images/gui/jsFile.gif", + "com/fr/design/images/gui/xmlFile.gif", + "com/fr/design/images/gui/htmlFile.gif", + "com/fr/design/images/gui/jarFile.gif", + "com/fr/design/images/gui/gifFile.gif", + "com/fr/design/images/gui/jpgFile.gif", + "com/fr/design/images/gui/bmpFile.gif", + "com/fr/design/images/gui/cptFile.png", + "com/fr/design/images/gui/frm.png", + "com/fr/design/images/gui/cht.png", + "com/fr/design/images/chart/ChartType.png", + "com/fr/van/chart/map/images/mapData.png", + "com/fr/design/images/buttonicon/add.png", + "com/fr/base/images/cell/control/remove.png", + "com/fr/design/images/control/up.png", + "com/fr/design/images/control/down.png", + "com/fr/design/images/control/sortAsc.png", + "com/fr/design/images/m_insert/formula.png", + "com/fr/design/images/calender/year_reduce.png", + "com/fr/design/images/calender/year_reduce_hover.png", + "com/fr/design/images/calender/year_reduce_click.png", + "com/fr/design/images/calender/month_reduce.png", + "com/fr/design/images/calender/month_reduce_hover.png", + "com/fr/design/images/calender/month_reduce_click.png", + "com/fr/design/images/calender/month_add.png", + "com/fr/design/images/calender/month_add_hover.png", + "com/fr/design/images/calender/month_add_click.png", + "com/fr/design/images/calender/year_add.png", + "com/fr/design/images/calender/year_add_hover.png", + "com/fr/design/images/calender/year_add_click.png", + "com/fr/design/images/buttonicon/type_string.png", + "com/fr/base/images/cell/control/add.png", + "com/fr/design/images/expand/cellAttr.gif", + "com/fr/design/images/expand/none16x16.png", + "com/fr/design/images/expand/asc.png", + "com/fr/design/images/expand/des.png", + "com/fr/design/images/form/toolbar/pie.png", + "com/fr/design/images/buttonicon/widget/date_16.png", + "com/fr/design/images/buttonicon/widget/tree_16.png", + "com/fr/design/images/buttonicon/widget/comboboxtree.png", + "com/fr/design/images/buttonicon/widget/checkbox_group_16.png", + "com/fr/design/images/buttonicon/widget/button_group_16.png", + "com/fr/design/images/buttonicon/widget/number_field_16.png", + "com/fr/design/images/buttonicon/widget/label_16.png", + "com/fr/web/images/form/resources/button_16.png", + "com/fr/design/images/buttonicon/widget/button_16.png", + "com/fr/design/images/buttonicon/widget/files_up.png", + "com/fr/design/images/buttonicon/widget/combo_box_16.png", + "com/fr/design/images/buttonicon/widget/combo_check_16.png", + "com/fr/design/images/buttonicon/widget/check_box_16.png", + "com/fr/web/images/form/resources/list_16.png", + "com/fr/design/images/buttonicon/widget/text_field_16.png", + "com/fr/design/images/buttonicon/widget/text_area_16.png", + "com/fr/design/images/buttonicon/widget/password_field_16.png", + "com/fr/web/images/form/resources/iframe_16.png", + "com/fr/design/images/form/toolbar/column.png", + "com/fr/design/images/form/toolbar/bar.png", + "com/fr/design/images/form/toolbar/line.png", + "com/fr/design/images/form/toolbar/area.png", + "com/fr/design/images/form/toolbar/gauge.png", + "com/fr/design/images/form/toolbar/radar.png", + "com/fr/design/images/form/toolbar/scatter.png", + "com/fr/design/images/form/toolbar/bubble.png", + "com/fr/design/images/form/toolbar/custom.png", + "com/fr/design/images/form/toolbar/multiPie.png", + "com/fr/design/images/form/toolbar/map.png", + "com/fr/design/images/form/toolbar/drillmap.png", + "com/fr/design/images/form/toolbar/treeMap.png", + "com/fr/design/images/form/toolbar/funnel.png", + "com/fr/design/images/form/toolbar/heatmap.png", + "com/fr/design/images/form/toolbar/wordcloud.png", + "com/fr/design/images/form/toolbar/gantt.png", + "com/fr/design/images/form/toolbar/structure.png", + "com/fr/design/images/control/help_open.png", + "com/fr/web/images/form/forbid.png", + "com/fr/web/images/form/resources/layout_absolute.png", + "com/fr/design/images/m_edit/cut.png", + "com/fr/design/images/m_edit/paste.png", + "com/fr/design/images/m_report/delete.png", + "com/fr/design/images/toolbarbtn/parametersetting.png", + "com/fr/base/images/oem/addworksheet.png", + "com/fr/design/images/sheet/addpolysheet.png", + "com/fr/base/images/oem/worksheet.png", + "com/fr/design/images/sheet/polysheet.png", + "com/fr/design/images/sheet/left_normal@1x.png", + "com/fr/design/images/sheet/right_normal@1x.png", + "com/fr/design/images/sheet/left_hover@1x.png", + "com/fr/design/images/sheet/right_hover@1x.png", + "com/fr/design/images/data/source/normalDown20.png", + "com/fr/design/images/data/source/hoverDown20.png", + "com/fr/design/images/data/source/normalUp20.png", + "com/fr/design/images/data/source/hoverUp20.png", + "com/fr/design/images/m_edit/formatBrush.png", + "com/fr/design/images/expand/none16x16_selected@1x.png", + "com/fr/design/images/expand/vertical.png", + "com/fr/design/images/expand/vertical_selected@1x.png", + "com/fr/design/images/expand/landspace.png", + "com/fr/design/images/expand/landspace_selected@1x.png", + "com/fr/design/images/buttonicon/select.png", + "com/fr/design/images/expand/asc_selected.png", + "com/fr/design/images/expand/des_selected.png", + "com/fr/design/images/m_format/cellstyle/bold.png", + "com/fr/design/images/m_format/cellstyle/italic.png", + "com/fr/design/images/m_format/cellstyle/underline.png", + "com/fr/design/images/m_format/cellstyle/strikethrough.png", + "com/fr/design/images/m_format/cellstyle/shadow.png", + "com/fr/design/images/m_format/cellstyle/sup.png", + "com/fr/design/images/m_format/cellstyle/sub.png", + "com/fr/base/images/dialog/border/top.png", + "com/fr/design/images/m_format/cellstyle/top_white.png", + "com/fr/base/images/dialog/border/left.png", + "com/fr/design/images/m_format/cellstyle/left_white.png", + "com/fr/base/images/dialog/border/bottom.png", + "com/fr/design/images/m_format/cellstyle/bottom_white.png", + "com/fr/base/images/dialog/border/right.png", + "com/fr/design/images/m_format/cellstyle/right_white.png", + "com/fr/base/images/dialog/border/horizontal.png", + "com/fr/design/images/m_format/cellstyle/horizontal_white.png", + "com/fr/base/images/dialog/border/vertical.png", + "com/fr/design/images/m_format/cellstyle/vertical_white.png", + "com/fr/design/images/m_format/out.png", + "com/fr/design/images/m_format/cellstyle/out_white.png", + "com/fr/design/images/m_format/in.png", + "com/fr/design/images/m_format/cellstyle/in_white.png", + "com/fr/design/images/m_format/cellstyle/h_left_normal.png", + "com/fr/design/images/m_format/cellstyle/h_left_normal_white.png", + "com/fr/design/images/m_format/cellstyle/h_center_normal.png", + "com/fr/design/images/m_format/cellstyle/h_center_normal_white.png", + "com/fr/design/images/m_format/cellstyle/h_right_normal.png", + "com/fr/design/images/m_format/cellstyle/h_right_normal_white.png", + "com/fr/design/images/m_format/cellstyle/h_s_normal.png", + "com/fr/design/images/m_format/cellstyle/h_s_normal_white.png", + "com/fr/design/images/m_format/cellstyle/defaultAlignment.png", + "com/fr/design/images/m_format/cellstyle/defaultAlignment_white.png", + "com/fr/design/images/m_format/cellstyle/v_top_normal.png", + "com/fr/design/images/m_format/cellstyle/v_top_normal_white.png", + "com/fr/design/images/m_format/cellstyle/v_center_normal.png", + "com/fr/design/images/m_format/cellstyle/v_center_normal_white.png", + "com/fr/design/images/m_format/cellstyle/v_down_normal.png", + "com/fr/design/images/m_format/cellstyle/v_down_normal_white.png", + "com/fr/design/images/control/refresh.png", + "com/fr/design/images/toolbarbtn/close.png", + "com/fr/design/images/buttonicon/new_form3.png", + "com/fr/design/images/m_file/save.png", + "com/fr/design/images/m_file/saveAs.png", + "com/fr/design/images/m_edit/undo.png", + "com/fr/design/images/m_edit/redo.png", + "com/fr/design/images/m_file/excel.png", + "com/fr/design/images/m_file/pdf.png", + "com/fr/design/images/m_file/word.png", + "com/fr/design/images/m_file/svg.png", + "com/fr/design/images/m_file/csv.png", + "com/fr/design/images/m_file/text.png", + "com/fr/design/images/m_web/datasource.png", + "com/fr/design/images/m_report/webreportattribute.png", + "com/fr/design/images/m_report/exportAttr.png", + "com/fr/design/images/m_report/p.png", + "com/fr/design/images/m_report/mobile.png", + "com/fr/web/images/print.png", + "com/fr/design/images/m_report/watermark.png", + "com/fr/design/images/m_file/pageSetup.png", + "com/fr/design/images/m_report/header.png", + "com/fr/design/images/m_report/footer.png", + "com/fr/design/images/m_report/background.png", + "com/fr/design/images/m_report/reportWriteAttr.png", + "com/fr/design/images/m_report/linearAttr.png", + "com/fr/design/images/m_report/reportEngineAttr.png", + "com/fr/design/images/m_report/allow_authority_edit.png", + "com/fr/design/images/m_insert/bindColumn.png", + "com/fr/design/images/m_insert/text.png", + "com/fr/design/images/m_insert/richtext.png", + "com/fr/design/images/m_insert/chart.png", + "com/fr/design/images/m_insert/image.png", + "com/fr/design/images/m_insert/bias.png", + "com/fr/design/images/arrow/arrow_up.png", + "com/fr/design/images/m_insert/subReport.png", + "com/fr/design/images/arrow/arrow_down.png", + "com/fr/design/images/toolbarbtn/toolbarbtnsetting.png", + "com/fr/design/images/control/addPopup.png", + "com/fr/design/images/toolbarbtn/toolbarbtnclear.png", + "com/fr/design/images/m_insert/insertRow.png", + "com/fr/design/images/m_insert/insertColumn.png", + "com/fr/design/images/m_format/modified.png", + "com/fr/design/images/m_format/highlight.png", + "com/fr/web/images/form/resources/preview_16.png", + "com/fr/web/images/save.png", + "com/fr/design/images/m_insert/hyperLink.png", + "com/fr/web/images/flashPrint.png", + "com/fr/design/images/m_edit/merge.png", + "com/fr/web/images/appletPrint.png", + "com/fr/design/images/m_edit/unmerge.png", + "com/fr/web/images/pdf.png", + "com/fr/design/images/m_format/cellAttr.png", + "com/fr/web/images/pdfPrint.png", + "com/fr/web/images/serverPrint.png", + "com/fr/web/images/email.png", + "com/fr/web/images/preview.png", + "com/fr/design/images/server/platform_16_16.png", + "com/fr/design/images/data/user_widget.png", + "com/fr/design/images/server/plugin.png", + "com/fr/web/images/excel.png", + "com/fr/design/images/m_web/function.png", + "com/fr/web/images/word.png", + "com/fr/web/images/pageSetup.png", + "com/fr/web/images/export.png", + "com/fr/design/images/m_web/edit.png", + "com/fr/web/images/pageNumber.png", + "com/fr/web/images/first.png", + "com/fr/design/images/m_web/style.png", + "com/fr/web/images/last.png", + "com/fr/web/images/previous.png", + "com/fr/web/images/next.png", + "com/fr/web/images/scale.png", + "com/fr/web/images/appendRow.png", + "com/fr/web/images/deleteRow.png", + "com/fr/web/images/verify.gif", + "com/fr/web/images/save2.png", + "com/fr/design/images/m_file/export.png", + "com/fr/web/images/showValue.png", + "com/fr/web/images/pianyi.png", + "com/fr/web/images/writeOffline.png", + "com/fr/web/images/edit/stash.png", + "com/fr/web/images/edit/clearstash.png", + "com/fr/design/images/m_insert/cell.png", + "com/fr/design/images/m_insert/float.png", + "com/fr/design/images/gui/color/background.png", + "com/fr/design/images/m_format/cell.png", + "com/fr/design/images/data/source/dataDictionary.png", + "com/fr/design/images/m_format/cellstyle/bold_white.png", + "com/fr/design/images/m_format/cellstyle/italic_white.png", + "com/fr/design/images/m_format/cellstyle/underline_white.png", + "com/fr/design/images/m_format/noboder.png", + "com/fr/design/images/gui/popup.gif", + "com/fr/design/images/m_insert/floatPop.png", + "com/fr/web/images/platform/demo.png", + "com/fr/base/images/dialog/pagesetup/down.png", + "com/fr/base/images/dialog/pagesetup/over.png", + "com/fr/web/images/reportlet.png", + "com/fr/design/images/buttonicon/switchShortCuts.png", + "com/fr/design/images/buttonicon/ds_column_name.png", + "com/fr/base/images/cell/control/add.png", + "com/fr/base/images/cell/control/rename.png", + "com/fr/base/images/cell/control/remove.png", + "com/fr/design/images/control/up.png", + "com/fr/design/images/control/down.png", + "com/fr/design/images/condition/bracket.png", + "com/fr/design/images/condition/unBracket.png" + }; +} From a9d73f94897436aa464d7bf67325e9ffa6c3ee6a Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Mon, 11 Jun 2018 11:45:32 +0800 Subject: [PATCH 06/15] preload --- .../src/com/fr/start/{ => preload}/ImagePreLoader.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename designer-realize/src/com/fr/start/{ => preload}/ImagePreLoader.java (100%) diff --git a/designer-realize/src/com/fr/start/ImagePreLoader.java b/designer-realize/src/com/fr/start/preload/ImagePreLoader.java similarity index 100% rename from designer-realize/src/com/fr/start/ImagePreLoader.java rename to designer-realize/src/com/fr/start/preload/ImagePreLoader.java From e9847bcc6b6908e0547b107491036dc397ff7a9e Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Mon, 11 Jun 2018 11:59:39 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1,=20?= =?UTF-8?q?=E5=8C=85=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer-realize/src/com/fr/start/Designer.java | 1 + designer-realize/src/com/fr/start/preload/ImagePreLoader.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/com/fr/start/Designer.java b/designer-realize/src/com/fr/start/Designer.java index c877876b8..d3a9d6306 100644 --- a/designer-realize/src/com/fr/start/Designer.java +++ b/designer-realize/src/com/fr/start/Designer.java @@ -54,6 +54,7 @@ import com.fr.stable.xml.XMLTools; import com.fr.start.fx.SplashFx; import com.fr.start.jni.SplashMac; import com.fr.start.module.StartupArgs; +import com.fr.start.preload.ImagePreLoader; import com.fr.start.server.ServerTray; import javax.swing.JComponent; diff --git a/designer-realize/src/com/fr/start/preload/ImagePreLoader.java b/designer-realize/src/com/fr/start/preload/ImagePreLoader.java index 7d020d2f7..2c80a9fad 100644 --- a/designer-realize/src/com/fr/start/preload/ImagePreLoader.java +++ b/designer-realize/src/com/fr/start/preload/ImagePreLoader.java @@ -1,4 +1,4 @@ -package com.fr.start; +package com.fr.start.preload; import com.fr.general.IOUtils; From 4505412ad9238d63257232a411cf0294f1806ea9 Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Mon, 11 Jun 2018 11:59:58 +0800 Subject: [PATCH 08/15] 1 --- designer-realize/src/com/fr/start/Designer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/com/fr/start/Designer.java b/designer-realize/src/com/fr/start/Designer.java index d3a9d6306..6e5cfb9ca 100644 --- a/designer-realize/src/com/fr/start/Designer.java +++ b/designer-realize/src/com/fr/start/Designer.java @@ -125,7 +125,7 @@ public class Designer extends BaseDesigner { service.submit(new Runnable() { @Override public void run() { - new ImagePreLoader(); + new Image PreLoader(); } }); From 62736b93de96f3ac9aea9c10da45afd387fdc70d Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Mon, 11 Jun 2018 12:00:06 +0800 Subject: [PATCH 09/15] 1 --- designer-realize/src/com/fr/start/Designer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-realize/src/com/fr/start/Designer.java b/designer-realize/src/com/fr/start/Designer.java index 6e5cfb9ca..d3a9d6306 100644 --- a/designer-realize/src/com/fr/start/Designer.java +++ b/designer-realize/src/com/fr/start/Designer.java @@ -125,7 +125,7 @@ public class Designer extends BaseDesigner { service.submit(new Runnable() { @Override public void run() { - new Image PreLoader(); + new ImagePreLoader(); } }); From 2f17cf0da766d4168513b30977105bd98459098e Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 11 Jun 2018 13:45:41 +0800 Subject: [PATCH 10/15] =?UTF-8?q?REPORT-8676=20=E6=8F=92=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=8610.0=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/PluginWebBridge.java | 5 +++ .../com/fr/design/extra/WebViewDlgHelper.java | 37 ++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/designer-base/src/com/fr/design/extra/PluginWebBridge.java b/designer-base/src/com/fr/design/extra/PluginWebBridge.java index 787626985..d922ae37f 100644 --- a/designer-base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer-base/src/com/fr/design/extra/PluginWebBridge.java @@ -559,6 +559,11 @@ public class PluginWebBridge { uiLabel.setText(Inter.getLocText("FR-Base_UnSignIn")); } + public void updatePluginStore(final JSObject callback){ + JSCallback jsCallback = new JSCallback(webEngine, callback); + jsCallback.execute(StringUtils.EMPTY); + } + /** * 初始化设计器部分 */ diff --git a/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java b/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java index 749c00447..0249c0b1e 100644 --- a/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java +++ b/designer-base/src/com/fr/design/extra/WebViewDlgHelper.java @@ -17,7 +17,9 @@ import com.fr.log.FineLoggerFactory; import com.fr.plugin.PluginStoreConstants; import com.fr.plugin.PluginVerifyException; import com.fr.stable.EnvChangedListener; +import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; import javax.swing.JOptionPane; import javax.swing.SwingWorker; @@ -44,7 +46,7 @@ public class WebViewDlgHelper { private static final int VERSION_8 = 8; private static String installHome = FRContext.getCurrentEnv().getWebReportPath(); private static final String MAIN_JS_PATH = "/scripts/plugin.html"; - private static final int BYTES_NUM = 1024; + private static final String ENV_VERSION = "ENV_VERSION"; static { GeneralContext.addEnvChangedListener(new EnvChangedListener() { @@ -70,10 +72,24 @@ public class WebViewDlgHelper { if (rv == JOptionPane.OK_OPTION) { downloadShopScripts(SHOP_SCRIPTS); } - } else { - showPluginDlg(); + } + String jar_version = PluginStoreConstants.getInstance().getProps(ENV_VERSION, StringUtils.EMPTY); + if (ComparatorUtils.equals(jar_version, ProductConstants.VERSION)) { updateShopScripts(SHOP_SCRIPTS); + } else { + int rv = JOptionPane.showConfirmDialog( + null, + Inter.getLocText("Fine-Plugin_Shop_Need_Install_Version"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE + ); + if (rv == JOptionPane.OK_OPTION) { + downloadShopScripts(SHOP_SCRIPTS); + deleteExtraFile(StableUtils.pathJoin(installHome, "plugin.html")); + } } + } else { BasicPane traditionalStorePane = new BasicPane() { @Override @@ -109,6 +125,16 @@ public class WebViewDlgHelper { } } + + /** + * 删除9.0工程下无用的plugin.html文件 + * + * @param filePath 待删除文件路径 + */ + private static void deleteExtraFile(String filePath){ + CommonIOUtils.deleteFile(new File(filePath)); + } + /** * 以关键词打开设计器商店 * @@ -252,12 +278,10 @@ public class WebViewDlgHelper { try { if (get()) { - String relativePath = "/scripts/plugin.html"; IOUtils.unzip(new File(StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE)), installHome); - copyMainFile(StableUtils.pathJoin(installHome, relativePath)); - // TODO: 2017/4/17 删除之前存放在安装目录下的script PluginStoreConstants.refreshProps(); // 下载完刷新一下版本号等 JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Shop_Installed"), Inter.getLocText("FR-Designer_Tooltips"), JOptionPane.INFORMATION_MESSAGE); + showPluginDlg(); } } catch (InterruptedException | ExecutionException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); @@ -290,6 +314,7 @@ public class WebViewDlgHelper { } } } + showPluginDlg(); return null; } }.execute(); From b92d50fe195e10833d63d098764930f2b14f3aa2 Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Mon, 11 Jun 2018 14:22:57 +0800 Subject: [PATCH 11/15] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=EF=BC=8Cn?= =?UTF-8?q?pe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/gui/imenu/UIBasicMenuItemUI.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/designer-base/src/com/fr/design/gui/imenu/UIBasicMenuItemUI.java b/designer-base/src/com/fr/design/gui/imenu/UIBasicMenuItemUI.java index 8dcb2d806..74c65e8ee 100644 --- a/designer-base/src/com/fr/design/gui/imenu/UIBasicMenuItemUI.java +++ b/designer-base/src/com/fr/design/gui/imenu/UIBasicMenuItemUI.java @@ -629,7 +629,7 @@ public class UIBasicMenuItemUI extends MenuItemUI { LookAndFeel.installBorder(menuItem, prefix + ".border"); oldBorderPainted = menuItem.isBorderPainted(); menuItem.setBorderPainted(((Boolean) (UIManager.get(prefix + ".borderPainted"))).booleanValue()); - installFont(prefix); + installFont(prefix, menuItem); // MenuItem specific defaults if (selectionBackground == null || selectionBackground instanceof UIResource) { @@ -666,10 +666,13 @@ public class UIBasicMenuItemUI extends MenuItemUI { defaultIconGap = DEFAULT_ICON_GAP; // Should be from table } - private void installFont(final String prefix) { + private void installFont(final String prefix, final JComponent menuItem) { Thread thread = new Thread(new Runnable() { @Override public void run() { + if (menuItem == null) { + return; + } LookAndFeel.installColorsAndFont(menuItem, prefix + ".background", prefix + ".foreground", prefix + ".font"); } }); From b3b68db75f58f2bc3891c75fbbc2e73b468447f1 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 11 Jun 2018 14:40:49 +0800 Subject: [PATCH 12/15] =?UTF-8?q?REPORT-8655=20=E3=80=90=E8=BE=83=E6=80=A5?= =?UTF-8?q?=E3=80=91=E8=AE=BE=E8=AE=A1=E5=99=A8=E8=8F=9C=E5=8D=95=E4=B8=AD?= =?UTF-8?q?=E7=9A=84400=E7=83=AD=E7=BA=BF=E6=9B=B4=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer-base/src/com/fr/design/actions/help/AboutPane.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/com/fr/design/actions/help/AboutPane.java b/designer-base/src/com/fr/design/actions/help/AboutPane.java index 1393f041b..14bcf98b2 100644 --- a/designer-base/src/com/fr/design/actions/help/AboutPane.java +++ b/designer-base/src/com/fr/design/actions/help/AboutPane.java @@ -9,7 +9,6 @@ import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.general.Inter; import com.fr.general.SiteCenter; @@ -34,6 +33,7 @@ public class AboutPane extends JPanel { private static final int DEFAULT_GAP = 12; private static final String COPYRIGHT_LABEL = "\u00A9 "; private static final String BUILD_PREFIX = " "; + private static final String COMPANY_TELEPHONE = SiteCenter.getInstance().acquireUrlByKind("company_telephone"); public AboutPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -90,7 +90,7 @@ public class AboutPane extends JPanel { if (FRContext.getLocale().equals(Locale.US)) { return; } - boxCenterAlignmentPane = new BoxCenterAligmentPane(Inter.getLocText("FR-Designer_Service_Phone") + SiteCenter.getInstance().acquireUrlByKind("service.phone." + FRContext.getLocale(), ProductConstants.COMPARE_TELEPHONE)); + boxCenterAlignmentPane = new BoxCenterAligmentPane(Inter.getLocText("FR-Designer_Service_Phone") + SiteCenter.getInstance().acquireUrlByKind("service.phone." + FRContext.getLocale(), COMPANY_TELEPHONE)); contentPane.add(boxCenterAlignmentPane); // 繁体版不显示QQ if (FRContext.getLocale().equals(Locale.TAIWAN)) { From 81f863f19174dedf359e12a35eb2a8edac4f1581 Mon Sep 17 00:00:00 2001 From: ju Date: Mon, 11 Jun 2018 15:51:33 +0800 Subject: [PATCH 13/15] =?UTF-8?q?CORE-87=20VT4FR=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/help/alphafine/AlphaFineConfigManager.java | 2 +- designer-chart/src/com/fr/design/chart/ChartTypePane.java | 2 +- .../com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java b/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java index b601a3429..1e2308f37 100644 --- a/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java +++ b/designer-base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java @@ -75,7 +75,7 @@ public class AlphaFineConfigManager implements XMLable { public static boolean isALPHALicAvailable() { - return FRContext.getCurrentEnv() != null && VT4FR.AlphaFine.support(); + return FRContext.getCurrentEnv() != null && VT4FR.AlphaFine.isSupport(); } @Override diff --git a/designer-chart/src/com/fr/design/chart/ChartTypePane.java b/designer-chart/src/com/fr/design/chart/ChartTypePane.java index 6f221922b..995b8370b 100644 --- a/designer-chart/src/com/fr/design/chart/ChartTypePane.java +++ b/designer-chart/src/com/fr/design/chart/ChartTypePane.java @@ -172,7 +172,7 @@ public class ChartTypePane extends ChartCommonWizardPane { } private boolean supportMap() { - return VT4FR.ChartMap.support(); + return VT4FR.ChartMap.isSupport(); } public void update(ChartCollection cc) { diff --git a/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java b/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java index 8e5471571..e470745be 100644 --- a/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java +++ b/designer-realize/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java @@ -69,7 +69,7 @@ public class ErrorInfoUploader { // 从云中心更新最新的解决方案文件 private void checkUpdateSolution() { - if (!VT4FR.AlphaFine.support()) { + if (!VT4FR.AlphaFine.isSupport()) { return; } From 3fa8978e30394ecba24f1ed38bdfb94152afaa25 Mon Sep 17 00:00:00 2001 From: richie Date: Mon, 11 Jun 2018 19:22:53 +0800 Subject: [PATCH 14/15] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20?= =?UTF-8?q?=E5=88=A0=E6=8E=89env=E4=B9=8B=E5=89=8D=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E6=B5=8B=E8=AF=95=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer-base/src/com/fr/env/RemoteEnv.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index e50da3169..9034d6c36 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -5,7 +5,6 @@ import com.fr.base.TableData; import com.fr.base.operator.common.CommonOperator; import com.fr.base.operator.connect.ConnectOperator; import com.fr.base.operator.file.FileOperator; -import com.fr.base.operator.file.SimpleFileOperator; import com.fr.base.operator.org.OrganizationOperator; import com.fr.base.remote.RemoteDeziConstants; import com.fr.common.rpc.RemoteCallServerConfig; @@ -127,11 +126,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return MessageSendExecutor.getInstance().execute(OrganizationOperator.class); } - @Override - public SimpleFileOperator getSimpleFileOperator() throws Exception { - return MessageSendExecutor.getInstance().execute(SimpleFileOperator.class); - } - @Override public RemoteEnvConfig getEnvConfig() { return config; From 2c1faac12d4c8d6926e597ee983d40013f88018d Mon Sep 17 00:00:00 2001 From: ju Date: Mon, 11 Jun 2018 23:08:10 +0800 Subject: [PATCH 15/15] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=201?= =?UTF-8?q?=E3=80=81=E5=AF=86=E7=A0=81=E4=B8=BA=E7=A9=BA=E6=97=B6=E6=9C=89?= =?UTF-8?q?=E6=8A=A5=E9=94=99=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=8B=202?= =?UTF-8?q?=E3=80=81=E6=8A=BD=E5=87=BADataOperator=EF=BC=88=E8=BF=98?= =?UTF-8?q?=E6=B2=A1=E8=B7=91=E9=80=9A=E6=95=B0=E6=8D=AE=E9=9B=86=E7=9A=84?= =?UTF-8?q?=E9=A2=84=E8=A7=88=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/DesignTableDataManager.java | 16 ++-- .../fr/design/data/datapane/ChoosePane.java | 7 +- .../connect/DatabaseConnectionPane.java | 4 +- .../datapane/preview/PreviewTablePane.java | 3 +- .../tabledatapane/ProcedureDataPane.java | 38 +++----- .../wrapper/StoreProcedureDataWrapper.java | 18 ++-- .../com/fr/design/file/TemplateTreePane.java | 2 +- .../fr/design/gui/ilist/TableViewList.java | 15 ++- designer-base/src/com/fr/env/RemoteEnv.java | 94 +++++-------------- 9 files changed, 75 insertions(+), 122 deletions(-) diff --git a/designer-base/src/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/com/fr/design/data/DesignTableDataManager.java index 91becffa8..635ba239a 100644 --- a/designer-base/src/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/com/fr/design/data/DesignTableDataManager.java @@ -1,6 +1,5 @@ package com.fr.design.data; -import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.base.StoreProcedureParameter; import com.fr.base.TableData; @@ -10,6 +9,7 @@ import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedureConstants; +import com.fr.data.operator.DataOperator; import com.fr.design.DesignModelAdapter; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.tabledata.wrapper.ServerTableDataWrapper; @@ -417,8 +417,7 @@ public abstract class DesignTableDataManager { */ private static EmbeddedTableData previewTableData(TableDataSource tableDataSource, TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception { final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar(); - Env currentEnv = FRContext.getCurrentEnv(); - ParameterProvider[] parameters = currentEnv.getTableDataParameters(tabledata); + ParameterProvider[] parameters = DataOperator.getInstance().getTableDataParameters(tabledata); if (ArrayUtils.isEmpty(parameters)) { parameters = tabledata.getParameters(Calculator.createCalculator()); } @@ -440,13 +439,13 @@ public abstract class DesignTableDataManager { loadingBar.start(); } try { - for (ParameterProvider parameter : currentEnv.getTableDataParameters(tabledata)) { + for (ParameterProvider parameter : DataOperator.getInstance().getTableDataParameters(tabledata)) { if (parameterMap.containsKey(parameter.getName())) { parameter.setValue(parameterMap.get(parameter.getName())); } } - return currentEnv.previewTableData(tableDataSource, tabledata, parameterMap, rowCount); - } catch (TableDataException e) { + return DataOperator.getInstance().previewTableData(tableDataSource, tabledata, parameterMap, rowCount); + } catch (Exception e) { throw new TableDataException(e.getMessage(), e); } finally { new Timer().schedule(new TimerTask() { @@ -510,11 +509,10 @@ public abstract class DesignTableDataManager { XMLPrintWriter writer = XMLPrintWriter.create(out); // 把storeProcedure写成xml文件到out DataCoreXmlUtils.writeXMLStoreProcedure(writer, storeProcedure, null); - Env currentEnv = FRContext.getCurrentEnv(); if (storeProcedure.getDataModelSize() > 0 && !storeProcedure.isFirstExpand()) { return storeProcedure.creatLazyDataModel(); } - ParameterProvider[] inParameters = currentEnv.getStoreProcedureParameters(storeProcedure); + ParameterProvider[] inParameters = DataOperator.getInstance().getStoreProcedureParameters(storeProcedure); final Map parameterMap = new HashMap(); if (inParameters.length > 0 && !ComparatorUtils.equals(threadLocal.get(), NO_PARAMETER)) {// 检查Parameter. final ParameterInputPane pPane = new ParameterInputPane(inParameters); @@ -529,7 +527,7 @@ public abstract class DesignTableDataManager { if (needLoadingBar) { StoreProcedureDataWrapper.loadingBar.start(); } - return FRContext.getCurrentEnv().previewProcedureDataModel(storeProcedure, parameterMap, 0); + return DataOperator.getInstance().previewProcedureDataModel(storeProcedure, parameterMap, 0); } public static void setThreadLocal(String value) { diff --git a/designer-base/src/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/com/fr/design/data/datapane/ChoosePane.java index 5fabd7c2b..8db095733 100644 --- a/designer-base/src/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/com/fr/design/data/datapane/ChoosePane.java @@ -9,6 +9,7 @@ import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.dialect.DialectFactory; import com.fr.data.impl.Connection; import com.fr.data.impl.DBTableData; +import com.fr.data.operator.DataOperator; import com.fr.dav.LocalEnv; import com.fr.design.DesignerEnvManager; import com.fr.design.beans.BasicBeanPane; @@ -449,7 +450,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha return TableData.EMPTY_TABLEDATA; } try { - connect = FRContext.getCurrentEnv().testConnection(database); + connect = DataOperator.getInstance().testConnection(database); } catch (Exception ignored) { } if (!connect) { @@ -468,7 +469,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha } else { try { TableData tableDataLocal = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(), DialectFactory.getDialectByName(paras.getDatabaseName()))); - tableData = FRContext.getCurrentEnv().previewTableData(tableDataLocal, java.util.Collections.EMPTY_MAP, + tableData = DataOperator.getInstance().previewTableData(tableDataLocal, java.util.Collections.EMPTY_MAP, DesignerEnvManager.getEnvManager().getMaxNumberOrPreviewRow()); } catch (Exception e) { failedToFindTable(); @@ -524,7 +525,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha } try { // daniel:增加参数 - colNames = FRContext.getCurrentEnv().getColumns(selectedDSName, paras.getSchemaName(), selectedTableObject); + colNames = DataOperator.getInstance().getColumns(selectedDSName, paras.getSchemaName(), selectedTableObject); } catch (Exception e2) { FRContext.getLogger().error(e2.getMessage(), e2); } diff --git a/designer-base/src/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java b/designer-base/src/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java index 94b38f681..c5666b81f 100644 --- a/designer-base/src/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java +++ b/designer-base/src/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java @@ -3,9 +3,9 @@ */ package com.fr.design.data.datapane.connect; -import com.fr.base.FRContext; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JNDIDatabaseConnection; +import com.fr.data.operator.DataOperator; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; @@ -118,7 +118,7 @@ public abstract class DatabaseConnectionPane implements ResponseDataSourceChange { private static final String[] DRIVERS = { "oracle.jdbc.driver.OracleDriver", @@ -194,7 +191,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp try { storeProcedureContext.setText(StringUtils.EMPTY); String connectionname = connectionTableProcedurePane.getSelectedDatabaseConnnectonName(); - String procedureText = FRContext.getCurrentEnv().getProcedureText(connectionname, storeprocedure.getQuery()); + String procedureText = DataOperator.getInstance().getProcedureText(connectionname, storeprocedure.getQuery()); storeProcedureContext.setText(procedureText); warningLabel.setText(StringUtils.EMPTY); } catch (Exception ex) { @@ -301,7 +298,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp text = text.trim(); String connectionname = this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName(); try { - String procedureText = FRContext.getCurrentEnv().getProcedureText(this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName(), text); + String procedureText = DataOperator.getInstance().getProcedureText(this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName(), text); // 获取参数默认值,例如:NAME in varchar2 default 'SCOTT',默认值为SCOTT String parameterDefaultValue = ""; @@ -315,22 +312,17 @@ public class ProcedureDataPane extends AbstractTableDataPane imp } StoreProcedureParameter[] newparameters; - newparameters = FRContext.getCurrentEnv().getStoreProcedureDeclarationParameters(connectionname, text, parameterDefaultValue); + newparameters = DataOperator.getInstance().getStoreProcedureDeclarationParameters(connectionname, text, parameterDefaultValue); editorPane.populate(newparameters); storeProcedureContext.setText(procedureText); warningLabel.setText(""); - } catch (SQLException sql) { - warningLabel.setText(Inter.getLocText(new String[]{"Database", "Datasource-Connection_failed"})); - storeProcedureContext.setText(""); - editorPane.populate(new StoreProcedureParameter[0]); } catch (Exception e) { - warningLabel.setText(e.getMessage()); + warningLabel.setText(Inter.getLocText(new String[]{"Database", "Datasource-Connection_failed"})); storeProcedureContext.setText(""); editorPane.populate(new StoreProcedureParameter[0]); } - return; } /** diff --git a/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java b/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java index d1ddeb502..845f03e32 100644 --- a/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java +++ b/designer-base/src/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java @@ -1,19 +1,11 @@ package com.fr.design.data.tabledata.wrapper; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.CancellationException; - -import javax.swing.Icon; -import javax.swing.JOptionPane; -import javax.swing.SwingWorker; - import com.fr.base.BaseUtils; import com.fr.base.FRContext; import com.fr.base.TableData; import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.storeproc.StoreProcedure; +import com.fr.data.operator.DataOperator; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.dialog.BasicDialog; @@ -24,6 +16,12 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; +import javax.swing.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CancellationException; + /** * StoreProcedureDataWrappe :存储过程的一个返回数据集,不是它本身。
* Oracle数据库肯定有它。SQL SERVER就不一定有了,大部分情况下都没有. @@ -191,7 +189,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { worker = new SwingWorker() { protected Void doInBackground() throws Exception { connectionBar.start(); - boolean status = FRContext.getCurrentEnv().testConnection(((StoreProcedure) getTableData()).getDatabaseConnection()); + boolean status = DataOperator.getInstance().testConnection(((StoreProcedure) getTableData()).getDatabaseConnection()); if (!status) { connectionBar.close(); // bug 61345 预览失败时,关闭窗口 diff --git a/designer-base/src/com/fr/design/file/TemplateTreePane.java b/designer-base/src/com/fr/design/file/TemplateTreePane.java index afb2a006a..a095595cf 100644 --- a/designer-base/src/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/com/fr/design/file/TemplateTreePane.java @@ -182,7 +182,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { } if (nodeFile.exists()) { String path = StableUtils.pathJoin(nodeFile.getEnvPath(), nodeFile.getPath()); - FileAssistUtils.moveToTrash(path); + FileAssistUtils.moveToTrash(nodeFile.getPath()); deleteHistory(path.replaceAll("/", "\\\\")); } else { JOptionPane.showMessageDialog(this, Inter.getLocText("Warning-Template_Do_Not_Exsit"), ProductConstants.PRODUCT_NAME, diff --git a/designer-base/src/com/fr/design/gui/ilist/TableViewList.java b/designer-base/src/com/fr/design/gui/ilist/TableViewList.java index 9f6014e33..01a951ea0 100644 --- a/designer-base/src/com/fr/design/gui/ilist/TableViewList.java +++ b/designer-base/src/com/fr/design/gui/ilist/TableViewList.java @@ -7,6 +7,7 @@ import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.dialect.DialectFactory; import com.fr.data.core.db.dialect.OracleDialect; import com.fr.data.impl.Connection; +import com.fr.data.operator.DataOperator; import com.fr.design.DesignerEnvManager; import com.fr.design.constants.UIConstants; import com.fr.design.mainframe.dnd.SerializableTransferable; @@ -17,7 +18,11 @@ import com.fr.stable.StringUtils; import javax.swing.*; import java.awt.*; -import java.awt.dnd.*; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceAdapter; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.MouseAdapter; @@ -90,7 +95,7 @@ public class TableViewList extends UIList { int count = 3; //总共给3次连接的机会 while (!status && count > 0) { - status = FRContext.getCurrentEnv().testConnection(datasource); + status = DataOperator.getInstance().testConnection(datasource); count--; } if (!status) { @@ -133,9 +138,9 @@ public class TableViewList extends UIList { String[] schemas = DataCoreUtils.getDatabaseSchema(datasource); searchFilter = searchFilter.toLowerCase(); - - - boolean isOracle = FRContext.getCurrentEnv().isOracle(datasource); + + + boolean isOracle = DataOperator.getInstance().isOracle(datasource); boolean isOracleSystemSpace = DesignerEnvManager.getEnvManager().isOracleSystemSpace(); // oracleb不勾选显示所有表,则只显示用户下的(包括存储过程和table表) if (isOracle && !isOracleSystemSpace) { diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index 9034d6c36..d2f178aea 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -1,7 +1,6 @@ package com.fr.env; import com.fr.base.EnvException; -import com.fr.base.TableData; import com.fr.base.operator.common.CommonOperator; import com.fr.base.operator.connect.ConnectOperator; import com.fr.base.operator.file.FileOperator; @@ -12,8 +11,6 @@ import com.fr.common.rpc.netty.MessageSendExecutor; import com.fr.common.rpc.netty.RemoteCallClient; import com.fr.core.env.EnvConstants; import com.fr.core.env.EnvContext; -import com.fr.data.TableDataSource; -import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.dav.AbstractEnv; import com.fr.dav.DavXMLUtils; @@ -23,6 +20,7 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.file.CacheManager; import com.fr.general.CommonIOUtils; import com.fr.general.ComparatorUtils; +import com.fr.general.EnvProxyFactory; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.general.http.HttpToolbox; @@ -110,9 +108,28 @@ public class RemoteEnv extends AbstractEnv implements DesignAut MessageSendExecutor.getInstance().stop(); return true; } - + + @Override + public EnvProxyFactory getProxyFactory() { + + return new EnvProxyFactory() { + + @Override + public T get(Class clazz, T obj) { + + assert clazz != null; + try { + return MessageSendExecutor.getInstance().execute(clazz); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }; + } + @Override public FileOperator getFileOperator() throws Exception { + return MessageSendExecutor.getInstance().execute(FileOperator.class); } @@ -125,7 +142,7 @@ public class RemoteEnv extends AbstractEnv implements DesignAut public OrganizationOperator getOrganizationOperator() throws Exception { return MessageSendExecutor.getInstance().execute(OrganizationOperator.class); } - + @Override public RemoteEnvConfig getEnvConfig() { return config; @@ -205,7 +222,7 @@ public class RemoteEnv extends AbstractEnv implements DesignAut * @param in InputStream输入流 * @return 转换后的字符串 */ - public static String stream2String(InputStream in) { + private static String stream2String(InputStream in) { if (in == null) { return null; } @@ -224,7 +241,7 @@ public class RemoteEnv extends AbstractEnv implements DesignAut * @return 测试连接成功返回true * @throws Exception 异常 */ - public boolean testServerConnection() throws Exception { + private boolean testServerConnection() throws Exception { return testConnection(true, true, DesignerContext.getDesignerFrame()); } @@ -426,67 +443,8 @@ public class RemoteEnv extends AbstractEnv implements DesignAut return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); } - - @Override - public EmbeddedTableData previewTableData(Object tableData, Map parameterMap, int rowCount) throws Exception { - return previewTableData(null, tableData, parameterMap, rowCount); - } - - /** - * 根据指定的参数生成一个实际可预览的数据集 - * - * @param tableData 带参数的数据集 - * @param parameterMap 参数键值对 - * @param rowCount 需要获取的行数 - * @return 实际的二维数据集 - * @throws Exception 如果生成数据失败则抛出此异常 - */ - @Override - public EmbeddedTableData previewTableData(TableDataSource dataSource, Object tableData, java.util.Map parameterMap, int rowCount) throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - // 把tableData写成xml文件到out - DavXMLUtils.writeXMLFileTableDataAndSource((TableData) tableData, out); - - // 把parameterMap转成JSON格式的字符串 - JSONObject jo = new JSONObject(parameterMap); - String jsonParameter = jo.toString(); - HashMap para = new HashMap<>(); - para.put("op", "fr_remote_design"); - para.put("cmd", "design_preview_td"); - para.put("pars", jsonParameter); - para.put("rowcount", String.valueOf(rowCount)); - InputStream input = postBytes2ServerB(out.toByteArray(), para); - - if (input == null) { - return null; - } - - return (EmbeddedTableData) DavXMLUtils.readXMLTableData(input); - } - - /** - * 根据指定的参数生成一个实际可预览的数据集 - * - * @param tableData 带参数的数据集 - * @param parameterMap 参数键值对 - * @param start 开始 - * @param end 结尾 - * @param cols 列名 - * @param colIdx 列序号 - * @return 实际的二位数据条 - * @throws Exception 异常 - */ - @Override - public Object previewTableData(Object tableData, java.util.Map parameterMap, int start, int end, String[] cols, int[] colIdx) throws Exception { - return previewTableData(tableData, parameterMap, -1); - } - - @Override - public Object previewTableData(TableDataSource dataSource, Object tableData, Map parameterMap, int start, int end, String[] cols, int[] colIdx) throws Exception { - return previewTableData(dataSource, tableData, parameterMap, -1); - } - + + /** * nameValuePairs,这个参数要接着this.path,拼成一个URL,否则服务器端req.getParameter是无法得到的 *