From 3b2ad83c5c3d8e8a73d4020e712fb38ca050a2c5 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Tue, 27 Feb 2018 18:56:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=90=9C=E7=B4=A2=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/WebViewDlgHelper.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/WebViewDlgHelper.java b/designer_base/src/com/fr/design/extra/WebViewDlgHelper.java index 16eb611921..59fb612765 100644 --- a/designer_base/src/com/fr/design/extra/WebViewDlgHelper.java +++ b/designer_base/src/com/fr/design/extra/WebViewDlgHelper.java @@ -5,6 +5,7 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.mainframe.DesignerContext; +import com.fr.general.CommonIOUtils; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.IOUtils; @@ -22,9 +23,7 @@ import javax.swing.SwingWorker; import java.awt.BorderLayout; import java.awt.Component; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; +import java.io.IOException; import java.lang.reflect.Constructor; import java.net.HttpURLConnection; import java.util.concurrent.ExecutionException; @@ -94,27 +93,17 @@ public class WebViewDlgHelper { public static void checkAndCopyMainFile(String indexPath, String mainJsPath) { File file = new File(indexPath); if (!file.exists()) { - copyMainFile(indexPath, mainJsPath); + copyMainFile(mainJsPath); } } /** * 將script文件夹中的plugin.html文件复制到webreport下 */ - public static void copyMainFile(String indexPath, String mainJsPath) { + private static void copyMainFile(String mainJsPath) { try { - File mainJsFile = new File(mainJsPath); - int byteread = 0; - if (mainJsFile.exists()) { - InputStream inStream = new FileInputStream(mainJsPath); - FileOutputStream fs = new FileOutputStream(indexPath); - byte[] buffer = new byte[BYTES_NUM]; - while ((byteread = inStream.read(buffer)) != -1) { - fs.write(buffer, 0, byteread); - } - inStream.close(); - } - } catch (Exception e) { + CommonIOUtils.copy(new File(mainJsPath), new File(installHome)); + } catch (IOException e) { FRContext.getLogger().error(e.getMessage()); } } @@ -129,6 +118,17 @@ public class WebViewDlgHelper { createPluginDialog(); } + /** + * 以关键词打开设计器商店显示搜索结果 + * + * @param keyword + * @param data + */ + public static void showPluginInStore(String keyword, String data) { + PluginWebBridge.getHelper().showResultInStore(keyword, data); + createPluginDialog(); + } + public static void createLoginDialog() { if (StableUtils.getMajorJavaVersion() == VERSION_8) { File file = new File(StableUtils.pathJoin(installHome, "scripts")); @@ -230,7 +230,7 @@ public class WebViewDlgHelper { if (get()) { String relativePath = "/scripts/plugin.html"; IOUtils.unzip(new File(StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE)), installHome); - copyMainFile(StableUtils.pathJoin(installHome, "plugin.html"), StableUtils.pathJoin(installHome, relativePath)); + 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);