Browse Source

REPORT-29722【组件复用插件】@harrison,社区的小红点,不装插件也有,需要处理

包括插入也要处理一下
feature/big-screen
Harrison 5 years ago
parent
commit
5290d345e8
  1. 6
      designer-base/src/main/java/com/fr/design/menu/MenuDef.java
  2. 39
      designer-base/src/main/java/com/fr/design/menu/SnapChatMenuDef.java
  3. 30
      designer-base/src/test/java/com/fr/design/menu/SnapChatMenuDefTest.java

6
designer-base/src/main/java/com/fr/design/menu/MenuDef.java

@ -138,10 +138,14 @@ public class MenuDef extends ShortCut {
*/ */
public void addShortCut(ShortCut... shortcut) { public void addShortCut(ShortCut... shortcut) {
for (ShortCut i : shortcut) { for (ShortCut i : shortcut) {
this.shortcutList.add(i); addShortCut(i);
} }
} }
public void addShortCut(ShortCut shortCut) {
this.shortcutList.add(shortCut);
}
public void removeShortCut(ShortCut shortCut) { public void removeShortCut(ShortCut shortCut) {
this.shortcutList.remove(shortCut); this.shortcutList.remove(shortCut);

39
designer-base/src/main/java/com/fr/design/menu/SnapChatMenuDef.java

@ -61,23 +61,20 @@ public class SnapChatMenuDef extends MenuDef implements SnapChat {
} }
@Override @Override
public void addShortCut(ShortCut... shortCuts) { public void addShortCut(ShortCut shortCut) {
if (shortCuts == null) { addSnapChatNotification(shortCut);
return; super.addShortCut(shortCut);
}
for (ShortCut shortCut : shortCuts) {
if (shortCut instanceof SnapChatUpdateAction) {
SnapChatUpdateAction action = (SnapChatUpdateAction) shortCut;
if (!action.hasRead()) {
String calcKey = calcKey();
SnapChatConfig.getInstance().resetRead(calcKey);
}
}
} }
super.addShortCut(shortCuts);
@Override
public void insertShortCut(int index, ShortCut shortCut) {
addSnapChatNotification(shortCut);
super.insertShortCut(index, shortCut);
} }
@Override @Override
public SnapChatKey key() { public SnapChatKey key() {
@ -90,6 +87,22 @@ public class SnapChatMenuDef extends MenuDef implements SnapChat {
return new SnapChatMenuListener(); return new SnapChatMenuListener();
} }
/**
* 添加提醒
*
* @param shortCut 快捷方式
*/
private void addSnapChatNotification(ShortCut shortCut) {
if (shortCut instanceof SnapChatUpdateAction) {
SnapChatUpdateAction action = (SnapChatUpdateAction) shortCut;
if (!action.hasRead()) {
String calcKey = calcKey();
SnapChatConfig.getInstance().resetRead(calcKey);
}
}
}
private String calcKey() { private String calcKey() {
return key().calc(); return key().calc();

30
designer-base/src/test/java/com/fr/design/menu/SnapChatMenuDefTest.java

@ -73,4 +73,34 @@ public class SnapChatMenuDefTest {
menuDef.addShortCut(action); menuDef.addShortCut(action);
Assert.assertFalse(menuDef.hasRead()); Assert.assertFalse(menuDef.hasRead());
} }
@Test
public void testInsertShortCut() throws Exception {
PowerMock.suppress(MemberMatcher.constructor(UpdateAction.class));
SnapChatConfig snapChatConfig = EasyMock.partialMockBuilder(SnapChatConfig.class)
.addMockedMethod("readXML")
.createMock();
Whitebox.setInternalState(snapChatConfig, "markReadMap", new HashMap());
snapChatConfig.readXML(EasyMock.anyObject(XMLableReader.class));
EasyMock.expectLastCall().anyTimes();
EasyMock.replay(snapChatConfig);
PowerMock.mockStatic(SnapChatConfig.class);
EasyMock.expect(SnapChatConfig.getInstance()).andReturn(snapChatConfig).anyTimes();
PowerMock.replayAll();
SnapChatMenuDef menuDef = new SnapChatMenuDef("test", SnapChatAllTypes.Menu.BBS);
ShortCut action = new SnapChatUpdateAction(SnapChatAllTypes.Menu.BBS) {
@Override
protected void actionPerformed0(ActionEvent e) {
}
};
Assert.assertTrue(menuDef.hasRead());
menuDef.insertShortCut(0, action);
Assert.assertFalse(menuDef.hasRead());
}
} }
Loading…
Cancel
Save