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

Merge pull request !146 from 格物方能致知/refactor-I85JM0
This commit is contained in:
Luke 2023-10-06 03:43:56 +00:00 committed by Gitee
commit 70d97cd6e9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
16 changed files with 243 additions and 159 deletions

View File

@ -45,5 +45,7 @@ module org.jcnc.jnotepad {
exports org.jcnc.jnotepad.component.stage.setting; exports org.jcnc.jnotepad.component.stage.setting;
exports org.jcnc.jnotepad.component.module.vbox; exports org.jcnc.jnotepad.component.module.vbox;
exports org.jcnc.jnotepad.component.module.hbox; 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.Scene;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
/** /**
@ -53,6 +54,8 @@ public abstract class AbstractPaneStage extends BorderPane {
stage.getIcons().add(getStageIcon()); stage.getIcons().add(getStageIcon());
stage.setTitle(getStageTitle()); stage.setTitle(getStageTitle());
stage.setScene(getCustomizationScene()); stage.setScene(getCustomizationScene());
// 设置为模态
stage.initModality(Modality.APPLICATION_MODAL);
stage.show(); stage.show();
} }
} }

View File

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

View File

@ -1,96 +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) {
this.setAlwaysOnTop(true);
// 创建主舞台
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

@ -14,6 +14,7 @@ import javafx.scene.layout.VBox;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.text.Font; import javafx.scene.text.Font;
import javafx.scene.text.Text; import javafx.scene.text.Text;
import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
import org.jcnc.jnotepad.app.config.AppConfig; import org.jcnc.jnotepad.app.config.AppConfig;
import org.jcnc.jnotepad.app.i18n.UiResourceBundle; import org.jcnc.jnotepad.app.i18n.UiResourceBundle;
@ -40,7 +41,7 @@ import static org.jcnc.jnotepad.common.constants.AppConstants.SCREEN_WIDTH;
* *
* @author luke * @author luke
*/ */
public class SetStage extends Stage { public class SetStage {
public static final String GENERAL_SETTING_1 = "常规设置项1"; public static final String GENERAL_SETTING_1 = "常规设置项1";
public static final String GENERAL_SETTING_2 = "常规设置项2"; public static final String GENERAL_SETTING_2 = "常规设置项2";
@ -50,7 +51,6 @@ public class SetStage extends Stage {
public static final String SECURITY_SETTING_1 = "安全设置项1"; public static final String SECURITY_SETTING_1 = "安全设置项1";
public static final String SECURITY_SETTING_2 = "安全设置项2"; public static final String SECURITY_SETTING_2 = "安全设置项2";
public static final String DEVELOPER_DEBUG_PAGE = "开发者调试页面";
private static SetStage instance; private static SetStage instance;
private StackPane contentDisplay; private StackPane contentDisplay;
@ -82,7 +82,7 @@ public class SetStage extends Stage {
primaryStage.getIcons().add(UiUtil.getAppIcon()); primaryStage.getIcons().add(UiUtil.getAppIcon());
primaryStage.setTitle("设置窗口"); primaryStage.setTitle("设置窗口");
// 将窗口设置为模态 // 将窗口设置为模态
//primaryStage.initModality(Modality.APPLICATION_MODAL); primaryStage.initModality(Modality.APPLICATION_MODAL);
contentDisplay = new StackPane(); contentDisplay = new StackPane();
@ -159,14 +159,11 @@ public class SetStage extends Stage {
securityItem.getChildren().add(securityItem1); securityItem.getChildren().add(securityItem1);
securityItem.getChildren().add(securityItem2); securityItem.getChildren().add(securityItem2);
// 开发者调试页面
TreeItem<String> developerItem = new TreeItem<>(DEVELOPER_DEBUG_PAGE);
root.getChildren().add(generalItem); root.getChildren().add(generalItem);
root.getChildren().add(appearanceItem); root.getChildren().add(appearanceItem);
root.getChildren().add(securityItem); root.getChildren().add(securityItem);
root.getChildren().add(developerItem);
root.getChildren().add(pluginsItem); root.getChildren().add(pluginsItem);
TreeView<String> treeView = new TreeView<>(root); TreeView<String> treeView = new TreeView<>(root);
treeView.setShowRoot(false); treeView.setShowRoot(false);
@ -190,8 +187,7 @@ public class SetStage extends Stage {
case APPEARANCE_SETTING_2 -> createAppearanceSettingsLayout2(); case APPEARANCE_SETTING_2 -> createAppearanceSettingsLayout2();
case SECURITY_SETTING_1 -> createSecuritySettingsLayout1(); case SECURITY_SETTING_1 -> createSecuritySettingsLayout1();
case SECURITY_SETTING_2 -> createSecuritySettingsLayout2(); case SECURITY_SETTING_2 -> createSecuritySettingsLayout2();
case DEVELOPER_DEBUG_PAGE -> createDevelopersDebugPageLayouts(); // case PLUGINS -> createPluginsLayout();
case PLUGINS -> createPluginsLayout();
default -> null; default -> null;
}; };
} }
@ -206,21 +202,7 @@ public class SetStage extends Stage {
return generalLayout; 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.setAlwaysOnTop (true);
debugPage.start(new Stage());
});
generalLayout.getChildren().addAll(devBox);
return generalLayout;
}
/** /**
* 创建常规设置项1的布局 * 创建常规设置项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.controls.Notification;
import atlantafx.base.theme.Styles; import atlantafx.base.theme.Styles;
@ -16,6 +16,7 @@ import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent; import javafx.scene.input.ClipboardContent;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
import org.jcnc.jnotepad.api.core.component.stage.AbstractPaneStage; import org.jcnc.jnotepad.api.core.component.stage.AbstractPaneStage;
import org.jcnc.jnotepad.util.LogUtil; import org.jcnc.jnotepad.util.LogUtil;
@ -193,6 +194,8 @@ public class HelpPaneStage extends AbstractPaneStage {
stage.setTitle(getStageTitle()); stage.setTitle(getStageTitle());
stage.setScene(getCustomizationScene()); stage.setScene(getCustomizationScene());
stage.setResizable(false); stage.setResizable(false);
// 设置为模态
stage.initModality(Modality.APPLICATION_MODAL);
stage.show(); 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.geometry.Orientation;
import javafx.scene.control.SplitPane; 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.Tile;
import atlantafx.base.controls.ToggleSwitch; import atlantafx.base.controls.ToggleSwitch;

View File

@ -32,6 +32,15 @@ public class TopMenuBar extends MenuBar {
*/ */
private final Menu setMenu = new Menu(); private final Menu setMenu = new Menu();
/**
* 帮助菜单
*/
private final Menu helpMenu = new Menu();
/**
* 运行菜单
*/
private final Menu runMenu = new Menu();
/// 菜单按钮 /// 菜单按钮
/** /**
@ -39,18 +48,6 @@ public class TopMenuBar extends MenuBar {
*/ */
private final Menu pluginMenu = new Menu(); private final Menu pluginMenu = new Menu();
/**
* 运行菜单
*/
private final Menu runMenu = new Menu();
/**
* 调试菜单
*/
private final MenuItem deBugItem = new MenuItem();
/**
* 新建
*/
private final MenuItem newItem = new MenuItem();
/** /**
* 语言菜单 * 语言菜单
*/ */
@ -58,8 +55,24 @@ public class TopMenuBar extends MenuBar {
/** /**
* 新建 * 新建
*/ */
private final MenuItem newItem = new MenuItem();
/**
* 关于
*/
private final MenuItem aboutItem = new MenuItem();
/**
* 调试
*/
private final MenuItem deBugItem = new MenuItem();
/**
* 运行
*/
private final MenuItem runItem = new MenuItem(); private final MenuItem runItem = new MenuItem();
private final MenuItem developerItem = new MenuItem();
/** /**
* 打开 * 打开
@ -112,15 +125,6 @@ public class TopMenuBar extends MenuBar {
*/ */
private final MenuItem pluginManagerItem = new MenuItem(); private final MenuItem pluginManagerItem = new MenuItem();
/**
* 帮助菜单
*/
private final Menu helpMenu = new Menu();
/**
* 关于
*/
private final MenuItem aboutItem = new MenuItem();
private TopMenuBar() { private TopMenuBar() {
} }
@ -154,10 +158,6 @@ public class TopMenuBar extends MenuBar {
public Menu getPluginMenu() { public Menu getPluginMenu() {
return pluginMenu; return pluginMenu;
} }
public Menu getRunMenu() {
return runMenu;
}
public Menu getLanguageMenu() { public Menu getLanguageMenu() {
@ -171,13 +171,6 @@ public class TopMenuBar extends MenuBar {
public MenuItem getNewItem() { public MenuItem getNewItem() {
return newItem; return newItem;
} }
public MenuItem getRunItem() {
return runItem;
}
public MenuItem getDeBugItem() {
return deBugItem;
}
public MenuItem getAboutItem() { public MenuItem getAboutItem() {
@ -232,4 +225,20 @@ public class TopMenuBar extends MenuBar {
public MenuItem getOpenDirItem() { public MenuItem getOpenDirItem() {
return openDirItem; return openDirItem;
} }
public MenuItem getDeveloperItem() {
return developerItem;
}
public Menu getRunMenu() {
return runMenu;
}
public MenuItem getDeBugItem() {
return deBugItem;
}
public MenuItem getRunItem() {
return runItem;
}
} }

View File

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

View File

@ -9,10 +9,9 @@ PLUGIN=插件
CHINESE=中文 CHINESE=中文
title=JNotepad title=JNotepad
OPEN=打开 OPEN=打开
DE_BUG=调试
OPEN_DIRECTORY=打开文件夹 OPEN_DIRECTORY=打开文件夹
ABOUT=关于 ABOUT=关于
RUN=运行 DEVELOPER=开发者
HELP=帮助 HELP=帮助
OPEN_CONFIGURATION_FILE=打开配置文件 OPEN_CONFIGURATION_FILE=打开配置文件
RENAME=重命名 RENAME=重命名
@ -25,3 +24,5 @@ ROW=行数
FILE=文件 FILE=文件
MANAGER_PLUGIN=管理插件 MANAGER_PLUGIN=管理插件
ENCODE=编码 ENCODE=编码
DE_BUG=调试
RUN=运行

View File

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

View File

@ -14,6 +14,7 @@ HELP=帮助
RUN=运行 RUN=运行
DE_BUG=调试 DE_BUG=调试
ABOUT=关于 ABOUT=关于
DEVELOPER=开发者
OPEN_CONFIGURATION_FILE=打开配置文件 OPEN_CONFIGURATION_FILE=打开配置文件
RENAME=重命名 RENAME=重命名
TOP=窗口置顶 TOP=窗口置顶