11 Commits

Author SHA1 Message Date
yangsuiyu
a82844cf35 v1.2.0更新
1. 设计代码模块文件,导入IDE后可快速生成符合JavaFX-Plus编程规范的FXPlusController、FXPlusWindow、FXPlusApplication、FXPlusFXML文件
2. 完善多窗口切换功能,可携带数据跳转
3. 新增注解@FXWindow中的icon属性,传入String类型的图标URL,可为窗口标题栏增设图标
4. 完善JavaFX-Plus生命周期
5. 新增日志log模块
6. 新增语言国际化操作
7. 新增测试生命周期LifeDemo示例和测试国际化的LanguageDemo示例代码
8. 规范化代码和更新README
2020-05-04 23:05:02 +08:00
yangsuiyu
b48325cd63 v1.2.0更新
1. 设计代码模块文件,导入IDE后可快速生成符合JavaFX-Plus编程规范的FXPlusController、FXPlusWindow、FXPlusApplication、FXPlusFXML文件
2. 完善多窗口切换功能,可携带数据跳转
3. 新增注解@FXWindow中的icon属性,传入String类型的图标URL,可为窗口标题栏增设图标
4. 完善JavaFX-Plus生命周期
5. 新增日志log模块
6. 新增语言国际化操作
7. 新增测试生命周期LifeDemo示例和测试国际化的LanguageDemo示例代码
8. 规范化代码和更新README
2020-05-04 15:13:58 +08:00
yangsuiyu
7c807d4b39 可携带数据跳转
1. 新增可携带数据跳转的功能
2. 完善README
3. 修改示例
2020-04-07 21:53:25 +08:00
yangsuiyu
119436dc3b 修正resizable的bug 2020-04-05 22:43:29 +08:00
yangsuiyu
5e60991bda 修改README
1. 修改README
2. 测试分支
2020-04-01 13:35:34 +08:00
suisui
5f9150b0f6 修改README 2020-01-22 10:21:48 +08:00
suisui
9a04efd84f 修改gitee的markdown解析器不支持[TOC]标签所导致目录索引无法显示的bug 2020-01-22 02:44:20 +08:00
suisui
d23cda4f47 新增英文README,修正部分文件结构 2020-01-22 02:18:46 +08:00
Biubiu
54dc098123 修改README 2020-01-15 10:37:23 +08:00
Biubiu
3147d9f9b7 解决了jar包无法扫描问题 2020-01-15 10:29:57 +08:00
Biubiu
4e968bcd08 添加具体应用 2020-01-09 22:57:17 +08:00
194 changed files with 5019 additions and 694 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.idea

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: cglib:cglib:3.1" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm:4.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>

View File

File diff suppressed because it is too large Load Diff

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

View File

Before

Width:  |  Height:  |  Size: 451 KiB

After

Width:  |  Height:  |  Size: 451 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 KiB

BIN
README.en/Resizable_en.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 MiB

View File

Before

Width:  |  Height:  |  Size: 14 MiB

After

Width:  |  Height:  |  Size: 14 MiB

BIN
README.en/bindhow.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
README.en/demo1.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
README.en/draggable_en.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 MiB

BIN
README.en/expression.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

BIN
README.en/expressionV2V.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

BIN
README.en/language_demo.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 MiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 MiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 MiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

BIN
README.en/log_demo_en.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
README.en/modulesAction.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 KiB

BIN
README.en/moveable.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 977 KiB

View File

Before

Width:  |  Height:  |  Size: 15 MiB

After

Width:  |  Height:  |  Size: 15 MiB

View File

Before

Width:  |  Height:  |  Size: 5.9 MiB

After

Width:  |  Height:  |  Size: 5.9 MiB

View File

Before

Width:  |  Height:  |  Size: 6.5 MiB

After

Width:  |  Height:  |  Size: 6.5 MiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 MiB

BIN
README.en/resizeAble.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 KiB

BIN
README.en/template_en.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

BIN
README.en/wrap_JavaBean.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

753
README.md
View File

File diff suppressed because it is too large Load Diff

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

BIN
README/JavaFX-Plus.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 KiB

BIN
README/JavaFX-Plus_en.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 KiB

BIN
README/Resizable.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 MiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 MiB

BIN
README/bindhow.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

BIN
README/controllerConfig.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
README/demo1.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
README/draggable.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

BIN
README/expression.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

BIN
README/expressionV2V.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
README/helloWorldDemo.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

BIN
README/language_demo.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 MiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 MiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

BIN
README/log_demo.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
README/modulesAction.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 KiB

