!90 ♻️ 重构代码 重构应用对话框类

Merge pull request !90 from 格物方能致知/refactor-I80I19
This commit is contained in:
Luke 2023-09-11 15:21:11 +00:00 committed by Gitee
commit 194d71cf91
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
19 changed files with 583 additions and 360 deletions

View File

@ -16,7 +16,7 @@ module org.jcnc.jnotepad {
requires org.kordamp.ikonli.javafx;
requires org.kordamp.ikonli.antdesignicons;
exports org.jcnc.jnotepad;
exports org.jcnc.jnotepad.model;
exports org.jcnc.jnotepad.model.enums;
exports org.jcnc.jnotepad.app.config;
exports org.jcnc.jnotepad.app.i18n;
exports org.jcnc.jnotepad.common.constants;
@ -30,5 +30,7 @@ module org.jcnc.jnotepad {
opens org.jcnc.jnotepad.app.config;
exports org.jcnc.jnotepad.views.root.center.main.bottom.status;
exports org.jcnc.jnotepad.ui.dialog;
exports org.jcnc.jnotepad.ui.dialog.interfaces;
exports org.jcnc.jnotepad.model.entity;
}

View File

@ -1,7 +1,7 @@
package org.jcnc.jnotepad.app.config;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.jcnc.jnotepad.model.ShortcutKey;
import org.jcnc.jnotepad.model.entity.ShortcutKey;
import java.util.ArrayList;
import java.util.List;
@ -85,5 +85,4 @@ public class AppConfig {
public void setTextWrap(boolean textWrap) {
this.textWrap = textWrap;
}
}

View File

@ -2,7 +2,7 @@ package org.jcnc.jnotepad.controller.config;
import org.jcnc.jnotepad.app.config.AppConfig;
import org.jcnc.jnotepad.exception.AppException;
import org.jcnc.jnotepad.model.ShortcutKey;
import org.jcnc.jnotepad.model.entity.ShortcutKey;
import org.jcnc.jnotepad.util.JsonUtil;
import org.jcnc.jnotepad.util.LogUtil;
import org.jcnc.jnotepad.util.PopUpUtil;
@ -119,22 +119,6 @@ public class AppConfigController {
return AppConfig.generateDefaultAppConfig();
}
/**
* 获取当前配置文件所在目录
*
* @return 所在目录
*/
public String getDir() {
return dir;
}
public void setDir(String dir) {
this.dir = dir;
}
private AppConfig getAppConfig() {
return appConfig;
}
/**
* 获取自动换行设置默认自动换行
@ -179,4 +163,21 @@ public class AppConfigController {
public List<ShortcutKey> getShortcutKey() {
return this.appConfig.getShortcutKey();
}
/**
* 获取当前配置文件所在目录
*
* @return 所在目录
*/
public String getDir() {
return dir;
}
public void setDir(String dir) {
this.dir = dir;
}
private AppConfig getAppConfig() {
return appConfig;
}
}

View File

