|
|
|
@ -1,9 +1,11 @@
|
|
|
|
|
package com.fr.design.dialog; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fine.theme.icon.LazyIcon; |
|
|
|
|
import com.fine.theme.utils.FineUIScale; |
|
|
|
|
import com.formdev.flatlaf.util.ScaledEmptyBorder; |
|
|
|
|
import com.fr.concurrent.NamedThreadFactory; |
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
import com.fr.design.i18n.DesignSizeI18nManager; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
@ -42,7 +44,7 @@ public class NotificationDialog extends JDialog {
|
|
|
|
|
private UILabel messageText; |
|
|
|
|
private NotificationDialogAction notificationDialogAction; |
|
|
|
|
private ScheduledExecutorService TIMER; |
|
|
|
|
private Dimension dialogSize = new Dimension(230, 95); |
|
|
|
|
private Dimension dialogSize = FineUIScale.scale(new Dimension(230, 95)); |
|
|
|
|
|
|
|
|
|
public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message, NotificationDialogAction action) { |
|
|
|
|
this(owner, title, isModal, messageType, message, action, null); |
|
|
|
@ -71,19 +73,19 @@ public class NotificationDialog extends JDialog {
|
|
|
|
|
setAutoRequestFocus(false); |
|
|
|
|
setResizable(false); |
|
|
|
|
JPanel body = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
|
|
|
|
body.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
|
|
|
body.setBorder(new ScaledEmptyBorder(0, 0, 0, 0)); |
|
|
|
|
|
|
|
|
|
//消息内容
|
|
|
|
|
UILabel icon = new UILabel(getIconForType(messageType)); |
|
|
|
|
JPanel iconPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
|
|
|
|
iconPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 10, 8)); |
|
|
|
|
iconPanel.setBorder(new ScaledEmptyBorder(0, 10, 10, 10)); |
|
|
|
|
iconPanel.add(icon); |
|
|
|
|
body.add(iconPanel, BorderLayout.WEST); |
|
|
|
|
|
|
|
|
|
messageText = new UILabel(HTML_TAG_1 + message + HTML_TAG_2); |
|
|
|
|
messageText.setForeground(new Color(51, 51, 52)); |
|
|
|
|
JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
|
|
|
|
centerPanel.setBorder(BorderFactory.createEmptyBorder(8, 0, 5, 20)); |
|
|
|
|
centerPanel.setBorder(new ScaledEmptyBorder(10, 0, 10, 10)); |
|
|
|
|
JScrollPane jScrollPane = new JScrollPane(messageText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
|
|
|
|
jScrollPane.setBorder(BorderFactory.createEmptyBorder()); |
|
|
|
|
centerPanel.add(jScrollPane, BorderLayout.CENTER); |
|
|
|
@ -161,21 +163,21 @@ public class NotificationDialog extends JDialog {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected Icon getIconForType(int messageType) { |
|
|
|
|
String propertyName; |
|
|
|
|
String id; |
|
|
|
|
switch (messageType) { |
|
|
|
|
case 0: |
|
|
|
|
propertyName = "OptionPane.circularErrorIcon"; |
|
|
|
|
id = "error"; |
|
|
|
|
break; |
|
|
|
|
case 1: |
|
|
|
|
propertyName = "OptionPane.newMessageIcon"; |
|
|
|
|
id = "new_information"; |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
propertyName = "OptionPane.circularWarningIcon"; |
|
|
|
|
id = "warning"; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
return UIManager.getIcon(propertyName); |
|
|
|
|
return new LazyIcon(id, 20); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Builder Builder() { |
|
|
|
|