From c004e4172b8b7890fcf8a552c58be647ddd41931 Mon Sep 17 00:00:00 2001 From: author Date: Thu, 10 Oct 2019 16:17:36 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-22587=20=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86=EF=BC=8C=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E4=BA=A4=E4=BA=92=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/upm/UpmFinder.java | 29 ++++++-- .../java/com/fr/design/upm/UpmShowPane.java | 69 ++++++++++--------- 2 files changed, 60 insertions(+), 38 deletions(-) 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 cf7716aa37..5238b0c657 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,7 @@ package com.fr.design.upm; import com.fr.base.FRContext; +import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader; import com.fr.design.dialog.UIDialog; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; @@ -8,6 +9,7 @@ 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.log.FineLoggerFactory; import com.fr.stable.StableUtils; import com.fr.workspace.Workspace; import com.fr.workspace.WorkspaceEvent; @@ -60,11 +62,30 @@ public class UpmFinder { flag = false; } if (flag) { - UpmShowPane upmPane = new UpmShowPane(); - if (dialog == null) { - dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane); + if (!checkUPMResourcesExist()){ + // upm下载 + int val = JOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Install"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); + if (val == JOptionPane.OK_OPTION){ + try { + UpmResourceLoader.INSTANCE.download(); + UpmResourceLoader.INSTANCE.install(); + JOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE); + } catch (Exception e){ + FineLoggerFactory.getLogger().error(e.getMessage(), e); + JOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Updater_Download_Failed"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE); + } + } + } + else { + UpmShowPane upmPane = new UpmShowPane(); + if (dialog == null) { + dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane); + } + dialog.setVisible(true); } - dialog.setVisible(true); } else { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message")); UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java b/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java index 31e44c8ab1..1bc4b9e948 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java @@ -29,40 +29,41 @@ public class UpmShowPane extends BasicPane { UpmShowPane() { setLayout(new BorderLayout()); - if (UpmFinder.checkUPMResourcesExist()) { - modernUIPane = new ModernUIPane.Builder<>() - .prepare(new ScriptContextAdapter() { - @Override - public void onScriptContextCreated(ScriptContextEvent event) { - JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); - window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser())); - } - }) - .withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()) - .build(); - EventDispatcher.listen(DownloadEvent.UPDATE, new Listener() { - @Override - public void on(Event event, String param) { - modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); - } - }); - } else { - modernUIPane = new ModernUIPane.Builder<>() - .withComponent(WarnComponent.KEY) - .prepare(new ScriptContextAdapter() { - @Override - public void onScriptContextCreated(ScriptContextEvent event) { - JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); - window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser())); - } - }).build(); - EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener() { - @Override - public void on(Event event, String param) { - modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); - } - }); - } +// 先屏蔽掉这个判断,后续可能修改交互 +// if (UpmFinder.checkUPMResourcesExist()) { + modernUIPane = new ModernUIPane.Builder<>() + .prepare(new ScriptContextAdapter() { + @Override + public void onScriptContextCreated(ScriptContextEvent event) { + JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); + window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser())); + } + }) + .withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()) + .build(); + EventDispatcher.listen(DownloadEvent.UPDATE, new Listener() { + @Override + public void on(Event event, String param) { + modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); + } + }); +// } else { +// modernUIPane = new ModernUIPane.Builder<>() +// .withComponent(WarnComponent.KEY) +// .prepare(new ScriptContextAdapter() { +// @Override +// public void onScriptContextCreated(ScriptContextEvent event) { +// JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); +// window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser())); +// } +// }).build(); +// EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener() { +// @Override +// public void on(Event event, String param) { +// modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); +// } +// }); +// } add(modernUIPane, BorderLayout.CENTER); } }