⚡️ 优化弹窗工具类,并为图标设置颜色样式
This commit is contained in:
parent
26bb88422d
commit
efd6e9880e
@ -13,7 +13,7 @@ public class PopUpUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取错误弹窗
|
||||
* 设置错误弹窗
|
||||
*
|
||||
* @param title 弹窗标题
|
||||
* @param headerText 头文本
|
||||
@ -23,9 +23,10 @@ public class PopUpUtil {
|
||||
* @apiNote
|
||||
* @since 2023/9/3 11:54
|
||||
*/
|
||||
public static void errorAlert(String title, String headerText, String message, AppDialog.ButtonAction leftBtnAction, AppDialog.ButtonAction rightBtnAction) {
|
||||
AppDialog.AppDialogBuilder builder = new AppDialog.AppDialogBuilder();
|
||||
builder
|
||||
public static void errorAlert(
|
||||
String title, String headerText, String message,
|
||||
AppDialog.ButtonAction leftBtnAction, AppDialog.ButtonAction rightBtnAction) {
|
||||
getCustomDialog()
|
||||
.setDialogType(AppDialog.DialogType.ERROR)
|
||||
.setTitle(title)
|
||||
.setHeaderText(headerText)
|
||||
@ -34,4 +35,86 @@ public class PopUpUtil {
|
||||
.setRightBtnAction(rightBtnAction)
|
||||
.build().showAndWait();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置信息弹窗
|
||||
*
|
||||
* @param title 弹窗标题
|
||||
* @param headerText 头文本
|
||||
* @param message 消息文本
|
||||
* @param leftBtnAction 左侧按钮点击事件
|
||||
* @param rightBtnAction 右侧按钮点击事件
|
||||
* @apiNote
|
||||
* @since 2023/9/3 11:54
|
||||
*/
|
||||
public static void infoAlert(
|
||||
String title, String headerText, String message,
|
||||
AppDialog.ButtonAction leftBtnAction, AppDialog.ButtonAction rightBtnAction) {
|
||||
getCustomDialog()
|
||||
.setDialogType(AppDialog.DialogType.INFO)
|
||||
.setTitle(title)
|
||||
.setHeaderText(headerText)
|
||||
.setCustomText(message)
|
||||
.setLeftBtnAction(leftBtnAction)
|
||||
.setRightBtnAction(rightBtnAction)
|
||||
.build().showAndWait();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置警告弹窗
|
||||
*
|
||||
* @param title 弹窗标题
|
||||
* @param headerText 头文本
|
||||
* @param message 消息文本
|
||||
* @param leftBtnAction 左侧按钮点击事件
|
||||
* @param rightBtnAction 右侧按钮点击事件
|
||||
* @apiNote
|
||||
* @since 2023/9/3 11:54
|
||||
*/
|
||||
public static void warningAlert(
|
||||
String title, String headerText, String message,
|
||||
AppDialog.ButtonAction leftBtnAction, AppDialog.ButtonAction rightBtnAction) {
|
||||
getCustomDialog()
|
||||
.setDialogType(AppDialog.DialogType.WARNING)
|
||||
.setTitle(title)
|
||||
.setHeaderText(headerText)
|
||||
.setCustomText(message)
|
||||
.setLeftBtnAction(leftBtnAction)
|
||||
.setRightBtnAction(rightBtnAction)
|
||||
.build().showAndWait();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置疑问弹窗
|
||||
*
|
||||
* @param title 弹窗标题
|
||||
* @param headerText 头文本
|
||||
* @param message 消息文本
|
||||
* @param leftBtnAction 左侧按钮点击事件
|
||||
* @param rightBtnAction 右侧按钮点击事件
|
||||
* @apiNote
|
||||
* @since 2023/9/3 11:54
|
||||
*/
|
||||
public static void questionAlert(
|
||||
String title, String headerText, String message,
|
||||
AppDialog.ButtonAction leftBtnAction, AppDialog.ButtonAction rightBtnAction) {
|
||||
getCustomDialog()
|
||||
.setDialogType(AppDialog.DialogType.QUESTION)
|
||||
.setTitle(title)
|
||||
.setHeaderText(headerText)
|
||||
.setCustomText(message)
|
||||
.setLeftBtnAction(leftBtnAction)
|
||||
.setRightBtnAction(rightBtnAction)
|
||||
.build().showAndWait();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取自定义弹窗
|
||||
*
|
||||
* @apiNote 使用此方法会返回原始的应用对话框建造者类,以实现自定义弹窗
|
||||
* @since 2023/9/3 11:54
|
||||
*/
|
||||
public static AppDialog.AppDialogBuilder getCustomDialog() {
|
||||
return new AppDialog.AppDialogBuilder();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package org.jcnc.jnotepad.util;
|
||||
|
||||
import atlantafx.base.theme.Styles;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.stage.Window;
|
||||
import org.jcnc.jnotepad.LunchApp;
|
||||
import org.jcnc.jnotepad.common.constants.AppConstants;
|
||||
@ -14,7 +14,7 @@ import static org.kordamp.ikonli.antdesignicons.AntDesignIconsFilled.*;
|
||||
/**
|
||||
* UI工具
|
||||
*
|
||||
* <p>封装了项目中所有的UI组件,以减少组件单例模式造成的代码复杂性。</p>
|
||||
* <p>封装了项目中需要引入的UI组件</p>
|
||||
*
|
||||
* @author gewuyou
|
||||
*/
|
||||
@ -27,24 +27,34 @@ public class UiUtil {
|
||||
/**
|
||||
* 错误图标
|
||||
*/
|
||||
private static final FontIcon ERROR_ICON = FontIcon.of(EXCLAMATION_CIRCLE, 64, Color.RED);
|
||||
private static final FontIcon ERROR_ICON = FontIcon.of(EXCLAMATION_CIRCLE);
|
||||
|
||||
/**
|
||||
* 信息图标
|
||||
*/
|
||||
private static final FontIcon INFO_ICON = FontIcon.of(INFO_CIRCLE, 64, Color.BLUE);
|
||||
private static final FontIcon INFO_ICON = FontIcon.of(INFO_CIRCLE);
|
||||
/**
|
||||
* 警告图标
|
||||
*/
|
||||
private static final FontIcon WARNING_ICON = FontIcon.of(WARNING, 64, Color.ORANGE);
|
||||
private static final FontIcon WARNING_ICON = FontIcon.of(WARNING);
|
||||
/**
|
||||
* 问题图标
|
||||
*/
|
||||
private static final FontIcon QUESTION_ICON = FontIcon.of(QUESTION_CIRCLE, 64, Color.YELLOW);
|
||||
private static final FontIcon QUESTION_ICON = FontIcon.of(QUESTION_CIRCLE);
|
||||
|
||||
private static final FontIcon SUCCEED_ICON = FontIcon.of(CHECK_CIRCLE);
|
||||
|
||||
private UiUtil() {
|
||||
}
|
||||
|
||||
static {
|
||||
// 暂时设置颜色
|
||||
ERROR_ICON.getStyleClass().addAll(Styles.DANGER);
|
||||
INFO_ICON.getStyleClass().addAll(Styles.ACCENT);
|
||||
QUESTION_ICON.getStyleClass().addAll(Styles.ACCENT);
|
||||
WARNING_ICON.getStyleClass().addAll(Styles.WARNING);
|
||||
SUCCEED_ICON.getStyleClass().addAll(Styles.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用程序图标。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user