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
index 7128fcc283..6ba1c115ba 100644
--- 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
@@ -7,7 +7,6 @@ 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.stable.collections.CollectionUtils;
import com.fr.workspace.WorkContext;
@@ -23,9 +22,10 @@ import java.util.List;
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 = "
";
+ public static final String COMMA = "、";
+ public static final String COLON = ":";
+ public static final String NEW_LINE_TAG = "
";
+ private static final int MAX_PLUGIN_NAME_PER_LINE = 3;
private static class Holder {
private static final PluginErrorDesignReminder INSTANCE = new PluginErrorDesignReminder();
@@ -84,13 +84,33 @@ public class PluginErrorDesignReminder implements PluginErrorReminder {
.append(Toolkit.i18nText("Fine-Design_Plugin_Embed_Notice"))
.append(COLON)
.append(NEW_LINE_TAG)
- .append(StableUtils.join(invalidatePluginNames, COMMA))
+ .append(NEW_LINE_TAG)
+ .append(dealWithPluginNames(invalidatePluginNames))
+ .append(NEW_LINE_TAG)
.append(NEW_LINE_TAG)
.append(Toolkit.i18nText("Fine-Design_Plugin_Embed_Description"))
.append(NEW_LINE_TAG)
.toString();
}
+ /**
+ * 处理消息中的插件名称展示
+ * 由于Notification那边展示的弹窗是随消息宽度变化的,所以插件名称很多时会变得很长。这里做个分行
+ * @return
+ * @param invalidatePluginNames
+ */
+ public String dealWithPluginNames(List invalidatePluginNames) {
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < invalidatePluginNames.size(); i++) {
+ String pluginName = invalidatePluginNames.get(i);
+ builder.append(pluginName);
+ if (i != invalidatePluginNames.size() - 1) {
+ builder.append(i % MAX_PLUGIN_NAME_PER_LINE == (MAX_PLUGIN_NAME_PER_LINE - 1) ? NEW_LINE_TAG : COMMA);
+ }
+ }
+ return builder.toString();
+ }
+
/**
* 构建通知对象
* @param message
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
index 19f4ba66c7..b7df5af5a7 100644
--- 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
@@ -5,6 +5,7 @@ import com.fr.workspace.WorkContext;
import com.fr.workspace.empty.EmptyWorkspace;
import junit.framework.TestCase;
import org.easymock.EasyMock;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
@@ -12,6 +13,8 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
/**
* @author Yvan
@@ -44,4 +47,26 @@ public class PluginErrorDesignReminderTest extends TestCase {
PowerMock.verifyAll();
}
+
+ public void testDealWithPluginNames() {
+ List pluginNames1 = Arrays.asList("1");
+ String content1 = PluginErrorDesignReminder.getInstance().dealWithPluginNames(pluginNames1);
+ Assert.assertFalse(content1.contains(PluginErrorDesignReminder.COMMA));
+ Assert.assertFalse(content1.contains(PluginErrorDesignReminder.NEW_LINE_TAG));
+
+ List pluginNames2 = Arrays.asList("1", "2");
+ String content2 = PluginErrorDesignReminder.getInstance().dealWithPluginNames(pluginNames2);
+ Assert.assertTrue(content2.contains(PluginErrorDesignReminder.COMMA));
+ Assert.assertFalse(content2.contains(PluginErrorDesignReminder.NEW_LINE_TAG));
+
+ List pluginNames3 = Arrays.asList("1", "2", "3", "4");
+ String content3 = PluginErrorDesignReminder.getInstance().dealWithPluginNames(pluginNames3);
+ Assert.assertTrue(content3.contains(PluginErrorDesignReminder.COMMA));
+ Assert.assertTrue(content3.contains(PluginErrorDesignReminder.NEW_LINE_TAG));
+
+ List pluginNames4 = Arrays.asList("1", "2", "3");
+ String content4 = PluginErrorDesignReminder.getInstance().dealWithPluginNames(pluginNames4);
+ Assert.assertTrue(content4.contains(PluginErrorDesignReminder.COMMA));
+ Assert.assertFalse(content4.contains(PluginErrorDesignReminder.NEW_LINE_TAG));
+ }
}