@ -0,0 +1,45 @@
package org.jcnc.jnotepad.model.entity;
/**
* 插件信息
*
* @author gewuyou
*/
public class PluginInfo {
/**
* 插件名称
*/
private String pluginName;
/**
* 插件版本
*/
private String version;
/**
* 启用状态
*/
private boolean enabled;
public String getPluginName() {
return pluginName;
}
public void setPluginName(String pluginName) {
this.pluginName = pluginName;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}

View File

@ -1,4 +1,5 @@
package org.jcnc.jnotepad.model;
package org.jcnc.jnotepad.model.entity;
/**
* 快捷键信息类
@ -6,7 +7,13 @@ package org.jcnc.jnotepad.model;
* @author gewuyou
*/
public class ShortcutKey {
/**
* 按钮名称
*/
private String buttonName;
/**
* 快捷键值
*/
private String shortcutKeyValue;
public String getButtonName() {

View File

@ -0,0 +1,29 @@
package org.jcnc.jnotepad.model.enums;
/**
* 对话框类型
*
* @author gewuyou
*/
public enum DialogType {
/**
* 信息
*/
INFO,
/**
* 警告
*/
WARNING,
/**
* 错误
*/
ERROR,
/**
* 成功
*/
SUCCESS,
/**
* 疑问
*/
QUESTION
}

View File

@ -1,7 +1,10 @@
package org.jcnc.jnotepad.plugin;
import org.jcnc.jnotepad.plugin.interfaces.Plugin;
import org.jcnc.jnotepad.util.LogUtil;
import java.util.Map;
/**
* 新按钮插件
*
@ -19,9 +22,37 @@ public class ButtonPlugin implements Plugin {
return "新按钮";
}
/**
* 初始化插件
*/
@Override
public void initialize() {
LogUtil.getLogger(this.getClass()).info("新按钮插件初始化了!");
}
@Override
public void execute() {
// 在这里实现新按钮插件的逻辑
LogUtil.getLogger(this.getClass()).info("新按钮插件执行了!");
}
/**
* 获取插件的配置参数
*
* @return 插件的配置参数
*/
@Override
public Map<String, Object> getConfig() {
return null;
}
/**
* 设置插件的配置参数
*
* @param config 插件的配置参数
*/
@Override
public void setConfig(Map<String, Object> config) {
}
}

View File

@ -1,23 +0,0 @@
package org.jcnc.jnotepad.plugin;
/**
* 插件接口
* <p>
* 描述插件的基本功能
*
* @author luke
*/
public interface Plugin extends PluginCategory {
/**
* 获取插件的显示名称
*
* @return 插件的显示名称
*/
String getDisplayName();
/**
* 执行插件的逻辑
*/
void execute();
}

View File

@ -29,7 +29,7 @@ public class PluginDemo {
* @param primaryStage JavaFX的主舞台
*/
public void start(Stage primaryStage) {
PluginManager pluginManager = new PluginManager();
PluginManager pluginManager = PluginManager.getInstance();
FileChooser fileChooser = BasicFileChooserFactory.getInstance().createFileChooser(
"选择插件",

View File

@ -1,5 +1,6 @@
package org.jcnc.jnotepad.plugin;
import org.jcnc.jnotepad.plugin.interfaces.Plugin;
import org.jcnc.jnotepad.util.LogUtil;
import org.slf4j.Logger;
@ -22,16 +23,17 @@ import java.util.Map;
* @author luke
*/
public class PluginManager {
private static final PluginManager INSTANCE = new PluginManager();
Logger logger = LogUtil.getLogger(this.getClass());
private final List<Plugin> plugins;
private final Map<String, List<String>> categories;
private final List<Plugin> plugins = new ArrayList<>();
private final Map<String, List<String>> categories = new HashMap<>();
/**
* 构造方法初始化插件列表和类别映射
*/
public PluginManager() {
plugins = new ArrayList<>();
categories = new HashMap<>();
private PluginManager() {
}
public static PluginManager getInstance() {
return INSTANCE;
}
/**
@ -41,7 +43,6 @@ public class PluginManager {
*/
public void loadPlugins(String pluginFilePath) {
File file = new File(pluginFilePath);
if (file.exists() && file.isFile()) {
// 创建URLClassLoader以加载Jar文件中的类
Class<?> pluginClass = null;
@ -73,10 +74,31 @@ public class PluginManager {
String displayName = plugin.getDisplayName();
categories.computeIfAbsent(categoryName, k -> new ArrayList<>()).add(displayName);
} else {
LogUtil.getLogger(this.getClass()).info("Plugin file not found: {}", pluginFilePath);
LogUtil.getLogger(this.getClass()).info("PluginInfo file not found: {}", pluginFilePath);
}
}
/**
* 卸载插件
*
* @param pluginClassName 插件类名
* @since 2023/9/11 12:28
*/
public void unloadPlugin(String pluginClassName) {
//todo Unload the plugin and remove it from the list
}
/**
* 禁用插件
*
* @param pluginClassName 禁用某个插件
* @apiNote
* @since 2023/9/11 12:34
*/
public void disablePlugIn(String pluginClassName) {
//todo Disable the plugin
}
/**
* 执行加载的插件
*/

View File

@ -0,0 +1,47 @@
package org.jcnc.jnotepad.plugin.interfaces;
import java.util.Map;
/**
* 插件接口
* <p>
* 描述插件的基本功能
*
* @author luke
*/
public interface Plugin extends PluginCategory {
/**
* 获取插件的显示名称
*
* @return 插件的显示名称
*/
String getDisplayName();
/**
* 初始化插件
*/
void initialize();
/**
* 执行插件的逻辑
*/
void execute();
/**
* 获取插件的配置参数
*
* @return 插件的配置参数
*/
Map<String, Object> getConfig();
/**
* 设置插件的配置参数
*
* @param config 插件的配置参数
*/
void setConfig(Map<String, Object> config);
}

View File

@ -1,4 +1,4 @@
package org.jcnc.jnotepad.plugin;
package org.jcnc.jnotepad.plugin.interfaces;
/**
* 插件类别接口

View File

@ -1,18 +1,12 @@
package org.jcnc.jnotepad.ui.dialog;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import org.jcnc.jnotepad.util.UiUtil;
import org.kordamp.ikonli.javafx.FontIcon;
/**
* 应用对话框
@ -27,16 +21,16 @@ public class AppDialog extends Stage {
*
* @param builder 提示框构建器
*/
private AppDialog(
public AppDialog(
AppDialogBuilder builder) {
// 设置窗口图标
this.getIcons().add(builder.appIcon);
setTitle(builder.title);
setResizable(builder.isResizable);
initModality(builder.modality);
this.getIcons().add(builder.getAppIcon());
setTitle(builder.getTitle());
setResizable(builder.isResizable());
initModality(builder.getModality());
BorderPane borderPane = createLayout(builder);
Scene scene = new Scene(borderPane, builder.width, builder.height);
Scene scene = new Scene(borderPane, builder.getWidth(), builder.getHeight());
setScene(scene);
}
@ -49,22 +43,22 @@ public class AppDialog extends Stage {
private BorderPane createLayout(
AppDialogBuilder builder) {
BorderPane borderPane = new BorderPane();
HBox iconBox = new HBox(builder.icon);
iconBox.setPadding(builder.iconCoxPaddingInsets);
VBox vbox = new VBox(builder.hBoxSpacing);
vbox.setAlignment(builder.vboxPos);
HBox iconBox = new HBox(builder.getIcon());
iconBox.setPadding(builder.getIconCoxPaddingInsets());
VBox vbox = new VBox(builder.getHBoxSpacing());
vbox.setAlignment(builder.getVboxPos());
Label label = new Label(builder.headerText);
Label label = new Label(builder.getHeaderText());
// 自定义文本
Label customTextLabel = new Label(builder.customText);
Label customTextLabel = new Label(builder.getCustomText());
Button confirmButton = createButton(builder.leftBtnText, builder.leftBtnAction::handleAction);
Button cancelButton = createButton(builder.rightBtnText, builder.rightBtnAction::handleAction);
Button confirmButton = createButton(builder.getLeftBtnText(), builder.getLeftBtnAction()::handleAction);
Button cancelButton = createButton(builder.getRightBtnText(), builder.getRightBtnAction()::handleAction);
HBox hBox = new HBox(builder.hBoxSpacing, confirmButton, cancelButton);
hBox.setAlignment(builder.hboxPos);
hBox.setPadding(builder.hBoxPaddingInsets);
HBox hBox = new HBox(builder.getHBoxSpacing(), confirmButton, cancelButton);
hBox.setAlignment(builder.getHboxPos());
hBox.setPadding(builder.gethBoxPaddingInsets());
vbox.getChildren().addAll(label, customTextLabel, hBox);
borderPane.setLeft(iconBox);
@ -86,269 +80,4 @@ public class AppDialog extends Stage {
button.setOnAction(e -> action.run());
return button;
}
public enum DialogType {
/**
* 信息
*/
INFO,
/**
* 警告
*/
WARNING,
/**
* 错误
*/
ERROR,
/**
* 成功
*/
SUCCESS,
/**
* 疑问
*/
QUESTION
}
public interface ButtonAction {
/**
* 处理按钮的操作子类必须实现此方法以定义按钮的行为
*
* @apiNote
* @since 2023/9/3 22:53
*/
void handleAction();
}
public static class AppDialogBuilder {
private AppDialog appDialog;
private Image appIcon = UiUtil.getAppIcon();
private String title;
private String headerText;
private String customText;
private double width = 350;
private double height = 150;
private FontIcon icon;
private ButtonAction leftBtnAction = () -> appDialog.close();
private ButtonAction rightBtnAction = () -> appDialog.close();
private String leftBtnText = "确定";
private String rightBtnText = "取消";
private Insets iconCoxPaddingInsets = new Insets(10, 10, 10, 10);
private Insets hBoxPaddingInsets = new Insets(10, 10, 10, 10);
private boolean isResizable = false;
private double hBoxSpacing = 10;
private Pos vboxPos = Pos.CENTER;
private Pos hboxPos = Pos.CENTER_RIGHT;
private Modality modality = Modality.APPLICATION_MODAL;
/**
* 设置默认的对话框构造
*
* @param type 对话框类型
* @return org.jcnc.jnotepad.ui.dialog.AppDialog.AppDialogBuilder
* @apiNote 该方法只会设置默认的对话框配置标题图标头文本和自定义文本需要自行设置
* @since 2023/9/3 22:24
*/
public AppDialogBuilder setDialogType(DialogType type) {
switch (type) {
case INFO ->
// 设置默认的对话框配置
{
return setTitle("信息").
setIcon(UiUtil.getInfoIcon());
}
case WARNING ->
// 设置默认的对话框配置
{
return setTitle("警告").
setIcon(UiUtil.getWarningIcon());
}
case ERROR ->
// 设置默认的对话框配置
{
return setTitle("错误").
setIcon(UiUtil.getErrorIcon());
}
case QUESTION ->
// 设置默认的对话框配置
{
return setTitle("问题").
setIcon(UiUtil.getQuestionIcon());
}
case SUCCESS ->
// 设置默认的对话框配置
{
return setTitle("成功").
setIcon(UiUtil.getSuccessIcon());
}
default -> {
return this;
}
}
}
/**
* 设置应用图标
*/
public AppDialogBuilder setAppIcon(Image appIcon) {
this.appIcon = appIcon;
return this;
}
/**
* 设置对话框标题
*/
public AppDialogBuilder setTitle(String title) {
this.title = title;
return this;
}
/**
* 设置对话框头部文本
*/
public AppDialogBuilder setHeaderText(String headerText) {
this.headerText = headerText;
return this;
}
/**
* 设置自定义文本
*/
public AppDialogBuilder setCustomText(String customText) {
this.customText = customText;
return this;
}
/**
* 设置对话框宽度
*/
public AppDialogBuilder setWidth(double width) {
this.width = width;
return this;
}
/**
* 设置对话框高度
*/
public AppDialogBuilder setHeight(double height) {
this.height = height;
return this;
}
/**
* 设置对话框左侧图标
*/
public AppDialogBuilder setIcon(FontIcon icon) {
this.icon = icon;
return this;
}
/**
* 设置左按钮操作
*/
public AppDialogBuilder setLeftBtnAction(ButtonAction leftBtnAction) {
if (leftBtnAction != null) {
this.leftBtnAction = leftBtnAction;
}
return this;
}
/**
* 设置右按钮操作
*/
public AppDialogBuilder setRightBtnAction(ButtonAction rightBtnAction) {
if (rightBtnAction != null) {
this.rightBtnAction = rightBtnAction;
}
return this;
}
/**
* 设置左按钮文本
*/
public AppDialogBuilder setLeftBtnText(String leftBtnText) {
this.leftBtnText = leftBtnText;
return this;
}
/**
* 设置右按钮文本
*/
public AppDialogBuilder setRightBtnText(String rightBtnText) {
this.rightBtnText = rightBtnText;
return this;
}
/**
* 设置图标边距
*/
public AppDialogBuilder setIconCoxPaddingInsets(Insets iconCoxPaddingInsets) {
this.iconCoxPaddingInsets = iconCoxPaddingInsets;
return this;
}
/**
* 设置水平盒子边距
*/
public AppDialogBuilder setHorizontalBoxPaddingInsets(Insets hBoxPaddingInsets) {
this.hBoxPaddingInsets = hBoxPaddingInsets;
return this;
}
/**
* 设置是否可调整大小
*/
public AppDialogBuilder setResizable(boolean resizable) {
isResizable = resizable;
return this;
}
/**
* 设置水平盒子间距
*/
public AppDialogBuilder setHorizontalBoxSpacing(double hBoxSpacing) {
this.hBoxSpacing = hBoxSpacing;
return this;
}
/**
* 设置垂直盒子位置
*/
public AppDialogBuilder setVboxPos(Pos vboxPos) {
this.vboxPos = vboxPos;
return this;
}
/**
* 设置水平盒子位置
*/
public AppDialogBuilder setHorizontalBoxPos(Pos hboxPos) {
this.hboxPos = hboxPos;
return this;
}
/**
* 设置模态性
*/
public AppDialogBuilder setModality(Modality modality) {
this.modality = modality;
return this;
}
public AppDialog build() {
appDialog = new AppDialog(this);
return appDialog;
}
}
}

View File

@ -0,0 +1,314 @@
package org.jcnc.jnotepad.ui.dialog;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.image.Image;
import javafx.stage.Modality;
import org.jcnc.jnotepad.model.enums.DialogType;
import org.jcnc.jnotepad.ui.dialog.interfaces.DialogButtonAction;
import org.jcnc.jnotepad.util.UiUtil;
import org.kordamp.ikonli.javafx.FontIcon;
/**
* 应用对话框建造者类
*
* @author gewuyou
*/
public class AppDialogBuilder {
private AppDialog appDialog;
private Image appIcon = UiUtil.getAppIcon();
private String title;
private String headerText;
private String customText;
private double width = 350;
private double height = 150;
private FontIcon icon;
private DialogButtonAction leftBtnAction = () -> appDialog.close();
private DialogButtonAction rightBtnAction = () -> appDialog.close();
private String leftBtnText = "确定";
private String rightBtnText = "取消";
private Insets iconCoxPaddingInsets = new Insets(10, 10, 10, 10);
private Insets hBoxPaddingInsets = new Insets(10, 10, 10, 10);
private boolean isResizable = false;
private double hBoxSpacing = 10;
private Pos vboxPos = Pos.CENTER;
private Pos hboxPos = Pos.CENTER_RIGHT;
private Modality modality = Modality.APPLICATION_MODAL;
/**
* 设置默认的对话框构造
*
* @param type 对话框类型
* @return org.jcnc.jnotepad.ui.dialog.AppDialogBuilder
* @apiNote 该方法只会设置默认的对话框配置标题图标头文本和自定义文本需要自行设置
* @since 2023/9/3 22:24
*/
public AppDialogBuilder setDialogType(DialogType type) {
switch (type) {
case INFO ->
// 设置默认的对话框配置
{
return setTitle("信息").
setIcon(UiUtil.getInfoIcon());
}
case WARNING ->
// 设置默认的对话框配置
{
return setTitle("警告").
setIcon(UiUtil.getWarningIcon());
}
case ERROR ->
// 设置默认的对话框配置
{
return setTitle("错误").
setIcon(UiUtil.getErrorIcon());
}
case QUESTION ->
// 设置默认的对话框配置
{
return setTitle("问题").
setIcon(UiUtil.getQuestionIcon());
}
case SUCCESS ->
// 设置默认的对话框配置
{
return setTitle("成功").
setIcon(UiUtil.getSuccessIcon());
}
default -> {
return this;
}
}
}
/**
* 设置应用图标
*/
public AppDialogBuilder setAppIcon(Image appIcon) {
this.appIcon = appIcon;
return this;
}
public AppDialog build() {
appDialog = new AppDialog(this);
return appDialog;
}
/**
* 设置对话框标题
*/
public AppDialogBuilder setTitle(String title) {
this.title = title;
return this;
}
/**
* 设置对话框头部文本
*/
public AppDialogBuilder setHeaderText(String headerText) {
this.headerText = headerText;
return this;
}
/**
* 设置自定义文本
*/
public AppDialogBuilder setCustomText(String customText) {
this.customText = customText;
return this;
}
/**
* 设置对话框宽度
*/
public AppDialogBuilder setWidth(double width) {
this.width = width;
return this;
}
/**
* 设置对话框高度
*/
public AppDialogBuilder setHeight(double height) {
this.height = height;
return this;
}
/**
* 设置对话框左侧图标
*/
public AppDialogBuilder setIcon(FontIcon icon) {
this.icon = icon;
return this;
}
/**
* 设置左按钮操作
*/
public AppDialogBuilder setLeftBtnAction(DialogButtonAction leftBtnAction) {
if (leftBtnAction != null) {
this.leftBtnAction = leftBtnAction;
}
return this;
}
/**
* 设置右按钮操作
*/
public AppDialogBuilder setRightBtnAction(DialogButtonAction rightBtnAction) {
if (rightBtnAction != null) {
this.rightBtnAction = rightBtnAction;
}
return this;
}
/**
* 设置左按钮文本
*/
public AppDialogBuilder setLeftBtnText(String leftBtnText) {
this.leftBtnText = leftBtnText;
return this;
}
/**
* 设置右按钮文本
*/
public AppDialogBuilder setRightBtnText(String rightBtnText) {
this.rightBtnText = rightBtnText;
return this;
}
/**
* 设置图标边距
*/
public AppDialogBuilder setIconCoxPaddingInsets(Insets iconCoxPaddingInsets) {
this.iconCoxPaddingInsets = iconCoxPaddingInsets;
return this;
}
/**
* 设置水平盒子边距
*/
public AppDialogBuilder setHorizontalBoxPaddingInsets(Insets hBoxPaddingInsets) {
this.hBoxPaddingInsets = hBoxPaddingInsets;
return this;
}
/**
* 设置是否可调整大小
*/
public AppDialogBuilder setResizable(boolean resizable) {
isResizable = resizable;
return this;
}
/**
* 设置水平盒子间距
*/
public AppDialogBuilder setHorizontalBoxSpacing(double hBoxSpacing) {
this.hBoxSpacing = hBoxSpacing;
return this;
}
/**
* 设置垂直盒子位置
*/
public AppDialogBuilder setVboxPos(Pos vboxPos) {
this.vboxPos = vboxPos;
return this;
}
/**
* 设置水平盒子位置
*/
public AppDialogBuilder setHorizontalBoxPos(Pos hboxPos) {
this.hboxPos = hboxPos;
return this;
}
/**
* 设置模态性
*/
public AppDialogBuilder setModality(Modality modality) {
this.modality = modality;
return this;
}
public Image getAppIcon() {
return appIcon;
}
public String getTitle() {
return title;
}
public String getHeaderText() {
return headerText;
}
public String getCustomText() {
return customText;
}
public double getWidth() {
return width;
}
public double getHeight() {
return height;
}
public FontIcon getIcon() {
return icon;
}
public DialogButtonAction getLeftBtnAction() {
return leftBtnAction;
}
public DialogButtonAction getRightBtnAction() {
return rightBtnAction;
}
public String getLeftBtnText() {
return leftBtnText;
}
public String getRightBtnText() {
return rightBtnText;
}
public Insets getIconCoxPaddingInsets() {
return iconCoxPaddingInsets;
}
public Insets gethBoxPaddingInsets() {
return hBoxPaddingInsets;
}
public boolean isResizable() {
return isResizable;
}
public double getHBoxSpacing() {
return hBoxSpacing;
}
public Pos getVboxPos() {
return vboxPos;
}
public Pos getHboxPos() {
return hboxPos;
}
public Modality getModality() {
return modality;
}
}

View File

@ -0,0 +1,17 @@
package org.jcnc.jnotepad.ui.dialog.interfaces;
/**
* 对话框按钮点击事件接口
*
* @author gewuyou
*/
public interface DialogButtonAction {
/**
* 处理按钮的操作子类必须实现此方法以定义按钮的行为
*
* @apiNote
* @since 2023/9/3 22:53
*/
void handleAction();
}

View File

@ -103,6 +103,7 @@ public class CustomTitleBar extends HBox {
}
private static class Delta {
double x, y;
double x;
double y;
}
}

View File

@ -1,6 +1,8 @@
package org.jcnc.jnotepad.util;
import org.jcnc.jnotepad.ui.dialog.AppDialog;
import org.jcnc.jnotepad.model.enums.DialogType;
import org.jcnc.jnotepad.ui.dialog.AppDialogBuilder;
import org.jcnc.jnotepad.ui.dialog.interfaces.DialogButtonAction;
/**
* 弹窗工具类
@ -25,9 +27,9 @@ public class PopUpUtil {
*/
public static void errorAlert(
String title, String headerText, String message,
AppDialog.ButtonAction leftBtnAction, AppDialog.ButtonAction rightBtnAction) {
DialogButtonAction leftBtnAction, DialogButtonAction rightBtnAction) {
getCustomDialog()
.setDialogType(AppDialog.DialogType.ERROR)
.setDialogType(DialogType.ERROR)
.setTitle(title)
.setHeaderText(headerText)
.setCustomText(message)
@ -49,9 +51,9 @@ public class PopUpUtil {
*/
public static void infoAlert(
String title, String headerText, String message,
AppDialog.ButtonAction leftBtnAction, AppDialog.ButtonAction rightBtnAction) {
DialogButtonAction leftBtnAction, DialogButtonAction rightBtnAction) {
getCustomDialog()
.setDialogType(AppDialog.DialogType.INFO)
.setDialogType(DialogType.INFO)
.setTitle(title)
.setHeaderText(headerText)
.setCustomText(message)
@ -73,9 +75,9 @@ public class PopUpUtil {
*/
public static void warningAlert(
String title, String headerText, String message,
AppDialog.ButtonAction leftBtnAction, AppDialog.ButtonAction rightBtnAction) {
DialogButtonAction leftBtnAction, DialogButtonAction rightBtnAction) {
getCustomDialog()
.setDialogType(AppDialog.DialogType.WARNING)
.setDialogType(DialogType.WARNING)
.setTitle(title)
.setHeaderText(headerText)
.setCustomText(message)
@ -97,9 +99,9 @@ public class PopUpUtil {
*/
public static void questionAlert(
String title, String headerText, String message,
AppDialog.ButtonAction leftBtnAction, AppDialog.ButtonAction rightBtnAction) {
DialogButtonAction leftBtnAction, DialogButtonAction rightBtnAction) {
getCustomDialog()
.setDialogType(AppDialog.DialogType.QUESTION)
.setDialogType(DialogType.QUESTION)
.setTitle(title)
.setHeaderText(headerText)
.setCustomText(message)
@ -110,9 +112,9 @@ public class PopUpUtil {
public static void successAlert(
String title, String headerText, String message,
AppDialog.ButtonAction leftBtnAction, AppDialog.ButtonAction rightBtnAction) {
DialogButtonAction leftBtnAction, DialogButtonAction rightBtnAction) {
getCustomDialog()
.setDialogType(AppDialog.DialogType.SUCCESS)
.setDialogType(DialogType.SUCCESS)
.setTitle(title)
.setHeaderText(headerText)
.setCustomText(message)
@ -128,7 +130,7 @@ public class PopUpUtil {
* @apiNote 使用此方法会返回原始的应用对话框建造者类以实现自定义弹窗
* @since 2023/9/3 11:54
*/
public static AppDialog.AppDialogBuilder getCustomDialog() {
return new AppDialog.AppDialogBuilder();
public static AppDialogBuilder getCustomDialog() {
return new AppDialogBuilder();
}
}

View File

@ -7,7 +7,7 @@ import org.jcnc.jnotepad.ui.module.AbstractVerticalBox;
*
* <p>该类用于管理右侧边栏的布局和内容</p>
*
* @Author 许轲
* @author 许轲
*/
public class RootRightSideBarVerticalBox extends AbstractVerticalBox {

View File

@ -9,7 +9,7 @@ import org.jcnc.jnotepad.controller.config.AppConfigController;
import org.jcnc.jnotepad.controller.event.handler.menubar.*;
import org.jcnc.jnotepad.controller.event.handler.util.SetBtn;
import org.jcnc.jnotepad.controller.i18n.LocalizationController;
import org.jcnc.jnotepad.model.ShortcutKey;
import org.jcnc.jnotepad.model.entity.ShortcutKey;
import org.jcnc.jnotepad.plugin.PluginDemo;
import org.jcnc.jnotepad.util.LogUtil;
import org.jcnc.jnotepad.views.root.center.main.center.tab.CenterTab;