Skip to content

Commit 34e24a7

Browse files
committed
调整设置窗口界面、调整退出对话框
1 parent f57f05e commit 34e24a7

4 files changed

Lines changed: 49 additions & 87 deletions

File tree

src/main/java/com/xwintop/xJavaFxTool/Main.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
import com.xwintop.xJavaFxTool.utils.StageUtils;
77
import com.xwintop.xJavaFxTool.utils.XJavaFxSystemUtil;
88
import com.xwintop.xcore.javafx.FxApp;
9-
import com.xwintop.xcore.util.javafx.AlertUtil;
9+
import com.xwintop.xcore.javafx.dialog.FxAlerts;
1010
import com.xwintop.xcore.util.javafx.JavaFxViewUtil;
11+
import java.util.ResourceBundle;
1112
import javafx.application.Application;
1213
import javafx.application.Platform;
1314
import javafx.event.Event;
@@ -18,8 +19,6 @@
1819
import javafx.stage.Stage;
1920
import lombok.extern.slf4j.Slf4j;
2021

21-
import java.util.ResourceBundle;
22-
2322
/**
2423
* @ClassName: Main
2524
* @Description: 启动类
@@ -81,7 +80,7 @@ public void start(Stage primaryStage) throws Exception {
8180

8281
private void confirmExit(Event event) {
8382
if (XJavaFxSystemUtil.getSystemConfigure().getBoolean("exitShowAlertCheckBox", true)) {
84-
if (AlertUtil.confirmOkCancel("退出应用", "确定要退出吗?")) {
83+
if (FxAlerts.confirmYesNo("退出应用", "确定要退出吗?")) {
8584
StageUtils.savePrimaryStageBound(stage);
8685
Platform.exit();
8786
System.exit(0);

src/main/java/com/xwintop/xJavaFxTool/controller/IndexController.java

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,31 @@
88
import com.xwintop.xJavaFxTool.utils.Config;
99
import com.xwintop.xJavaFxTool.utils.XJavaFxSystemUtil;
1010
import com.xwintop.xJavaFxTool.view.IndexView;
11+
import com.xwintop.xcore.javafx.FxApp;
12+
import com.xwintop.xcore.javafx.dialog.FxDialog;
1113
import com.xwintop.xcore.util.ConfigureUtil;
1214
import com.xwintop.xcore.util.HttpClientUtil;
1315
import com.xwintop.xcore.util.javafx.AlertUtil;
1416
import com.xwintop.xcore.util.javafx.JavaFxSystemUtil;
1517
import com.xwintop.xcore.util.javafx.JavaFxViewUtil;
18+
import java.io.File;
19+
import java.io.FilenameFilter;
20+
import java.io.InputStream;
21+
import java.net.URL;
22+
import java.util.ArrayList;
23+
import java.util.Date;
24+
import java.util.HashMap;
25+
import java.util.List;
26+
import java.util.Map;
27+
import java.util.ResourceBundle;
28+
import java.util.jar.JarEntry;
29+
import java.util.jar.JarFile;
1630
import javafx.application.Platform;
1731
import javafx.event.ActionEvent;
1832
import javafx.fxml.FXML;
1933
import javafx.fxml.FXMLLoader;
2034
import javafx.scene.Parent;
35+
import javafx.scene.control.ButtonType;
2136
import javafx.scene.control.ContextMenu;
2237
import javafx.scene.control.Menu;
2338
import javafx.scene.control.MenuItem;
@@ -35,14 +50,6 @@
3550
import org.dom4j.tree.DefaultAttribute;
3651
import org.dom4j.tree.DefaultElement;
3752

38-
import java.io.File;
39-
import java.io.FilenameFilter;
40-
import java.io.InputStream;
41-
import java.net.URL;
42-
import java.util.*;
43-
import java.util.jar.JarEntry;
44-
import java.util.jar.JarFile;
45-
4653
/**
4754
* @ClassName: IndexController
4855
* @Description: 主页
@@ -271,7 +278,21 @@ private void pluginManageAction(ActionEvent event) throws Exception {
271278

272279
@FXML
273280
private void SettingAction(ActionEvent event) throws Exception {
274-
SystemSettingController.showSystemSetting(bundle.getString("Setting"));
281+
282+
FxDialog<SystemSettingController> dialog = new FxDialog<SystemSettingController>()
283+
.setTitle(bundle.getString("Setting"))
284+
.setBodyFxml("/com/xwintop/xJavaFxTool/fxmlView/index/SystemSetting.fxml")
285+
.setOwner(FxApp.primaryStage)
286+
.setButtonTypes(ButtonType.OK, ButtonType.CANCEL);
287+
288+
SystemSettingController controller = dialog.show();
289+
290+
dialog
291+
.setButtonHandler(ButtonType.OK, (actionEvent, stage) -> {
292+
controller.applySettings();
293+
stage.close();
294+
})
295+
.setButtonHandler(ButtonType.CANCEL, (actionEvent, stage) -> stage.close());
275296
}
276297

277298
@FXML
Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
package com.xwintop.xJavaFxTool.controller.index;
22

3-
import com.xwintop.xJavaFxTool.controller.IndexController;
43
import com.xwintop.xJavaFxTool.services.index.SystemSettingService;
54
import com.xwintop.xJavaFxTool.utils.XJavaFxSystemUtil;
65
import com.xwintop.xJavaFxTool.view.index.SystemSettingView;
7-
import com.xwintop.xcore.util.javafx.JavaFxViewUtil;
8-
import javafx.event.ActionEvent;
9-
import javafx.fxml.FXML;
10-
import javafx.fxml.FXMLLoader;
11-
import javafx.scene.Parent;
12-
import javafx.stage.Modality;
6+
import java.net.URL;
7+
import java.util.ResourceBundle;
138
import javafx.stage.Stage;
149
import lombok.Getter;
1510
import lombok.Setter;
1611
import lombok.extern.slf4j.Slf4j;
1712
import org.apache.commons.configuration.PropertiesConfiguration;
1813

19-
import java.net.URL;
20-
import java.util.ResourceBundle;
21-
2214
/**
2315
* @ClassName: SystemSettingController
2416
* @Description: 设置页面
@@ -30,25 +22,14 @@
3022
@Setter
3123
@Slf4j
3224
public class SystemSettingController extends SystemSettingView {
25+
3326
private SystemSettingService systemSettingService = new SystemSettingService(this);
34-
private Stage newStage = null;
3527

36-
//显示设置界面
37-
public static void showSystemSetting(String title) throws Exception {
38-
FXMLLoader fXMLLoader = new FXMLLoader(IndexController.class.getResource("/com/xwintop/xJavaFxTool/fxmlView/index/SystemSetting.fxml"));
39-
Parent root = fXMLLoader.load();
40-
SystemSettingController systemSettingController = fXMLLoader.getController();
41-
Stage newStage = JavaFxViewUtil.getNewStageNull(title, null, root, -1, -1, false, false, false);
42-
newStage.initModality(Modality.APPLICATION_MODAL);
43-
systemSettingController.setNewStage(newStage);
44-
newStage.showAndWait();
45-
}
28+
private Stage newStage = null;
4629

4730
@Override
4831
public void initialize(URL location, ResourceBundle resources) {
4932
initView();
50-
initEvent();
51-
initService();
5233
}
5334

5435
private void initView() {
@@ -60,17 +41,9 @@ private void initView() {
6041
} catch (Exception e) {
6142
log.error("加载配置失败:", e);
6243
}
63-
64-
}
65-
66-
private void initEvent() {
67-
}
68-
69-
private void initService() {
7044
}
7145

72-
@FXML
73-
private void saveAction(ActionEvent event) {
46+
public void applySettings() {
7447
try {
7548
PropertiesConfiguration xmlConfigure = XJavaFxSystemUtil.getSystemConfigure();
7649
xmlConfigure.setProperty("exitShowAlertCheckBox", exitShowAlertCheckBox.isSelected());
@@ -84,11 +57,4 @@ private void saveAction(ActionEvent event) {
8457
log.error("保存配置失败:", e);
8558
}
8659
}
87-
88-
@FXML
89-
private void cancelAction(ActionEvent event) {
90-
if (newStage != null) {
91-
newStage.close();
92-
}
93-
}
9460
}
Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<?import javafx.geometry.Insets?>
4-
<?import javafx.scene.control.Button?>
54
<?import javafx.scene.control.CheckBox?>
6-
<?import javafx.scene.layout.AnchorPane?>
7-
<?import javafx.scene.layout.HBox?>
85
<?import javafx.scene.layout.VBox?>
6+
<VBox xmlns="http://javafx.com/javafx/8.0.171"
7+
xmlns:fx="http://javafx.com/fxml/1" spacing="15"
8+
fx:controller="com.xwintop.xJavaFxTool.controller.index.SystemSettingController">
99

10-
<AnchorPane prefHeight="155.0" prefWidth="297.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.xwintop.xJavaFxTool.controller.index.SystemSettingController">
11-
<children>
12-
<VBox alignment="CENTER" spacing="10.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
13-
<children>
14-
<HBox alignment="CENTER" spacing="10.0">
15-
<children>
16-
<CheckBox fx:id="exitShowAlertCheckBox" mnemonicParsing="false" selected="true" text="退出时是否显示确认对话框" />
17-
</children>
18-
</HBox>
19-
<HBox alignment="CENTER" spacing="10.0">
20-
<children>
21-
<CheckBox fx:id="addNotepadCheckBox" mnemonicParsing="false" selected="true" text="打开时是否加载临时记事本页面" />
22-
</children>
23-
</HBox>
24-
<HBox alignment="CENTER" spacing="10.0">
25-
<children>
26-
<CheckBox fx:id="saveStageBoundCheckBox" mnemonicParsing="false" selected="true" text="是否在退出时保存窗口大小及位置信息" />
27-
</children>
28-
</HBox>
29-
<HBox alignment="CENTER" spacing="10.0">
30-
<children>
31-
<Button fx:id="saveButton" mnemonicParsing="false" onAction="#saveAction" text="保存" />
32-
<Button fx:id="cancelButton" mnemonicParsing="false" onAction="#cancelAction" text="取消" />
33-
</children>
34-
<VBox.margin>
35-
<Insets top="10.0" />
36-
</VBox.margin>
37-
</HBox>
38-
</children>
39-
</VBox>
40-
</children>
41-
</AnchorPane>
10+
<padding>
11+
<Insets topRightBottomLeft="30"/>
12+
</padding>
13+
14+
<CheckBox fx:id="exitShowAlertCheckBox" selected="true" text="退出时是否显示确认对话框"/>
15+
<CheckBox fx:id="addNotepadCheckBox" selected="true" text="打开时是否加载临时记事本页面"/>
16+
<CheckBox fx:id="saveStageBoundCheckBox" selected="true" text="是否在退出时保存窗口大小及位置信息"/>
17+
</VBox>

0 commit comments

Comments
 (0)