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 1/5] =?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 2/5] =?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 3/5] =?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 4/5] =?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 5/5] =?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);