Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6189b1bf9 | ||
|
|
d139cbe3c5 | ||
|
|
5b7131febf | ||
|
|
a82844cf35 | ||
|
|
b48325cd63 | ||
|
|
7c807d4b39 | ||
|
|
119436dc3b | ||
|
|
5e60991bda | ||
|
|
5f9150b0f6 | ||
|
|
9a04efd84f | ||
|
|
d23cda4f47 | ||
|
|
54dc098123 | ||
|
|
3147d9f9b7 | ||
|
|
4e968bcd08 |
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.idea
|
||||
@@ -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>
|
||||
1325
README.en.md
|
After Width: | Height: | Size: 159 KiB |
|
After Width: | Height: | Size: 147 KiB |
|
Before Width: | Height: | Size: 451 KiB After Width: | Height: | Size: 451 KiB |
BIN
README.en/JavaFX-Plus_en.png
Normal file
|
After Width: | Height: | Size: 531 KiB |
BIN
README.en/Resizable_en.gif
Normal file
|
After Width: | Height: | Size: 5.1 MiB |
|
Before Width: | Height: | Size: 14 MiB After Width: | Height: | Size: 14 MiB |
BIN
README.en/bindhow.gif
Normal file
|
After Width: | Height: | Size: 175 KiB |
BIN
README.en/controllerConfig.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
README.en/demo1.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
README.en/draggable_en.gif
Normal file
|
After Width: | Height: | Size: 4.8 MiB |
BIN
README.en/expression.gif
Normal file
|
After Width: | Height: | Size: 104 KiB |
BIN
README.en/expressionV2V.gif
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
README.en/helloWorldDemo.gif
Normal file
|
After Width: | Height: | Size: 191 KiB |
BIN
README.en/language_demo.gif
Normal file
|
After Width: | Height: | Size: 6.8 MiB |
BIN
README.en/language_demo_en.gif
Normal file
|
After Width: | Height: | Size: 6.8 MiB |
BIN
README.en/lifeDemo/lifeDemo_en.gif
Normal file
|
After Width: | Height: | Size: 12 MiB |
BIN
README.en/lifeDemo/lifeDemo_pkg_en.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
README.en/lifeDemo/life_demo01_en.png
Normal file
|
After Width: | Height: | Size: 193 KiB |
BIN
README.en/lifeDemo/life_demo_en.png
Normal file
|
After Width: | Height: | Size: 69 KiB |
BIN
README.en/log_demo_en.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
README.en/modulesAction.gif
Normal file
|
After Width: | Height: | Size: 512 KiB |
BIN
README.en/moveable.gif
Normal file
|
After Width: | Height: | Size: 977 KiB |
|
Before Width: | Height: | Size: 15 MiB After Width: | Height: | Size: 15 MiB |
|
Before Width: | Height: | Size: 5.9 MiB After Width: | Height: | Size: 5.9 MiB |
|
Before Width: | Height: | Size: 6.5 MiB After Width: | Height: | Size: 6.5 MiB |
BIN
README.en/redirect_with_data_en.gif
Normal file
|
After Width: | Height: | Size: 16 MiB |
BIN
README.en/resizeAble.gif
Normal file
|
After Width: | Height: | Size: 364 KiB |
BIN
README.en/template_en.png
Normal file
|
After Width: | Height: | Size: 526 KiB |
BIN
README.en/template_incude_en.png
Normal file
|
After Width: | Height: | Size: 210 KiB |
BIN
README.en/wrap_JavaBean.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
README/JavaFX-Plus-LifeCycle/JavaFX-Plus-LifeCycle_01.png
Normal file
|
After Width: | Height: | Size: 168 KiB |
BIN
README/JavaFX-Plus-LifeCycle/JavaFX-Plus-LifeCycle_02.png
Normal file
|
After Width: | Height: | Size: 167 KiB |
BIN
README/JavaFX-Plus.png
Normal file
|
After Width: | Height: | Size: 451 KiB |
BIN
README/JavaFX-Plus_en.png
Normal file
|
After Width: | Height: | Size: 531 KiB |
BIN
README/Resizable.gif
Normal file
|
After Width: | Height: | Size: 5.1 MiB |
BIN
README/actionDemo/20191210-175409-actionDemo.gif
Normal file
|
After Width: | Height: | Size: 14 MiB |
BIN
README/bindhow.gif
Normal file
|
After Width: | Height: | Size: 175 KiB |
BIN
README/controllerConfig.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
README/demo1.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
README/draggable.gif
Normal file
|
After Width: | Height: | Size: 4.1 MiB |
BIN
README/expression.gif
Normal file
|
After Width: | Height: | Size: 104 KiB |
BIN
README/expressionV2V.gif
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
README/helloWorldDemo.gif
Normal file
|
After Width: | Height: | Size: 191 KiB |
BIN
README/image-20200407003220469.png
Normal file
|
After Width: | Height: | Size: 1.8 MiB |
BIN
README/language_demo.gif
Normal file
|
After Width: | Height: | Size: 6.8 MiB |
BIN
README/lifeDemo/lifeDemo.gif
Normal file
|
After Width: | Height: | Size: 12 MiB |
BIN
README/lifeDemo/lifeDemo.png
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
README/lifeDemo/lifeDemo_pkg.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
README/lifeDemo/life_demo01.png
Normal file
|
After Width: | Height: | Size: 165 KiB |
BIN
README/log_demo.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
README/modulesAction.gif
Normal file
|
After Width: | Height: | Size: 512 KiB |
BIN
README/moveable.gif
Normal file
|
After Width: | Height: | Size: 977 KiB |
BIN
README/mqDemo/20191208-194336-signalshow.gif
Normal file
|
After Width: | Height: | Size: 15 MiB |
BIN
README/redirectDemo/20191208-125511-not_close.gif
Normal file
|
After Width: | Height: | Size: 5.9 MiB |
BIN
README/redirectDemo/20191208-125739-close.gif
Normal file
|
After Width: | Height: | Size: 6.5 MiB |
BIN
README/redirect_with_data.gif
Normal file
|
After Width: | Height: | Size: 16 MiB |
BIN
README/resizeAble.gif
Normal file
|
After Width: | Height: | Size: 364 KiB |
BIN
README/template.png
Normal file
|
After Width: | Height: | Size: 526 KiB |
BIN
README/template_incude.png
Normal file
|
After Width: | Height: | Size: 210 KiB |
BIN
README/wrap_JavaBean.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
doc/JavaFX-Plus-Introduction.xmind
Normal file
BIN
doc/JavaFX-Plus-Introduction_en.xmind
Normal file
BIN
doc/JavaFX-Plus-LifeCycle.pptx
Normal file
BIN
doc/JavaFX-Plus-LifeCycle_en.pptx
Normal file
37
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<name>javafx-plus</name>
|
||||
|
||||
<groupId>com.gitee.Biubiuyuyu</groupId>
|
||||
<artifactId>javafx-plus</artifactId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<version>1.2.0-RELEASE</version>
|
||||
<!-- packaging为pom时,不会加载resources 故注释-->
|
||||
<!-- <packaging>pom</packaging>-->
|
||||
|
||||
<parent>
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
@@ -30,21 +31,50 @@
|
||||
</distributionManagement>
|
||||
|
||||
<dependencies>
|
||||
<!-- 第三方动态代理库 -->
|
||||
<dependency>
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Junit单元测试 -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<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>
|
||||
<!--配置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>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -52,6 +82,7 @@
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
<compilerArgs>
|
||||
<!-- 过期的方法的警告-->
|
||||
<arg>-Xlint:deprecation</arg>
|
||||
|
||||
@@ -2,10 +2,13 @@ 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
|
||||
public @interface FXBind {
|
||||
String [] value();
|
||||
String[] value();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -11,28 +11,30 @@ 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
|
||||
* public class A{
|
||||
* public void test(){
|
||||
*
|
||||
* }
|
||||
* }
|
||||
* <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(){
|
||||
*
|
||||
* }
|
||||
* }
|
||||
* name will be A.testDemo
|
||||
*
|
||||
* @Author jack
|
||||
* @Date:2019/6/25 13:02
|
||||
* @author jack
|
||||
* @version 1.0
|
||||
* @FXSernder("testDemo") public class A{
|
||||
* public void test(){
|
||||
* <p>
|
||||
* }
|
||||
* }
|
||||
* name will be A.testDemo
|
||||
* @date 2019/6/25 13:02
|
||||
* @since JavaFX2.0 JDK1.8
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface FXSender {
|
||||
String name()default "";
|
||||
String name() default "";
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 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 () ;
|
||||
|
||||
String title();
|
||||
|
||||
/**
|
||||
* @description 图标URL
|
||||
* @version 1.2
|
||||
*/
|
||||
String icon() default "";
|
||||
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1159,7 +1142,7 @@ public class FXMLLoaderPlus {
|
||||
if (fields != null) {
|
||||
try {
|
||||
for (Field f : fields) {
|
||||
if(baseController!=null) {
|
||||
if (baseController != null) {
|
||||
f.set(baseController, value);
|
||||
}
|
||||
f.set(controller, value);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,19 +4,28 @@ 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.exception.ProtocolNotSupport;
|
||||
import cn.edu.scau.biubiusuisui.function.DragWindowHandlerImpl;
|
||||
import cn.edu.scau.biubiusuisui.log.FXPlusLoggerFactory;
|
||||
import cn.edu.scau.biubiusuisui.log.IFXPlusLogger;
|
||||
import cn.edu.scau.biubiusuisui.utils.FileUtil;
|
||||
import cn.edu.scau.biubiusuisui.utils.ResourceBundleUtil;
|
||||
import cn.edu.scau.biubiusuisui.utils.StringUtil;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.File;
|
||||
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
|
||||
* We use MVC model
|
||||
* V means view which stand for fxml
|
||||
@@ -24,70 +33,255 @@ 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 final IFXPlusLogger logger = FXPlusLoggerFactory.getLogger(FXBaseController.class);
|
||||
|
||||
protected String name = "";
|
||||
private Stage stage;
|
||||
private boolean isController = false;
|
||||
private boolean isWindow = false;
|
||||
|
||||
|
||||
/**
|
||||
* <p>description 用于携带信息数据</p>
|
||||
*
|
||||
* @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)) {
|
||||
isWindow = true;
|
||||
fxWindow = (FXWindow) annotation;
|
||||
this.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 {
|
||||
}
|
||||
|
||||
/**
|
||||
* 唤起舞台
|
||||
*/
|
||||
public void showStage() {
|
||||
if (isWindow) {
|
||||
if (this.isWindow) {
|
||||
this.stage.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示并等待
|
||||
*/
|
||||
public void showAndWait() {
|
||||
if (this.isWindow) {
|
||||
this.stage.showAndWait();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭舞台
|
||||
*/
|
||||
public void closeStage() {
|
||||
if (isWindow) {
|
||||
if (this.isWindow) {
|
||||
this.stage.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 最小化
|
||||
* @version 1.2
|
||||
*/
|
||||
public void hideStage() {
|
||||
if (this.isWindow) {
|
||||
this.stage.setIconified(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>description: 开放设置窗口标题 </p>
|
||||
*
|
||||
* @param title 标题
|
||||
* @return true--修改标题成功 false--修改失败
|
||||
* @version 1.3
|
||||
*/
|
||||
public final void setWindowTitle(String title) {
|
||||
if (this.isWindow) {
|
||||
this.stage.setTitle(title);
|
||||
logger.info("setting title of window");
|
||||
} else {
|
||||
logger.warn("the controller is not window");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>description: 开放设置窗口图标</p>
|
||||
*
|
||||
* @param icon String 图标URL地址,需要放在resources文件下或项目根目录下
|
||||
*/
|
||||
public final void setIcon(String icon) {
|
||||
if (this.isWindow) {
|
||||
if (!"".equals(icon)) {
|
||||
try {
|
||||
URL iconUrl = new FileUtil().getFilePathFromResources(icon);
|
||||
if (iconUrl != null) {
|
||||
if (new File(StringUtil.getRootPath(iconUrl)).exists()) {
|
||||
this.stage.getIcons().clear();
|
||||
this.stage.getIcons().add(new Image(icon));
|
||||
} else {
|
||||
logger.warn("the icon file has not existed");
|
||||
}
|
||||
} else {
|
||||
logger.warn("the icon file has not existed");
|
||||
}
|
||||
} catch (ProtocolNotSupport protocolNotSupport) {
|
||||
logger.error(protocolNotSupport.getMessage(), protocolNotSupport);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Description 开放是否允许窗口可拖拽和缩放的接口</p>
|
||||
*
|
||||
* @param draggable 可拖拽
|
||||
* @param resizable 可缩放
|
||||
*/
|
||||
public final void setDragAndResize(boolean draggable, boolean resizable) {
|
||||
this.stage.setResizable(resizable);
|
||||
if (draggable || resizable) {
|
||||
EventHandler dragWindowHandler = new DragWindowHandlerImpl(stage, this, draggable, resizable);
|
||||
this.setOnMousePressed(dragWindowHandler);
|
||||
this.setOnMouseDragged(dragWindowHandler);
|
||||
this.setOnMouseMoved(dragWindowHandler);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Controller名字
|
||||
*
|
||||
* @return name
|
||||
*/
|
||||
public String getName() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,11 +298,11 @@ public class FXBaseController extends Pane {
|
||||
}
|
||||
|
||||
public boolean isWindow() {
|
||||
return isWindow;
|
||||
return this.isWindow;
|
||||
}
|
||||
|
||||
public void setWindow(boolean window) {
|
||||
isWindow = window;
|
||||
this.isWindow = window;
|
||||
}
|
||||
|
||||
public Stage getStage() {
|
||||
@@ -119,4 +313,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -36,7 +46,7 @@ public class FXFieldWrapper {
|
||||
return property;
|
||||
}
|
||||
|
||||
public void setProperty(Property property){
|
||||
public void setProperty(Property property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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加强
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package cn.edu.scau.biubiusuisui.example.langDemo;
|
||||
|
||||
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/langDemo/langDemo.fxml", locale = FXPlusLocale.SIMPLIFIED_CHINESE)
|
||||
public class ChineseController extends FXBaseController {
|
||||
private String title = "languageDemo";
|
||||
private int count = 0;
|
||||
|
||||
@FXML
|
||||
public void clickToChinese() {
|
||||
redirect("ChineseController");
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void clickToEnglish() {
|
||||
redirect("EnglishController");
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void clickToKorean() {
|
||||
redirect("KoreanController");
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试是否setWindowTitle接口
|
||||
*/
|
||||
@FXML
|
||||
public void changeTitleClick() {
|
||||
this.setWindowTitle(this.title + count);
|
||||
count++;
|
||||
}
|
||||
|
||||
@FXRedirect
|
||||
public String redirect(String name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||