Browse Source

REPORT-76076 插件管理-插件管理机制优化-内置插件多时,消息提示显示异常

【问题原因】设计器通知中心的消息弹窗,弹窗的宽度是由消息内容长度决定的,所以插件过多时,会把弹窗拉得很长
【改动思路】跟产品沟通后,添加分行逻辑
【review建议】无
feature/x
Yvan 2 years ago
parent
commit
92342129f5
  1. 30
      designer-base/src/main/java/com/fr/design/plugin/remind/PluginErrorDesignReminder.java
  2. 25
      designer-base/src/test/java/com/fr/design/plugin/remind/PluginErrorDesignReminderTest.java

30
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.design.notification.NotificationCenter;
import com.fr.plugin.error.PluginErrorRemindHandler; import com.fr.plugin.error.PluginErrorRemindHandler;
import com.fr.plugin.error.PluginErrorReminder; import com.fr.plugin.error.PluginErrorReminder;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.collections.CollectionUtils; import com.fr.stable.collections.CollectionUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
@ -23,9 +22,10 @@ import java.util.List;
public class PluginErrorDesignReminder implements PluginErrorReminder { public class PluginErrorDesignReminder implements PluginErrorReminder {
private static final String MESSAGE_ID = "plugin-invalidate-remind"; private static final String MESSAGE_ID = "plugin-invalidate-remind";
private static final String COMMA = "、"; public static final String COMMA = "、";
private static final String COLON = ":"; public static final String COLON = ":";
private static final String NEW_LINE_TAG = "<br/>"; public static final String NEW_LINE_TAG = "<br/>";
private static final int MAX_PLUGIN_NAME_PER_LINE = 3;
private static class Holder { private static class Holder {
private static final PluginErrorDesignReminder INSTANCE = new PluginErrorDesignReminder(); 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(Toolkit.i18nText("Fine-Design_Plugin_Embed_Notice"))
.append(COLON) .append(COLON)
.append(NEW_LINE_TAG) .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(NEW_LINE_TAG)
.append(Toolkit.i18nText("Fine-Design_Plugin_Embed_Description")) .append(Toolkit.i18nText("Fine-Design_Plugin_Embed_Description"))
.append(NEW_LINE_TAG) .append(NEW_LINE_TAG)
.toString(); .toString();
} }
/**
* 处理消息中的插件名称展示
* 由于Notification那边展示的弹窗是随消息宽度变化的所以插件名称很多时会变得很长这里做个分行
* @return
* @param invalidatePluginNames
*/
public String dealWithPluginNames(List<String> 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 * @param message

25
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 com.fr.workspace.empty.EmptyWorkspace;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock; import org.powermock.api.easymock.PowerMock;
@ -12,6 +13,8 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/** /**
* @author Yvan * @author Yvan
@ -44,4 +47,26 @@ public class PluginErrorDesignReminderTest extends TestCase {
PowerMock.verifyAll(); PowerMock.verifyAll();
} }
public void testDealWithPluginNames() {
List<String> 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<String> 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<String> 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<String> 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));
}
} }

Loading…
Cancel
Save