🚚 移动开发者页面到帮助,移除插件示例按钮

This commit is contained in:
gewuyou 2023-10-05 22:38:36 +08:00
parent b99db6f5d9
commit 3034568047
16 changed files with 206 additions and 123 deletions

View File

@ -45,5 +45,7 @@ module org.jcnc.jnotepad {
exports org.jcnc.jnotepad.component.stage.setting;
exports org.jcnc.jnotepad.component.module.vbox;
exports org.jcnc.jnotepad.component.module.hbox;
exports org.jcnc.jnotepad.component.stage.topmenu.help;
exports org.jcnc.jnotepad.component.stage.topmenu.plugin;
}

View File

@ -3,6 +3,7 @@ package org.jcnc.jnotepad.api.core.component.stage;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.BorderPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
/**
@ -53,6 +54,8 @@ public abstract class AbstractPaneStage extends BorderPane {
stage.getIcons().add(getStageIcon());
stage.setTitle(getStageTitle());
stage.setScene(getCustomizationScene());
// 设置为模态
stage.initModality(Modality.APPLICATION_MODAL);
stage.show();
}
}

View File

@ -24,6 +24,7 @@ public class TextConstants {
public static final String ABOUT = "ABOUT";
public static final String DEVELOPER = "DEVELOPER";
public static final String STATISTICS = "STATISTICS";
public static final String OPEN_CONFIGURATION_FILE = "OPEN_CONFIGURATION_FILE";
public static final String TOP = "TOP";

View File

@ -1,95 +0,0 @@
package org.jcnc.jnotepad.component.stage.setting;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import org.jcnc.jnotepad.app.manager.ApplicationManager;
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(10);
HBox alertBox = new HBox(5);
HBox toolBox = new HBox(5);
root.setPadding(new Insets(20));
root.setSpacing(10);
// 添加一些调试功能按钮和标签
Label alertLabel = new Label("提示框");
Label toolLabel = new Label("工具");
Button debugButton1 = new Button("错误提示框");
Button debugButton2 = new Button("信息提示框");
Button debugButton3 = new Button("警告提示框");
Button debugButton4 = new Button("疑问提示框");
Button debugButton5 = new Button("成功提示框");
// 按钮点击事件处理
debugButton1.setOnAction(e -> {
// 在这里执行调试功能1的代码
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);
});
Button debugButton6 = new Button("重启软件");
debugButton6.setOnAction(event -> {
logger.debug("开发者调试: {}启动!", debugButton6.getText());
// 执行重启操作
ApplicationManager.getInstance().restart();
});
alertBox.getChildren().addAll(debugButton1, debugButton2, debugButton3, debugButton4, debugButton5);
toolBox.getChildren().addAll(debugButton6);
// 将组件添加到布局中
root.getChildren().addAll(alertLabel, alertBox, toolLabel, toolBox);
// 创建场景
Scene scene = new Scene(root, 800, 600);
// 将场景添加到舞台
primaryStage.setScene(scene);
// 显示舞台
primaryStage.show();
}
}

View File

@ -41,7 +41,7 @@ import static org.jcnc.jnotepad.common.constants.AppConstants.SCREEN_WIDTH;
*
* @author luke
*/
public class SetStage extends Stage {
public class SetStage {
public static final String GENERAL_SETTING_1 = "常规设置项1";
public static final String GENERAL_SETTING_2 = "常规设置项2";
@ -51,7 +51,6 @@ public class SetStage extends Stage {
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;
@ -160,14 +159,11 @@ public class SetStage extends Stage {
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);
root.getChildren().add(pluginsItem);
TreeView<String> treeView = new TreeView<>(root);
treeView.setShowRoot(false);
@ -191,8 +187,7 @@ 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();
case PLUGINS -> createPluginsLayout();
// case PLUGINS -> createPluginsLayout();
default -> null;
};
}
@ -207,20 +202,7 @@ public class SetStage extends Stage {
return generalLayout;
}
private Node createDevelopersDebugPageLayouts() {
VBox generalLayout = new VBox(10);
generalLayout.setPadding(new Insets(25));
SetDevBox devBox = new SetDevBox("打开开发者调试页面", DEVELOPER_DEBUG_PAGE);
devBox.setButtonAction(event -> {
// 创建并启动DeveloperDebugPage
DeveloperDebugStage debugPage = new DeveloperDebugStage();
debugPage.start(new Stage());
});
generalLayout.getChildren().addAll(devBox);
return generalLayout;
}
/**
* 创建常规设置项1的布局

View File

@ -0,0 +1,34 @@
package org.jcnc.jnotepad.component.stage.topmenu.builder;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
/**
* 舞台按钮建造者
*
* @author gewuyou
*/
public class StageButtonBuilder {
private final Button button = new Button();
private String text;
private EventHandler<ActionEvent> eventEventHandler;
public StageButtonBuilder setText(String text) {
this.text = text;
return this;
}
public StageButtonBuilder setEventEventHandler(EventHandler<ActionEvent> eventEventHandler) {
this.eventEventHandler = eventEventHandler;
return this;
}
public Button build() {
button.setText(text);
button.setOnAction(eventEventHandler);
return button;
}
}

View File

@ -0,0 +1,142 @@
package org.jcnc.jnotepad.component.stage.topmenu.help;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import org.jcnc.jnotepad.api.core.component.stage.AbstractPaneStage;
import org.jcnc.jnotepad.app.manager.ApplicationManager;
import org.jcnc.jnotepad.component.stage.topmenu.builder.StageButtonBuilder;
import org.jcnc.jnotepad.util.LogUtil;
import org.jcnc.jnotepad.util.PopUpUtil;
import org.jcnc.jnotepad.util.UiUtil;
import org.slf4j.Logger;
/**
* 开发者调试页面
*
* @author gewuyou
*/
public class DeveloperDebugPaneStage extends AbstractPaneStage {
private static final String DEBUG_STR = "开发者调试: {}启动!";
Logger logger = LogUtil.getLogger(this.getClass());
/**
* 获取舞台图标
*
* @return 舞台图标
*/
@Override
protected Image getStageIcon() {
return UiUtil.getAppIcon();
}
/**
* 获取舞台标题
*
* @return 舞台标题
*/
@Override
protected String getStageTitle() {
return "开发者调试页面";
}
/**
* 获取自定义舞台
*
* @return 舞台
*/
@Override
protected Scene getCustomizationScene() {
return new Scene(createVerticalLayout(), 800, 600);
}
/**
* 创建垂直布局
*
* @return 垂直布局
*/
private VBox createVerticalLayout() {
VBox root = new VBox(10);
root.setPadding(new Insets(20));
root.setSpacing(10);
HBox alertBox = new HBox(5);
alertBox.getChildren().addAll(
new StageButtonBuilder()
.setText("错误提示框").setEventEventHandler(e -> {
Button button = (Button) e.getSource();
// 在这里执行调试功能1的代码
logger.debug(DEBUG_STR, button.getText());
PopUpUtil.errorAlert("错误", "错误", "这是一个示例错误提示框!", null, null);
}).build(),
new StageButtonBuilder()
.setText("信息提示框").setEventEventHandler(e -> {
Button button = (Button) e.getSource();
// 在这里执行调试功能2的代码
logger.debug(DEBUG_STR, button.getText());
PopUpUtil.infoAlert("信息", "信息", "这是一个示例信息提示框!", null, null);
}).build(),
new StageButtonBuilder()
.setText("警告提示框").setEventEventHandler(e -> {
Button button = (Button) e.getSource();
// 在这里执行调试功能3的代码
logger.debug(DEBUG_STR, button.getText());
PopUpUtil.warningAlert("警告", "警告", "这是一个示例警告提示框!", null, null);
}).build(),
new StageButtonBuilder()
.setText("疑问提示框").setEventEventHandler(e -> {
Button button = (Button) e.getSource();
// 在这里执行调试功能4的代码
logger.debug(DEBUG_STR, button.getText());
PopUpUtil.questionAlert("疑问", "疑问", "这是一个示例疑问提示框!", null, null);
}).build(),
new StageButtonBuilder()
.setText("成功提示框").setEventEventHandler(e -> {
Button button = (Button) e.getSource();
// 在这里执行调试功能5的代码
logger.debug(DEBUG_STR, button.getText());
PopUpUtil.successAlert("成功", "成功", "这是一个示例成功提示框!", null, null);
}).build()
);
HBox toolBox = new HBox(5);
toolBox.getChildren().addAll(
new StageButtonBuilder()
.setText("重启软件").setEventEventHandler(e -> {
Button button = (Button) e.getSource();
// 执行重启操作
logger.debug(DEBUG_STR, button.getText());
ApplicationManager.getInstance().restart();
}).build()
);
// 添加一些调试功能按钮和标签
Label alertLabel = new Label("提示框");
Label toolLabel = new Label("工具");
root.getChildren().addAll(alertLabel, alertBox, toolLabel, toolBox);
return root;
}
/**
* 初始化方法
*/
@Override
protected void initialize() {
// 在此写初始化
logger.info("开发者调试页面初始化");
}
/**
* 自定义启动方法
*
* @param stage 自定义舞台
*/
@Override
public void run(Stage stage) {
// 在此添加自定义逻辑
stage.show();
}
}

View File

@ -1,4 +1,4 @@
package org.jcnc.jnotepad.component.stage.setting;
package org.jcnc.jnotepad.component.stage.topmenu.help;
import atlantafx.base.controls.Notification;
import atlantafx.base.theme.Styles;
@ -16,6 +16,7 @@ import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import org.jcnc.jnotepad.api.core.component.stage.AbstractPaneStage;
import org.jcnc.jnotepad.util.LogUtil;
@ -193,6 +194,8 @@ public class HelpPaneStage extends AbstractPaneStage {
stage.setTitle(getStageTitle());
stage.setScene(getCustomizationScene());
stage.setResizable(false);
// 设置为模态
stage.initModality(Modality.APPLICATION_MODAL);
stage.show();
}

View File

@ -1,4 +1,4 @@
package org.jcnc.jnotepad.component.stage.setting.plugin;
package org.jcnc.jnotepad.component.stage.topmenu.plugin;
import javafx.geometry.Orientation;
import javafx.scene.control.SplitPane;

View File

@ -1,4 +1,4 @@
package org.jcnc.jnotepad.component.stage.setting.plugin;
package org.jcnc.jnotepad.component.stage.topmenu.plugin;
import atlantafx.base.controls.Tile;
import atlantafx.base.controls.ToggleSwitch;

View File

@ -52,9 +52,12 @@ public class TopMenuBar extends MenuBar {
private final MenuItem newItem = new MenuItem();
/**
* 新建
* 关于
*/
private final MenuItem aboutItem = new MenuItem();
private final MenuItem developerItem = new MenuItem();
/**
* 打开
*/
@ -206,4 +209,8 @@ public class TopMenuBar extends MenuBar {
public MenuItem getOpenDirItem() {
return openDirItem;
}
public MenuItem getDeveloperItem() {
return developerItem;
}
}

View File

@ -4,13 +4,13 @@ import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.stage.Stage;
import org.jcnc.jnotepad.api.core.views.top.menu.AbstractTopMenu;
import org.jcnc.jnotepad.component.stage.setting.HelpPaneStage;
import org.jcnc.jnotepad.component.stage.topmenu.help.DeveloperDebugPaneStage;
import org.jcnc.jnotepad.component.stage.topmenu.help.HelpPaneStage;
import java.util.HashMap;
import java.util.Map;
import static org.jcnc.jnotepad.common.constants.TextConstants.ABOUT;
import static org.jcnc.jnotepad.common.constants.TextConstants.HELP;
import static org.jcnc.jnotepad.common.constants.TextConstants.*;
/**
* 帮助菜单
@ -64,5 +64,6 @@ public class HelpTopMenu extends AbstractTopMenu {
@Override
protected void registerTopMenu() {
registerMenuItem(topMenuBar.getAboutItem(), ABOUT, "aboutItem", event -> new HelpPaneStage().run(new Stage()));
registerMenuItem(topMenuBar.getDeveloperItem(), DEVELOPER, "developerItem", event -> new DeveloperDebugPaneStage().run());
}
}

View File

@ -3,7 +3,7 @@ package org.jcnc.jnotepad.views.root.top.menubar.menu;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import org.jcnc.jnotepad.api.core.views.top.menu.AbstractTopMenu;
import org.jcnc.jnotepad.component.stage.setting.plugin.PluginManagementPane;
import org.jcnc.jnotepad.component.stage.topmenu.plugin.PluginManagementPane;
import java.util.HashMap;
import java.util.Map;

View File

@ -11,6 +11,7 @@ title=JNotepad
OPEN=打开
OPEN_DIRECTORY=打开文件夹
ABOUT=关于
DEVELOPER=开发者
HELP=帮助
OPEN_CONFIGURATION_FILE=打开配置文件
RENAME=重命名

View File

@ -5,6 +5,7 @@ SET=Settings
ENGLISH=English
STATISTICS=Word Count
ABOUT=About
DEVELOPER=Developer
COLUMN=Column
PLUGIN=Plugins
CHINESE=Chinese

View File

@ -12,6 +12,7 @@ OPEN=打开
OPEN_DIRECTORY=打开文件夹
HELP=帮助
ABOUT=关于
DEVELOPER=开发者
OPEN_CONFIGURATION_FILE=打开配置文件
RENAME=重命名
TOP=窗口置顶