BIN
README/moveable.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 977 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 MiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 MiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 MiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 MiB

BIN
README/resizeAble.gif Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 KiB

BIN
README/template.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 KiB

BIN
README/template_incude.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

BIN
README/wrap_JavaBean.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

16
pom.xml
View File

@@ -6,7 +6,7 @@
<name>javafx-plus</name>
<groupId>com.gitee.Biubiuyuyu</groupId>
<artifactId>javafx-plus</artifactId>
<version>1.0.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
<packaging>jar</packaging>
@@ -30,6 +30,7 @@
</distributionManagement>
<dependencies>
<!-- 第三方动态代理库-->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
@@ -42,6 +43,19 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- log4j 日志-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>9.0.29</version>
</dependency>
</dependencies>
<build>

View File

@@ -2,7 +2,10 @@ package cn.edu.scau.biubiusuisui.annotation;
import java.lang.annotation.*;
/**
* @version 1.0
* @since JavaFX2.0 JDK1.8
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Inherited

View File

@@ -1,17 +1,32 @@
package cn.edu.scau.biubiusuisui.annotation;
import cn.edu.scau.biubiusuisui.entity.FXPlusLocale;
import java.lang.annotation.*;
/**
* This is use for marking A controller as FX-Plus Controller
@Author jack
@Date:2019/6/25 1:34
*
* @author jack
* @author suisui
* @version 1.0
* @date 2019/6/25 1:34
* @since JavaFX2.0 JDK1.8
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
public @interface FXController {
String path();
double preWidth() default 0.0;
double preHeight() default 0.0;
/**
* @return
* @description 程序语言,默认不设置
* @version 1.2
*/
FXPlusLocale locale() default FXPlusLocale.NONE;
}

View File

@@ -3,8 +3,10 @@ package cn.edu.scau.biubiusuisui.annotation;
import java.lang.annotation.*;
/**
* @Author jack
* @Date:2019/6/25 1:36
* @author jack
* @version 1.0
* @date 2019/6/25 1:36
* @since JavaFX2.0 JDK1.8
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)

View File

@@ -3,8 +3,10 @@ package cn.edu.scau.biubiusuisui.annotation;
import java.lang.annotation.*;
/**
* @Author jack
* @Date:2019/6/25 1:35
* @author jack
* @version 1.0
* @date 2019/6/25 1:35
* @since JavaFX2.0 JDK1.8
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)

View File

@@ -6,8 +6,10 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @Author jack
* @Date:2019/6/27 20:10
* @author jack
* @version 1.0
* @date 2019/6/27 20:10
* @since JavaFX2.0 JDK1.8
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)

View File

@@ -3,8 +3,10 @@ package cn.edu.scau.biubiusuisui.annotation;
import java.lang.annotation.*;
/**
* @Author jack
* @Date:2019/6/25 13:06
* @author jack
* @version 1.0
* @date 2019/6/25 13:06
* @since JavaFX2.0 JDK1.8
*/
@Retention(RetentionPolicy.RUNTIME)
@Inherited

View File

@@ -3,10 +3,11 @@ package cn.edu.scau.biubiusuisui.annotation;
import java.lang.annotation.*;
/**
* @author suiyu_yang
* @author suisui
* @version 1.1
* @description 重定向的注解
* @date 2019/12/3 12:53
* @email suiyu_yang@163.com
* @since JavaFX2.0 JDK1.8
*/
@Retention(RetentionPolicy.RUNTIME)

View File

@@ -6,8 +6,9 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @Author jack
* @Date:2019/6/25 2:55
* @author jack
* @date 2019/6/25 2:55
* @since JavaFX2.0 JDK1.8
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)

View File

