Compare commits
3 Commits
v1.2.0-REL
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6189b1bf9 | ||
|
|
d139cbe3c5 | ||
|
|
5b7131febf |
12
README.en.md
12
README.en.md
@@ -8,7 +8,7 @@ Language: [中文](README.md)
|
|||||||
|
|
||||||
- [The Process of Developing](#the-process-of-developing)
|
- [The Process of Developing](#the-process-of-developing)
|
||||||
|
|
||||||
[Maven Repository](#maven-repository)
|
~~[Maven Repository](#maven-repository)~~
|
||||||
|
|
||||||
[Git](#git)
|
[Git](#git)
|
||||||
|
|
||||||
@@ -70,8 +70,6 @@ The framework is not the framework for beautifying UI, but to simplify the step
|
|||||||
|
|
||||||
### The Process of Developing
|
### The Process of Developing
|
||||||
|
|
||||||
Our project has suspended update from Nov. 25, 2019, and the next release will be updated to 2.0. We try to provides more data binding operations and optimize performance.
|
|
||||||
|
|
||||||
- [x] Modularization
|
- [x] Modularization
|
||||||
- [x] Integration with Spring
|
- [x] Integration with Spring
|
||||||
- [x] Signal Mechanism
|
- [x] Signal Mechanism
|
||||||
@@ -87,7 +85,7 @@ Our project has suspended update from Nov. 25, 2019, and the next release will b
|
|||||||
- [ ] Data valication
|
- [ ] Data valication
|
||||||
- [ ] Optimize performance
|
- [ ] Optimize performance
|
||||||
|
|
||||||
## Maven Repository
|
## ~~Maven Repository~~
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -936,7 +934,7 @@ When an FXController needs to be internationalized and localized, you need to ad
|
|||||||
|
|
||||||
```java
|
```java
|
||||||
@FXWindow(mainStage = true, title = "languageDemo")
|
@FXWindow(mainStage = true, title = "languageDemo")
|
||||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
||||||
public class ChineseController extends FXBaseController {
|
public class ChineseController extends FXBaseController {
|
||||||
@FXML
|
@FXML
|
||||||
public void clickToOtherLanguage() {
|
public void clickToOtherLanguage() {
|
||||||
@@ -952,7 +950,7 @@ public class ChineseController extends FXBaseController {
|
|||||||
|
|
||||||
```java
|
```java
|
||||||
@FXWindow(mainStage = false, title = "languageDemo")
|
@FXWindow(mainStage = false, title = "languageDemo")
|
||||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.ENGLISH)
|
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.ENGLISH)
|
||||||
public class EnglishController extends FXBaseController {
|
public class EnglishController extends FXBaseController {
|
||||||
@FXML
|
@FXML
|
||||||
public void clickToOtherLanguage() {
|
public void clickToOtherLanguage() {
|
||||||
@@ -1024,7 +1022,7 @@ register.email=\u90ae\u7bb1
|
|||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
The sample code is in `cn.edu.scau.biubiusuisui.example.languageDemo`, the running result as follows:
|
The sample code is in `cn.edu.scau.biubiusuisui.example.langDemo`, the running result as follows:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
21
README.md
21
README.md
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
- [开发进程](#开发进程)
|
- [开发进程](#开发进程)
|
||||||
|
|
||||||
[Maven仓库地址](#Maven仓库地址)
|
~~[Maven仓库地址](#Maven仓库地址)~~
|
||||||
|
|
||||||
[Git地址](#git地址)
|
[Git地址](#git地址)
|
||||||
|
|
||||||
@@ -70,8 +70,6 @@
|
|||||||
|
|
||||||

|

|
||||||
### 开发进程
|
### 开发进程
|
||||||
2019年11月25日起项目暂停更新,将会下次发布将会升级为2.0版本,到时候将会提供更多数据绑定操作,以及优化性能。
|
|
||||||
|
|
||||||
- [x] 模块化
|
- [x] 模块化
|
||||||
- [x] 与Spring的融合
|
- [x] 与Spring的融合
|
||||||
- [x] 信号机制
|
- [x] 信号机制
|
||||||
@@ -87,7 +85,10 @@
|
|||||||
- [ ] 键盘事件绑定
|
- [ ] 键盘事件绑定
|
||||||
- [ ] 优化性能
|
- [ ] 优化性能
|
||||||
|
|
||||||
## Maven仓库地址
|
## ~~Maven仓库地址~~
|
||||||
|
|
||||||
|
maven仓库中的JavaFX-Plus版本是较旧版本,建议使用最新发行版。
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.Biubiuyuyu</groupId>
|
<groupId>com.gitee.Biubiuyuyu</groupId>
|
||||||
@@ -959,7 +960,7 @@ public enum FXPlusLocale {
|
|||||||
|
|
||||||
```java
|
```java
|
||||||
@FXWindow(mainStage = true, title = "languageDemo")
|
@FXWindow(mainStage = true, title = "languageDemo")
|
||||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
||||||
public class ChineseController extends FXBaseController {
|
public class ChineseController extends FXBaseController {
|
||||||
@FXML
|
@FXML
|
||||||
public void clickToOtherLanguage() {
|
public void clickToOtherLanguage() {
|
||||||
@@ -975,7 +976,7 @@ public class ChineseController extends FXBaseController {
|
|||||||
|
|
||||||
```java
|
```java
|
||||||
@FXWindow(mainStage = false, title = "languageDemo")
|
@FXWindow(mainStage = false, title = "languageDemo")
|
||||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.ENGLISH)
|
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.ENGLISH)
|
||||||
public class EnglishController extends FXBaseController {
|
public class EnglishController extends FXBaseController {
|
||||||
@FXML
|
@FXML
|
||||||
public void clickToOtherLanguage() {
|
public void clickToOtherLanguage() {
|
||||||
@@ -1047,7 +1048,7 @@ register.email=\u90ae\u7bb1
|
|||||||
|
|
||||||
#### 示例演示
|
#### 示例演示
|
||||||
|
|
||||||
示例代码在`cn.edu.scau.biubiusuisui.example.languageDemo`中,运行可得:
|
示例代码在`cn.edu.scau.biubiusuisui.example.langDemo`中,运行可得:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -1328,6 +1329,10 @@ public class Student {
|
|||||||
4. 完善JavaFX-Plus生命周期
|
4. 完善JavaFX-Plus生命周期
|
||||||
5. 新增日志log模块
|
5. 新增日志log模块
|
||||||
6. 新增语言国际化操作
|
6. 新增语言国际化操作
|
||||||
7. 新增测试生命周期LifeDemo示例和测试国际化的LanguageDemo示例代码
|
7. 新增测试生命周期LifeDemo示例和测试国际化的LangDemo示例代码
|
||||||
8. 规范化代码和更新README
|
8. 规范化代码和更新README
|
||||||
|
|
||||||
|
## v1.3.0 TODO
|
||||||
|
|
||||||
|
1. 开放动态修改窗口标题setWindowTitles、窗口图标setIcon、窗口可拖拽缩放setDragAndResize的接口
|
||||||
|
|
||||||
|
|||||||
29
pom.xml
29
pom.xml
@@ -4,11 +4,12 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<name>javafx-plus</name>
|
<name>javafx-plus</name>
|
||||||
|
|
||||||
<groupId>com.gitee.Biubiuyuyu</groupId>
|
<groupId>com.gitee.Biubiuyuyu</groupId>
|
||||||
<artifactId>javafx-plus</artifactId>
|
<artifactId>javafx-plus</artifactId>
|
||||||
<version>1.1.1-RELEASE</version>
|
<version>1.2.0-RELEASE</version>
|
||||||
<packaging>jar</packaging>
|
<!-- packaging为pom时,不会加载resources 故注释-->
|
||||||
|
<!-- <packaging>pom</packaging>-->
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.sonatype.oss</groupId>
|
<groupId>org.sonatype.oss</groupId>
|
||||||
@@ -30,13 +31,14 @@
|
|||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- 第三方动态代理库-->
|
<!-- 第三方动态代理库 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cglib</groupId>
|
<groupId>cglib</groupId>
|
||||||
<artifactId>cglib</artifactId>
|
<artifactId>cglib</artifactId>
|
||||||
<version>3.1</version>
|
<version>3.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Junit单元测试 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
@@ -44,7 +46,7 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- log4j 日志-->
|
<!-- log4j 日志 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
@@ -55,10 +57,24 @@
|
|||||||
<artifactId>tomcat-embed-core</artifactId>
|
<artifactId>tomcat-embed-core</artifactId>
|
||||||
<version>9.0.29</version>
|
<version>9.0.29</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<!--配置Maven 对resource文件 过滤 -->
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/java</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.properties</include>
|
||||||
|
<include>**/*.xml</include>
|
||||||
|
<include>**/*.fxml</include>
|
||||||
|
</includes>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@@ -66,6 +82,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
<compilerArgs>
|
<compilerArgs>
|
||||||
<!-- 过期的方法的警告-->
|
<!-- 过期的方法的警告-->
|
||||||
<arg>-Xlint:deprecation</arg>
|
<arg>-Xlint:deprecation</arg>
|
||||||
|
|||||||
@@ -4,13 +4,19 @@ import cn.edu.scau.biubiusuisui.annotation.FXController;
|
|||||||
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
|
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
|
||||||
import cn.edu.scau.biubiusuisui.config.FXMLLoaderPlus;
|
import cn.edu.scau.biubiusuisui.config.FXMLLoaderPlus;
|
||||||
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
||||||
|
import cn.edu.scau.biubiusuisui.exception.ProtocolNotSupport;
|
||||||
|
import cn.edu.scau.biubiusuisui.function.DragWindowHandlerImpl;
|
||||||
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
|
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
|
||||||
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
|
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
|
||||||
|
import cn.edu.scau.biubiusuisui.utils.FileUtil;
|
||||||
import cn.edu.scau.biubiusuisui.utils.ResourceBundleUtil;
|
import cn.edu.scau.biubiusuisui.utils.ResourceBundleUtil;
|
||||||
import cn.edu.scau.biubiusuisui.utils.StringUtil;
|
import cn.edu.scau.biubiusuisui.utils.StringUtil;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -19,7 +25,7 @@ import java.util.Map;
|
|||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* In JavaFX-Plus Framework Controller
|
* In JavaFX-Plus Framework Controller
|
||||||
* We use MVC model
|
* We use MVC model
|
||||||
* V means view which stand for fxml
|
* V means view which stand for fxml
|
||||||
@@ -36,7 +42,7 @@ import java.util.ResourceBundle;
|
|||||||
* @since JavaFX2.0 JDK1.8
|
* @since JavaFX2.0 JDK1.8
|
||||||
*/
|
*/
|
||||||
public class FXBaseController extends Pane {
|
public class FXBaseController extends Pane {
|
||||||
private static IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(FXBaseController.class);
|
private static final IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(FXBaseController.class);
|
||||||
|
|
||||||
protected String name = "";
|
protected String name = "";
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
@@ -45,7 +51,8 @@ public class FXBaseController extends Pane {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 用于携带信息数据
|
* <p>description 用于携带信息数据</p>
|
||||||
|
*
|
||||||
* @version 1.2
|
* @version 1.2
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> query = new HashMap<>();
|
private Map<String, Object> query = new HashMap<>();
|
||||||
@@ -69,7 +76,7 @@ public class FXBaseController extends Pane {
|
|||||||
// 添加赋予是否为窗口的逻辑
|
// 添加赋予是否为窗口的逻辑
|
||||||
if (annotation.annotationType().equals(FXWindow.class)) {
|
if (annotation.annotationType().equals(FXWindow.class)) {
|
||||||
fxWindow = (FXWindow) annotation;
|
fxWindow = (FXWindow) annotation;
|
||||||
isWindow = true;
|
this.isWindow = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//load fxml file to show panel in scene builder
|
//load fxml file to show panel in scene builder
|
||||||
@@ -173,13 +180,16 @@ public class FXBaseController extends Pane {
|
|||||||
* 唤起舞台
|
* 唤起舞台
|
||||||
*/
|
*/
|
||||||
public void showStage() {
|
public void showStage() {
|
||||||
if (isWindow) {
|
if (this.isWindow) {
|
||||||
this.stage.show();
|
this.stage.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示并等待
|
||||||
|
*/
|
||||||
public void showAndWait() {
|
public void showAndWait() {
|
||||||
if (isWindow) {
|
if (this.isWindow) {
|
||||||
this.stage.showAndWait();
|
this.stage.showAndWait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -188,7 +198,7 @@ public class FXBaseController extends Pane {
|
|||||||
* 关闭舞台
|
* 关闭舞台
|
||||||
*/
|
*/
|
||||||
public void closeStage() {
|
public void closeStage() {
|
||||||
if (isWindow) {
|
if (this.isWindow) {
|
||||||
this.stage.close();
|
this.stage.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,11 +208,75 @@ public class FXBaseController extends Pane {
|
|||||||
* @version 1.2
|
* @version 1.2
|
||||||
*/
|
*/
|
||||||
public void hideStage() {
|
public void hideStage() {
|
||||||
if (isWindow) {
|
if (this.isWindow) {
|
||||||
this.stage.setIconified(true);
|
this.stage.setIconified(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>description: 开放设置窗口标题 </p>
|
||||||
|
*
|
||||||
|
* @param title 标题
|
||||||
|
* @return true--修改标题成功 false--修改失败
|
||||||
|
* @version 1.3
|
||||||
|
*/
|
||||||
|
public final void setWindowTitle(String title) {
|
||||||
|
if (this.isWindow) {
|
||||||
|
this.stage.setTitle(title);
|
||||||
|
logger.info("setting title of window");
|
||||||
|
} else {
|
||||||
|
logger.warn("the controller is not window");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>description: 开放设置窗口图标</p>
|
||||||
|
*
|
||||||
|
* @param icon String 图标URL地址,需要放在resources文件下或项目根目录下
|
||||||
|
*/
|
||||||
|
public final void setIcon(String icon) {
|
||||||
|
if (this.isWindow) {
|
||||||
|
if (!"".equals(icon)) {
|
||||||
|
try {
|
||||||
|
URL iconUrl = new FileUtil().getFilePathFromResources(icon);
|
||||||
|
if (iconUrl != null) {
|
||||||
|
if (new File(StringUtil.getRootPath(iconUrl)).exists()) {
|
||||||
|
this.stage.getIcons().clear();
|
||||||
|
this.stage.getIcons().add(new Image(icon));
|
||||||
|
} else {
|
||||||
|
logger.warn("the icon file has not existed");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.warn("the icon file has not existed");
|
||||||
|
}
|
||||||
|
} catch (ProtocolNotSupport protocolNotSupport) {
|
||||||
|
logger.error(protocolNotSupport.getMessage(), protocolNotSupport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Description 开放是否允许窗口可拖拽和缩放的接口</p>
|
||||||
|
*
|
||||||
|
* @param draggable 可拖拽
|
||||||
|
* @param resizable 可缩放
|
||||||
|
*/
|
||||||
|
public final void setDragAndResize(boolean draggable, boolean resizable) {
|
||||||
|
this.stage.setResizable(resizable);
|
||||||
|
if (draggable || resizable) {
|
||||||
|
EventHandler dragWindowHandler = new DragWindowHandlerImpl(stage, this, draggable, resizable);
|
||||||
|
this.setOnMousePressed(dragWindowHandler);
|
||||||
|
this.setOnMouseDragged(dragWindowHandler);
|
||||||
|
this.setOnMouseMoved(dragWindowHandler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Controller名字
|
||||||
|
*
|
||||||
|
* @return name
|
||||||
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if ("".equals(name) || name == null) { // 原本无“name == null”判断条件,会出错
|
if ("".equals(name) || name == null) { // 原本无“name == null”判断条件,会出错
|
||||||
return StringUtil.getBaseClassName(getClass().getSimpleName());
|
return StringUtil.getBaseClassName(getClass().getSimpleName());
|
||||||
@@ -224,11 +298,11 @@ public class FXBaseController extends Pane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWindow() {
|
public boolean isWindow() {
|
||||||
return isWindow;
|
return this.isWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWindow(boolean window) {
|
public void setWindow(boolean window) {
|
||||||
isWindow = window;
|
this.isWindow = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stage getStage() {
|
public Stage getStage() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package cn.edu.scau.biubiusuisui.example.languageDemo;
|
package cn.edu.scau.biubiusuisui.example.langDemo;
|
||||||
|
|
||||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||||
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
||||||
@@ -15,8 +15,11 @@ import javafx.fxml.FXML;
|
|||||||
* @since JDK1.8
|
* @since JDK1.8
|
||||||
*/
|
*/
|
||||||
@FXWindow(mainStage = true, title = "languageDemo")
|
@FXWindow(mainStage = true, title = "languageDemo")
|
||||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
||||||
public class ChineseController extends FXBaseController {
|
public class ChineseController extends FXBaseController {
|
||||||
|
private String title = "languageDemo";
|
||||||
|
private int count = 0;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void clickToChinese() {
|
public void clickToChinese() {
|
||||||
redirect("ChineseController");
|
redirect("ChineseController");
|
||||||
@@ -32,8 +35,18 @@ public class ChineseController extends FXBaseController {
|
|||||||
redirect("KoreanController");
|
redirect("KoreanController");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试是否setWindowTitle接口
|
||||||
|
*/
|
||||||
|
@FXML
|
||||||
|
public void changeTitleClick() {
|
||||||
|
this.setWindowTitle(this.title + count);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
@FXRedirect
|
@FXRedirect
|
||||||
public String redirect(String name) {
|
public String redirect(String name) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package cn.edu.scau.biubiusuisui.example.languageDemo;
|
package cn.edu.scau.biubiusuisui.example.langDemo;
|
||||||
|
|
||||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||||
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
||||||
@@ -14,8 +14,11 @@ import javafx.fxml.FXML;
|
|||||||
* @since JDK1.8
|
* @since JDK1.8
|
||||||
*/
|
*/
|
||||||
@FXWindow(mainStage = false, title = "languageDemo")
|
@FXWindow(mainStage = false, title = "languageDemo")
|
||||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.ENGLISH)
|
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.ENGLISH)
|
||||||
public class EnglishController extends FXBaseController {
|
public class EnglishController extends FXBaseController {
|
||||||
|
private String title = "languageDemo";
|
||||||
|
private int count = 0;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void clickToChinese() {
|
public void clickToChinese() {
|
||||||
redirect("ChineseController");
|
redirect("ChineseController");
|
||||||
@@ -31,6 +34,15 @@ public class EnglishController extends FXBaseController {
|
|||||||
redirect("KoreanController");
|
redirect("KoreanController");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试是否setWindowTitle接口
|
||||||
|
*/
|
||||||
|
@FXML
|
||||||
|
public void changeTitleClick() {
|
||||||
|
this.setWindowTitle(this.title + count);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
@FXRedirect
|
@FXRedirect
|
||||||
public String redirect(String name) {
|
public String redirect(String name) {
|
||||||
return name;
|
return name;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package cn.edu.scau.biubiusuisui.example.languageDemo;
|
package cn.edu.scau.biubiusuisui.example.langDemo;
|
||||||
|
|
||||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||||
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
||||||
@@ -14,8 +14,11 @@ import javafx.fxml.FXML;
|
|||||||
* @since JDK1.8
|
* @since JDK1.8
|
||||||
*/
|
*/
|
||||||
@FXWindow(mainStage = false, title = "languageDemo")
|
@FXWindow(mainStage = false, title = "languageDemo")
|
||||||
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.KOREAN)
|
@FXController(path = "fxml/langDemo/langDemo.fxml", locale = FXPlusLocale.KOREAN)
|
||||||
public class KoreanController extends FXBaseController {
|
public class KoreanController extends FXBaseController {
|
||||||
|
private String title = "languageDemo";
|
||||||
|
private int count = 0;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void clickToChinese() {
|
public void clickToChinese() {
|
||||||
redirect("ChineseController");
|
redirect("ChineseController");
|
||||||
@@ -31,6 +34,16 @@ public class KoreanController extends FXBaseController {
|
|||||||
redirect("KoreanController");
|
redirect("KoreanController");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试是否setWindowTitle接口
|
||||||
|
*/
|
||||||
|
@FXML
|
||||||
|
public void changeTitleClick() {
|
||||||
|
this.setWindowTitle(this.title + count);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
@FXRedirect
|
@FXRedirect
|
||||||
public String redirect(String name) {
|
public String redirect(String name) {
|
||||||
return name;
|
return name;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package cn.edu.scau.biubiusuisui.example.languageDemo;
|
package cn.edu.scau.biubiusuisui.example.langDemo;
|
||||||
|
|
||||||
import cn.edu.scau.biubiusuisui.annotation.FXScan;
|
import cn.edu.scau.biubiusuisui.annotation.FXScan;
|
||||||
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
||||||
@@ -11,10 +11,11 @@ import javafx.stage.Stage;
|
|||||||
* @date 2020/5/3 09:57
|
* @date 2020/5/3 09:57
|
||||||
* @since JDK1.8
|
* @since JDK1.8
|
||||||
*/
|
*/
|
||||||
@FXScan(base = "cn.edu.scau.biubiusuisui.example.languageDemo")
|
@FXScan(base = "cn.edu.scau.biubiusuisui.example.langDemo")
|
||||||
public class LanguageDemo extends Application {
|
public class LanguageDemo extends Application {
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
FXPlusApplication.start(getClass());
|
FXPlusApplication.start(getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,6 @@ import cn.edu.scau.biubiusuisui.entity.FXPlusLocale;
|
|||||||
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
|
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
|
||||||
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
|
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.input.Clipboard;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author suisui
|
* @author suisui
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package cn.edu.scau.biubiusuisui.example.windowDemo;
|
||||||
|
|
||||||
|
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||||
|
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
|
||||||
|
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.ToggleButton;
|
||||||
|
import javafx.stage.StageStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author suisui
|
||||||
|
* @description 测试Controller
|
||||||
|
* @date 2020/8/29 09:41
|
||||||
|
* @since JDK1.8
|
||||||
|
*/
|
||||||
|
@FXWindow(mainStage = true, title = "windowDemo", icon = "image/icon.png", style = StageStyle.UNDECORATED)
|
||||||
|
@FXController(path = "fxml/windowDemo/windowDemo.fxml")
|
||||||
|
public class DemoController extends FXBaseController {
|
||||||
|
private String title = "windowDemo -- ";
|
||||||
|
private int count = 0;
|
||||||
|
private String iconStr = "image/icon2.png";
|
||||||
|
private String iconStr2 = "image/icon3.png";
|
||||||
|
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ToggleButton canResizableTB;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() throws Exception {
|
||||||
|
canResizableTB.selectedProperty().addListener(e -> {
|
||||||
|
this.setDragAndResize(true, canResizableTB.isSelected());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改标题点击事件
|
||||||
|
*/
|
||||||
|
@FXML
|
||||||
|
public void changeTitleClick() {
|
||||||
|
this.setWindowTitle(title + count);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字符串修改图标
|
||||||
|
*/
|
||||||
|
@FXML
|
||||||
|
public void changeIconClick() {
|
||||||
|
this.setIcon(count % 2 == 0 ? iconStr : iconStr2);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package cn.edu.scau.biubiusuisui.example.windowDemo;
|
||||||
|
|
||||||
|
import cn.edu.scau.biubiusuisui.annotation.FXScan;
|
||||||
|
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author suisui
|
||||||
|
* @description 测试开放设置部分FXWindow属性的接口
|
||||||
|
* @date 2020/8/29 09:40
|
||||||
|
* @since JDK1.8
|
||||||
|
*/
|
||||||
|
@FXScan(base = "cn.edu.scau.biubiusuisui.example.windowDemo")
|
||||||
|
public class FXWindowDemo extends Application {
|
||||||
|
@Override
|
||||||
|
public void start(Stage primaryStage) throws Exception {
|
||||||
|
FXPlusApplication.start(FXWindowDemo.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ import cn.edu.scau.biubiusuisui.expression.data.ExpressionParser;
|
|||||||
import cn.edu.scau.biubiusuisui.function.FXWindowParser;
|
import cn.edu.scau.biubiusuisui.function.FXWindowParser;
|
||||||
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
|
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
|
||||||
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
|
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
|
||||||
import cn.edu.scau.biubiusuisui.messageQueue.MessageQueue;
|
import cn.edu.scau.biubiusuisui.mq.MessageQueue;
|
||||||
import cn.edu.scau.biubiusuisui.proxy.FXControllerProxy;
|
import cn.edu.scau.biubiusuisui.proxy.FXControllerProxy;
|
||||||
import cn.edu.scau.biubiusuisui.stage.StageManager;
|
import cn.edu.scau.biubiusuisui.stage.StageManager;
|
||||||
import cn.edu.scau.biubiusuisui.utils.ResourceBundleUtil;
|
import cn.edu.scau.biubiusuisui.utils.ResourceBundleUtil;
|
||||||
@@ -168,7 +168,7 @@ public class FXControllerFactory {
|
|||||||
* @Description 为有FXWindow注解的类创建Stage
|
* @Description 为有FXWindow注解的类创建Stage
|
||||||
*/
|
*/
|
||||||
private static Stage createWindow(FXWindow fxWindow, Class clazz, FXBaseController fxBaseControllerProxy) {
|
private static Stage createWindow(FXWindow fxWindow, Class clazz, FXBaseController fxBaseControllerProxy) {
|
||||||
logger.info("creating window");
|
logger.info("creating window.....");
|
||||||
Stage stage = new Stage();
|
Stage stage = new Stage();
|
||||||
fxBaseControllerProxy.setStage(stage);
|
fxBaseControllerProxy.setStage(stage);
|
||||||
double preWidth = fxWindow.preWidth() == 0 ? fxBaseControllerProxy.getPrefWidth() : fxWindow.preWidth();
|
double preWidth = fxWindow.preWidth() == 0 ? fxBaseControllerProxy.getPrefWidth() : fxWindow.preWidth();
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ package cn.edu.scau.biubiusuisui.function;
|
|||||||
* @date 2019/7/27 1:54
|
* @date 2019/7/27 1:54
|
||||||
* @since JavaFX2.0 JDK1.8
|
* @since JavaFX2.0 JDK1.8
|
||||||
*/
|
*/
|
||||||
public interface Draggale {
|
public interface Draggable {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -22,44 +22,28 @@ import java.net.URL;
|
|||||||
* @since JavaFX2.0 JDK1.8
|
* @since JavaFX2.0 JDK1.8
|
||||||
*/
|
*/
|
||||||
public class FXWindowParser {
|
public class FXWindowParser {
|
||||||
private static IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(FXWindowParser.class);
|
private static final IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(FXWindowParser.class);
|
||||||
|
|
||||||
public void parse(Stage stage, FXBaseController fxControllerProxy, FXWindow fxWindow) {
|
public void parse(Stage stage, FXBaseController fxControllerProxy, FXWindow fxWindow) {
|
||||||
logger.info("parsing @FXWindow of class: " + fxControllerProxy.getName());
|
logger.info("parsing @FXWindow of class: " + fxControllerProxy.getName());
|
||||||
|
|
||||||
// 处理 title
|
// 处理 title
|
||||||
stage.setTitle(fxWindow.title());
|
fxControllerProxy.setWindowTitle(fxWindow.title());
|
||||||
|
|
||||||
// 处理 icon
|
// 处理 icon
|
||||||
if (!"".equals(fxWindow.icon())) {
|
fxControllerProxy.setIcon(fxWindow.icon());
|
||||||
try {
|
|
||||||
URL iconUrl = new FileUtil().getFilePathFromResources(fxWindow.icon());
|
// 处理draggable和resizable
|
||||||
if (iconUrl != null) {
|
if (fxWindow.draggable() || fxWindow.resizable()) {
|
||||||
if (new File(StringUtil.getRootPath(iconUrl)).exists()) {
|
fxControllerProxy.setDragAndResize(fxWindow.draggable(), fxWindow.resizable());
|
||||||
stage.getIcons().add(new Image(fxWindow.icon()));
|
|
||||||
} else {
|
|
||||||
logger.warn("the icon file has not existed");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.warn("the icon file has not existed");
|
|
||||||
}
|
|
||||||
} catch (ProtocolNotSupport protocolNotSupport) {
|
|
||||||
logger.error(protocolNotSupport.getMessage(), protocolNotSupport);
|
|
||||||
protocolNotSupport.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fxWindow的resizable默认为false
|
// fxWindow的resizable默认为false
|
||||||
if (fxWindow.resizable()) {
|
if (fxWindow.resizable()) {
|
||||||
stage.setResizable(true);
|
fxControllerProxy.setDragAndResize(fxWindow.draggable(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理draggable和resizable
|
|
||||||
if (fxWindow.draggable() || fxWindow.resizable()) {
|
|
||||||
EventHandler dragWindowHandler = new DragWindowHandlerImpl(stage, fxWindow.minWidth(), fxWindow.minHeight(), fxControllerProxy, fxWindow.draggable(), fxWindow.resizable());
|
|
||||||
fxControllerProxy.setOnMousePressed(dragWindowHandler);
|
|
||||||
fxControllerProxy.setOnMouseDragged(dragWindowHandler);
|
|
||||||
fxControllerProxy.setOnMouseMoved(dragWindowHandler);
|
|
||||||
}
|
|
||||||
// 处理style
|
// 处理style
|
||||||
stage.initStyle(fxWindow.style());
|
stage.initStyle(fxWindow.style());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package cn.edu.scau.biubiusuisui.messageQueue;
|
package cn.edu.scau.biubiusuisui.mq;
|
||||||
|
|
||||||
import cn.edu.scau.biubiusuisui.annotation.FXReceiver;
|
import cn.edu.scau.biubiusuisui.annotation.FXReceiver;
|
||||||
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
||||||
@@ -20,9 +20,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
* @date 2019/6/25 12:24
|
* @date 2019/6/25 12:24
|
||||||
* @since JavaFX2.0 JDK1.8
|
* @since JavaFX2.0 JDK1.8
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MessageQueue {
|
public class MessageQueue {
|
||||||
private IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(MessageQueue.class);
|
private static final IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(MessageQueue.class);
|
||||||
|
|
||||||
private static Map<String, List<FXMethodEntity>> receivers = new ConcurrentHashMap<>(); //Map<主题,订阅了主题的所有方法>
|
private static Map<String, List<FXMethodEntity>> receivers = new ConcurrentHashMap<>(); //Map<主题,订阅了主题的所有方法>
|
||||||
|
|
||||||
@@ -31,6 +30,11 @@ public class MessageQueue {
|
|||||||
private MessageQueue() {
|
private MessageQueue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取mq单例
|
||||||
|
*
|
||||||
|
* @return MessageQueue
|
||||||
|
*/
|
||||||
public static synchronized MessageQueue getInstance() {
|
public static synchronized MessageQueue getInstance() {
|
||||||
if (messageQueue == null) {
|
if (messageQueue == null) {
|
||||||
messageQueue = new MessageQueue();
|
messageQueue = new MessageQueue();
|
||||||
@@ -39,9 +43,9 @@ public class MessageQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param fxBaseController
|
* @param fxBaseController 基础controller
|
||||||
* @param fxBaseControllerProxy
|
* @param fxBaseControllerProxy 基础controller代理
|
||||||
* @Description 注册消费者,即FXReceiver注解的method
|
* @description 注册消费者,即FXReceiver注解的method
|
||||||
*/
|
*/
|
||||||
public void registerConsumer(FXBaseController fxBaseController, FXBaseController fxBaseControllerProxy) {
|
public void registerConsumer(FXBaseController fxBaseController, FXBaseController fxBaseControllerProxy) {
|
||||||
Class clazz = fxBaseController.getClass();
|
Class clazz = fxBaseController.getClass();
|
||||||
@@ -51,7 +55,6 @@ public class MessageQueue {
|
|||||||
for (Annotation annotation : annotations) {
|
for (Annotation annotation : annotations) {
|
||||||
if (FXReceiver.class.equals(annotation.annotationType())) {
|
if (FXReceiver.class.equals(annotation.annotationType())) {
|
||||||
logger.info("registering consumer: " + fxBaseControllerProxy.getName());
|
logger.info("registering consumer: " + fxBaseControllerProxy.getName());
|
||||||
// System.out.println("FXReceiver");
|
|
||||||
FXReceiver receiver = (FXReceiver) annotation;
|
FXReceiver receiver = (FXReceiver) annotation;
|
||||||
FXMethodEntity fxMethodEntity = new FXMethodEntity(fxBaseControllerProxy, method);
|
FXMethodEntity fxMethodEntity = new FXMethodEntity(fxBaseControllerProxy, method);
|
||||||
List<FXMethodEntity> fxMethodEntities = receivers.get(receiver.name());
|
List<FXMethodEntity> fxMethodEntities = receivers.get(receiver.name());
|
||||||
@@ -66,9 +69,9 @@ public class MessageQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param id
|
* @param id 消息topic
|
||||||
* @param msg
|
* @param msg 消息内容
|
||||||
* @Description 处理消息发送,id为topic,msg为消息
|
* @description 处理消息发送
|
||||||
*/
|
*/
|
||||||
public void sendMsg(String id, Object msg) {
|
public void sendMsg(String id, Object msg) {
|
||||||
List<FXMethodEntity> lists = receivers.get(id);
|
List<FXMethodEntity> lists = receivers.get(id);
|
||||||
@@ -80,23 +83,15 @@ public class MessageQueue {
|
|||||||
if (method.getParameterCount() == 0) {
|
if (method.getParameterCount() == 0) {
|
||||||
try {
|
try {
|
||||||
method.invoke(fxBaseController);
|
method.invoke(fxBaseController);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// obj the object the underlying method is invoked from
|
// 调起FXReceiver注解的方法
|
||||||
method.invoke(fxBaseController, msg);
|
method.invoke(fxBaseController, msg);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ package cn.edu.scau.biubiusuisui.proxy;
|
|||||||
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
|
||||||
import cn.edu.scau.biubiusuisui.annotation.FXSender;
|
import cn.edu.scau.biubiusuisui.annotation.FXSender;
|
||||||
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
||||||
import cn.edu.scau.biubiusuisui.messageQueue.MessageQueue;
|
import cn.edu.scau.biubiusuisui.mq.MessageQueue;
|
||||||
import cn.edu.scau.biubiusuisui.stage.StageManager;
|
import cn.edu.scau.biubiusuisui.stage.StageManager;
|
||||||
import net.sf.cglib.proxy.Enhancer;
|
import net.sf.cglib.proxy.Enhancer;
|
||||||
import net.sf.cglib.proxy.MethodInterceptor;
|
import net.sf.cglib.proxy.MethodInterceptor;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class FileUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param filePath
|
* @param filePath
|
||||||
* @return
|
* @return 返回URL
|
||||||
* @throws ProtocolNotSupport
|
* @throws ProtocolNotSupport
|
||||||
* @decription 从resources文件夹中读取File
|
* @decription 从resources文件夹中读取File
|
||||||
* 输出如: file:/Users/suisui/workspace/Idea/JavaFX-Plus/target/classes/image/icon.png
|
* 输出如: file:/Users/suisui/workspace/Idea/JavaFX-Plus/target/classes/image/icon.png
|
||||||
@@ -28,19 +28,24 @@ public class FileUtil {
|
|||||||
return FileUtil.class.getClassLoader().getResource(filePath);
|
return FileUtil.class.getClassLoader().getResource(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param filePath
|
* @param filePath
|
||||||
* @return
|
* @return
|
||||||
* @description 读取resources文件夹下的file,相对于resources的文件路径,如 resources/config.conf 则只需 config.conf
|
* @description 读取resources文件夹下的file,相对于resources的文件路径,如 resources/config.conf 则只需 config.conf
|
||||||
*/
|
*/
|
||||||
public static String readFileFromResources(String filePath) {
|
public static String readFileFromResources(String filePath) {
|
||||||
String path = StringUtil.getRootPath(FileUtil.class.getClassLoader().getResource(filePath));
|
URL url = FileUtil.class.getClassLoader().getResource(filePath);
|
||||||
return readFile(path);
|
if (url != null) {
|
||||||
|
String path = StringUtil.getRootPath(url);
|
||||||
|
return readFile(path);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param filePath 绝对路径或相对路径
|
* @param filePath 绝对路径或相对路径
|
||||||
* @return
|
* @return 返回文件内容
|
||||||
* @description 读取文件
|
* @description 读取文件
|
||||||
*/
|
*/
|
||||||
public static String readFile(String filePath) {
|
public static String readFile(String filePath) {
|
||||||
@@ -61,8 +66,8 @@ public class FileUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param filePath
|
* @param filePath 写出文件的地址
|
||||||
* @param content
|
* @param content 文件内容
|
||||||
* @description 写文件
|
* @description 写文件
|
||||||
*/
|
*/
|
||||||
public static void writeFile(String filePath, String content) {
|
public static void writeFile(String filePath, String content) {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package cn.edu.scau.biubiusuisui.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author suisui
|
||||||
|
* @description 函数工具类
|
||||||
|
* @date 2020/8/28 23:32
|
||||||
|
* @since JDK1.8
|
||||||
|
*/
|
||||||
|
public class FunctionUtil {
|
||||||
|
}
|
||||||
@@ -119,7 +119,7 @@ public class StringUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cn/edu/scau/biubiusuisui/resources/fxml/languageDemo/languageDemo.fxml -> fxml/languageDemo/languageDemo.fxml
|
* cn/edu/scau/biubiusuisui/resources/fxml/languageDemo/langDemo.fxml -> fxml/languageDemo/langDemo.fxml
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @return
|
* @return
|
||||||
@@ -135,7 +135,7 @@ public class StringUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cn/edu/scau/biubiusuisui/resources/fxml/languageDemo/languageDemo.fxml -> languageDemo
|
* cn/edu/scau/biubiusuisui/resources/fxml/languageDemo/langDemo.fxml -> languageDemo
|
||||||
*
|
*
|
||||||
* @param name 文件名
|
* @param name 文件名
|
||||||
* @return
|
* @return
|
||||||
@@ -144,7 +144,7 @@ public class StringUtil {
|
|||||||
public static String getFileBaseName(String name) {
|
public static String getFileBaseName(String name) {
|
||||||
String result = "";
|
String result = "";
|
||||||
String[] tempStrs = name.split("/");
|
String[] tempStrs = name.split("/");
|
||||||
if (1 == tempStrs.length) { //只有文件名,即name: languageDemo.fxml
|
if (1 == tempStrs.length) { //只有文件名,即name: langDemo.fxml
|
||||||
result = StringUtil.trimExtension(name);
|
result = StringUtil.trimExtension(name);
|
||||||
} else {
|
} else {
|
||||||
result = StringUtil.trimExtension(tempStrs[tempStrs.length - 1]);
|
result = StringUtil.trimExtension(tempStrs[tempStrs.length - 1]);
|
||||||
|
|||||||
@@ -58,6 +58,7 @@
|
|||||||
<Button mnemonicParsing="false" onAction="#clickToChinese" text="%chinese"/>
|
<Button mnemonicParsing="false" onAction="#clickToChinese" text="%chinese"/>
|
||||||
<Button mnemonicParsing="false" onAction="#clickToEnglish" text="%english"/>
|
<Button mnemonicParsing="false" onAction="#clickToEnglish" text="%english"/>
|
||||||
<Button mnemonicParsing="false" onAction="#clickToKorean" text="%korean"/>
|
<Button mnemonicParsing="false" onAction="#clickToKorean" text="%korean"/>
|
||||||
|
<Button mnemonicParsing="false" onAction="#changeTitleClick" text="修改"/>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
</children>
|
</children>
|
||||||
@@ -1 +1 @@
|
|||||||
dialog=弹窗
|
dialog=\u5f39\u7a97
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
button.goAndClose=跳转并关闭此窗口
|
button.goAndClose=\u8df3\u8f6c\u5e76\u5173\u95ed\u6b64\u7a97\u53e3
|
||||||
button.go=弹窗
|
button.go=\u5f39\u7a97
|
||||||
parentController=父组件
|
parentController=\u7236\u7ec4\u4ef6
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
childrenController=子组件
|
childrenController=\u5b50\u7ec4\u4ef6
|
||||||
19
src/main/resources/fxml/windowDemo/windowDemo.fxml
Normal file
19
src/main/resources/fxml/windowDemo/windowDemo.fxml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.ToggleButton?>
|
||||||
|
<?import javafx.scene.control.ToolBar?>
|
||||||
|
<?import javafx.scene.layout.Pane?>
|
||||||
|
|
||||||
|
<fx:root maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0"
|
||||||
|
prefWidth="600.0" type="Pane" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
|
<children>
|
||||||
|
<ToolBar layoutY="276.0" prefHeight="124.0" prefWidth="600.0">
|
||||||
|
<items>
|
||||||
|
<Button mnemonicParsing="false" onAction="#changeTitleClick" text="修改标题"/>
|
||||||
|
<Button mnemonicParsing="false" onAction="#changeIconClick" text="修改图标"/>
|
||||||
|
<ToggleButton fx:id="canResizableTB" mnemonicParsing="false" text="是否允许窗口拖拽缩放"/>
|
||||||
|
</items>
|
||||||
|
</ToolBar>
|
||||||
|
</children>
|
||||||
|
</fx:root>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
changeTitle
|
||||||
BIN
src/main/resources/image/icon2.png
Normal file
BIN
src/main/resources/image/icon2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
src/main/resources/image/icon3.png
Normal file
BIN
src/main/resources/image/icon3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Reference in New Issue
Block a user