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 5b90d4330..7f084f823 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 @@ -2,11 +2,16 @@ package com.fr.design.upm; import com.fr.base.FRContext; import com.fr.design.dialog.UIDialog; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.update.domain.UpdateConstants; +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.stable.project.ProjectConstants; import com.fr.workspace.Workspace; import com.fr.workspace.WorkspaceEvent; @@ -51,11 +56,32 @@ public class UpmFinder { } public static void showUPMDialog() { - UpmShowPane upmPane = new UpmShowPane(); - if (dialog == null) { - dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane); + boolean flag = false; + File file = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LIB_NAME)); + File[] files = file.listFiles(); + if (files != null) { + for (File file1 : files) { + if (file1.getName().contains(UpdateConstants.JXBROWSER)) { + flag = true; + break; + } + } + }else { + FineLoggerFactory.getLogger().error("Designer lib can not be null"); + } + if (flag) { + UpmShowPane upmPane = new UpmShowPane(); + if (dialog == null) { + dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane); + } + dialog.setVisible(true); + } else { + FineLoggerFactory.getLogger().error("jsxb false"); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message")); + UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); + dialog.setAutoUpdateAfterInit(); + dialog.showDialog(); } - dialog.setVisible(true); } public static void closeWindow() { 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 834600e53..31e44c8ab 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 @@ -1,26 +1,16 @@ package com.fr.design.upm; import com.fr.design.dialog.BasicPane; -import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.ui.ModernUIPane; -import com.fr.design.update.domain.UpdateConstants; -import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.design.upm.event.DownloadEvent; 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.stable.project.ProjectConstants; import com.teamdev.jxbrowser.chromium.JSValue; import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; -import javax.swing.*; import java.awt.*; -import java.io.File; -import java.io.FileNotFoundException; /** * @author richie @@ -39,61 +29,40 @@ public class UpmShowPane extends BasicPane { UpmShowPane() { setLayout(new BorderLayout()); - boolean flag = false; - File file = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),ProjectConstants.LIB_NAME)); - File[] files = file.listFiles(); - if (files != null) { - for (File file1 : files) { - if (file1.getName().contains(UpdateConstants.JXBROWSER)) { - flag = true; - break; + 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 { - FineLoggerFactory.getLogger().error("Designer lib can not be null"); - } - if (flag) { - 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()); - } - }); - } + }); } else { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message")); - UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); - dialog.setAutoUpdateAfterInit(); - dialog.showDialog(); + 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); } - }