|
|
@ -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()); |
|
|
|
|
|
|
|
|
|
|
|