Skip to content

Commit 2532b2c

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents e55be4c + 496096c commit 2532b2c

15 files changed

Lines changed: 299 additions & 91 deletions

File tree

README.md

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ xJavaFxTool是使用javaFx开发的实用小工具集,利用业余时间把工
125125
```
126126
xJavaFxTool
127127
├─ images 项目截图
128-
├─ lib 外部引用jar包存放
129-
├─ libs 插件jar包存放
130128
├─ pom.xml maven配置文件
131129
├─ README.md 说明文件
132130
├─ src
@@ -136,39 +134,14 @@ xJavaFxTool
136134
│  │  │  └─ xwintop
137135
│  │  │  └─ xJavaFxTool
138136
│  │  │  ├─ common 第三方工具类
139-
│  │  │  ├─ config springBoot配置类
140137
│  │  │  ├─ controller javafx控制层
141-
│  │  │  │  ├─ assistTools 辅助工具控制层
142-
│  │  │  │  ├─ codeTools Code工具控制层
143-
│  │  │  │  ├─ debugTools 调试工具控制层
144-
│  │  │  │  ├─ developTools 开发工具控制层
145-
│  │  │  │  ├─ epmsTools epms工具控制层
146-
│  │  │  │  ├─ javaFxTools javaFx工具控制层
147-
│  │  │  │  ├─ littleTools 小工具控制层
148-
│  │  │  │  └─ webTools html工具控制层
149-
│  │  │  ├─ job 定时任务处理job
150-
│  │  │  ├─ main 主函数包
151-
│  │  │  ├─ manager 管理层
138+
│  │  │  │  └─ index 首页控制层
152139
│  │  │  ├─ model 基础bean类层
153140
│  │  │  ├─ services 工具服务层
154-
│  │  │  │  ├─ assistTools 辅助工具服务层
155-
│  │  │  │  ├─ codeTools Code工具服务层
156-
│  │  │  │  ├─ debugTools 调试工具服务层
157-
│  │  │  │  ├─ developTools 开发工具服务层
158-
│  │  │  │  ├─ epmsTools epms工具服务层
159-
│  │  │  │  ├─ javaFxTools javaFx工具服务层
160-
│  │  │  │  ├─ littleTools 小工具服务层
161-
│  │  │  │  └─ webTools html工具服务层
141+
│  │  │  │  └─ index 首页工具服务层
162142
│  │  │  ├─ utils 系统工具类
163-
│  │  │  ├─ view javafx视图层
164-
│  │  │  │ ├─ assistTools 辅助工具视图层
165-
│  │  │  │ ├─ codeTools Code工具视图层
166-
│  │  │  │ ├─ debugTools 调试工具视图层
167-
│  │  │  │ ├─ developTools 开发工具视图层
168-
│  │  │  │ ├─ javaFxTools javaFx工具视图层
169-
│  │  │  │ ├─ littleTools 小工具视图层
170-
│  │  │  │ └─ webTools html工具视图层
171-
│  │  │  └─ web web控制视图层
143+
│  │  │  └─ view javafx视图层
144+
│  │  │  └─ index 首页工具视图层
172145
│  │  └─ resources
173146
│  │  ├─ com
174147
│  │  │  └─ xwintop
@@ -177,17 +150,13 @@ xJavaFxTool
177150
│  │  ├─ config 配置文件
178151
│  │  │  └─ toolFxmlLoaderConfiguration.xml 系统菜单加载配置文件
179152
│  │  ├─ css 样式资源
180-
│  │  ├─ data 数据资源
181153
│  │  ├─ images 图片资源
182154
│  │  ├─ locale 国际化
183-
│  │  ├─ web html工具
184-
│  │  ├─ application.yaml SpringBoot配置文件
185155
│  │  ├─ banner.txt 启动banner图片
186156
│  │  └─ logback.xml logback日志配置文件
187157
│  └─ test 测试类
188158
│  ├─ java
189159
│  └─ resources
190-
├─ xJavaFxTool.jar 直接运行程序包
191160
192161
```
193162

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<dependency>
6161
<groupId>com.xwintop</groupId>
6262
<artifactId>xcore</artifactId>
63-
<version>0.0.2-SNAPSHOT</version>
63+
<version>0.0.3-SNAPSHOT</version>
6464
</dependency>
6565

