Compare commits
9 Commits
v1.2.0-REL
...
1.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a7efd76c6 | ||
|
|
96a58bcda5 | ||
|
|
34ddd6f26e | ||
|
|
38dc53b484 | ||
|
|
547c036cdb | ||
|
|
a69651447c | ||
|
|
f6189b1bf9 | ||
|
|
d139cbe3c5 | ||
|
|
5b7131febf |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
.idea
|
.idea
|
||||||
|
*.iml
|
||||||
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
|
||||||
@@ -93,7 +91,7 @@ Our project has suspended update from Nov. 25, 2019, and the next release will b
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.Biubiuyuyu</groupId>
|
<groupId>com.gitee.Biubiuyuyu</groupId>
|
||||||
<artifactId>javafx-plus</artifactId>
|
<artifactId>javafx-plus</artifactId>
|
||||||
<version>1.0.0-RELEASE</version>
|
<version>1.2.1-SNAPSHOT</version>
|
||||||
</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] 信号机制
|
||||||
@@ -88,11 +86,14 @@
|
|||||||
- [ ] 优化性能
|
- [ ] 优化性能
|
||||||
|
|
||||||
## Maven仓库地址
|
## Maven仓库地址
|
||||||
|
|
||||||
|
maven仓库中的JavaFX-Plus版本是较旧版本,建议使用最新发行版。
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gitee.Biubiuyuyu</groupId>
|
<groupId>com.gitee.Biubiuyuyu</groupId>
|
||||||
<artifactId>javafx-plus</artifactId>
|
<artifactId>javafx-plus</artifactId>
|
||||||
<version>1.0.0-RELEASE</version>
|
<version>1.2.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
## Git地址
|
## Git地址
|
||||||
@@ -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的接口
|
||||||
|
|
||||||
|
|||||||
94
pom.xml
94
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.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<!-- packaging为pom时,不会加载resources 故注释-->
|
||||||
|
<!-- <packaging>pom</packaging>-->
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.sonatype.oss</groupId>
|
<groupId>org.sonatype.oss</groupId>
|
||||||
@@ -18,29 +19,27 @@
|
|||||||
|
|
||||||
<description>this is javafx framework that simplified coding</description>
|
<description>this is javafx framework that simplified coding</description>
|
||||||
|
|
||||||
<distributionManagement>
|
<properties>
|
||||||
<repository>
|
<cglib.version>3.1</cglib.version>
|
||||||
<id>javafx-plus</id>
|
<junit.version>4.13.1</junit.version>
|
||||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
<slf4j-log4j12.version>1.7.21</slf4j-log4j12.version>
|
||||||
</repository>
|
<tomcat.version>9.0.48</tomcat.version>
|
||||||
<snapshotRepository>
|
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||||
<id>javafx-plus</id>
|
<commons-io.version>2.11.0</commons-io.version>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
</properties>
|
||||||
</snapshotRepository>
|
|
||||||
</distributionManagement>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- 第三方动态代理库 -->
|
<!-- 第三方动态代理库 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cglib</groupId>
|
<groupId>cglib</groupId>
|
||||||
<artifactId>cglib</artifactId>
|
<artifactId>cglib</artifactId>
|
||||||
<version>3.1</version>
|
<version>${cglib.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Junit单元测试 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.11</version>
|
<version>${junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -48,17 +47,55 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
<version>1.7.21</version>
|
<version>${slf4j-log4j12.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
<groupId>org.apache.tomcat.embed</groupId>
|
||||||
<artifactId>tomcat-embed-core</artifactId>
|
<artifactId>tomcat-embed-core</artifactId>
|
||||||
<version>9.0.29</version>
|
<version>${tomcat.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>${commons-lang3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>${commons-io.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>javafx-plus</id>
|
||||||
|
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||||
|
</repository>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>javafx-plus</id>
|
||||||
|
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
</distributionManagement>
|
||||||
|
|
||||||
<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 +103,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>
|
||||||
@@ -87,19 +125,11 @@
|
|||||||
</descriptorRefs>
|
</descriptorRefs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
<!-- Source 开源 -->
|
||||||
</build>
|
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>release</id>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<!-- Source -->
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>2.2.1</version>
|
<version>3.0.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@@ -109,6 +139,14 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>release</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
<!-- Javadoc -->
|
<!-- Javadoc -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import cn.edu.scau.biubiusuisui.utils.ClassUtil;
|
|||||||
import cn.edu.scau.biubiusuisui.utils.FileUtil;
|
import cn.edu.scau.biubiusuisui.utils.FileUtil;
|
||||||
import cn.edu.scau.biubiusuisui.utils.LogUtil;
|
import cn.edu.scau.biubiusuisui.utils.LogUtil;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -25,7 +26,6 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public class FXPlusApplication {
|
public class FXPlusApplication {
|
||||||
private static final IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(FXPlusApplication.class);
|
private static final IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(FXPlusApplication.class);
|
||||||
// Application
|
|
||||||
|
|
||||||
private static FXWindowParser windowAnnotationParser = new FXWindowParser();
|
private static FXWindowParser windowAnnotationParser = new FXWindowParser();
|
||||||
|
|
||||||
@@ -37,7 +37,11 @@ public class FXPlusApplication {
|
|||||||
|
|
||||||
public static void start(Class clazz, BeanBuilder beanBuilder) {
|
public static void start(Class clazz, BeanBuilder beanBuilder) {
|
||||||
logger.info("starting JavaFX-Plus Application");
|
logger.info("starting JavaFX-Plus Application");
|
||||||
|
try {
|
||||||
logger.info("\n" + FileUtil.readFileFromResources("banner.txt"));
|
logger.info("\n" + FileUtil.readFileFromResources("banner.txt"));
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
logger.error("\n read classpath:banner.txt error, you can ignore it");
|
||||||
|
}
|
||||||
// 初始化日志路径
|
// 初始化日志路径
|
||||||
LogUtil.initLog4jBase();
|
LogUtil.initLog4jBase();
|
||||||
|
|
||||||
@@ -56,15 +60,15 @@ public class FXPlusApplication {
|
|||||||
for (String dir : sets) {
|
for (String dir : sets) {
|
||||||
logger.info("scanning directory: " + dir);
|
logger.info("scanning directory: " + dir);
|
||||||
ClassUtil classUtil = new ClassUtil();
|
ClassUtil classUtil = new ClassUtil();
|
||||||
List<String> temps = classUtil.scanAllClassName(dir);
|
List<String> temps = null;
|
||||||
for (String className : temps) {
|
|
||||||
try {
|
try {
|
||||||
|
temps = classUtil.scanAllClassName(dir);
|
||||||
|
for (String className : temps) {
|
||||||
logger.info("loading class: " + className);
|
logger.info("loading class: " + className);
|
||||||
loadFXPlusClass(className, beanBuilder);
|
loadFXPlusClass(className, beanBuilder);
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
} catch (UnsupportedEncodingException | ClassNotFoundException exception) {
|
||||||
|
logger.error("{}", exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,22 @@ 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.IFxPlusConstants;
|
||||||
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.io.UnsupportedEncodingException;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -19,7 +27,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 +44,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 +53,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 +78,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 +182,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 +200,7 @@ public class FXBaseController extends Pane {
|
|||||||
* 关闭舞台
|
* 关闭舞台
|
||||||
*/
|
*/
|
||||||
public void closeStage() {
|
public void closeStage() {
|
||||||
if (isWindow) {
|
if (this.isWindow) {
|
||||||
this.stage.close();
|
this.stage.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,16 +210,80 @@ 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 | UnsupportedEncodingException exception) {
|
||||||
|
logger.error(exception.getMessage(), exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <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());
|
||||||
} else {
|
} else {
|
||||||
return StringUtil.getBaseClassName(getClass().getSimpleName()) + "#" + name;
|
return StringUtil.getBaseClassName(getClass().getSimpleName()) + IFxPlusConstants.CONTROLLER_NAME_SEPARATOR + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,11 +300,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() {
|
||||||
|
|||||||
@@ -12,9 +12,13 @@ import java.lang.reflect.Method;
|
|||||||
* @since JavaFX2.0 JDK1.8
|
* @since JavaFX2.0 JDK1.8
|
||||||
*/
|
*/
|
||||||
public class FXMethodEntity {
|
public class FXMethodEntity {
|
||||||
|
/**
|
||||||
|
* 所属Controller
|
||||||
|
*/
|
||||||
private FXBaseController fxBaseController;
|
private FXBaseController fxBaseController;
|
||||||
|
/**
|
||||||
|
* 实际方法
|
||||||
|
*/
|
||||||
private Method method;
|
private Method method;
|
||||||
|
|
||||||
public FXMethodEntity(FXBaseController fxBaseController, Method method) {
|
public FXMethodEntity(FXBaseController fxBaseController, Method method) {
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public class FXPlusContext {
|
|||||||
controllers = new LinkedList<>();
|
controllers = new LinkedList<>();
|
||||||
}
|
}
|
||||||
controllers.add(fxBaseController);
|
controllers.add(fxBaseController);
|
||||||
|
// @since 1.2.1 fix: 没有将controller真正注册到context的异常
|
||||||
|
controllerContext.put(fxBaseController.getName(), controllers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,19 @@ import java.util.Map;
|
|||||||
* @since JavaFX2.0 JDK1.8
|
* @since JavaFX2.0 JDK1.8
|
||||||
*/
|
*/
|
||||||
public class FXRedirectParam {
|
public class FXRedirectParam {
|
||||||
|
/**
|
||||||
|
* 跳转的目标Controller
|
||||||
|
*/
|
||||||
private String toController;
|
private String toController;
|
||||||
|
/**
|
||||||
|
* query方式的参数, like: helloController?name=JavaFx-Plus&msg=helloWorld
|
||||||
|
* the map will store: { name -> JavaFx-Plus, msg -> helloWorld}
|
||||||
|
*/
|
||||||
private Map<String, Object> query = new HashMap<>();
|
private Map<String, Object> query = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* param方式的参数,会以map方式传递给目标Controller
|
||||||
|
*/
|
||||||
private Map<String, Object> params = new HashMap<>();
|
private Map<String, Object> params = new HashMap<>();
|
||||||
|
|
||||||
public FXRedirectParam(String toController) {
|
public FXRedirectParam(String toController) {
|
||||||
|
|||||||
@@ -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,8 +1,6 @@
|
|||||||
package cn.edu.scau.biubiusuisui.log;
|
package cn.edu.scau.biubiusuisui.log;
|
||||||
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author suisui
|
* @author suisui
|
||||||
* @version 1.2
|
* @version 1.2
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cn.edu.scau.biubiusuisui.utils;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -22,7 +23,14 @@ public class ClassUtil {
|
|||||||
classLoader = getClass().getClassLoader();
|
classLoader = getClass().getClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getAllFXControllerClassName(String base, List<String> nameList) {
|
/**
|
||||||
|
* 获取所有FxController的类名
|
||||||
|
*
|
||||||
|
* @param base 基础目录路径
|
||||||
|
* @param nameList 类名列表
|
||||||
|
* @return 所有FXController的类名列表
|
||||||
|
*/
|
||||||
|
private List<String> getAllFXControllerClassName(String base, List<String> nameList) throws UnsupportedEncodingException {
|
||||||
String splashPath = StringUtil.dotToSplash(base);
|
String splashPath = StringUtil.dotToSplash(base);
|
||||||
URL url = classLoader.getResource(splashPath);
|
URL url = classLoader.getResource(splashPath);
|
||||||
String filePath = StringUtil.getRootPath(url);
|
String filePath = StringUtil.getRootPath(url);
|
||||||
@@ -42,7 +50,7 @@ public class ClassUtil {
|
|||||||
return nameList;
|
return nameList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> scanAllClassName(String base) {
|
public List<String> scanAllClassName(String base) throws UnsupportedEncodingException {
|
||||||
return getAllFXControllerClassName(base, new LinkedList<>());
|
return getAllFXControllerClassName(base, new LinkedList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +70,9 @@ public class ClassUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static List<String> readFromDirectory(String path) {
|
private static List<String> readFromDirectory(String path) {
|
||||||
if (path == null) return null;
|
if (path == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return readFromFileDirectory(path);
|
return readFromFileDirectory(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ package cn.edu.scau.biubiusuisui.utils;
|
|||||||
import cn.edu.scau.biubiusuisui.exception.ProtocolNotSupport;
|
import cn.edu.scau.biubiusuisui.exception.ProtocolNotSupport;
|
||||||
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 org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jack
|
* @author jack
|
||||||
@@ -18,7 +20,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 +30,40 @@ 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
|
||||||
|
* @since 1.2.0 update: 使用getResourcesAsStream读取,屏蔽jar包读取障碍
|
||||||
*/
|
*/
|
||||||
public static String readFileFromResources(String filePath) {
|
public static String readFileFromResources(String filePath) throws UnsupportedEncodingException {
|
||||||
String path = StringUtil.getRootPath(FileUtil.class.getClassLoader().getResource(filePath));
|
InputStream is = FileUtil.class.getClassLoader().getResourceAsStream(filePath);
|
||||||
return readFile(path);
|
if (is == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
StringBuffer content = new StringBuffer();
|
||||||
|
try (
|
||||||
|
InputStreamReader inputStreamReader = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(inputStreamReader);
|
||||||
|
) {
|
||||||
|
String temp;
|
||||||
|
while ((temp = br.readLine()) != null) {
|
||||||
|
// 一次读入一行数据
|
||||||
|
content.append(temp + "\r\n");
|
||||||
|
}
|
||||||
|
return content.toString();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("reading file error", e);
|
||||||
|
} finally {
|
||||||
|
IOUtils.closeQuietly(is);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param filePath 绝对路径或相对路径
|
* @param filePath 绝对路径或相对路径
|
||||||
* @return
|
* @return 返回文件内容
|
||||||
* @description 读取文件
|
* @description 读取文件
|
||||||
*/
|
*/
|
||||||
public static String readFile(String filePath) {
|
public static String readFile(String filePath) {
|
||||||
@@ -54,15 +77,14 @@ public class FileUtil {
|
|||||||
content.append(temp + "\r\n");
|
content.append(temp + "\r\n");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error(e.getMessage());
|
logger.error("reading file error", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return content.toString();
|
return content.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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 {
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package cn.edu.scau.biubiusuisui.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author suisui
|
||||||
|
* @version 1.2.0
|
||||||
|
* <p> Description: JavaFx-Plus常量 </p>
|
||||||
|
* @time 2021/9/5 10:36 下午
|
||||||
|
*/
|
||||||
|
public interface IFxPlusConstants {
|
||||||
|
/**
|
||||||
|
* 项目默认编码 UTF-8
|
||||||
|
*/
|
||||||
|
String DEFAULT_CHARSET = "UTF-8";
|
||||||
|
/**
|
||||||
|
* FXController名称分隔符
|
||||||
|
*/
|
||||||
|
String CONTROLLER_NAME_SEPARATOR = "#";
|
||||||
|
}
|
||||||
@@ -2,8 +2,11 @@ package cn.edu.scau.biubiusuisui.utils;
|
|||||||
|
|
||||||
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 org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jack
|
* @author jack
|
||||||
@@ -11,20 +14,20 @@ import java.net.URL;
|
|||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @date 2019/6/25 3:46
|
* @date 2019/6/25 3:46
|
||||||
* @since JavaFX2.0 JDK1.8
|
* @since JavaFX2.0 JDK1.8
|
||||||
|
* @since 1.3.0 add:继承StringUtils
|
||||||
*/
|
*/
|
||||||
public class StringUtil {
|
public class StringUtil extends StringUtils {
|
||||||
private static IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(StringUtil.class);
|
private static IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(StringUtil.class);
|
||||||
|
|
||||||
private StringUtil() {
|
private StringUtil() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "file:/home/whf/cn/fh" -> "/home/whf/cn/fh"
|
* "file:/home/whf/cn/fh" -> "/home/whf/cn/fh"
|
||||||
* "jar:file:/home/whf/foo.jar!cn/fh" -> "/home/whf/foo.jar"
|
* "jar:file:/home/whf/foo.jar!cn/fh" -> "/home/whf/foo.jar"
|
||||||
*/
|
*/
|
||||||
public static String getRootPath(URL url) {
|
public static String getRootPath(URL url) throws UnsupportedEncodingException {
|
||||||
String fileUrl = url.getFile();
|
String fileUrl = URLDecoder.decode(url.getFile(),IFxPlusConstants.DEFAULT_CHARSET);
|
||||||
int pos = fileUrl.indexOf('!');
|
int pos = fileUrl.indexOf('!');
|
||||||
|
|
||||||
if (-1 == pos) {
|
if (-1 == pos) {
|
||||||
@@ -51,7 +54,6 @@ public class StringUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String splashToDot(String name) {
|
public static String splashToDot(String name) {
|
||||||
|
|
||||||
return name.replaceAll("/", "\\.");
|
return name.replaceAll("/", "\\.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +65,6 @@ public class StringUtil {
|
|||||||
if (-1 != pos) {
|
if (-1 != pos) {
|
||||||
return name.substring(0, pos);
|
return name.substring(0, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +77,6 @@ public class StringUtil {
|
|||||||
public static String trimURI(String uri) {
|
public static String trimURI(String uri) {
|
||||||
String trimmed = uri.substring(1);
|
String trimmed = uri.substring(1);
|
||||||
int splashIndex = trimmed.indexOf('/');
|
int splashIndex = trimmed.indexOf('/');
|
||||||
|
|
||||||
return trimmed.substring(splashIndex);
|
return trimmed.substring(splashIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,8 +103,7 @@ public class StringUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String toInstanceName(String name) {
|
public static String toInstanceName(String name) {
|
||||||
String result = name.substring(0, 1).toLowerCase().concat(name.substring(1));
|
return name.substring(0, 1).toLowerCase().concat(name.substring(1));
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,12 +113,11 @@ public class StringUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String toClassName(String name) {
|
public static String toClassName(String name) {
|
||||||
String result = name.substring(0, 1).toUpperCase().concat(name.substring(1));
|
return name.substring(0, 1).toUpperCase().concat(name.substring(1));
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 +133,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 +142,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