From 1b2c08473b52c081c70c9bfe9cb1c66dd2688530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E8=BD=B2?= Date: Sat, 30 Sep 2023 01:15:47 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0jlink=E7=9A=84=E6=89=93?= =?UTF-8?q?=E5=8C=85=E6=96=B9=E6=B3=95,=E6=8F=90=E9=AB=98=E6=89=93?= =?UTF-8?q?=E5=8C=85=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3b68ce2..c5092ad 100644 --- a/pom.xml +++ b/pom.xml @@ -131,7 +131,6 @@ org.jcnc.jnotepad/org.jcnc.jnotepad.LunchApp JNotepad - JNotepad JNotepad true true From 34a42310ab5f79cccc8c4089f387ff7e81b253df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E8=BD=B2?= Date: Sat, 30 Sep 2023 01:34:25 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/util/ApplicationRestarter.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/java/org/jcnc/jnotepad/app/util/ApplicationRestarter.java diff --git a/src/main/java/org/jcnc/jnotepad/app/util/ApplicationRestarter.java b/src/main/java/org/jcnc/jnotepad/app/util/ApplicationRestarter.java new file mode 100644 index 0000000..5aa891d --- /dev/null +++ b/src/main/java/org/jcnc/jnotepad/app/util/ApplicationRestarter.java @@ -0,0 +1,30 @@ +package org.jcnc.jnotepad.app.util; + +import org.jcnc.jnotepad.util.LogUtil; +import org.slf4j.Logger; + +import java.io.IOException; + +/** + * @author luke + */ +public class ApplicationRestarter { + + public static void restart() { + try { + // 获取当前Java应用程序的命令 + String javaCommand = System.getProperty("java.home") + "/bin/java"; + String mainClass = ApplicationRestarter.class.getName(); + + // 构建新进程来重新启动应用程序 + ProcessBuilder builder = new ProcessBuilder(javaCommand, "-cp", System.getProperty("java.class.path"), mainClass); + builder.start(); + + // 关闭当前应用程序 + System.exit(0); + } catch (IOException e) { + LogUtil.getLogger("正在重启当前应用程序".getClass()); + + } + } +} From f99ed4e7067291b8423716650d12729d3e376705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E8=BD=B2?= Date: Sat, 30 Sep 2023 01:34:42 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jcnc/jnotepad/app/util/ApplicationRestarter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/jcnc/jnotepad/app/util/ApplicationRestarter.java b/src/main/java/org/jcnc/jnotepad/app/util/ApplicationRestarter.java index 5aa891d..ab9a87e 100644 --- a/src/main/java/org/jcnc/jnotepad/app/util/ApplicationRestarter.java +++ b/src/main/java/org/jcnc/jnotepad/app/util/ApplicationRestarter.java @@ -1,7 +1,6 @@ package org.jcnc.jnotepad.app.util; import org.jcnc.jnotepad.util.LogUtil; -import org.slf4j.Logger; import java.io.IOException; From a16b9577304ec0bdcf86f3c0509058a1616f25bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E8=BD=B2?= Date: Sat, 30 Sep 2023 01:41:11 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E8=80=85=E8=B0=83=E8=AF=95=E7=9A=84=E9=87=8D=E5=90=AF=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jcnc/jnotepad/plugin/manager/PluginManager.java | 5 +++-- .../jcnc/jnotepad/ui/setstage/DeveloperDebugStage.java | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jcnc/jnotepad/plugin/manager/PluginManager.java b/src/main/java/org/jcnc/jnotepad/plugin/manager/PluginManager.java index adc8e8e..6132a9f 100644 --- a/src/main/java/org/jcnc/jnotepad/plugin/manager/PluginManager.java +++ b/src/main/java/org/jcnc/jnotepad/plugin/manager/PluginManager.java @@ -1,6 +1,7 @@ package org.jcnc.jnotepad.plugin.manager; import org.jcnc.jnotepad.app.manager.ApplicationManager; +import org.jcnc.jnotepad.app.util.ApplicationRestarter; import org.jcnc.jnotepad.common.manager.ThreadPoolManager; import org.jcnc.jnotepad.controller.config.PluginConfigController; import org.jcnc.jnotepad.model.entity.PluginDescriptor; @@ -200,8 +201,8 @@ public class PluginManager { PopUpUtil.questionAlert("更改", "程序与插件更新", "请重启程序以应用插件中的更改!", appDialog -> { appDialog.close(); - // 执行关闭操作 - ApplicationManager.getInstance().stopApplication(); + // 执行重启操作 + ApplicationRestarter.restart(); }, null); } } diff --git a/src/main/java/org/jcnc/jnotepad/ui/setstage/DeveloperDebugStage.java b/src/main/java/org/jcnc/jnotepad/ui/setstage/DeveloperDebugStage.java index 3fbad92..eae75a3 100644 --- a/src/main/java/org/jcnc/jnotepad/ui/setstage/DeveloperDebugStage.java +++ b/src/main/java/org/jcnc/jnotepad/ui/setstage/DeveloperDebugStage.java @@ -6,6 +6,7 @@ import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.VBox; import javafx.stage.Stage; +import org.jcnc.jnotepad.app.util.ApplicationRestarter; import org.jcnc.jnotepad.util.LogUtil; import org.jcnc.jnotepad.util.PopUpUtil; import org.jcnc.jnotepad.util.UiUtil; @@ -33,6 +34,7 @@ public class DeveloperDebugStage extends Stage { Button debugButton3 = new Button("警告提示框"); Button debugButton4 = new Button("疑问提示框"); Button debugButton5 = new Button("成功提示框"); + Button debugButton6 = new Button("重启软件"); // 按钮点击事件处理 debugButton1.setOnAction(e -> { @@ -64,8 +66,13 @@ public class DeveloperDebugStage extends Stage { PopUpUtil.successAlert("成功", "成功", "这是一个示例成功提示框!", null, null); }); + debugButton6.setOnAction(event -> { + logger.debug("开发者调试: {}启动!", debugButton6.getText()); + // 执行重启操作 + ApplicationRestarter.restart(); + }); // 将组件添加到布局中 - root.getChildren().addAll(titleLabel, debugButton1, debugButton2, debugButton3, debugButton4, debugButton5); + root.getChildren().addAll(titleLabel, debugButton1, debugButton2, debugButton3, debugButton4, debugButton5, debugButton6); // 创建场景 Scene scene = new Scene(root, 400, 300); From ddafba2f0151db29313bb5265fd761a5e667cbeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E8=BD=B2?= Date: Sat, 30 Sep 2023 01:56:12 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E8=80=85=E8=B0=83=E8=AF=95=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/util/ApplicationRestarter.java | 3 ++- .../ui/setstage/DeveloperDebugStage.java | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jcnc/jnotepad/app/util/ApplicationRestarter.java b/src/main/java/org/jcnc/jnotepad/app/util/ApplicationRestarter.java index ab9a87e..0794af8 100644 --- a/src/main/java/org/jcnc/jnotepad/app/util/ApplicationRestarter.java +++ b/src/main/java/org/jcnc/jnotepad/app/util/ApplicationRestarter.java @@ -1,5 +1,6 @@ package org.jcnc.jnotepad.app.util; +import org.jcnc.jnotepad.LunchApp; import org.jcnc.jnotepad.util.LogUtil; import java.io.IOException; @@ -13,7 +14,7 @@ public class ApplicationRestarter { try { // 获取当前Java应用程序的命令 String javaCommand = System.getProperty("java.home") + "/bin/java"; - String mainClass = ApplicationRestarter.class.getName(); + String mainClass = LunchApp.class.getName(); // 构建新进程来重新启动应用程序 ProcessBuilder builder = new ProcessBuilder(javaCommand, "-cp", System.getProperty("java.class.path"), mainClass); diff --git a/src/main/java/org/jcnc/jnotepad/ui/setstage/DeveloperDebugStage.java b/src/main/java/org/jcnc/jnotepad/ui/setstage/DeveloperDebugStage.java index eae75a3..700ecd7 100644 --- a/src/main/java/org/jcnc/jnotepad/ui/setstage/DeveloperDebugStage.java +++ b/src/main/java/org/jcnc/jnotepad/ui/setstage/DeveloperDebugStage.java @@ -4,6 +4,7 @@ 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.util.ApplicationRestarter; @@ -23,18 +24,22 @@ public class DeveloperDebugStage extends Stage { primaryStage.setTitle("开发者调试页面"); primaryStage.getIcons().add(UiUtil.getAppIcon()); // 创建一个垂直布局 - VBox root = new VBox(); + VBox root = new VBox(10); + HBox alertBox = new HBox(5); + HBox toolBox = new HBox(5); + root.setPadding(new Insets(20)); root.setSpacing(10); // 添加一些调试功能按钮和标签 - Label titleLabel = new Label("开发者调试页面"); + 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("成功提示框"); - Button debugButton6 = new Button("重启软件"); // 按钮点击事件处理 debugButton1.setOnAction(e -> { @@ -66,16 +71,20 @@ public class DeveloperDebugStage extends Stage { PopUpUtil.successAlert("成功", "成功", "这是一个示例成功提示框!", null, null); }); + Button debugButton6 = new Button("重启软件"); debugButton6.setOnAction(event -> { logger.debug("开发者调试: {}启动!", debugButton6.getText()); // 执行重启操作 ApplicationRestarter.restart(); }); + + alertBox.getChildren().addAll(debugButton1, debugButton2, debugButton3, debugButton4, debugButton5); + toolBox.getChildren().addAll(debugButton6); // 将组件添加到布局中 - root.getChildren().addAll(titleLabel, debugButton1, debugButton2, debugButton3, debugButton4, debugButton5, debugButton6); + root.getChildren().addAll(alertLabel, alertBox, toolLabel, toolBox); // 创建场景 - Scene scene = new Scene(root, 400, 300); + Scene scene = new Scene(root, 800, 600); // 将场景添加到舞台 primaryStage.setScene(scene); From 02165abde2b0ff476b4a6ded3c82a5f6aa04f72a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E8=BD=B2?= Date: Sat, 30 Sep 2023 02:57:16 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B8=AE=E5=8A=A9?= =?UTF-8?q?=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constants/TextConstants.java | 1 + .../event/handler/menubar/About.java | 30 +++++++++++++++++++ .../views/manager/TopMenuBarManager.java | 16 ++++++++++ .../views/root/top/menu/TopMenuBar.java | 26 ++++++++++++++++ src/main/resources/i18n/i18n.properties | 1 + src/main/resources/i18n/i18n_en.properties | 1 + src/main/resources/i18n/i18n_zh_CN.properties | 1 + 7 files changed, 76 insertions(+) create mode 100644 src/main/java/org/jcnc/jnotepad/controller/event/handler/menubar/About.java diff --git a/src/main/java/org/jcnc/jnotepad/common/constants/TextConstants.java b/src/main/java/org/jcnc/jnotepad/common/constants/TextConstants.java index 0c8c514..5f31944 100644 --- a/src/main/java/org/jcnc/jnotepad/common/constants/TextConstants.java +++ b/src/main/java/org/jcnc/jnotepad/common/constants/TextConstants.java @@ -16,6 +16,7 @@ public class TextConstants { public static final String SAVE_AS = "SAVE_AS"; public static final String RENAME = "RENAME"; public static final String SET = "SET"; + public static final String HELP = "HELP"; public static final String WORD_WRAP = "WORD_WRAP"; public static final String PLUGIN = "PLUGIN"; public static final String MANAGER_PLUGIN = "MANAGER_PLUGIN"; diff --git a/src/main/java/org/jcnc/jnotepad/controller/event/handler/menubar/About.java b/src/main/java/org/jcnc/jnotepad/controller/event/handler/menubar/About.java new file mode 100644 index 0000000..46fda19 --- /dev/null +++ b/src/main/java/org/jcnc/jnotepad/controller/event/handler/menubar/About.java @@ -0,0 +1,30 @@ +package org.jcnc.jnotepad.controller.event.handler.menubar; + +import javafx.event.ActionEvent; +import javafx.event.EventHandler; + +/** + * 打开关于页面程序。 + * + *

当用户选择关于时,将创建一个新的Stage。

+ * + * @author 许轲 + */ +public class About implements EventHandler { + /** + * 处理关于页面。 + * + * @param event 事件对象 + */ + @Override + public void handle(ActionEvent event) { + addAboutStage(); + } + + /** + * 关于页面。 + */ + public void addAboutStage() { + + } +} diff --git a/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java b/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java index 6b8c845..4be718b 100644 --- a/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java +++ b/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java @@ -39,6 +39,8 @@ public class TopMenuBarManager { private final Map pluginMenuItems = new HashMap<>(); + private final Map helpMenuItems = new HashMap<>(); + private final Map languageMenuItems = new HashMap<>(); Logger logger = LogUtil.getLogger(this.getClass()); AppConfigController appConfigController = AppConfigController.getInstance(); @@ -66,8 +68,11 @@ public class TopMenuBarManager { toggleLanguageCheck(appConfigController.getLanguage()); // 初始化设置菜单 initSettingMenu(); + // 初始化设置菜单 + initHelpMenu(); // 初始化插件菜单 initPluginMenu(); + // 刷新顶部菜单栏 refreshTopMenuBar(); // 初始化快捷键 @@ -300,6 +305,17 @@ public class TopMenuBarManager { initMenuItems(pluginMenuItems, pluginMenu); } + /** + * 初始化插件菜单 + */ + private void initHelpMenu() { + logger.info("初始化帮助菜单!"); + var helpMenu = topMenuBar.gethelpMenuMenu(); + // 插件菜单 + UiResourceBundle.bindStringProperty(helpMenu.textProperty(), HELP); + + initMenuItems(helpMenuItems, helpMenu); + } /** * 初始化设置菜单 */ diff --git a/src/main/java/org/jcnc/jnotepad/views/root/top/menu/TopMenuBar.java b/src/main/java/org/jcnc/jnotepad/views/root/top/menu/TopMenuBar.java index 550293b..c9674e2 100644 --- a/src/main/java/org/jcnc/jnotepad/views/root/top/menu/TopMenuBar.java +++ b/src/main/java/org/jcnc/jnotepad/views/root/top/menu/TopMenuBar.java @@ -32,11 +32,16 @@ public class TopMenuBar extends MenuBar { */ private final Menu setMenu = new Menu(); + /** + * 帮助菜单 + */ + private final Menu helpMenu = new Menu(); /// 菜单按钮 /** * 插件菜单 */ private final Menu pluginMenu = new Menu(); + /** * 语言菜单 */ @@ -45,6 +50,11 @@ public class TopMenuBar extends MenuBar { * 新建 */ private final MenuItem newItem = new MenuItem(); + + /** + * 新建 + */ + private final MenuItem aboutItem = new MenuItem(); /** * 打开 */ @@ -116,10 +126,21 @@ public class TopMenuBar extends MenuBar { return setMenu; } + public Menu getHelpMenu() { + return helpMenu; + } + + + public Menu getPluginMenu() { return pluginMenu; } + public Menu gethelpMenuMenu() { + return helpMenu; + } + + public Menu getLanguageMenu() { return languageMenu; } @@ -132,6 +153,11 @@ public class TopMenuBar extends MenuBar { return newItem; } + + public MenuItem getAboutItem() { + return aboutItem; + } + public MenuItem getOpenItem() { return openItem; } diff --git a/src/main/resources/i18n/i18n.properties b/src/main/resources/i18n/i18n.properties index 0c89879..4759334 100644 --- a/src/main/resources/i18n/i18n.properties +++ b/src/main/resources/i18n/i18n.properties @@ -9,6 +9,7 @@ PLUGIN=插件 CHINESE=中文 title=JNotepad OPEN=打开 +HELP=帮助 OPEN_CONFIGURATION_FILE=打开配置文件 RENAME=重命名 TOP=窗口置顶 diff --git a/src/main/resources/i18n/i18n_en.properties b/src/main/resources/i18n/i18n_en.properties index e37eab2..94ad5b8 100644 --- a/src/main/resources/i18n/i18n_en.properties +++ b/src/main/resources/i18n/i18n_en.properties @@ -9,6 +9,7 @@ PLUGIN=Plugins CHINESE=Chinese title=JNotepad OPEN=Open +HELP=Help OPEN_CONFIGURATION_FILE=Open Configuration File RENAME=Rename TOP=Window Top diff --git a/src/main/resources/i18n/i18n_zh_CN.properties b/src/main/resources/i18n/i18n_zh_CN.properties index 1fbb8bb..9224042 100644 --- a/src/main/resources/i18n/i18n_zh_CN.properties +++ b/src/main/resources/i18n/i18n_zh_CN.properties @@ -9,6 +9,7 @@ PLUGIN=插件 CHINESE=中文 title=JNotepad OPEN=打开 +HELP=帮助 OPEN_CONFIGURATION_FILE=打开配置文件 RENAME=重命名 TOP=窗口置顶 From 7a330ec3f384effe5e71aa0a37b944677d4089d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E8=BD=B2?= Date: Sat, 30 Sep 2023 04:50:59 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=85=B3=E4=BA=8E?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jcnc/jnotepad/app/config/AppConfig.java | 2 + .../common/constants/AppConstants.java | 12 ++ .../common/constants/TextConstants.java | 3 + .../event/handler/menubar/About.java | 30 ---- .../jnotepad/ui/titlebar/CustomTitleBar.java | 2 +- .../views/manager/TopMenuBarManager.java | 134 +++++++++++++++++- .../views/root/top/menu/TopMenuBar.java | 4 - src/main/resources/i18n/i18n.properties | 1 + src/main/resources/i18n/i18n_en.properties | 1 + src/main/resources/i18n/i18n_zh_CN.properties | 1 + 10 files changed, 154 insertions(+), 36 deletions(-) delete mode 100644 src/main/java/org/jcnc/jnotepad/controller/event/handler/menubar/About.java diff --git a/src/main/java/org/jcnc/jnotepad/app/config/AppConfig.java b/src/main/java/org/jcnc/jnotepad/app/config/AppConfig.java index e15c3d0..fc1a831 100644 --- a/src/main/java/org/jcnc/jnotepad/app/config/AppConfig.java +++ b/src/main/java/org/jcnc/jnotepad/app/config/AppConfig.java @@ -43,6 +43,8 @@ public class AppConfig { shortcutKeys.add(createShortcutKey("openConfigItem", ALT_S)); shortcutKeys.add(createShortcutKey("pluginManager", "")); shortcutKeys.add(createShortcutKey("countItem", "")); + shortcutKeys.add(createShortcutKey("aboutItem", "")); + config.setShortcutKey(shortcutKeys); return config; } diff --git a/src/main/java/org/jcnc/jnotepad/common/constants/AppConstants.java b/src/main/java/org/jcnc/jnotepad/common/constants/AppConstants.java index 9cb5f62..4c946b0 100644 --- a/src/main/java/org/jcnc/jnotepad/common/constants/AppConstants.java +++ b/src/main/java/org/jcnc/jnotepad/common/constants/AppConstants.java @@ -10,6 +10,18 @@ import java.util.regex.Pattern; * @author 许轲 */ public class AppConstants { + /** + * 版本号 + */ + public static final String VERSION = "1.0.12"; + /** + * 作者 + */ + public static final String AUTHOR = "JCNC"; + /** + * 软件名称 + */ + public static final String APP_NAME = "JNotepad"; /** * 初始宽度 */ diff --git a/src/main/java/org/jcnc/jnotepad/common/constants/TextConstants.java b/src/main/java/org/jcnc/jnotepad/common/constants/TextConstants.java index 5f31944..9045874 100644 --- a/src/main/java/org/jcnc/jnotepad/common/constants/TextConstants.java +++ b/src/main/java/org/jcnc/jnotepad/common/constants/TextConstants.java @@ -20,6 +20,9 @@ public class TextConstants { public static final String WORD_WRAP = "WORD_WRAP"; public static final String PLUGIN = "PLUGIN"; public static final String MANAGER_PLUGIN = "MANAGER_PLUGIN"; + + public static final String ABOUT = "ABOUT"; + public static final String STATISTICS = "STATISTICS"; public static final String OPEN_CONFIGURATION_FILE = "OPEN_CONFIGURATION_FILE"; public static final String TOP = "TOP"; diff --git a/src/main/java/org/jcnc/jnotepad/controller/event/handler/menubar/About.java b/src/main/java/org/jcnc/jnotepad/controller/event/handler/menubar/About.java deleted file mode 100644 index 46fda19..0000000 --- a/src/main/java/org/jcnc/jnotepad/controller/event/handler/menubar/About.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.jcnc.jnotepad.controller.event.handler.menubar; - -import javafx.event.ActionEvent; -import javafx.event.EventHandler; - -/** - * 打开关于页面程序。 - * - *

当用户选择关于时,将创建一个新的Stage。

- * - * @author 许轲 - */ -public class About implements EventHandler { - /** - * 处理关于页面。 - * - * @param event 事件对象 - */ - @Override - public void handle(ActionEvent event) { - addAboutStage(); - } - - /** - * 关于页面。 - */ - public void addAboutStage() { - - } -} diff --git a/src/main/java/org/jcnc/jnotepad/ui/titlebar/CustomTitleBar.java b/src/main/java/org/jcnc/jnotepad/ui/titlebar/CustomTitleBar.java index b243079..bec70f6 100644 --- a/src/main/java/org/jcnc/jnotepad/ui/titlebar/CustomTitleBar.java +++ b/src/main/java/org/jcnc/jnotepad/ui/titlebar/CustomTitleBar.java @@ -19,7 +19,7 @@ import javafx.util.Duration; public class CustomTitleBar extends HBox { private static CustomTitleBar instance; - private CustomTitleBar() { + public CustomTitleBar() { // 设置样式和布局 this.setAlignment(Pos.CENTER); diff --git a/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java b/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java index 4be718b..27a6005 100644 --- a/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java +++ b/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java @@ -1,13 +1,20 @@ package org.jcnc.jnotepad.views.manager; +import atlantafx.base.theme.Styles; import javafx.beans.value.ChangeListener; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; +import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.*; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; import javafx.scene.input.KeyCombination; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; import javafx.stage.Stage; import org.jcnc.jnotepad.app.i18n.UiResourceBundle; import org.jcnc.jnotepad.controller.config.AppConfigController; @@ -22,6 +29,7 @@ import org.slf4j.Logger; import java.util.*; +import static org.jcnc.jnotepad.common.constants.AppConstants.*; import static org.jcnc.jnotepad.common.constants.TextConstants.*; /** @@ -130,6 +138,116 @@ public class TopMenuBarManager { }); registerPluginMenuItem(topMenuBar.getCountItem(), STATISTICS, "countItem", event -> { }); + + //帮助菜单 + registerHelpMenuItem(topMenuBar.getAboutItem(), ABOUT, "aboutItem", event -> { + Stage aboutStage = new Stage(); + String leftBtnText = " 确定 "; + + String rightBtnText = " 取消 "; + Button leftBtn = new Button(); + leftBtn.getStyleClass().addAll(Styles.SMALL); + leftBtn.setText(leftBtnText); + + Button rightBtn = new Button(); + rightBtn.getStyleClass().addAll(Styles.SMALL); + rightBtn.setText(rightBtnText); + aboutStage.getIcons().add(UiUtil.getAppIcon()); + aboutStage.setTitle("关于 " + APP_NAME); + BorderPane root = new BorderPane(); + VBox textBox = new VBox(); + VBox iconBox = new VBox(); + ImageView iconImageView = new ImageView(new Image("icon.png")); + iconImageView.setFitWidth(50); + iconImageView.setFitHeight(50); + iconBox.setPadding(new Insets(20)); + + iconBox.getChildren().addAll(iconImageView); + + + textBox.setPadding(new Insets(10)); + + HBox titleBox = new HBox(5); + titleBox.setPadding(new Insets(10, 0, 0, 0)); + + Label titleLabel = new Label(APP_NAME); + titleLabel.setStyle("-fx-font-size: 16px; -fx-font-weight: bold;"); + + Label versionLabel = new Label(VERSION); + versionLabel.setPadding(new Insets(0.5, 0, 0, 0)); + versionLabel.setStyle("-fx-font-size: 15px; -fx-font-weight: bold;"); + + titleBox.getChildren().addAll(titleLabel, versionLabel); + + Label descriptionLabel = new Label(APP_NAME + "是一款自由的集成开发环境。"); + descriptionLabel.setPadding(new Insets(8, 0, 8, 0)); + descriptionLabel.setStyle("-fx-font-size: 14px;"); + + VBox linkBox = new VBox(7); + Hyperlink repositoryLink = new Hyperlink(); + repositoryLink.setText("仓库地址"); + repositoryLink.setOnAction(event1 -> { + openWebsite("https://gitee.com/jcnc-org/JNotepad"); + }); + repositoryLink.setVisited(true); + repositoryLink.setMnemonicParsing(true); + repositoryLink.setStyle("-color-link-fg-visited:-color-accent-fg;"); + + Hyperlink feedBackLink = new Hyperlink(); + feedBackLink.setText("提交反馈"); + feedBackLink.setOnAction(event1 -> { + openWebsite("https://gitee.com/jcnc-org/JNotepad/issues/new/choose"); + }); + feedBackLink.setVisited(true); + feedBackLink.setMnemonicParsing(true); + feedBackLink.setStyle("-color-link-fg-visited:-color-accent-fg;"); + + Hyperlink qLink = new Hyperlink(); + qLink.setText("加入QQ群"); + qLink.setOnAction(event1 -> { + openWebsite("https://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=x3QF-jrJAKTiwu8kV5-giBk2ow66Kzyr&authKey=qNqrQauD7Ra4fXH%2Ftu4ylHXCyrf2EOYj9oMYOmFjlzYmrgDL8Yd0m2qhrQQEBL25&noverify=0&group_code=386279455"); + }); + qLink.setVisited(true); + qLink.setMnemonicParsing(true); + qLink.setStyle("-color-link-fg-visited:-color-accent-fg;"); + + linkBox.getChildren().addAll(repositoryLink, feedBackLink, qLink); + + Label authorLabel = new Label("Copyleft © 2023 " + AUTHOR + "."); + authorLabel.setPadding(new Insets(8, 0, 8, 0)); + authorLabel.setStyle("-fx-font-size: 14px;"); + + textBox.getChildren().addAll(titleBox, descriptionLabel, linkBox, authorLabel); + + HBox bottomBox = new HBox(10); + bottomBox.setPadding(new Insets(7, 15, 7, 0)); + + bottomBox.setAlignment(Pos.CENTER_RIGHT); + + bottomBox.getChildren().addAll(leftBtn, rightBtn); + root.setBottom(bottomBox); + + root.setCenter(textBox); + root.setLeft(iconBox); + + Scene scene = new Scene(root, 450, 240); + aboutStage.setResizable (false); + aboutStage.setScene(scene); + aboutStage.show(); + + }); + } + + /** + * 打开网页方法 + */ + private void openWebsite(String url) { + try { + LogUtil.getLogger(this.getClass()).info("正在打开---" + url); + java.awt.Desktop.getDesktop().browse(java.net.URI.create(url)); + } catch (java.io.IOException e) { + LogUtil.getLogger(this.getClass()).info("打开失败---" + url); + } } /** @@ -170,6 +288,19 @@ public class TopMenuBarManager { setMenuItem(menuItem, buttonName, eventHandler); } + /** + * 注册帮助菜单项 + * + * @param menuItem 菜单项 + * @param menuItemName 菜单项名称 + * @param buttonName 按钮名称 + * @param eventHandler 操作事件 + */ + public void registerHelpMenuItem(MenuItem menuItem, String menuItemName, String buttonName, EventHandler eventHandler) { + helpMenuItems.put(menuItemName, menuItem); + setMenuItem(menuItem, buttonName, eventHandler); + } + /** * 注册设置菜单项 * @@ -310,12 +441,13 @@ public class TopMenuBarManager { */ private void initHelpMenu() { logger.info("初始化帮助菜单!"); - var helpMenu = topMenuBar.gethelpMenuMenu(); + var helpMenu = topMenuBar.getHelpMenu(); // 插件菜单 UiResourceBundle.bindStringProperty(helpMenu.textProperty(), HELP); initMenuItems(helpMenuItems, helpMenu); } + /** * 初始化设置菜单 */ diff --git a/src/main/java/org/jcnc/jnotepad/views/root/top/menu/TopMenuBar.java b/src/main/java/org/jcnc/jnotepad/views/root/top/menu/TopMenuBar.java index c9674e2..12c0f9f 100644 --- a/src/main/java/org/jcnc/jnotepad/views/root/top/menu/TopMenuBar.java +++ b/src/main/java/org/jcnc/jnotepad/views/root/top/menu/TopMenuBar.java @@ -136,10 +136,6 @@ public class TopMenuBar extends MenuBar { return pluginMenu; } - public Menu gethelpMenuMenu() { - return helpMenu; - } - public Menu getLanguageMenu() { return languageMenu; diff --git a/src/main/resources/i18n/i18n.properties b/src/main/resources/i18n/i18n.properties index 4759334..f9a767e 100644 --- a/src/main/resources/i18n/i18n.properties +++ b/src/main/resources/i18n/i18n.properties @@ -9,6 +9,7 @@ PLUGIN=插件 CHINESE=中文 title=JNotepad OPEN=打开 +ABOUT=关于 HELP=帮助 OPEN_CONFIGURATION_FILE=打开配置文件 RENAME=重命名 diff --git a/src/main/resources/i18n/i18n_en.properties b/src/main/resources/i18n/i18n_en.properties index 94ad5b8..f09df8f 100644 --- a/src/main/resources/i18n/i18n_en.properties +++ b/src/main/resources/i18n/i18n_en.properties @@ -4,6 +4,7 @@ NEW_FILE=New File SET=Settings ENGLISH=English STATISTICS=Word Count +ABOUT=About COLUMN=Column PLUGIN=Plugins CHINESE=Chinese diff --git a/src/main/resources/i18n/i18n_zh_CN.properties b/src/main/resources/i18n/i18n_zh_CN.properties index 9224042..e9d8ba7 100644 --- a/src/main/resources/i18n/i18n_zh_CN.properties +++ b/src/main/resources/i18n/i18n_zh_CN.properties @@ -10,6 +10,7 @@ CHINESE=中文 title=JNotepad OPEN=打开 HELP=帮助 +ABOUT=关于 OPEN_CONFIGURATION_FILE=打开配置文件 RENAME=重命名 TOP=窗口置顶 From c7c27d785acc1c08578b0ddcdab940a8692ee569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E8=BD=B2?= Date: Sat, 30 Sep 2023 05:01:39 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/manager/TopMenuBarManager.java | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java b/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java index 27a6005..fd8feeb 100644 --- a/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java +++ b/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java @@ -11,6 +11,8 @@ import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.image.Image; import javafx.scene.image.ImageView; +import javafx.scene.input.Clipboard; +import javafx.scene.input.ClipboardContent; import javafx.scene.input.KeyCombination; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; @@ -142,9 +144,9 @@ public class TopMenuBarManager { //帮助菜单 registerHelpMenuItem(topMenuBar.getAboutItem(), ABOUT, "aboutItem", event -> { Stage aboutStage = new Stage(); - String leftBtnText = " 确定 "; + String leftBtnText = " 复制并关闭 "; - String rightBtnText = " 取消 "; + String rightBtnText = " 关闭 "; Button leftBtn = new Button(); leftBtn.getStyleClass().addAll(Styles.SMALL); leftBtn.setText(leftBtnText); @@ -222,16 +224,34 @@ public class TopMenuBarManager { HBox bottomBox = new HBox(10); bottomBox.setPadding(new Insets(7, 15, 7, 0)); - bottomBox.setAlignment(Pos.CENTER_RIGHT); + bottomBox.setAlignment(Pos.BOTTOM_RIGHT); + leftBtn.setOnAction(event1 -> { + Clipboard clipboard = Clipboard.getSystemClipboard(); + ClipboardContent content = new ClipboardContent(); + String info="软件名字:" + APP_NAME + "\t" + "版本:" + VERSION; + content.putString(info); + LogUtil.getLogger(this.getClass()).info("软件信息已经复制到剪贴板:" + info); + clipboard.setContent(content); + // 关闭当前的 Stage + Stage currentStage = (Stage) leftBtn.getScene().getWindow(); + currentStage.close(); + }); + + rightBtn.setOnAction(event1 -> { + // 关闭当前的 Stage + Stage currentStage = (Stage) rightBtn.getScene().getWindow(); + currentStage.close(); + }); bottomBox.getChildren().addAll(leftBtn, rightBtn); + + root.setLeft(iconBox); + root.setCenter(textBox); + root.setBottom(bottomBox); - root.setCenter(textBox); - root.setLeft(iconBox); - Scene scene = new Scene(root, 450, 240); - aboutStage.setResizable (false); + aboutStage.setResizable(false); aboutStage.setScene(scene); aboutStage.show(); From c547a29b46dc06ad56d1eb6e824b362cb1aa5049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E8=BD=B2?= Date: Sat, 30 Sep 2023 06:17:40 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/manager/ApplicationManager.java | 1 + .../views/manager/RootBorderPaneManager.java | 1 + .../jnotepad/views/manager/RootManager.java | 45 +++++++++++++++++-- .../views/manager/TopMenuBarManager.java | 15 ++++++- .../jnotepad/views/root/RootBorderPane.java | 1 - 5 files changed, 58 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jcnc/jnotepad/app/manager/ApplicationManager.java b/src/main/java/org/jcnc/jnotepad/app/manager/ApplicationManager.java index af42fb0..3ee10fe 100644 --- a/src/main/java/org/jcnc/jnotepad/app/manager/ApplicationManager.java +++ b/src/main/java/org/jcnc/jnotepad/app/manager/ApplicationManager.java @@ -168,6 +168,7 @@ public class ApplicationManager { RootRightSideBarVerticalBoxManager.getInstance().initRootRightSideBarVerticalBox(); // 初始化根布局 RootBorderPaneManager.getInstance().initRootBorderPane(); + } public Pane getRoot() { diff --git a/src/main/java/org/jcnc/jnotepad/views/manager/RootBorderPaneManager.java b/src/main/java/org/jcnc/jnotepad/views/manager/RootBorderPaneManager.java index 6e18f29..022a4fe 100644 --- a/src/main/java/org/jcnc/jnotepad/views/manager/RootBorderPaneManager.java +++ b/src/main/java/org/jcnc/jnotepad/views/manager/RootBorderPaneManager.java @@ -43,5 +43,6 @@ public class RootBorderPaneManager { rootBorderPane.setTopComponent(RootTopBorderPane.getInstance()); // 主界面的下面,底部边栏 rootBorderPane.setBottomComponent(RootBottomSideBarVerticalBox.getInstance()); + } } diff --git a/src/main/java/org/jcnc/jnotepad/views/manager/RootManager.java b/src/main/java/org/jcnc/jnotepad/views/manager/RootManager.java index 8bdcbdb..8a9a6be 100644 --- a/src/main/java/org/jcnc/jnotepad/views/manager/RootManager.java +++ b/src/main/java/org/jcnc/jnotepad/views/manager/RootManager.java @@ -1,7 +1,15 @@ package org.jcnc.jnotepad.views.manager; +import atlantafx.base.controls.Notification; +import atlantafx.base.theme.Styles; +import atlantafx.base.util.Animations; +import javafx.geometry.Insets; +import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; +import javafx.scene.layout.Region; +import javafx.scene.layout.StackPane; +import javafx.util.Duration; import org.jcnc.jnotepad.exception.AppException; import org.jcnc.jnotepad.views.root.RootBorderPane; @@ -15,7 +23,7 @@ import org.jcnc.jnotepad.views.root.RootBorderPane; public class RootManager { private static RootManager instance = null; - + StackPane rootStackPane; /** * 主布局 */ @@ -65,11 +73,42 @@ public class RootManager { * @param scene 与视图相关联的 JavaFX 场景。 */ public void initScreen(Scene scene) { + rootStackPane = new StackPane(); + // 创建主界面布局 - root = new BorderPane(); + BorderPane root = new BorderPane(); root.setCenter(RootBorderPane.getInstance()); - scene.setRoot(root); + rootStackPane.getChildren().addAll(root); + scene.setRoot(rootStackPane); } + + /** + * 将提示框添加到 StackPane 中。 + * + * @param stackPane 要添加提示框的 StackPane。 + * @param msg 要显示的提示框。 + */ + public void addNotificationToStackPane(StackPane stackPane, Notification msg) { + msg.getStyleClass().addAll(Styles.ACCENT, Styles.ELEVATED_1); + msg.setPrefHeight(Region.USE_PREF_SIZE); + msg.setMaxHeight(Region.USE_PREF_SIZE); + StackPane.setAlignment(msg, Pos.TOP_RIGHT); + StackPane.setMargin(msg, new Insets(10, 10, 0, 0)); + + msg.setOnClose(e -> { + var out = Animations.slideOutUp(msg, Duration.millis(250)); + out.setOnFinished(f -> stackPane.getChildren().remove(msg)); + out.playFromStart(); + }); + + + var in = Animations.slideInDown(msg, Duration.millis(250)); + if (!stackPane.getChildren().contains(msg)) { + stackPane.getChildren().add(msg); + } + in.playFromStart(); + } + } diff --git a/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java b/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java index fd8feeb..63d71d0 100644 --- a/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java +++ b/src/main/java/org/jcnc/jnotepad/views/manager/TopMenuBarManager.java @@ -1,5 +1,6 @@ package org.jcnc.jnotepad.views.manager; +import atlantafx.base.controls.Notification; import atlantafx.base.theme.Styles; import javafx.beans.value.ChangeListener; import javafx.collections.ObservableList; @@ -227,15 +228,27 @@ public class TopMenuBarManager { bottomBox.setAlignment(Pos.BOTTOM_RIGHT); leftBtn.setOnAction(event1 -> { + + // 获取 RootManager 的实例 + RootManager rootManager = RootManager.getInstance(); + + // 创建一个新的 Notification + Notification notification = new Notification(); + notification.setMessage("已成功复制软件信息!"); + + // 调用 RootManager 中的方法来显示 Notification + rootManager.addNotificationToStackPane(rootManager.rootStackPane, notification); + Clipboard clipboard = Clipboard.getSystemClipboard(); ClipboardContent content = new ClipboardContent(); - String info="软件名字:" + APP_NAME + "\t" + "版本:" + VERSION; + String info = "软件名字:" + APP_NAME + "\t" + "版本:" + VERSION; content.putString(info); LogUtil.getLogger(this.getClass()).info("软件信息已经复制到剪贴板:" + info); clipboard.setContent(content); // 关闭当前的 Stage Stage currentStage = (Stage) leftBtn.getScene().getWindow(); currentStage.close(); + }); rightBtn.setOnAction(event1 -> { diff --git a/src/main/java/org/jcnc/jnotepad/views/root/RootBorderPane.java b/src/main/java/org/jcnc/jnotepad/views/root/RootBorderPane.java index 34a9b76..2959c36 100644 --- a/src/main/java/org/jcnc/jnotepad/views/root/RootBorderPane.java +++ b/src/main/java/org/jcnc/jnotepad/views/root/RootBorderPane.java @@ -16,7 +16,6 @@ public class RootBorderPane extends AbstractBorderPane { private static final RootBorderPane INSTANCE = new RootBorderPane(); private RootBorderPane() { - } /** From c63066e26ea07b6682f62774026c1396da9ab1ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E8=BD=B2?= Date: Sat, 30 Sep 2023 06:23:41 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E6=A1=86=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jcnc/jnotepad/views/manager/RootManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jcnc/jnotepad/views/manager/RootManager.java b/src/main/java/org/jcnc/jnotepad/views/manager/RootManager.java index 8a9a6be..5a352f8 100644 --- a/src/main/java/org/jcnc/jnotepad/views/manager/RootManager.java +++ b/src/main/java/org/jcnc/jnotepad/views/manager/RootManager.java @@ -94,8 +94,8 @@ public class RootManager { msg.getStyleClass().addAll(Styles.ACCENT, Styles.ELEVATED_1); msg.setPrefHeight(Region.USE_PREF_SIZE); msg.setMaxHeight(Region.USE_PREF_SIZE); - StackPane.setAlignment(msg, Pos.TOP_RIGHT); - StackPane.setMargin(msg, new Insets(10, 10, 0, 0)); + StackPane.setAlignment(msg, Pos.BOTTOM_RIGHT); + StackPane.setMargin(msg, new Insets(5, 10, 35, 0)); msg.setOnClose(e -> { var out = Animations.slideOutUp(msg, Duration.millis(250)); @@ -103,7 +103,6 @@ public class RootManager { out.playFromStart(); }); - var in = Animations.slideInDown(msg, Duration.millis(250)); if (!stackPane.getChildren().contains(msg)) { stackPane.getChildren().add(msg);