6666
<!-- oshi获取系统信息工具 -->

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

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
import com.jfoenix.controls.JFXDecorator;
44
import com.xwintop.xJavaFxTool.controller.IndexController;
55
import com.xwintop.xJavaFxTool.utils.Config;
6-
import com.xwintop.xJavaFxTool.utils.Config.Keys.MainWindow;
76
import com.xwintop.xJavaFxTool.utils.StageUtils;
87
import com.xwintop.xJavaFxTool.utils.XJavaFxSystemUtil;
98
import com.xwintop.xcore.util.javafx.AlertUtil;
109
import com.xwintop.xcore.util.javafx.JavaFxViewUtil;
11-
import java.util.ResourceBundle;
12-
import java.util.prefs.Preferences;
1310
import javafx.application.Application;
1411
import javafx.application.Platform;
1512
import javafx.event.Event;
@@ -20,6 +17,8 @@
2017
import javafx.stage.Stage;
2118
import lombok.extern.slf4j.Slf4j;
2219

20+
import java.util.ResourceBundle;
21+
2322
/**
2423
* @ClassName: Main
2524
* @Description: 启动类
@@ -52,10 +51,10 @@ public void start(Stage primaryStage) throws Exception {
5251
Parent root = fXMLLoader.load();
5352

5453
JFXDecorator decorator = JavaFxViewUtil.getJFXDecorator(
55-
primaryStage,
56-
resourceBundle.getString("Title") + Config.xJavaFxToolVersions,
57-
"/images/icon.jpg",
58-
root
54+
primaryStage,
55+
resourceBundle.getString("Title") + Config.xJavaFxToolVersions,
56+
"/images/icon.jpg",
57+
root
5958
);
6059
decorator.setOnCloseButtonAction(() -> confirmExit(null));
6160

@@ -67,63 +66,34 @@ public void start(Stage primaryStage) throws Exception {
6766
primaryStage.setScene(scene);
6867
primaryStage.setOnCloseRequest(this::confirmExit);
6968

70-
loadPrimaryStageBound(primaryStage);
69+
StageUtils.loadPrimaryStageBound(primaryStage);
7170
primaryStage.show();
7271

7372
StageUtils.updateStageStyle(primaryStage);
7473
stage = primaryStage;
7574
}
7675

77-
private void loadPrimaryStageBound(Stage stage) {
78-
double left = getPreferences().getDouble(MainWindow.LEFT, -1);
79-
double top = getPreferences().getDouble(MainWindow.TOP, -1);
80-
double width = getPreferences().getDouble(MainWindow.WIDTH, -1);
81-
double height = getPreferences().getDouble(MainWindow.HEIGHT, -1);
82-
83-
if (left > 0) {
84-
stage.setX(left);
85-
}
86-
if (top > 0) {
87-
stage.setY(top);
88-
}
89-
if (width > 0) {
90-
stage.setWidth(width);
91-
}
92-
if (height > 0) {
93-
stage.setHeight(height);
94-
}
95-
}
96-
97-
private Preferences getPreferences() {
98-
return Preferences.userRoot().node(PREFERENCE_ROOT);
99-
}
100-
10176
private void confirmExit(Event event) {
102-
if (AlertUtil.showConfirmAlert("确定要退出吗?")) {
103-
savePrimaryStageBound();
77+
if (XJavaFxSystemUtil.getSystemConfigure().getBoolean("exitShowAlertCheckBox", true)) {
78+
if (AlertUtil.showConfirmAlert("确定要退出吗?")) {
79+
StageUtils.savePrimaryStageBound(stage);
80+
Platform.exit();
81+
System.exit(0);
82+
} else if (event != null) {
83+
event.consume();
84+
}
85+
} else {
86+
StageUtils.savePrimaryStageBound(stage);
10487
Platform.exit();
10588
System.exit(0);
106-
} else if (event != null) {
107-
event.consume();
10889
}
10990
}
11091

111-
private void savePrimaryStageBound() {
112-
if (stage == null || stage.isIconified()) {
113-
return;
114-
}
115-
116-
getPreferences().putDouble(MainWindow.LEFT, stage.getX());
117-
getPreferences().putDouble(MainWindow.TOP, stage.getY());
118-
getPreferences().putDouble(MainWindow.WIDTH, stage.getWidth());
119-
getPreferences().putDouble(MainWindow.HEIGHT, stage.getHeight());
120-
}
121-
12292
public static Stage getStage() {
12393
return stage;
12494
}
12595

12696
public static void setStage(Stage stage) {
12797
Main.stage = stage;
12898
}
129-
}
99+
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.xwintop.xJavaFxTool.controller;
22

33
import com.xwintop.xJavaFxTool.controller.index.PluginManageController;
4+
import com.xwintop.xJavaFxTool.controller.index.SystemSettingController;
45
import com.xwintop.xJavaFxTool.model.ToolFxmlLoaderConfiguration;
56
import com.xwintop.xJavaFxTool.services.IndexService;
67
import com.xwintop.xJavaFxTool.services.index.PluginManageService;
@@ -70,7 +71,9 @@ public void initialize(URL location, ResourceBundle resources) {
7071
initView();
7172
initEvent();
7273
initService();
73-
addNodepadAction(null);
74+
if (XJavaFxSystemUtil.getSystemConfigure().getBoolean("addNotepadCheckBox", true)) {
75+
addNodepadAction(null);
76+
}
7477
indexService.addWebView("欢迎吐槽", "https://support.qq.com/product/127577", null);
7578
tongjiWebView.getEngine().load("https://xwintop.gitee.io/maven/tongji/xJavaFxTool.html");
7679
}
@@ -265,6 +268,11 @@ private void pluginManageAction(ActionEvent event) throws Exception {
265268
JavaFxViewUtil.openNewWindow(bundle.getString("plugin_manage"), root);
266269
}
267270

271+
@FXML
272+
private void SettingAction(ActionEvent event) throws Exception {
273+
SystemSettingController.showSystemSetting(bundle.getString("Setting"));
274+
}
275+
268276
@FXML
269277
private void aboutAction(ActionEvent event) throws Exception {
270278
AlertUtil.showInfoAlert(bundle.getString("aboutText") + Config.xJavaFxToolVersions);
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package com.xwintop.xJavaFxTool.controller.index;
2+
3+
import com.xwintop.xJavaFxTool.controller.IndexController;
4+
import com.xwintop.xJavaFxTool.services.index.SystemSettingService;
5+
import com.xwintop.xJavaFxTool.utils.XJavaFxSystemUtil;
6+
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;
13+
import javafx.stage.Stage;
14+
import lombok.Getter;
15+
import lombok.Setter;
16+
import lombok.extern.slf4j.Slf4j;
17+
import org.apache.commons.configuration.PropertiesConfiguration;
18+
19+
import java.net.URL;
20+
import java.util.ResourceBundle;
21+
22+
/**
23+
* @ClassName: SystemSettingController
24+
* @Description: 设置页面
25+
* @author: xufeng
26+
* @date: 2020/2/25 0025 16:44
27+
*/
28+
29+
@Getter
30+
@Setter
31+
@Slf4j
32+
public class SystemSettingController extends SystemSettingView {
33+
private SystemSettingService systemSettingService = new SystemSettingService(this);
34+
private Stage newStage = null;
35+
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+
}
46+
47+
@Override
48+
public void initialize(URL location, ResourceBundle resources) {
49+
initView();
50+
initEvent();
51+
initService();
52+
}
53+
54+
private void initView() {
55+
try {
56+
PropertiesConfiguration xmlConfigure = XJavaFxSystemUtil.getSystemConfigure();
57+
exitShowAlertCheckBox.setSelected(xmlConfigure.getBoolean("exitShowAlertCheckBox", true));
58+
addNotepadCheckBox.setSelected(xmlConfigure.getBoolean("addNotepadCheckBox", true));
59+
saveStageBoundCheckBox.setSelected(xmlConfigure.getBoolean("saveStageBoundCheckBox", true));
60+
} catch (Exception e) {
61+
log.error("加载配置失败:", e);
62+
}
63+
64+
}
65+
66+
private void initEvent() {
67+
}
68+
69+
private void initService() {
70+
}
71+
72+
@FXML
73+
private void saveAction(ActionEvent event) {
74+
try {
75+
PropertiesConfiguration xmlConfigure = XJavaFxSystemUtil.getSystemConfigure();
76+
xmlConfigure.setProperty("exitShowAlertCheckBox", exitShowAlertCheckBox.isSelected());
77+
xmlConfigure.setProperty("addNotepadCheckBox", addNotepadCheckBox.isSelected());
78+
xmlConfigure.setProperty("saveStageBoundCheckBox", saveStageBoundCheckBox.isSelected());
79+
xmlConfigure.save();
80+
if (newStage != null) {
81+
newStage.close();
82+
}
83+
} catch (Exception e) {
84+
log.error("保存配置失败:", e);
85+
}
86+
}
87+
88+
@FXML
89+
private void cancelAction(ActionEvent event) {
90+
if (newStage != null) {
91+
newStage.close();
92+
}
93+
}
94+
}

