diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 7d2fc6106..4cc6b7fa3 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -1,7 +1,7 @@ package com.fr.design; import com.fr.common.report.ReportState; -import com.fr.decision.webservice.v10.plugin.helper.PluginErrorRemindHandler; +import com.fr.design.plugin.remind.PluginErrorDesignReminder; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; @@ -35,7 +35,6 @@ import com.fr.process.engine.core.FineProcessContext; import com.fr.rpc.Result; import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; -import com.fr.env.PluginErrorRemindDialog; import com.fr.start.server.ServerTray; import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContextCallback; @@ -139,7 +138,7 @@ public class EnvChangeEntrance { if (template != null) { template.refreshToolArea(); } - pluginErrorRemind(); + PluginErrorDesignReminder.getInstance().remindStartFailedPlugins(); } catch (Exception exception) { // 失败的处理 WorkspaceExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); @@ -245,28 +244,6 @@ public class EnvChangeEntrance { } } - /** - * 插件启动错误信息提示 - */ - public void pluginErrorRemind() { - if (!WorkContext.getCurrent().isLocal()) { - return; - } - - String content = PluginErrorRemindHandler.pluginErrorContent(); - if (StringUtils.isNotEmpty(content)) { - // 该操作需要在当前awt操作之后执行,使用SwingUtilities.invokeLater将其置于awt操作对列末尾 - // 若使用UIUtil.invokeLaterIfNeeded,会立即执行,影响其他UI操作 - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - PluginErrorRemindDialog dialog = new PluginErrorRemindDialog(DesignerContext.getDesignerFrame(), content); - dialog.setVisible(true); - } - }); - } - } - /** * 判断是否需要做版本验证,判断依据为 * 1、选择的环境为远程环境 diff --git a/designer-base/src/main/java/com/fr/design/notification/NotificationCenter.java b/designer-base/src/main/java/com/fr/design/notification/NotificationCenter.java index 3faadf795..12e3503a0 100644 --- a/designer-base/src/main/java/com/fr/design/notification/NotificationCenter.java +++ b/designer-base/src/main/java/com/fr/design/notification/NotificationCenter.java @@ -2,6 +2,8 @@ package com.fr.design.notification; import com.fr.design.notification.ui.NotificationCenterPane; +import com.fr.stable.StringUtils; + import java.util.ArrayList; import java.util.List; @@ -30,6 +32,15 @@ public class NotificationCenter { NotificationCenterPane.getNotificationCenterPane().refreshButton(); } + /** + * 通过messageId删除消息 + * @param messageID + */ + public void removeNotificationByMessageID(String messageID) { + notifications.removeIf(notification -> StringUtils.equals(notification.getMessageId(), messageID)); + NotificationCenterPane.getNotificationCenterPane().refreshButton(); + } + public Notification getNotification(int index){ return notifications.get(index); } diff --git a/designer-base/src/main/java/com/fr/design/plugin/remind/PluginErrorDesignReminder.java b/designer-base/src/main/java/com/fr/design/plugin/remind/PluginErrorDesignReminder.java new file mode 100644 index 000000000..e5691d570 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/plugin/remind/PluginErrorDesignReminder.java @@ -0,0 +1,126 @@ +package com.fr.design.plugin.remind; + +import com.fr.design.dialog.NotificationDialogAction; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.notification.Notification; +import com.fr.design.notification.NotificationCenter; +import com.fr.plugin.error.PluginErrorRemindHandler; +import com.fr.plugin.error.PluginErrorReminder; +import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; +import com.fr.workspace.WorkContext; + +import javax.swing.SwingUtilities; +import java.util.List; + +/** + * 插件错误信息提醒-设计器模块 + * + * @author Yvan + */ +public class PluginErrorDesignReminder implements PluginErrorReminder { + + private static final String MESSAGE_ID = "plugin-invalidate-remind"; + private static final String COMMA = "、"; + private static final String COLON = ":"; + private static final String NEW_LINE_TAG_HEAD = "
"; + private static final String NEW_LINE_TAG_TAIL = "
"; + + private static class Holder { + private static final PluginErrorDesignReminder INSTANCE = new PluginErrorDesignReminder(); + } + + private PluginErrorDesignReminder() {} + + public static PluginErrorDesignReminder getInstance() { + return Holder.INSTANCE; + } + + @Override + public void remindStartFailedPlugins() { + + if (!WorkContext.getCurrent().isLocal()) { + return; + } + String content = PluginErrorRemindHandler.pluginErrorContent(); + if (StringUtils.isNotEmpty(content)) { + // 该操作需要在当前awt操作之后执行,使用SwingUtilities.invokeLater将其置于awt操作对列末尾 + // 若使用UIUtil.invokeLaterIfNeeded,会立即执行,影响其他UI操作 + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + PluginStartFailedRemindDialog dialog = new PluginStartFailedRemindDialog(DesignerContext.getDesignerFrame(), content); + dialog.setVisible(true); + } + }); + } + } + + @Override + public void remindInvalidatePlugins() { + + if (!WorkContext.getCurrent().isLocal()) { + return; + } + // 获取失效插件名称列表 + List embedPluginNames = PluginErrorRemindHandler.getInvalidateEmbedPluginNames(); + if (embedPluginNames.size() > 0) { + // 构建消息 + String message = generateMessageContent(embedPluginNames); + Notification notification = generateNotification(message, embedPluginNames); + // 添加消息 + NotificationCenter.getInstance().addNotification(notification); + } + } + + /** + * 构建消息内容 + * @param invalidatePluginNames + * @return + */ + private String generateMessageContent(List invalidatePluginNames) { + return new StringBuilder() + .append(NEW_LINE_TAG_HEAD) + .append(Toolkit.i18nText("Fine-Design_Plugin_Embed_Notice")) + .append(COLON) + .append(NEW_LINE_TAG_TAIL) + .append(NEW_LINE_TAG_HEAD) + .append(StableUtils.join(invalidatePluginNames, COMMA)) + .append(NEW_LINE_TAG_TAIL) + .append(NEW_LINE_TAG_HEAD) + .append(Toolkit.i18nText("Fine-Design_Plugin_Embed_Description")) + .append(NEW_LINE_TAG_TAIL) + .toString(); + } + + /** + * 构建通知对象 + * @param message + * @param invalidatePluginNames + * @return + */ + private Notification generateNotification(String message, List invalidatePluginNames) { + return new Notification( + MESSAGE_ID, + Notification.WARNING_MESSAGE, + message, + new NotificationDialogAction() { + @Override + public String name() { + return "plugin-invalidate-remind-show"; + } + + @Override + public void doClick() { + PluginInvalidateRemindDialog remindDialog = new PluginInvalidateRemindDialog( + DesignerContext.getDesignerFrame(), + invalidatePluginNames, + PluginErrorRemindHandler.getInvalidateEmbedPluginMarkers(), + MESSAGE_ID); + remindDialog.setVisible(true); + } + } + ); + } +} diff --git a/designer-base/src/main/java/com/fr/design/plugin/remind/PluginInvalidateRemindDialog.java b/designer-base/src/main/java/com/fr/design/plugin/remind/PluginInvalidateRemindDialog.java new file mode 100644 index 000000000..c432f3be8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/plugin/remind/PluginInvalidateRemindDialog.java @@ -0,0 +1,212 @@ +package com.fr.design.plugin.remind; + +import com.fr.design.actions.UpdateAction; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.DesignSizeI18nManager; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.notification.NotificationCenter; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; +import com.fr.general.IOUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.PluginTaskCallback; +import com.fr.plugin.manage.control.PluginTaskResult; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextPane; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +/** + * @author Yvan + */ +public class PluginInvalidateRemindDialog extends JDialog implements ActionListener{ + + /** + * 因内置而失效的插件Marker列表 + */ + private List pluginMarkers; + + /** + * 因内置而失效的插件名称列表 + */ + private List pluginNames; + + /** + * 本弹窗对应的消息的id + * 方便弹窗逻辑执行完之后,删除通知中心的消息 + */ + private String messageID; + + + public PluginInvalidateRemindDialog(Frame parent, List pluginNames, List pluginMarkers, String messageId) { + super(parent, true); + this.pluginMarkers = pluginMarkers; + this.pluginNames = pluginNames; + this.messageID = messageId; + // 标题 + this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")); + this.setResizable(false); + + this.add(initTopPane(), BorderLayout.NORTH); + this.add(initCenterPanel(), BorderLayout.CENTER); + this.add(initBottomPanel(), BorderLayout.SOUTH); + this.setSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.plugin.remind.PluginInvalidateRemindDialog.dialog")); + + GUICoreUtils.centerWindow(this); + + } + + /** + * 上层的面板,用于解释插件内置 + * @return + */ + private JPanel initTopPane() { + JPanel topPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + + // 图标面板 + JPanel imagePanel = new JPanel(); + Icon icon = IOUtils.readIcon("com/fr/design/images/warnings/icon_WarningIcon_normal.png"); + UILabel imageLabel = new UILabel(); + imageLabel.setIcon(icon); + imagePanel.add(imageLabel); + imagePanel.setBorder(BorderFactory.createEmptyBorder(20, 10, 0, 10)); + + JPanel verticalPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); + UILabel noticeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Plugin_Embed_Notice")); + noticeLabel.setFont(FRFont.getInstance().applySize(16)); + UILabel adviceLabel = new UILabel(Toolkit.i18nText("Fine-Design_Plugin_Embed_Advice")); + UILabel descriptionLabel = new UILabel(Toolkit.i18nText("Fine-Design_Plugin_Embed_Description")); + verticalPanel.add(noticeLabel); + verticalPanel.add(adviceLabel); + verticalPanel.add(descriptionLabel); + + topPane.add(imagePanel, BorderLayout.WEST); + topPane.add(verticalPanel, BorderLayout.CENTER); +// topPane.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.plugin.remind.PluginInvalidateRemindDialog.topPane")); + topPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 20)); + return topPane; + } + + /** + * 中层面板,用于展示内置插件列表 + * @return + */ + private JPanel initCenterPanel() { + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + + // "插件列表"标签面板 + UILabel textLabel = new UILabel(Toolkit.i18nText("Fine-Design_Plugin_Embed_List")); + textLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); + + JTextPane textPane = new JTextPane(); + textPane.setEditable(false); + textPane.setBackground(Color.WHITE); + SimpleAttributeSet attributeSet = new SimpleAttributeSet(); + StyleConstants.setLineSpacing(attributeSet, 0.5f); + textPane.setParagraphAttributes(attributeSet, true); + textPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + textPane.setText(generatePluginListText(pluginNames)); + JScrollPane scrollPane = new JScrollPane(textPane); + + centerPane.add(textLabel, BorderLayout.NORTH); + centerPane.add(scrollPane, BorderLayout.CENTER); + centerPane.setBorder(BorderFactory.createEmptyBorder(20, 10, 0, 10)); + centerPane.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.plugin.remind.PluginInvalidateRemindDialog.centerPane")); + return centerPane; + } + + /** + * 生成中间面板展示的插件列表 + * @param pluginNames + * @return + */ + private String generatePluginListText(List pluginNames) { + String space = " "; + StringBuilder sb = new StringBuilder(); + for (String pluginName : pluginNames) { + sb.append(space).append(pluginName).append("\n"); + } + return sb.toString(); + } + + /** + * 底层面板,用于处理用户操作 + * @return + */ + private JPanel initBottomPanel() { + JPanel bottomPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + + UIButton ignore = new UIButton(Toolkit.i18nText("Fine-Design_Plugin_Embed_Ignore")); + UIButton delete = new UIButton(Toolkit.i18nText("Fine-Design_Plugin_Embed_Delete_Plugins")); + UILabel emptyLabel = new UILabel(); + ignore.addActionListener(this); + delete.addActionListener(new DeleteEmbedPluginsAction(this)); + bottomPane.add(ignore, BorderLayout.WEST); + bottomPane.add(emptyLabel, BorderLayout.CENTER); + bottomPane.add(delete, BorderLayout.EAST); + return bottomPane; + } + + @Override + public void actionPerformed(ActionEvent e) { + this.dispose(); + } + + private class DeleteEmbedPluginsAction extends UpdateAction { + + private JDialog dialog; + + + DeleteEmbedPluginsAction(JDialog dialog) { + this.dialog = dialog; + } + + @Override + public void actionPerformed(ActionEvent e) { + this.dialog.dispose(); + // 删除插件 + deleteEmbedPlugins(pluginMarkers); + // 删除消息 + NotificationCenter.getInstance().removeNotificationByMessageID(messageID); + } + + /** + * 删除插件 + * @param toDelete + */ + private void deleteEmbedPlugins(List toDelete) { + if (toDelete == null) { + return; + } + for (PluginMarker pluginMarker : toDelete) { + // 删除插件 + PluginManager.getController().uninstall(pluginMarker, false, new PluginTaskCallback() { + @Override + public void done(PluginTaskResult result) { + // 输出结果日志 + FineLoggerFactory.getLogger().info( + "Detele Embed Plugin(id = {}, version = {}) {}", + pluginMarker.getPluginID(), + pluginMarker.getVersion(), result.isSuccess() ? "Succeeded" : "Failed"); + } + }); + } + } + } +} diff --git a/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java b/designer-base/src/main/java/com/fr/design/plugin/remind/PluginStartFailedRemindDialog.java similarity index 96% rename from designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java rename to designer-base/src/main/java/com/fr/design/plugin/remind/PluginStartFailedRemindDialog.java index 1558d72e9..639c7a292 100644 --- a/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java +++ b/designer-base/src/main/java/com/fr/design/plugin/remind/PluginStartFailedRemindDialog.java @@ -1,4 +1,4 @@ -package com.fr.env; +package com.fr.design.plugin.remind; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; @@ -32,11 +32,11 @@ import java.util.Set; /** * 插件启动失败提示窗 */ -public class PluginErrorRemindDialog extends JDialog implements ActionListener { +public class PluginStartFailedRemindDialog extends JDialog implements ActionListener { private static final String SIM_HEI = "SimHei"; - public PluginErrorRemindDialog(Frame parent, String text) { + public PluginStartFailedRemindDialog(Frame parent, String text) { super(parent, true); //上面的标签面板 JPanel topPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties index f4840b71a..03a445fab 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties @@ -18,4 +18,6 @@ com.fr.design.mainframe.ForbiddenPane.refreshButton=75*24 com.fr.design.cell.expand.sort.pane=257*185 com.fr.design.sort.rule.item=125*20 com.fr.design.ds.column.sort.pane=250*180 -com.fr.design.sort.expand.header.pane=95*10 \ No newline at end of file +com.fr.design.sort.expand.header.pane=95*10 +com.fr.design.plugin.remind.PluginInvalidateRemindDialog.dialog=600*500 +com.fr.design.plugin.remind.PluginInvalidateRemindDialog.centerPane=580*369 diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties index fb0ecfb3d..3cb9b007d 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties @@ -17,4 +17,6 @@ com.fr.design.mainframe.ForbiddenPane.refreshButton=68*24 com.fr.design.cell.expand.sort.pane=257*170 com.fr.design.sort.rule.item=125*20 com.fr.design.ds.column.sort.pane=250*165 -com.fr.design.sort.expand.header.pane=95*10 \ No newline at end of file +com.fr.design.sort.expand.header.pane=95*10 +com.fr.design.plugin.remind.PluginInvalidateRemindDialog.dialog=600*500 +com.fr.design.plugin.remind.PluginInvalidateRemindDialog.centerPane=580*369 diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties index 19bb7e97a..df59420a4 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties @@ -17,4 +17,6 @@ com.fr.design.mainframe.ForbiddenPane.refreshButton=80*24 com.fr.design.cell.expand.sort.pane=267*165 com.fr.design.sort.rule.item=125*20 com.fr.design.ds.column.sort.pane=250*180 -com.fr.design.sort.expand.header.pane=95*10 \ No newline at end of file +com.fr.design.sort.expand.header.pane=95*10 +com.fr.design.plugin.remind.PluginInvalidateRemindDialog.dialog=600*500 +com.fr.design.plugin.remind.PluginInvalidateRemindDialog.centerPane=580*369 diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties index 3c398efc0..c460babec 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties @@ -18,4 +18,6 @@ com.fr.design.mainframe.ForbiddenPane.refreshButton=68*24 com.fr.design.cell.expand.sort.pane=227*155 com.fr.design.sort.rule.item=80*20 com.fr.design.ds.column.sort.pane=220*150 -com.fr.design.sort.expand.header.pane=108*10 \ No newline at end of file +com.fr.design.sort.expand.header.pane=108*10 +com.fr.design.plugin.remind.PluginInvalidateRemindDialog.dialog=600*500 +com.fr.design.plugin.remind.PluginInvalidateRemindDialog.centerPane=580*369 diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties index 7130938c7..50a94b622 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties @@ -17,4 +17,6 @@ com.fr.design.mainframe.ForbiddenPane.refreshButton=68*24 com.fr.design.cell.expand.sort.pane=227*155 com.fr.design.sort.rule.item=80*20 com.fr.design.ds.column.sort.pane=220*150 -com.fr.design.sort.expand.header.pane=108*10 \ No newline at end of file +com.fr.design.sort.expand.header.pane=108*10 +com.fr.design.plugin.remind.PluginInvalidateRemindDialog.dialog=600*500 +com.fr.design.plugin.remind.PluginInvalidateRemindDialog.centerPane=580*369 diff --git a/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java b/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java index 090838fd0..cab7037cd 100644 --- a/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java +++ b/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java @@ -1,12 +1,12 @@ package com.fr.design; -import com.fr.decision.webservice.v10.plugin.helper.PluginErrorRemindHandler; +import com.fr.design.plugin.remind.PluginErrorDesignReminder; +import com.fr.plugin.error.PluginErrorRemindHandler; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.env.CheckServiceDialog; -import com.fr.env.PluginErrorRemindDialog; import com.fr.invoke.Reflect; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; @@ -108,33 +108,4 @@ public class EnvChangeEntranceTest { Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info3).get()); Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info4).get()); } - - @Test - public void testPluginErrorRemind() { - - try { - - Workspace workspace = EasyMock.mock(Workspace.class); - EasyMock.expect(workspace.isLocal()).andReturn(false).once(); - EasyMock.expect(workspace.isLocal()).andReturn(true).once(); - PowerMock.mockStatic(WorkContext.class); - EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes(); - - PowerMock.mockStatic(PluginErrorRemindHandler.class); - EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("").once(); - - EasyMock.replay(workspace); - PowerMock.replayAll(); - - EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); - - entrance.pluginErrorRemind(); - entrance.pluginErrorRemind(); - - EasyMock.verify(workspace); - PowerMock.verifyAll(); - } catch (Exception e) { - Assert.fail(); - } - } -} \ No newline at end of file +} diff --git a/designer-base/src/test/java/com/fr/design/plugin/remind/PluginErrorDesignReminderTest.java b/designer-base/src/test/java/com/fr/design/plugin/remind/PluginErrorDesignReminderTest.java new file mode 100644 index 000000000..19f4ba66c --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/plugin/remind/PluginErrorDesignReminderTest.java @@ -0,0 +1,47 @@ +package com.fr.design.plugin.remind; + +import com.fr.plugin.error.PluginErrorRemindHandler; +import com.fr.workspace.WorkContext; +import com.fr.workspace.empty.EmptyWorkspace; +import junit.framework.TestCase; +import org.easymock.EasyMock; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.ArrayList; + +/** + * @author Yvan + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(PluginErrorRemindHandler.class) +public class PluginErrorDesignReminderTest extends TestCase { + + @Before + public void before() { + WorkContext.switchTo(EmptyWorkspace.getInstance()); + } + + public void testRemindStartFailedPlugins() { + PowerMock.mockStatic(PluginErrorRemindHandler.class); + EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("").once(); + + PowerMock.replayAll(); + PluginErrorDesignReminder.getInstance().remindStartFailedPlugins(); + + PowerMock.verifyAll(); + } + + public void testRemindInvalidatePlugins() { + PowerMock.mockStatic(PluginErrorRemindHandler.class); + EasyMock.expect(PluginErrorRemindHandler.getInvalidateEmbedPluginNames()).andReturn(new ArrayList<>()).once(); + + PowerMock.replayAll(); + PluginErrorDesignReminder.getInstance().remindInvalidatePlugins(); + + PowerMock.verifyAll(); + } +} diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java index de57164bc..f82bf4f22 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java @@ -7,7 +7,7 @@ import com.fr.design.editlock.ConnectionLockChangeChecker; import com.fr.design.editlock.ServerTableDataLockChangeChecker; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; -import com.fr.design.env.LocalDesignerWorkspaceInfo; +import com.fr.design.plugin.remind.PluginErrorDesignReminder; import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.env.utils.WorkspaceUtils; import com.fr.event.Event; @@ -16,7 +16,6 @@ import com.fr.event.Listener; import com.fr.event.Null; import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; -import com.fr.stable.StringUtils; import com.fr.value.NotNullLazyValue; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; @@ -86,7 +85,8 @@ public class DesignerWorkspaceProvider extends Activator { EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener() { @Override public void on(Event event, Null aNull) { - EnvChangeEntrance.getInstance().pluginErrorRemind(); + PluginErrorDesignReminder.getInstance().remindStartFailedPlugins(); + PluginErrorDesignReminder.getInstance().remindInvalidatePlugins(); } }); }