!123 fea:增加重启方法和更新开发者调试页面
Merge pull request !123 from Luke/release-v1.1.13
This commit is contained in:
commit
e4d5d8a129
1
pom.xml
1
pom.xml
@ -131,7 +131,6 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<mainClass>org.jcnc.jnotepad/org.jcnc.jnotepad.LunchApp</mainClass>
|
<mainClass>org.jcnc.jnotepad/org.jcnc.jnotepad.LunchApp</mainClass>
|
||||||
<launcher>JNotepad</launcher>
|
<launcher>JNotepad</launcher>
|
||||||
<jlinkZipName>JNotepad</jlinkZipName>
|
|
||||||
<jlinkImageName>JNotepad</jlinkImageName>
|
<jlinkImageName>JNotepad</jlinkImageName>
|
||||||
<noManPages>true</noManPages>
|
<noManPages>true</noManPages>
|
||||||
<stripDebug>true</stripDebug>
|
<stripDebug>true</stripDebug>
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
package org.jcnc.jnotepad.app.util;
|
||||||
|
|
||||||
|
import org.jcnc.jnotepad.LunchApp;
|
||||||
|
import org.jcnc.jnotepad.util.LogUtil;
|
||||||
|
|
||||||
|
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 = LunchApp.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());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
package org.jcnc.jnotepad.plugin.manager;
|
package org.jcnc.jnotepad.plugin.manager;
|
||||||
|
|
||||||
import org.jcnc.jnotepad.app.manager.ApplicationManager;
|
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.common.manager.ThreadPoolManager;
|
||||||
import org.jcnc.jnotepad.controller.config.PluginConfigController;
|
import org.jcnc.jnotepad.controller.config.PluginConfigController;
|
||||||
import org.jcnc.jnotepad.model.entity.PluginDescriptor;
|
import org.jcnc.jnotepad.model.entity.PluginDescriptor;
|
||||||
@ -200,8 +201,8 @@ public class PluginManager {
|
|||||||
PopUpUtil.questionAlert("更改", "程序与插件更新", "请重启程序以应用插件中的更改!",
|
PopUpUtil.questionAlert("更改", "程序与插件更新", "请重启程序以应用插件中的更改!",
|
||||||
appDialog -> {
|
appDialog -> {
|
||||||
appDialog.close();
|
appDialog.close();
|
||||||
// 执行关闭操作
|
// 执行重启操作
|
||||||
ApplicationManager.getInstance().stopApplication();
|
ApplicationRestarter.restart();
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,8 +4,10 @@ import javafx.geometry.Insets;
|
|||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import org.jcnc.jnotepad.app.util.ApplicationRestarter;
|
||||||
import org.jcnc.jnotepad.util.LogUtil;
|
import org.jcnc.jnotepad.util.LogUtil;
|
||||||
import org.jcnc.jnotepad.util.PopUpUtil;
|
import org.jcnc.jnotepad.util.PopUpUtil;
|
||||||
import org.jcnc.jnotepad.util.UiUtil;
|
import org.jcnc.jnotepad.util.UiUtil;
|
||||||
@ -22,12 +24,17 @@ public class DeveloperDebugStage extends Stage {
|
|||||||
primaryStage.setTitle("开发者调试页面");
|
primaryStage.setTitle("开发者调试页面");
|
||||||
primaryStage.getIcons().add(UiUtil.getAppIcon());
|
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.setPadding(new Insets(20));
|
||||||
root.setSpacing(10);
|
root.setSpacing(10);
|
||||||
|
|
||||||
// 添加一些调试功能按钮和标签
|
// 添加一些调试功能按钮和标签
|
||||||
Label titleLabel = new Label("开发者调试页面");
|
Label alertLabel = new Label("提示框");
|
||||||
|
Label toolLabel = new Label("工具");
|
||||||
|
|
||||||
Button debugButton1 = new Button("错误提示框");
|
Button debugButton1 = new Button("错误提示框");
|
||||||
Button debugButton2 = new Button("信息提示框");
|
Button debugButton2 = new Button("信息提示框");
|
||||||
Button debugButton3 = new Button("警告提示框");
|
Button debugButton3 = new Button("警告提示框");
|
||||||
@ -64,11 +71,20 @@ public class DeveloperDebugStage extends Stage {
|
|||||||
PopUpUtil.successAlert("成功", "成功", "这是一个示例成功提示框!", null, null);
|
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);
|
root.getChildren().addAll(alertLabel, alertBox, toolLabel, toolBox);
|
||||||
|
|
||||||
// 创建场景
|
// 创建场景
|
||||||
Scene scene = new Scene(root, 400, 300);
|
Scene scene = new Scene(root, 800, 600);
|
||||||
|
|
||||||
// 将场景添加到舞台
|
// 将场景添加到舞台
|
||||||
primaryStage.setScene(scene);
|
primaryStage.setScene(scene);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user