@@ -11,24 +11,26 @@ import java.lang.annotation.Target;
* It is legal to use same method which has same name because JavaFX-Plus will identify a method with its full class name
* In addition ,name is optional , default name will be the class name and method name
* you can use this cn.edu.scau.biubiusuisui.annotation as the following cn.edu.scau.biubiusuisui.example
* @FXSernder
* <p>
* \@FXSender
* public class A{
* public void test(){
*
* <p>
* }
* }
* name will be A.name(It will only contain base class name and this name)
* or you can use
* @FXSernder("testDemo")
* public class A{
* public void test(){
*
* @author jack
* @version 1.0
* @FXSernder("testDemo") public class A{
* public void test(){
* <p>
* }
* }
* name will be A.testDemo
*
* @Author jack
* @Date:2019/6/25 13:02
* @date 2019/6/25 13:02
* @since JavaFX2.0 JDK1.8
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)

View File

@@ -3,8 +3,10 @@ package cn.edu.scau.biubiusuisui.annotation;
import java.lang.annotation.*;
/**
* @Author jack
* @Date:2019/7/27 3:06
* @author jack
* @version 1.0
* @date 2019/7/27 3:06
* @since JavaFX2.0 JDK1.8
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)

View File

@@ -1,24 +1,44 @@
package cn.edu.scau.biubiusuisui.annotation;
import cn.edu.scau.biubiusuisui.entity.FXPlusLocale;
import javafx.stage.StageStyle;
import java.lang.annotation.*;
import java.util.Locale;
/**
* @Author jack
* @Date:2019/6/25 1:36
* @author jack
* @author suisui
* @version 1.0
* @date 2019/6/25 1:36
* @since JavaFX2.0 JDK1.8
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
public @interface FXWindow {
double preWidth() default 0.0;
double preHeight() default 0.0;
double minWidth() default 0.0;
double minHeight() default 0.0;
boolean resizable() default false;
boolean draggable() default false;
boolean mainStage() default false;
StageStyle style() default StageStyle.DECORATED;
String title();
/**
* @description 图标URL
* @version 1.2
*/
String icon() default "";
}

View File

