From fd6832105343d5142ec7cfa9bf6b25c07691869d Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 27 May 2021 22:42:12 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-52942=20=E5=A4=84=E7=90=86=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=8F=90=E5=88=B0=E5=85=AC=E5=85=B1=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=A8=8D=E5=90=8E=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/app/AbstractWorkBookApp.java | 65 +-------------- .../mainframe/app/DesignerAppUtils.java | 83 +++++++++++++++++++ .../com/fr/design/mainframe/app/FormApp.java | 1 + 3 files changed, 85 insertions(+), 64 deletions(-) create mode 100644 designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/AbstractWorkBookApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/AbstractWorkBookApp.java index 4f22528c7..60ce295a3 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/AbstractWorkBookApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/AbstractWorkBookApp.java @@ -1,31 +1,16 @@ package com.fr.design.mainframe.app; import com.fr.base.Parameter; -import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.dialog.UIExpandDialog; -import com.fr.design.extra.exe.callback.InstallOnlineCallback; -import com.fr.design.extra.exe.callback.ModifyStatusCallback; -import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.App; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JWorkBook; import com.fr.design.worker.open.OpenResult; import com.fr.design.worker.open.OpenWorker; import com.fr.file.FILE; -import com.fr.io.TemplateIOErrorUtils; import com.fr.log.FineLoggerFactory; import com.fr.main.impl.WorkBook; -import com.fr.plugin.context.PluginMarker; -import com.fr.plugin.context.PluginMarkerAdapter; -import com.fr.plugin.manage.PluginManager; -import com.fr.plugin.manage.control.PluginControllerHelper; -import com.fr.plugin.manage.control.PluginTask; import com.fr.report.worksheet.WorkSheet; -import com.fr.third.guava.collect.Multimap; -import com.fr.workspace.WorkContext; -import java.util.Collection; import java.util.concurrent.Callable; /** @@ -48,7 +33,7 @@ abstract class AbstractWorkBookApp implements App { @Override public OpenResult call() { WorkBook workBook = asIOFile(tplFile); - dealWithTemplateIOError(tplFile.getPath()); + DesignerAppUtils.dealWithTemplateIOError(tplFile.getPath()); return new OpenResult<>(workBook, workBook.getParameters()); } }, emptyTemplate); @@ -68,54 +53,6 @@ abstract class AbstractWorkBookApp implements App { return emptyTemplate; } - private void dealWithTemplateIOError(String path) { - // 试图获取多行读取错误提示并缓存待处理列表 - String detail = TemplateIOErrorUtils.dealWithErrorDetailMultiLineAndCache(path); - if (detail.length() > 0) { - if (WorkContext.getCurrent().isLocal()) { - UIExpandDialog.Builder() - .owner(DesignerContext.getDesignerFrame()) - .title(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")) - .message(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_Message_Local")) - .detail(detail) - .okText(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_OK_Btn")) - .cancelText(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_Cancel_Btn")) - .dialogActionListener(new DialogActionAdapter() { - public void doOk() { - installAndEnablePlugin(path); - } - - @Override - public void doCancel() { - TemplateIOErrorUtils.invalidatePlugins(path); - } - }).build().setVisible(true); - } else { - UIExpandDialog.Builder().owner(DesignerContext.getDesignerFrame()) - .title(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")) - .message(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_Message_Remote")) - .detail(detail) - .build() - .setVisible(true); - } - - } - } - - public void installAndEnablePlugin(String key) { - Multimap stringPluginMarkerAdapterMultimap = TemplateIOErrorUtils.popPluginInfoMap(key); - Collection disablePlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorUtils.DISABLE_PLUGIN); - for (PluginMarkerAdapter disablePlugin : disablePlugins) { - PluginManager.getController().enable(disablePlugin, new ModifyStatusCallback(false)); - } - - Collection uninstallPlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorUtils.NOT_INSTALLED_PLUGIN); - for (PluginMarker uninstallPlugin : uninstallPlugins) { - PluginTask pluginTask = PluginTask.installTask(uninstallPlugin); - PluginControllerHelper.installOnline(uninstallPlugin, new InstallOnlineCallback(pluginTask)); - } - } - @Override public String mark4Provider() { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java new file mode 100644 index 000000000..4ac1a273a --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java @@ -0,0 +1,83 @@ +package com.fr.design.mainframe.app; + +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.UIExpandDialog; +import com.fr.design.extra.exe.callback.InstallOnlineCallback; +import com.fr.design.extra.exe.callback.ModifyStatusCallback; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.ui.util.UIUtil; +import com.fr.io.TemplateIOErrorUtils; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.context.PluginMarkerAdapter; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.PluginControllerHelper; +import com.fr.plugin.manage.control.PluginTask; +import com.fr.third.guava.collect.Multimap; +import com.fr.workspace.WorkContext; + +import java.util.Collection; + +/** + * 设计器app共用工具类 + * + * @author vito + * @version 10.0 + * Created by vito on 2021/5/27 + */ +public class DesignerAppUtils { + + /** + * 处理模板读取时的异常 + * + * @param path 模板路径 + */ + public static void dealWithTemplateIOError(String path) { + // 试图获取多行读取错误提示并缓存待处理列表 + String detail = TemplateIOErrorUtils.dealWithErrorDetailMultiLineAndCache(path); + if (detail.length() > 0) { + UIUtil.invokeLaterIfNeeded(() -> { + if (WorkContext.getCurrent().isLocal()) { + UIExpandDialog.Builder() + .owner(DesignerContext.getDesignerFrame()) + .title(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")) + .message(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_Message_Local")) + .detail(detail) + .okText(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_OK_Btn")) + .cancelText(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_Cancel_Btn")) + .dialogActionListener(new DialogActionAdapter() { + public void doOk() { + installAndEnablePlugin(path); + } + + @Override + public void doCancel() { + TemplateIOErrorUtils.invalidatePlugins(path); + } + }).build().setVisible(true); + } else { + UIExpandDialog.Builder().owner(DesignerContext.getDesignerFrame()) + .title(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")) + .message(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_Message_Remote")) + .detail(detail) + .build() + .setVisible(true); + } + }); + } + } + + private static void installAndEnablePlugin(String key) { + Multimap stringPluginMarkerAdapterMultimap = TemplateIOErrorUtils.popPluginInfoMap(key); + Collection disablePlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorUtils.DISABLE_PLUGIN); + for (PluginMarkerAdapter disablePlugin : disablePlugins) { + PluginManager.getController().enable(disablePlugin, new ModifyStatusCallback(false)); + } + + Collection uninstallPlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorUtils.NOT_INSTALLED_PLUGIN); + for (PluginMarker uninstallPlugin : uninstallPlugins) { + PluginTask pluginTask = PluginTask.installTask(uninstallPlugin); + PluginControllerHelper.installOnline(uninstallPlugin, new InstallOnlineCallback(pluginTask)); + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java index 5d828713f..511c98e62 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java @@ -63,6 +63,7 @@ class FormApp extends AbstractAppProvider { @Override public OpenResult call() throws Exception { Form form = asIOFile(tplFile); + DesignerAppUtils.dealWithTemplateIOError(tplFile.getPath()); return new OpenResult<>(form, form.getParameters()); } }, emptyForm);