src/main/java/com/xwintop/xJavaFxTool/services/IndexService.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.xwintop.xJavaFxTool.controller.IndexController;
55
import com.xwintop.xJavaFxTool.utils.Config;
66
import com.xwintop.xJavaFxTool.utils.FxmlUtils;
7+
import com.xwintop.xJavaFxTool.utils.XJavaFxSystemUtil;
78
import com.xwintop.xcore.util.ConfigureUtil;
89
import com.xwintop.xcore.util.javafx.AlertUtil;
910
import com.xwintop.xcore.util.javafx.JavaFxViewUtil;
@@ -38,9 +39,7 @@ public IndexService(IndexController indexController) {
3839
}
3940

4041
public void setLanguageAction(String languageType) throws Exception {
41-
File file = ConfigureUtil.getConfigureFile("systemConfigure.properties");
42-
FileUtils.touch(file);
43-
PropertiesConfiguration xmlConfigure = new PropertiesConfiguration(file);
42+
PropertiesConfiguration xmlConfigure = XJavaFxSystemUtil.getSystemConfigure();
4443
if ("简体中文".equals(languageType)) {
4544
xmlConfigure.setProperty("Locale", Locale.SIMPLIFIED_CHINESE);
4645
} else if ("English".equals(languageType)) {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.xwintop.xJavaFxTool.services.index;
2+
3+
import com.xwintop.xJavaFxTool.controller.index.SystemSettingController;
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
import lombok.extern.slf4j.Slf4j;
7+
8+
/**
9+
* @ClassName: SystemSettingService
10+
* @Description: 设置页面
11+
* @author: xufeng
12+
* @date: 2020/2/25 0025 16:44
13+
*/
14+
15+
@Getter
16+
@Setter
17+
@Slf4j
18+
public class SystemSettingService {
19+
private SystemSettingController systemSettingController;
20+
21+
public SystemSettingService(SystemSettingController systemSettingController) {
22+
this.systemSettingController = systemSettingController;
23+
}
24+
}

src/main/java/com/xwintop/xJavaFxTool/utils/Config.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class Config {
99

1010
public static Locale defaultLocale = Locale.getDefault();// 设置系统语言
1111

12-
public static final String xJavaFxToolVersions = "V0.2.1-beta1";// xJavaFxTool版本信息
12+
public static final String xJavaFxToolVersions = "V0.2.1-beta2";// xJavaFxTool版本信息
1313

1414
public static final int xJavaFxToolVersionsInteger = 13;// xJavaFxTool更新信息
1515

0 commit comments

Comments
 (0)