Browse Source

REPORT-73262【设计器环境监测】右下角弹窗文字显示不全

测试右下角弹窗文字的展示问题
feature/x
Harrison 3 years ago
parent
commit
c564a875cf
  1. 20
      designer-base/src/main/java/com/fr/design/components/notification/NotificationDialog.java
  2. 2
      designer-base/src/test/java/com/fr/design/components/notification/NotificationDialogTest.java

20
designer-base/src/main/java/com/fr/design/components/notification/NotificationDialog.java

@ -32,6 +32,7 @@ import java.awt.event.MouseEvent;
import java.net.URI; import java.net.URI;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -151,15 +152,28 @@ public class NotificationDialog extends JDialog {
} }
return new UILabel(LinkStrUtils.generateHtmlTag(messageModel.format())); return new UILabel(LinkStrUtils.generateHtmlTag(messageModel.format()));
}) })
.collect(Collectors.toList());
Function<Double, Integer> calStandardWidth = e -> e > 4 ? 280 : 300;
int widthUnit = messageComponents.stream()
.map((component) -> {
Dimension preferredSize = component.getPreferredSize();
return preferredSize.getHeight();
})
.reduce(Double::sum)
.map(calStandardWidth)
.orElse(300);
messageComponents = messageComponents.stream()
.peek((component) -> { .peek((component) -> {
Dimension preferredSize = component.getPreferredSize(); Dimension preferredSize = component.getPreferredSize();
double componentWidth = preferredSize.getWidth(); double componentWidth = preferredSize.getWidth();
double componentHeight = preferredSize.getHeight(); double componentHeight = preferredSize.getHeight();
double widthFactor = Math.ceil(componentWidth / 300);
double heightFactor = Math.ceil(componentHeight / 15); double heightFactor = Math.ceil(componentHeight / 15);
double widthFactor = Math.ceil(componentWidth / widthUnit);
int realHeight = (int) (heightFactor + widthFactor - 1) * 15; int realHeight = (int) (heightFactor + widthFactor - 1) * 15;
component.setPreferredSize(new Dimension(300, realHeight)); component.setPreferredSize(new Dimension(widthUnit, realHeight));
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());

2
designer-base/src/test/java/com/fr/design/components/notification/NotificationDialogTest.java

@ -31,7 +31,7 @@ public class NotificationDialogTest {
public void run(Object... args) { public void run(Object... args) {
System.out.println("1111"); System.out.println("1111");
} }
}, new NotificationMessage.LinkMessage("1111 2222 33333333 4444 555 6666 66555 888 999 333 <br/> 3333", ""),new NotificationMessage.LinkMessage("display <a href='#'>model2</a> test", "abc")); }, new NotificationMessage.LinkMessage("1111 2222 33333333 4444 555 6666 66555 888 999 333 <br/> 3333 <br /> 444 <br/> 555 <br/>", ""),new NotificationMessage.LinkMessage("display <a href='#'>model2</a> test", "abc"));
NotificationDialogProperties properties = new NotificationDialogProperties(frame, "test"); NotificationDialogProperties properties = new NotificationDialogProperties(frame, "test");
NotificationDialog dialog = new NotificationDialog(properties, Lists.newArrayList(model1, model2)); NotificationDialog dialog = new NotificationDialog(properties, Lists.newArrayList(model1, model2));

Loading…
Cancel
Save