From e69e76edcae88ce27109fd91e269fa5b5698067e Mon Sep 17 00:00:00 2001 From: Lanlan Date: Wed, 9 Feb 2022 16:00:28 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-9974=20=E3=80=90=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E9=97=B4=E9=80=9A=E4=BF=A1=E3=80=91RPC=E7=A7=BB=E9=99=A4-?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=95=86=E5=9F=8E=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/WebViewDlgHelper.java | 23 ++++++++------ .../java/com/fr/design/upm/UpmFinder.java | 31 +++++++++++++------ .../fr/start/module/DesignerActivator.java | 4 +++ 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java b/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java index f35fbdf11..f671f220b 100644 --- a/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java +++ b/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java @@ -1,6 +1,6 @@ package com.fr.design.extra; -import com.fr.base.FRContext; +import com.fr.decision.webservice.v10.plugin.helper.category.impl.PluginResourceLoader; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.UIDialog; @@ -15,12 +15,12 @@ import com.fr.general.IOUtils; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.PluginStoreConfig; import com.fr.plugin.PluginStoreConstants; import com.fr.stable.CommonUtils; 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,15 +44,15 @@ public class WebViewDlgHelper { private static final String LATEST = "latest"; private static final String SHOP_SCRIPTS = "shop_scripts"; private static final int VERSION_8 = 8; - private static String installHome = FRContext.getCommonOperator().getWebRootPath(); + private static String installHome = PluginStoreConstants.getLocalInstallHome(); private static final String MAIN_JS_PATH = "/scripts/plugin.html"; - private static final String ENV_VERSION = "ENV_VERSION"; static { GeneralContext.addEnvChangedListener(new EnvChangedListener() { @Override public void envChanged() { - installHome = FRContext.getCommonOperator().getWebRootPath(); + installHome = PluginStoreConstants.getLocalInstallHome(); + PluginResourceLoader.INSTANCE.checkOldShopFile(); } }); } @@ -74,8 +74,11 @@ public class WebViewDlgHelper { } return; } - String jar_version = PluginStoreConstants.getProps(ENV_VERSION, StringUtils.EMPTY); - if (ComparatorUtils.equals(jar_version, ProductConstants.VERSION)) { + // 检测更新前先刷新一下版本号 + PluginStoreConstants.refreshProps(); + + String jarVersion = PluginStoreConfig.getInstance().getEnvVersion(); + if (ComparatorUtils.equals(jarVersion, ProductConstants.VERSION)) { updateShopScripts(SHOP_SCRIPTS); showPluginDlg(); } else { @@ -133,7 +136,7 @@ public class WebViewDlgHelper { * * @param filePath 待删除文件路径 */ - private static void deleteExtraFile(String filePath){ + private static void deleteExtraFile(String filePath) { CommonIOUtils.deleteFile(new File(filePath)); } @@ -259,7 +262,7 @@ public class WebViewDlgHelper { try { if (get()) { File scriptZip = new File(StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE)); - if(scriptZip.exists()){ + if (scriptZip.exists()) { IOUtils.unzip(scriptZip, installHome); CommonUtils.deleteFile(scriptZip); } @@ -283,7 +286,7 @@ public class WebViewDlgHelper { protected Void doInBackground() throws Exception { String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.update"); if (url != null) { - String text = HttpToolbox.get(url + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginStoreConstants.getProps("VERSION")); + String text = HttpToolbox.get(url + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginStoreConfig.getInstance().getVersion()); JSONObject resultJSONObject = new JSONObject(text); String isLatest = resultJSONObject.optString("result"); if (!ComparatorUtils.equals(isLatest, LATEST)) { diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java index f3284c11e..576c5a9b9 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java @@ -1,6 +1,6 @@ package com.fr.design.upm; -import com.fr.base.FRContext; +import com.fr.decision.webservice.v10.plugin.helper.category.impl.BaseResourceLoader; import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.UIDialog; @@ -12,8 +12,11 @@ import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; +import com.fr.general.CommonIOUtils; import com.fr.general.GeneralContext; +import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.PluginStoreConstants; import com.fr.stable.StableUtils; import com.fr.workspace.Workspace; import com.fr.workspace.WorkspaceEvent; @@ -33,7 +36,7 @@ public class UpmFinder { private static final String MAIN_RESOURCE_PATH = UPM_DIR + "/plugin_design.html"; private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser"; - public static String installHome = FRContext.getCommonOperator().getWebRootPath(); + public static String installHome = PluginStoreConstants.getLocalInstallHome(); private static UIDialog dialog = null; @@ -41,7 +44,8 @@ public class UpmFinder { EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { @Override public void on(Event event, Workspace param) { - installHome = FRContext.getCommonOperator().getWebRootPath(); + installHome = PluginStoreConstants.getLocalInstallHome(); + UpmResourceLoader.INSTANCE.checkOldShopFile(); } }); } @@ -75,24 +79,24 @@ public class UpmFinder { } private static void showUpmPane() { - if (!checkUPMResourcesExist()){ + if (!checkUPMResourcesExist()) { // upm下载 int val = FineJOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Install"), Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); - if (val == JOptionPane.OK_OPTION){ + if (val == JOptionPane.OK_OPTION) { try { UpmResourceLoader.INSTANCE.download(); - UpmResourceLoader.INSTANCE.install(); + installUpmResource(); + FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"), Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Updater_Download_Failed"), Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE); } } - } - else { + } else { UpmShowPane upmPane = new UpmShowPane(); if (dialog == null) { dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane); @@ -102,6 +106,15 @@ public class UpmFinder { } } + private static void installUpmResource() { + String installHome = PluginStoreConstants.getLocalInstallHome(); + File scriptZip = new File(BaseResourceLoader.SCRIPT_DOWNLOAD_PATH); + if (scriptZip.exists()) { + IOUtils.unzip(scriptZip, installHome); + CommonIOUtils.deleteFile(scriptZip); + } + } + private static void showUpdatePane() { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message")); if (!GeneralContext.getLocale().equals(Locale.JAPANESE) && !GeneralContext.getLocale().equals(Locale.JAPAN) diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index eea3360ba..be583c7d5 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -12,6 +12,8 @@ import com.fr.chart.chartattr.ChartCollection; import com.fr.config.MarketConfig; import com.fr.config.ServerPreferenceConfig; import com.fr.decision.update.backup.RecoverManager; +import com.fr.decision.webservice.v10.plugin.helper.category.impl.PluginResourceLoader; +import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.NewFormAction; @@ -180,6 +182,8 @@ public class DesignerActivator extends Activator implements Prepare { AlphaFineHelper.switchConfig4Locale(); RecoverManager.register(new RecoverForDesigner()); pushUpdateTask.run(); + PluginResourceLoader.INSTANCE.checkOldShopFile(); + UpmResourceLoader.INSTANCE.checkOldShopFile(); } @Override