⚡️ 优化开发者调试页面
This commit is contained in:
parent
efd6e9880e
commit
38797e36fd
@ -100,6 +100,10 @@ public class AppDialog extends Stage {
|
||||
* 错误
|
||||
*/
|
||||
ERROR,
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESS,
|
||||
/**
|
||||
* 疑问
|
||||
*/
|
||||
@ -178,6 +182,12 @@ public class AppDialog extends Stage {
|
||||
return setTitle("问题").
|
||||
setIcon(UiUtil.getQuestionIcon());
|
||||
}
|
||||
case SUCCESS ->
|
||||
// 设置默认的对话框配置
|
||||
{
|
||||
return setTitle("成功").
|
||||
setIcon(UiUtil.getSuccessIcon());
|
||||
}
|
||||
default -> {
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -6,17 +6,21 @@ import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
import org.jcnc.jnotepad.util.LogUtil;
|
||||
import org.jcnc.jnotepad.util.PopUpUtil;
|
||||
import org.jcnc.jnotepad.util.UiUtil;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
* @author luke
|
||||
*/
|
||||
public class DeveloperDebugStage extends Stage {
|
||||
Logger logger = LogUtil.getLogger(this.getClass());
|
||||
|
||||
public void start(Stage primaryStage) {
|
||||
// 创建主舞台
|
||||
primaryStage.setTitle("开发者调试页面");
|
||||
|
||||
primaryStage.getIcons().add(UiUtil.getAppIcon());
|
||||
// 创建一个垂直布局
|
||||
VBox root = new VBox();
|
||||
root.setPadding(new Insets(20));
|
||||
@ -25,27 +29,43 @@ public class DeveloperDebugStage extends Stage {
|
||||
// 添加一些调试功能按钮和标签
|
||||
Label titleLabel = new Label("开发者调试页面");
|
||||
Button debugButton1 = new Button("错误提示框");
|
||||
Button debugButton2 = new Button("调试功能2");
|
||||
Button debugButton3 = new Button("调试功能3");
|
||||
Button debugButton2 = new Button("信息提示框");
|
||||
Button debugButton3 = new Button("警告提示框");
|
||||
Button debugButton4 = new Button("疑问提示框");
|
||||
Button debugButton5 = new Button("成功提示框");
|
||||
|
||||
// 按钮点击事件处理
|
||||
debugButton1.setOnAction(e -> {
|
||||
// 在这里执行调试功能1的代码
|
||||
System.out.println("开发者调试: " + debugButton1.getText() + " 启动!");
|
||||
PopUpUtil.errorAlert("错误", "读写错误", "配置文件读写错误!", null, null);
|
||||
logger.debug("开发者调试: {}启动!", debugButton1.getText());
|
||||
PopUpUtil.errorAlert("错误", "错误", "这是一个示例错误提示框!", null, null);
|
||||
|
||||
});
|
||||
|
||||
debugButton2.setOnAction(e -> {
|
||||
// 在这里执行调试功能2的代码
|
||||
logger.debug("开发者调试: {}启动!", debugButton2.getText());
|
||||
PopUpUtil.infoAlert("信息", "信息", "这是一个示例信息提示框!", null, null);
|
||||
});
|
||||
|
||||
debugButton3.setOnAction(e -> {
|
||||
// 在这里执行调试功能3的代码
|
||||
logger.debug("开发者调试: {}启动!", debugButton3.getText());
|
||||
PopUpUtil.warningAlert("警告", "警告", "这是一个示例警告提示框!", null, null);
|
||||
});
|
||||
debugButton4.setOnAction(e -> {
|
||||
// 在这里执行调试功能4的代码
|
||||
logger.debug("开发者调试: {}启动!", debugButton4.getText());
|
||||
PopUpUtil.questionAlert("疑问", "疑问", "这是一个示例疑问提示框!", null, null);
|
||||
});
|
||||
debugButton5.setOnAction(e -> {
|
||||
// 在这里执行调试功能5的代码
|
||||
logger.debug("开发者调试: {}启动!", debugButton5.getText());
|
||||
PopUpUtil.successAlert("成功", "成功", "这是一个示例成功提示框!", null, null);
|
||||
});
|
||||
|
||||
// 将组件添加到布局中
|
||||
root.getChildren().addAll(titleLabel, debugButton1, debugButton2, debugButton3);
|
||||
root.getChildren().addAll(titleLabel, debugButton1, debugButton2, debugButton3, debugButton4, debugButton5);
|
||||
|
||||
// 创建场景
|
||||
Scene scene = new Scene(root, 400, 300);
|
||||
|
||||
@ -33,6 +33,8 @@ public class SetStage extends Stage {
|
||||
public static final String APPEARANCE_SETTING_2 = "外观设置项2";
|
||||
public static final String SECURITY_SETTING_1 = "安全设置项1";
|
||||
public static final String SECURITY_SETTING_2 = "安全设置项2";
|
||||
|
||||
public static final String DEVELOPER_DEBUG_PAGE = "开发者调试页面";
|
||||
private static SetStage instance;
|
||||
private StackPane contentDisplay;
|
||||
|
||||
@ -59,6 +61,7 @@ public class SetStage extends Stage {
|
||||
*/
|
||||
public void openSetStage() {
|
||||
Stage primaryStage = new Stage();
|
||||
primaryStage.getIcons().add(UiUtil.getAppIcon());
|
||||
primaryStage.setTitle("设置窗口");
|
||||
|
||||
|
||||
@ -112,7 +115,7 @@ public class SetStage extends Stage {
|
||||
root.setExpanded(true);
|
||||
|
||||
//常规设置树
|
||||
TreeItem<String> generalItem = new TreeItem<>("常规设置");
|
||||
TreeItem<String> generalItem = new TreeItem<>("常规");
|
||||
|
||||
TreeItem<String> generalItem1 = new TreeItem<>("常规设置项1");
|
||||
TreeItem<String> generalItem2 = new TreeItem<>("常规设置项2");
|
||||
@ -121,7 +124,7 @@ public class SetStage extends Stage {
|
||||
|
||||
|
||||
//外观设置树
|
||||
TreeItem<String> appearanceItem = new TreeItem<>("外观设置");
|
||||
TreeItem<String> appearanceItem = new TreeItem<>("外观");
|
||||
|
||||
TreeItem<String> appearanceItem1 = new TreeItem<>("外观设置项1");
|
||||
TreeItem<String> appearanceItem2 = new TreeItem<>("外观设置项2");
|
||||
@ -129,16 +132,21 @@ public class SetStage extends Stage {
|
||||
appearanceItem.getChildren().add(appearanceItem2);
|
||||
|
||||
//安全设置树
|
||||
TreeItem<String> securityItem = new TreeItem<>("安全设置");
|
||||
TreeItem<String> securityItem = new TreeItem<>("安全");
|
||||
|
||||
TreeItem<String> securityItem1 = new TreeItem<>("安全设置项1");
|
||||
TreeItem<String> securityItem2 = new TreeItem<>("安全设置项2");
|
||||
securityItem.getChildren().add(securityItem1);
|
||||
securityItem.getChildren().add(securityItem2);
|
||||
|
||||
// 开发者调试页面
|
||||
TreeItem<String> developerItem = new TreeItem<>(DEVELOPER_DEBUG_PAGE);
|
||||
|
||||
|
||||
root.getChildren().add(generalItem);
|
||||
root.getChildren().add(appearanceItem);
|
||||
root.getChildren().add(securityItem);
|
||||
root.getChildren().add(developerItem);
|
||||
TreeView<String> treeView = new TreeView<>(root);
|
||||
treeView.setShowRoot(false);
|
||||
|
||||
@ -161,20 +169,16 @@ public class SetStage extends Stage {
|
||||
case APPEARANCE_SETTING_2 -> createAppearanceSettingsLayout2();
|
||||
case SECURITY_SETTING_1 -> createSecuritySettingsLayout1();
|
||||
case SECURITY_SETTING_2 -> createSecuritySettingsLayout2();
|
||||
case DEVELOPER_DEBUG_PAGE -> createDevelopersDebugPageLayouts();
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建常规设置项1的布局。
|
||||
*
|
||||
* @return 常规设置项1的布局节点
|
||||
*/
|
||||
private Node createGeneralSettingsLayout1() {
|
||||
private Node createDevelopersDebugPageLayouts() {
|
||||
VBox generalLayout = new VBox(10);
|
||||
generalLayout.setPadding(new Insets(25));
|
||||
|
||||
SettingsComponent devBox = new SettingsComponent("打开开发者调试页面","开发者调试页面");
|
||||
SettingsComponent devBox = new SettingsComponent("打开开发者调试页面", DEVELOPER_DEBUG_PAGE);
|
||||
devBox.setButtonAction(event -> {
|
||||
// 创建并启动DeveloperDebugPage
|
||||
DeveloperDebugStage debugPage = new DeveloperDebugStage();
|
||||
@ -187,6 +191,18 @@ public class SetStage extends Stage {
|
||||
return generalLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建常规设置项1的布局。
|
||||
*
|
||||
* @return 常规设置项1的布局节点
|
||||
*/
|
||||
private Node createGeneralSettingsLayout1() {
|
||||
VBox generalLayout = new VBox();
|
||||
generalLayout.getChildren().add(new Label("常规设置项1的布局"));
|
||||
|
||||
return generalLayout;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建常规设置项2的布局。
|
||||
|
||||
@ -108,6 +108,20 @@ public class PopUpUtil {
|
||||
.build().showAndWait();
|
||||
}
|
||||
|
||||
public static void successAlert(
|
||||
String title, String headerText, String message,
|
||||
AppDialog.ButtonAction leftBtnAction, AppDialog.ButtonAction rightBtnAction) {
|
||||
getCustomDialog()
|
||||
.setDialogType(AppDialog.DialogType.SUCCESS)
|
||||
.setTitle(title)
|
||||
.setHeaderText(headerText)
|
||||
.setCustomText(message)
|
||||
.setLeftBtnAction(leftBtnAction)
|
||||
.setRightBtnAction(rightBtnAction)
|
||||
.build().showAndWait();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取自定义弹窗
|
||||
*
|
||||
|
||||
@ -42,7 +42,7 @@ public class UiUtil {
|
||||
*/
|
||||
private static final FontIcon QUESTION_ICON = FontIcon.of(QUESTION_CIRCLE);
|
||||
|
||||
private static final FontIcon SUCCEED_ICON = FontIcon.of(CHECK_CIRCLE);
|
||||
private static final FontIcon SUCCESS_ICON = FontIcon.of(CHECK_CIRCLE);
|
||||
|
||||
private UiUtil() {
|
||||
}
|
||||
@ -53,7 +53,7 @@ public class UiUtil {
|
||||
INFO_ICON.getStyleClass().addAll(Styles.ACCENT);
|
||||
QUESTION_ICON.getStyleClass().addAll(Styles.ACCENT);
|
||||
WARNING_ICON.getStyleClass().addAll(Styles.WARNING);
|
||||
SUCCEED_ICON.getStyleClass().addAll(Styles.SUCCESS);
|
||||
SUCCESS_ICON.getStyleClass().addAll(Styles.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,6 +102,15 @@ public class UiUtil {
|
||||
return QUESTION_ICON;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the success icon.
|
||||
*
|
||||
* @return the success icon as a FontIcon object
|
||||
*/
|
||||
public static FontIcon getSuccessIcon() {
|
||||
return SUCCESS_ICON;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用窗口。
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user