@@ -58,29 +58,12 @@ import java.util.regex.Pattern;
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
/**
* Loads an object hierarchy from an XML document.
*
* @since JavaFX 2.0
* @since JavaFX2.0 JDK1.8
*/
public class FXMLLoaderPlus {

View File

@@ -6,7 +6,11 @@ import cn.edu.scau.biubiusuisui.factory.BeanBuilder;
import cn.edu.scau.biubiusuisui.factory.FXBuilder;
import cn.edu.scau.biubiusuisui.factory.FXControllerFactory;
import cn.edu.scau.biubiusuisui.function.FXWindowParser;
import cn.edu.scau.biubiusuisui.utils.ClassUtils;
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
import cn.edu.scau.biubiusuisui.utils.ClassUtil;
import cn.edu.scau.biubiusuisui.utils.FileUtil;
import cn.edu.scau.biubiusuisui.utils.LogUtil;
import java.lang.annotation.Annotation;
import java.util.HashSet;
@@ -14,23 +18,33 @@ import java.util.List;
import java.util.Set;
/**
* @Author jack
* @Date:2019/6/25 2:54
* @author jack
* @version 1.0
* @date 2019/6/25 2:54
* @since JavaFX2.0 JDK1.8
*/
public class FXPlusApplication {
private static final IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(FXPlusApplication.class);
// Application
private static FXWindowParser windowAnnotationParser = new FXWindowParser();
private static BeanBuilder DEFALUT_BEAN_FACTORY = new FXBuilder();
private static BeanBuilder DEFAULT_BEAN_FACTORY = new FXBuilder();
private static BeanBuilder beanBuilder;
public static boolean IS_SCENE_BUILDER = true;
public static void start(Class clazz, BeanBuilder beanBuilder) {
logger.info("starting JavaFX-Plus Application");
logger.info("\n" + FileUtil.readFileFromResources("banner.txt"));
// 初始化日志路径
LogUtil.initLog4jBase();
IS_SCENE_BUILDER = false;
FXPlusApplication.beanBuilder = beanBuilder;
Annotation[] annotations = clazz.getDeclaredAnnotations();
logger.info("starting to scanning and registering controllers");
for (Annotation annotation : annotations) {
if (FXScan.class.equals(annotation.annotationType())) {
String[] dirs = ((FXScan) annotation).base();
@@ -40,12 +54,15 @@ public class FXPlusApplication {
}
Set<String> classNames = new HashSet<>();
for (String dir : sets) {
ClassUtils classUtils = new ClassUtils();
List<String> temps = classUtils.scanAllClassName(dir);
logger.info("scanning directory: " + dir);
ClassUtil classUtil = new ClassUtil();
List<String> temps = classUtil.scanAllClassName(dir);
for (String className : temps) {
try {
logger.info("loading class: " + className);
loadFXPlusClass(className, beanBuilder);
} catch (ClassNotFoundException e) {
logger.error(e.getMessage());
e.printStackTrace();
}
}
@@ -55,12 +72,14 @@ public class FXPlusApplication {
}
public static void start(Class clazz) {
start(clazz, DEFALUT_BEAN_FACTORY);
start(clazz, DEFAULT_BEAN_FACTORY);
}
private static void loadFXPlusClass(String className, BeanBuilder beanBuilder) throws ClassNotFoundException {
Class clazz = Class.forName(className);
// 是窗口需要初始化Stage
if (clazz.getAnnotation(FXWindow.class) != null) {
logger.info("loading stage of class: " + className);
FXControllerFactory.loadStage(clazz, beanBuilder);
}
}

View File

@@ -4,17 +4,20 @@ import cn.edu.scau.biubiusuisui.annotation.FXController;
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
import cn.edu.scau.biubiusuisui.config.FXMLLoaderPlus;
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
import cn.edu.scau.biubiusuisui.utils.StringUtils;
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
import cn.edu.scau.biubiusuisui.utils.ResourceBundleUtil;
import cn.edu.scau.biubiusuisui.utils.StringUtil;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;
/**
* @Author jack
* @Date:2019/6/25 5:51
*/
/**
* In JavaFX-Plus Framework Controller
@@ -24,48 +27,146 @@ import java.lang.annotation.Annotation;
* M means model which is base cn.edu.scau.biubiusuisui.entity in your program
* Every BaseController has a name which is used for identifying different <strong>instance</strong>
*/
/**
* @author jack
* @author suisui
* @version 1.0
* @date 2019/6/25 5:51
* @since JavaFX2.0 JDK1.8
*/
public class FXBaseController extends Pane {
private static IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(FXBaseController.class);
protected String name = "";
private Stage stage;
private boolean isController = false;
private boolean isWindow = false;
/**
* @description 用于携带信息数据
* @version 1.2
*/
private Map<String, Object> query = new HashMap<>();
private Map<String, Object> param = new HashMap<>();
public FXBaseController(String name) {
this.name = name;
}
public FXBaseController() {
FXController fxController = null;
FXWindow fxWindow = null;
Annotation[] annotations = getClass().getAnnotations();
// Find FXController cn.edu.scau.biubiusuisui.annotation
for (Annotation annotation : annotations) {
// 是否Controller
if (annotation.annotationType().equals(FXController.class)) {
fxController = (FXController) annotation;
isController = true;
}
// 添加赋予是否为窗口的逻辑
if (annotation.annotationType().equals(FXWindow.class)) {
fxWindow = (FXWindow) annotation;
isWindow = true;
}
}
//load fxml file to show panel in scene builder
if (isController && FXPlusApplication.IS_SCENE_BUILDER == true) {
FXMLLoaderPlus fxmlLoader = new FXMLLoaderPlus(getClass().getClassLoader().getResource(fxController.path()));
logger.info("loading the FXML file of " + this.getName());
URL location = getClass().getClassLoader().getResource(fxController.path());
String fxmlBaseName = StringUtil.getFilePathInResources(fxController.path());
ResourceBundle resourceBundle = ResourceBundleUtil.getResourceBundle(fxmlBaseName, fxController.locale());
FXMLLoaderPlus fxmlLoader = new FXMLLoaderPlus(location);
fxmlLoader.setRoot(this);
fxmlLoader.setController(this);
fxmlLoader.setShow(true);
// System.out.println("?");
fxmlLoader.setResources(resourceBundle);
try {
// 加载前
onLoad();
fxmlLoader.load();
} catch (IOException e) {
logger.error(e.getMessage());
e.printStackTrace();
} catch (Exception e) {
logger.error(e.getMessage());
e.printStackTrace();
}
}
}
public void initialize() {
/**
* @description 相当于onReady, 页面渲染完后的操作
* @version 1.2
*/
public void initialize() throws Exception {
}
/**
* @description 初始化onShow, onHide, onClose的生命周期
* @version 1.2
*/
public final void initLifeCycle() {
logger.info("init the life cycle of " + this.getName());
this.stage.setOnShowing(event -> {
try {
onShow();
} catch (Exception e) {
logger.error(e.getMessage());
e.printStackTrace();
}
});
this.stage.setOnCloseRequest(event -> {
try {
onClose();
} catch (Exception e) {
logger.error(e.getMessage());
e.printStackTrace();
}
});
// 监听最小化窗口
this.stage.iconifiedProperty().addListener((observable, oldValue, newValue) -> {
try {
if (newValue) { //最小化
onHide();
} else {
onShow(); //取消最小化
}
} catch (Exception e) {
logger.error(e.getMessage());
e.printStackTrace();
}
});
}
/**
* @description 在加载页面之前的操作
* @version 1.2
*/
public void onLoad() throws Exception {
}
/**
* @description 在显示页面之前的操作
* @version 1.2
*/
public void onShow() throws Exception {
}
/**
* @description 在关闭窗口之前的操作
* @version 1.2
*/
public void onClose() throws Exception {
}
/**
* @description 在隐藏窗口之前的操作
* @version 1.2
*/
public void onHide() throws Exception {
}
/**
@@ -77,17 +178,36 @@ public class FXBaseController extends Pane {
}
}
public void showAndWait() {
if (isWindow) {
this.stage.showAndWait();
}
}
/**
* 关闭舞台
*/
public void closeStage() {
if (isWindow) {
this.stage.close();
}
}
/**
* @description 最小化
* @version 1.2
*/
public void hideStage() {
if (isWindow) {
this.stage.setIconified(true);
}
}
public String getName() {
if ("".equals(name) || name == null) { // 原本无“name == null”判断条件会出错
return StringUtils.getBaseClassName(getClass().getSimpleName());
return StringUtil.getBaseClassName(getClass().getSimpleName());
} else {
return StringUtils.getBaseClassName(getClass().getSimpleName()) + "#" + name;
return StringUtil.getBaseClassName(getClass().getSimpleName()) + "#" + name;
}
}
@@ -119,4 +239,19 @@ public class FXBaseController extends Pane {
this.stage = stage;
}
public Map<String, Object> getQuery() {
return query;
}
public Map<String, Object> getParam() {
return param;
}
public void setQuery(Map<String, Object> query) {
this.query = query;
}
public void setParam(Map<String, Object> param) {
this.param = param;
}
}

View File

@@ -5,16 +5,26 @@ import javafx.beans.property.Property;
/**
* 将Controller中的JavaFX的field包装成FXFieldWrapper
* @Author jack
* @Date:2019/6/28 10:03
*
* @author jack
* @version 1.0
* @date 2019/6/28 10:03
* @since JavaFX2.0 JDK1.8
*/
public class FXFieldWrapper {
private FXField fxField;
private Class type;
private Property property;
private Class type;
public FXFieldWrapper() {
}
public FXFieldWrapper(FXField fxField, Class type) {
this.fxField = fxField;
this.type = type;
}
public Class getType() {
return type;

View File

@@ -5,8 +5,11 @@ import java.lang.reflect.Method;
/**
* This class is base cn.edu.scau.biubiusuisui.entity for queue message(or signal)
* you mush save the instance and method which means who will run this method
* @Author jack
* @Date:2019/6/26 15:39
*
* @author jack
* @version 1.0
* @date 2019/6/26 15:39
* @since JavaFX2.0 JDK1.8
*/
public class FXMethodEntity {

View File

@@ -12,8 +12,10 @@ import java.util.concurrent.ConcurrentHashMap;
* Context is use for storing Controller
* In addition,you can store an instance into Session to use it everywhere
*
* @Author jack
* @Date:2019/6/26 12:28
* @author jack
* @version 1.0
* @date 2019/6/26 12:28
* @since JavaFX2.0 JDK1.8
*/
public class FXPlusContext {
@@ -25,7 +27,7 @@ public class FXPlusContext {
private static Map<Object, FXEntityProxy> beanMap = new ConcurrentHashMap<>(); // Object注册为FXEntityObject
public static void addController(FXBaseController fxBaseController) {
public static void registerController(FXBaseController fxBaseController) {
List<FXBaseController> controllers = controllerContext.get(fxBaseController.getName());
if (controllers == null) {
controllers = new LinkedList<>();
@@ -33,9 +35,6 @@ public class FXPlusContext {
controllers.add(fxBaseController);
}
public static List<FXBaseController> getControllers(String key) {
return controllerContext.get(key);
}
public static FXEntityProxy getProxyByBeanObject(Object object) {
return beanMap.get(object);
@@ -45,6 +44,10 @@ public class FXPlusContext {
beanMap.put(object, fxEntityProxy);
}
public static List<FXBaseController> getControllers(String key) {
return controllerContext.get(key);
}
public static Property getEntityPropertyByName(Object object, String fieldName) {
return getProxyByBeanObject(object).getPropertyByFieldName(fieldName);
}

View File

@@ -0,0 +1,67 @@
package cn.edu.scau.biubiusuisui.entity;
/**
* @author suisui
* @version 1.2
* @description JavaFX的Locale枚举类型
* @date 2020/5/3 10:47
* @since JDK1.8 JavaFX2.0
*/
public enum FXPlusLocale {
/**
* 不设置
*/
NONE,
/**
* 简体中文
*/
SIMPLIFIED_CHINESE,
/**
* 繁体中文
*/
TRADITIONAL_CHINESE,
/**
* English 英语
*/
ENGLISH,
/**
* American 美语
*/
AMERICAN,
/**
* Le français 法语
*/
FRANCE,
/**
* Deutsch 德语
*/
GERMANY,
/**
* lingua italiana 意大利语
*/
ITALIAN,
/**
* 日本人 日语
*/
JAPANESE,
/**
* 한국어 韩语
*/
KOREAN,
}

View File

@@ -0,0 +1,54 @@
package cn.edu.scau.biubiusuisui.entity;
import java.util.HashMap;
import java.util.Map;
/**
* @author suisui
* @version 1.2
* @description 跳转窗口携带的参数
* @date 2020/4/6 18:06
* @since JavaFX2.0 JDK1.8
*/
public class FXRedirectParam {
private String toController;
private Map<String, Object> query = new HashMap<>();
private Map<String, Object> params = new HashMap<>();
public FXRedirectParam(String toController) {
this.toController = toController;
}
public String getToController() {
return toController;
}
public void setToController(String toController) {
this.toController = toController;
}
public Map<String, Object> getParams() {
return params;
}
public Map<String, Object> getQueryMap() {
return query;
}
public void addParam(String key, Object param) {
this.params.put(key, param);
}
public Object getParam(String key) {
return this.params.get(key);
}
public void addQuery(String key, Object param) {
this.query.put(key, param);
}
public Object getOneQuery(String key) {
return this.query.get(key);
}
}

View File

@@ -1,18 +0,0 @@
package cn.edu.scau.biubiusuisui.example.actionDemo;
import cn.edu.scau.biubiusuisui.annotation.FXScan;
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
import javafx.application.Application;
import javafx.stage.Stage;
/**
* @Author jack
* @Date:2019/7/27 1:43
*/
@FXScan(base = "cn.edu.scau.biubiusuisui.example.actionDemo")
public class Demo extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
FXPlusApplication.start(Demo.class);
}
}

View File

@@ -1,71 +0,0 @@
package cn.edu.scau.biubiusuisui.example.actionDemo;
import cn.edu.scau.biubiusuisui.annotation.FXBind;
import cn.edu.scau.biubiusuisui.annotation.FXController;
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import java.net.URL;
import java.util.ResourceBundle;
/**
* @Author jack
* @Date:2019/7/27 1:43
*/
@FXController(path = "actionDemo/actionDemo.fxml")
@FXWindow(title = "actionDemo", mainStage = true)
public class MainController extends FXBaseController implements Initializable {
@FXML
@FXBind("text=${@toUs(time.text)}")
private Label us;
@FXML
@FXBind("text=${@toJp(time.text)}")
private Label jp;
@FXML
@FXBind("text=${@toUk(time.text)}")
private Label uk;
@FXML
private TextField time;
public String toUs(String value) {
double money = Double.valueOf(value);
double percent = 0.1454;
return String.valueOf(money * percent);
}
public String toJp(String value) {
double money = Double.valueOf(value);
double percent = 15.797;
return String.valueOf(money * percent);
}
public String toUk(String value) {
double money = Double.valueOf(value);
double percent = 0.1174;
return String.valueOf(money * percent);
}
@Override
public void initialize(URL location, ResourceBundle resources) {
time.setText("0");
time.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
if (null == newValue || "".equals(newValue)) {
time.setText("0");
} else if (!newValue.matches("^[0-9]*$")) {
time.setText(oldValue);
}
}
});
}
}

View File

@@ -1,32 +0,0 @@
package cn.edu.scau.biubiusuisui.example.actionDemo;
import cn.edu.scau.biubiusuisui.annotation.FXEntity;
import cn.edu.scau.biubiusuisui.annotation.FXField;
/**
* @Author jack
* @Date:2019/7/27 12:19
*/
@FXEntity
public class User {
@FXField
private String name;
@FXField
private String password;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

View File

@@ -0,0 +1,21 @@
package cn.edu.scau.biubiusuisui.example.bindDemo;
import cn.edu.scau.biubiusuisui.annotation.FXScan;
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
import javafx.application.Application;
import javafx.stage.Stage;
/**
* @author jack
* @author suisui
* @version 1.2
* @date 2020/5/1 1:43
* @since JavaFX2.0 JDK1.8
*/
@FXScan(base = "cn.edu.scau.biubiusuisui.example.bindDemo")
public class BindDemo extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
FXPlusApplication.start(BindDemo.class);
}
}

View File

@@ -0,0 +1,130 @@
package cn.edu.scau.biubiusuisui.example.bindDemo;
import cn.edu.scau.biubiusuisui.annotation.FXBind;
import cn.edu.scau.biubiusuisui.annotation.FXController;
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;
import java.net.URL;
import java.util.ResourceBundle;
/**
* @author jack
* @author suisui
* @version 1.2
* @date 2020/5/1 1:43
* @since JavaFX2.0 JDK1.8
*/
@FXController(path = "fxml/bindDemo/bindDemo.fxml")
@FXWindow(title = "bindDemo", mainStage = true)
// TODO 待完善
public class MainController extends FXBaseController implements Initializable {
// View bind to View
@FXML
@FXBind("text=${inputTF.text}")
private Label inputLabel;
@FXML
private TextField inputTF;
// View bind to a Java Bean
@FXML
private Label usernameLabel;
@FXML
private Label userPswLabel;
@FXML
private Label ageLabel;
@FXML
private Label enableLabel;
@FXML
private TextField usernameTF;
@FXML
private PasswordField pswPF;
@FXML
private TextField ageTF;
@FXML
private ToggleGroup enableButtons;
//
// @FXData
// @FXBind({
// "name=${usernameTF.text}",
// "password=${pswPF.text}",
// "age=${ageTF.text}",
// "isEnable=${enableButtons.getSelectedToggle().getUserData()}"
// })
// private User user = new User();
private UserPropertyEntity user = new UserPropertyEntity();
// View bind to Expression
@FXML
private TextField money;
@FXML
@FXBind("text=${@toUs(money.text)}")
private Label us;
@FXML
@FXBind("text=${@toJp(money.text)}")
private Label jp;
@FXML
@FXBind("text=${@toUk(money.text)}")
private Label uk;
@Override
public void initialize(URL location, ResourceBundle resources) {
money.setText("0");
money.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
if (null == newValue || "".equals(newValue)) {
money.setText("0");
} else if (!newValue.matches("^[0-9]*$")) {
money.setText(oldValue);
}
}
});
}
@FXML
public void clickToShowInfo() {
RadioButton button = (RadioButton) enableButtons.getSelectedToggle();
System.out.println(button.getText());
usernameLabel.setText(user.getName());
userPswLabel.setText(user.getPassword());
ageLabel.setText(Integer.toString(user.getAge()));
enableLabel.setText(Boolean.toString(user.getEnable()));
}
public String toUs(String value) {
double money = Double.valueOf(value);
double percent = 0.1454;
return String.valueOf(money * percent);
}
public String toJp(String value) {
double money = Double.valueOf(value);
double percent = 15.797;
return String.valueOf(money * percent);
}
public String toUk(String value) {
double money = Double.valueOf(value);
double percent = 0.1174;
return String.valueOf(money * percent);
}
}

View File

@@ -0,0 +1,38 @@
package cn.edu.scau.biubiusuisui.example.bindDemo;
/**
* @author suisui
* @version 1.2
* @description 详细信息
* @date 2020/4/6 00:29
* @since JavaFX2.0 JDK1.8
*/
public class Profile {
private String birthday;
private String address;
private String avatar;
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
}

View File

@@ -0,0 +1,88 @@
package cn.edu.scau.biubiusuisui.example.bindDemo;
import cn.edu.scau.biubiusuisui.annotation.FXEntity;
import cn.edu.scau.biubiusuisui.annotation.FXField;
import java.util.List;
/**
* @author suisui
* @version 1.2
* @date 2020/4/5 12:19
* @since JavaFX2.0 JDK1.8
*/
@FXEntity
public class User {
@FXField
private String name;
@FXField
private String password;
@FXField
private Integer age;
@FXField
private List<Double> scores;
@FXField
private Double gpa;//平均分
@FXField
private Profile profile;
@FXField
private boolean isEnable;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public List<Double> getScores() {
return scores;
}
public void addScore(double score) {
this.scores.add(score);
}
public Profile getProfile() {
return profile;
}
public void setProfile(Profile profile) {
this.profile = profile;
}
public boolean isEnable() {
return isEnable;
}
public void setEnable(boolean enable) {
isEnable = enable;
}
public double getGpa() {
double sum = 0;
for (double score : scores) {
sum += score;
}
gpa = sum / scores.size();
return gpa;
}
}

View File

@@ -0,0 +1,105 @@
package cn.edu.scau.biubiusuisui.example.bindDemo;
import javafx.beans.property.*;
import javafx.collections.ObservableList;
/**
* @author suisui
* @version 1.2
* @description User的JavaFXBean
* @date 2020/4/6 14:30
* @since JavaFX2.0 JDK1.8
*/
public class UserPropertyEntity {
private SimpleStringProperty name;
private SimpleStringProperty password;
private SimpleIntegerProperty age;
private SimpleListProperty<Double> scores;
private SimpleDoubleProperty gpa;//平均分
private SimpleObjectProperty<Profile> profile;
private SimpleBooleanProperty enable;
public String getName() {
return name.get();
}
public SimpleStringProperty nameProperty() {
return name;
}
public void setName(String name) {
this.name.set(name);
}
public String getPassword() {
return password.get();
}
public SimpleStringProperty passwordProperty() {
return password;
}
public void setPassword(String password) {
this.password.set(password);
}
public int getAge() {
return age.get();
}
public SimpleIntegerProperty ageProperty() {
return age;
}
public void setAge(int age) {
this.age.set(age);
}
public ObservableList<Double> getScores() {
return scores.get();
}
public SimpleListProperty<Double> scoresProperty() {
return scores;
}
public void setScores(ObservableList<Double> scores) {
this.scores.set(scores);
}
public double getGpa() {
return gpa.get();
}
public SimpleDoubleProperty gpaProperty() {
return gpa;
}
public void setGpa(double gpa) {
this.gpa.set(gpa);
}
public Profile getProfile() {
return profile.get();
}
public SimpleObjectProperty<Profile> profileProperty() {
return profile;
}
public void setProfile(Profile profile) {
this.profile.set(profile);
}
public boolean getEnable() {
return enable.get();
}
public SimpleBooleanProperty enableProperty() {
return enable;
}
public void setEnable(boolean enable) {
this.enable.set(enable);
}
}

View File

@@ -6,15 +6,17 @@ import javafx.application.Application;
import javafx.stage.Stage;
/**
* @author suiyu_yang
* @author jack
* @author suisui
* @version 1.0
* @description 第一个示例
* @date 2020/1/1 23:06
* @email suiyu_yang@163.com
* @since JavaFX2.0 JDK1.8
*/
@FXScan(base = {"cn.edu.scau.biubiusuisui.example.firstDemo"}) //会扫描带FXController和FXEntity的类进行初始化
public class Demo extends Application {
public class FirstDemo extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
FXPlusApplication.start(Demo.class); //其他配置和JavaFX相同这里要调用FXPlusAppcalition的start方法开始FX-plus加强
FXPlusApplication.start(FirstDemo.class); //其他配置和JavaFX相同这里要调用FXPlusAppcalition的start方法开始FX-plus加强
}
}

View File

@@ -16,12 +16,14 @@ import java.net.URL;
import java.util.ResourceBundle;
/**
* @author suiyu_yang
* @description
* @author jack
* @author suisui
* @version 1.0
* @description 示例的主窗口
* @date 2020/1/1 23:06
* @email suiyu_yang@163.com
* @since JavaFX2.0 JDK1.8
*/
@FXController(path = "firstDemo/firstDemo.fxml")
@FXController(path = "fxml/firstDemo/firstDemo.fxml")
@FXWindow(title = "firstDemo", mainStage = true)
public class MainController extends FXBaseController implements Initializable {
@@ -47,7 +49,7 @@ public class MainController extends FXBaseController implements Initializable {
@Override
public void initialize(URL location, ResourceBundle resources) {
student = (Student) FXEntityFactory.wrapFxBean(Student.class); // 从工厂中拿到将JavaBean转换得到的JavaFXBean
student = (Student) FXEntityFactory.wrapFXBean(Student.class); // 从工厂中拿到将JavaBean转换得到的JavaFXBean
Property listProperty = FXPlusContext.getEntityPropertyByName(student, "list");
list.itemsProperty().bind(listProperty);
}

View File

@@ -7,10 +7,11 @@ import java.util.ArrayList;
import java.util.List;
/**
* @author suiyu_yang
* @author suisui
* @version 1.0
* @description
* @date 2020/1/1 23:07
* @email suiyu_yang@163.com
* @since JavaFX2.0 JDK1.8
*/
@FXEntity

View File

@@ -0,0 +1,39 @@
package cn.edu.scau.biubiusuisui.example.languageDemo;
import cn.edu.scau.biubiusuisui.annotation.FXController;
import cn.edu.scau.biubiusuisui.annotation.FXRedirect;
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
import cn.edu.scau.biubiusuisui.entity.FXPlusLocale;
import javafx.fxml.FXML;
/**
* @author suisui
* @description 中文界面
* @date 2020/5/3 16:23
* @since JDK1.8
*/
@FXWindow(mainStage = true, title = "languageDemo")
@FXController(path = "fxml/languageDemo/languageDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
public class ChineseController extends FXBaseController {
@FXML
public void clickToChinese() {
redirect("ChineseController");
}
@FXML
public void clickToEnglish() {
redirect("EnglishController");
}
@FXML
public void clickToKorean() {
redirect("KoreanController");
}
@FXRedirect
public String redirect(String name) {
return name;
}
}

Some files were not shown because too many files have changed in this diff Show More