支持函数表达式和change表达式
This commit is contained in:
5
.idea/compiler.xml
generated
5
.idea/compiler.xml
generated
@@ -13,4 +13,9 @@
|
||||
<module name="JavaFx-Plus" target="1.8" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="JavaFx-Plus" options="-bootclasspath C:/java/jdk/jre\lib\rt.jar;C:/java/jdk/jre\lib\jce.jar -Xlint:deprecation" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/encodings.xml
generated
Normal file
6
.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
36
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
36
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,36 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="TOP_LEVEL_CLASS_OPTIONS">
|
||||
<value>
|
||||
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||
<option name="REQUIRED_TAGS" value="" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="INNER_CLASS_OPTIONS">
|
||||
<value>
|
||||
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||
<option name="REQUIRED_TAGS" value="" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="METHOD_OPTIONS">
|
||||
<value>
|
||||
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="FIELD_OPTIONS">
|
||||
<value>
|
||||
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||
<option name="REQUIRED_TAGS" value="" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="IGNORE_DEPRECATED" value="false" />
|
||||
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
|
||||
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
|
||||
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
|
||||
<option name="myAdditionalJavadocTags" value="Author" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
@@ -1,13 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: commons-logging:commons-logging:1.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.2/commons-logging-1.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.2/commons-logging-1.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.2/commons-logging-1.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -1,13 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.javassist:javassist:3.21.0-GA">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/javassist/javassist/3.21.0-GA/javassist-3.21.0-GA.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/javassist/javassist/3.21.0-GA/javassist-3.21.0-GA-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/javassist/javassist/3.21.0-GA/javassist-3.21.0-GA-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -1,13 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.springframework:spring-aop:4.3.13.RELEASE">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-aop/4.3.13.RELEASE/spring-aop-4.3.13.RELEASE.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-aop/4.3.13.RELEASE/spring-aop-4.3.13.RELEASE-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-aop/4.3.13.RELEASE/spring-aop-4.3.13.RELEASE-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -1,13 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.springframework:spring-beans:4.3.13.RELEASE">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-beans/4.3.13.RELEASE/spring-beans-4.3.13.RELEASE.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-beans/4.3.13.RELEASE/spring-beans-4.3.13.RELEASE-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-beans/4.3.13.RELEASE/spring-beans-4.3.13.RELEASE-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -1,13 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.springframework:spring-context:4.3.13.RELEASE">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/4.3.13.RELEASE/spring-context-4.3.13.RELEASE.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/4.3.13.RELEASE/spring-context-4.3.13.RELEASE-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/4.3.13.RELEASE/spring-context-4.3.13.RELEASE-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -1,13 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.springframework:spring-core:4.3.13.RELEASE">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-core/4.3.13.RELEASE/spring-core-4.3.13.RELEASE.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-core/4.3.13.RELEASE/spring-core-4.3.13.RELEASE-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-core/4.3.13.RELEASE/spring-core-4.3.13.RELEASE-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -1,13 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.springframework:spring-expression:4.3.13.RELEASE">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-expression/4.3.13.RELEASE/spring-expression-4.3.13.RELEASE.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-expression/4.3.13.RELEASE/spring-expression-4.3.13.RELEASE-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-expression/4.3.13.RELEASE/spring-expression-4.3.13.RELEASE-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
1312
.idea/workspace.xml
generated
1312
.idea/workspace.xml
generated
File diff suppressed because it is too large
Load Diff
@@ -20,12 +20,5 @@
|
||||
<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" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.13.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.13.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.13.RELEASE" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
165
pom.xml
165
pom.xml
@@ -3,13 +3,33 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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>
|
||||
|
||||
<groupId>groupId</groupId>
|
||||
<artifactId>JavaFx-Plus</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
<artifactId>oss-parent</artifactId>
|
||||
<version>7</version>
|
||||
</parent>
|
||||
|
||||
<description>this is javafx framework that simplified coding</description>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>javafx-plus</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>javafx-plus</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib</artifactId>
|
||||
@@ -22,37 +42,112 @@
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
<version>3.21.0-GA</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>4.3.13.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>4.3.13.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<compilerArgs>
|
||||
<!-- 过期的方法的警告-->
|
||||
<arg>-Xlint:deprecation</arg>
|
||||
</compilerArgs>
|
||||
<compilerArguments>
|
||||
<!-- 是否输出所有的编译信息(包括类的加载等)-->
|
||||
<!--<verbose />-->
|
||||
<!-- 解决maven命令编译报错,因为rt.jar 和jce.jar在jre的lib下面,不在jdk的lib下面,
|
||||
导致maven找不到(java7以后会出现这个问题),将这2个jar包拷贝到jdk的lib下面估计也好使-->
|
||||
<bootclasspath>${java.home}\lib\rt.jar;${java.home}\lib\jce.jar</bootclasspath>
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Source -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Javadoc -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<additionalparam>-Xdoclint:none</additionalparam>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- GPG -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GNU Lesser General Public License Version 3</name>
|
||||
<url>http://www.gnu.org/licenses/lgpl.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<tag>master</tag>
|
||||
<url>https://gitee.com/Biubiuyuyu/JavaFX-Plus.git</url>
|
||||
<connection>scm:git:https://gitee.com/Biubiuyuyu/JavaFX-Plus.git</connection>
|
||||
<developerConnection>scm:git:https://gitee.com/Biubiuyuyu/JavaFX-Plus.git</developerConnection>
|
||||
</scm>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Zhu zhanbiao</name>
|
||||
<email>747441355@qq.com</email>
|
||||
<organization>cn.edu.scau</organization>
|
||||
</developer>
|
||||
|
||||
<developer>
|
||||
<name>Yang suiyu</name>
|
||||
<email>498870048@qq.com</email>
|
||||
<organization>cn.edu.scau</organization>
|
||||
</developer>
|
||||
</developers>
|
||||
</project>
|
||||
@@ -2,10 +2,7 @@ package cn.edu.scau.biubiusuisui.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/4 13:58
|
||||
*/
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Inherited
|
||||
|
||||
@@ -4,8 +4,8 @@ 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
|
||||
@Date:2019/6/25 1:34
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.edu.scau.biubiusuisui.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/27 3:06
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Inherited
|
||||
public @interface FXValue {
|
||||
String value();
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package cn.edu.scau.biubiusuisui.config;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
||||
import cn.edu.scau.biubiusuisui.expression.MyBeanAdapter;
|
||||
import cn.edu.scau.biubiusuisui.expression.MyExpressionValue;
|
||||
import cn.edu.scau.biubiusuisui.expression.data.MyBeanAdapter;
|
||||
import cn.edu.scau.biubiusuisui.expression.data.MyExpressionValue;
|
||||
import cn.edu.scau.biubiusuisui.factory.FXFactory;
|
||||
import com.sun.javafx.beans.IDProperty;
|
||||
import com.sun.javafx.fxml.BeanAdapter;
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.Set;
|
||||
* @Author jack
|
||||
* @Date:2019/6/25 2:54
|
||||
*/
|
||||
|
||||
public class FXPlusApplication {
|
||||
|
||||
private static FXWindowParser windowAnnotationParser = new FXWindowParser();
|
||||
@@ -62,7 +61,6 @@ public class FXPlusApplication {
|
||||
private static void loadFXPlusClass(String className,BeanBuilder beanBuilder) throws ClassNotFoundException {
|
||||
Class clazz = Class.forName(className);
|
||||
if(clazz.getAnnotation(FXWindow.class)!=null) {
|
||||
System.out.println(className);
|
||||
FXFactory.loadFXController(clazz, beanBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package cn.edu.scau.biubiusuisui.example.moveDemo;
|
||||
package cn.edu.scau.biubiusuisui.example.actionDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXScan;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXSender;
|
||||
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/6/25 7:05
|
||||
* @Date:2019/7/27 1:43
|
||||
*/
|
||||
@FXScan(base = {"cn.edu.scau.biubiusuisui.example.moveDemo"})
|
||||
//项目目录中带有中文字符会导致无法启动
|
||||
@FXScan(base = "cn.edu.scau.biubiusuisui.example.actionDemo")
|
||||
public class Demo extends Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
@@ -0,0 +1,58 @@
|
||||
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.FXData;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
|
||||
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.TextField;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/27 1:43
|
||||
*/
|
||||
@FXController(path = "actionDemo.fxml")
|
||||
@FXWindow(title = "actionDemo")
|
||||
public class MainController extends FXBaseController {
|
||||
|
||||
|
||||
|
||||
@FXML
|
||||
@FXBind("text=${@toUs(time.text)}")
|
||||
private Label us;
|
||||
|
||||
@FXML
|
||||
@FXBind("text=${@toJp(time.text)}")
|
||||
private Label jp;
|
||||
|
||||
@FXML
|
||||
private TextField time;
|
||||
|
||||
@FXML
|
||||
@FXBind("text=${@toUk(time.text)}")
|
||||
private Label uk;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,19 @@
|
||||
package cn.edu.scau.biubiusuisui.example;
|
||||
package cn.edu.scau.biubiusuisui.example.actionDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXEntity;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXField;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/6/27 20:02
|
||||
* @Date:2019/7/27 12:19
|
||||
*/
|
||||
|
||||
@FXEntity
|
||||
@Component
|
||||
public class Student {
|
||||
|
||||
public class User {
|
||||
@FXField
|
||||
private String name;
|
||||
|
||||
@FXField
|
||||
private String password;
|
||||
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package cn.edu.scau.biubiusuisui.example.expressionDemo;
|
||||
|
||||
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/6/25 7:05
|
||||
*/
|
||||
@FXScan(base = {"cn.edu.scau.biubiusuisui.example.expressionDemo"})
|
||||
//项目目录中带有中文字符会导致无法启动
|
||||
public class Demo extends Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
FXPlusApplication.start(Demo.class);
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package cn.edu.scau.biubiusuisui.example.expressionDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXBind;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXData;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
|
||||
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
||||
import cn.edu.scau.biubiusuisui.example.Student;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.stage.StageStyle;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/4 11:36
|
||||
*/
|
||||
@FXController(path = "Main.fxml")
|
||||
@FXWindow(title = "hello", resizable = true, draggable = true)
|
||||
public class Main2 extends FXBaseController {
|
||||
|
||||
@FXData
|
||||
@FXBind(
|
||||
{
|
||||
"name=${usr.text}",
|
||||
"password=${psw.text}"
|
||||
}
|
||||
)
|
||||
Student student = new Student();
|
||||
|
||||
@FXML
|
||||
private PasswordField psw;
|
||||
|
||||
@FXML
|
||||
private Label label;
|
||||
|
||||
@FXML
|
||||
private TextField usr;
|
||||
|
||||
@FXML
|
||||
private Button resetBtn;
|
||||
|
||||
@FXML
|
||||
private Button loginBtn;
|
||||
|
||||
@FXML
|
||||
private Label usrMsg;
|
||||
|
||||
@FXBind("text=${student.name}")
|
||||
@FXML
|
||||
private Label pswMsg;
|
||||
|
||||
@FXML
|
||||
void login(ActionEvent event) {
|
||||
System.out.println("user:" + student.getName());
|
||||
System.out.println("psw:" + student.getPassword());
|
||||
if ("admin".equals(student.getName()) && "admin".equals(student.getPassword())) {
|
||||
System.out.println("Ok");
|
||||
} else {
|
||||
System.out.println("fail");
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
void reset(ActionEvent event) {
|
||||
psw.setText("");
|
||||
usr.setText("");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package cn.edu.scau.biubiusuisui.example.listViewExpressionDemo;
|
||||
|
||||
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/24 22:56
|
||||
*/
|
||||
@FXScan(base = {"cn.edu.scau.biubiusuisui.example.expressionDemo"})
|
||||
//项目目录中带有中文字符会导致无法启动
|
||||
public class Demo extends Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
FXPlusApplication.start(Demo.class);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package cn.edu.scau.biubiusuisui.example.listViewExpressionDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/24 22:58
|
||||
*/
|
||||
public class MainController extends FXBaseController {
|
||||
//待开发
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package cn.edu.scau.biubiusuisui.example.moveDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXEntity;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXField;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/25 9:24
|
||||
*/
|
||||
@FXEntity
|
||||
public class CircleBean {
|
||||
|
||||
@FXField
|
||||
double x = 0;
|
||||
|
||||
@FXField
|
||||
double y = 0;
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CircleBean{" +
|
||||
"x=" + x +
|
||||
", y=" + y +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package cn.edu.scau.biubiusuisui.example.moveDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXBind;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXData;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
|
||||
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
||||
import cn.edu.scau.biubiusuisui.example.Student;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.shape.Circle;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/4 11:36
|
||||
*/
|
||||
@FXController(path = "moveDemo.fxml")
|
||||
@FXWindow(title = "hello", resizable = true, draggable = true)
|
||||
public class Main2 extends FXBaseController {
|
||||
|
||||
@FXML
|
||||
@FXBind({"layoutX=${bean.x}","layoutY=${bean.y}"})
|
||||
private Circle circle;
|
||||
|
||||
@FXData
|
||||
CircleBean bean = new CircleBean();
|
||||
|
||||
@FXML
|
||||
@FXBind("text=${bean.x}")
|
||||
private TextField xinput;
|
||||
|
||||
@FXML
|
||||
@FXBind("text=${bean.y}")
|
||||
private TextField yinput;
|
||||
|
||||
@FXML
|
||||
private Button xSub;
|
||||
|
||||
@FXML
|
||||
private Button xAdd;
|
||||
|
||||
@FXML
|
||||
private Button ySub;
|
||||
|
||||
@FXML
|
||||
private Button yAdd;
|
||||
@FXML
|
||||
public void addX(){
|
||||
double x = bean.getX() + 5 ;
|
||||
bean.setX(x);
|
||||
System.out.println("? ? " + bean);
|
||||
}
|
||||
@FXML
|
||||
public void subX(){
|
||||
double x = bean.getX() - 5 ;
|
||||
bean.setX(x);
|
||||
}
|
||||
@FXML
|
||||
public void addY(){
|
||||
double y = bean.getY() + 5 ;
|
||||
bean.setY(y);
|
||||
}
|
||||
@FXML
|
||||
public void subY(){
|
||||
double y = bean.getY() - 5 ;
|
||||
bean.setY(y);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package cn.edu.scau.biubiusuisui.example.springDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
|
||||
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
||||
import cn.edu.scau.biubiusuisui.entity.FXPlusContext;
|
||||
import cn.edu.scau.biubiusuisui.example.Student;
|
||||
import cn.edu.scau.biubiusuisui.factory.FXEntityFactory;
|
||||
import cn.edu.scau.biubiusuisui.factory.FXFactory;
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.stage.StageStyle;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/4 11:36
|
||||
*/
|
||||
@FXController(path = "springDemo.fxml")
|
||||
//@Component
|
||||
//@FXWindow(title = "hello",resizable = true,style = StageStyle.UNDECORATED)
|
||||
public class SpringController extends FXBaseController {
|
||||
|
||||
@Autowired
|
||||
Student student;
|
||||
|
||||
@Autowired
|
||||
Student studentProxy;
|
||||
|
||||
@FXML
|
||||
Label label;
|
||||
|
||||
int count = 1;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
System.out.println("為什麼");
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void add(){
|
||||
System.out.println("add");
|
||||
}
|
||||
|
||||
public Student getStudent() {
|
||||
return student;
|
||||
}
|
||||
|
||||
public void setStudent(Student student) {
|
||||
this.student = student;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package cn.edu.scau.biubiusuisui.example.springDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXScan;
|
||||
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
||||
import cn.edu.scau.biubiusuisui.factory.BeanBuilder;
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.Stage;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/7 10:43
|
||||
*/
|
||||
@FXScan(base = {"cn.edu.scau.biubiusuisui.example.springDemo"})
|
||||
public class SpringDemo extends Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
|
||||
FXPlusApplication.start(SpringDemo.class, new BeanBuilder() {
|
||||
@Override
|
||||
public Object getBean(Class type) {
|
||||
return context.getBean(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package cn.edu.scau.biubiusuisui.example.springDemo2;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
|
||||
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
||||
import cn.edu.scau.biubiusuisui.example.springDemo.SpringController;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.stage.StageStyle;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/4 11:36
|
||||
*/
|
||||
@FXController(path = "springDemo2.fxml")
|
||||
@Component
|
||||
//@FXWindow(title = "hello",resizable = true,style = StageStyle.UNDECORATED)
|
||||
public class SpringController2 extends FXBaseController {
|
||||
|
||||
|
||||
@FXML
|
||||
SpringController springController;
|
||||
|
||||
int count = 1;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void test(){
|
||||
System.out.println("student"+springController.getStudent());
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package cn.edu.scau.biubiusuisui.example.springDemo2;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXScan;
|
||||
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
||||
import cn.edu.scau.biubiusuisui.factory.BeanBuilder;
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.Stage;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/7 10:43
|
||||
*/
|
||||
@FXScan(base = {"cn.edu.scau.biubiusuisui.example.springDemo2"})
|
||||
public class SpringDemo extends Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
|
||||
FXPlusApplication.start(SpringDemo.class, new BeanBuilder() {
|
||||
@Override
|
||||
public Object getBean(Class type) {
|
||||
return context.getBean(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package cn.edu.scau.biubiusuisui.example.springExpressionDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXScan;
|
||||
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
||||
import cn.edu.scau.biubiusuisui.example.springDemo.SpringDemo;
|
||||
import cn.edu.scau.biubiusuisui.factory.BeanBuilder;
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.Stage;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/6/25 7:05
|
||||
*/
|
||||
@FXScan(base = {"cn.edu.scau.biubiusuisui.example.springExpressionDemo"})
|
||||
//项目目录中带有中文字符会导致无法启动
|
||||
public class SpringExpressionDemo extends Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
|
||||
FXPlusApplication.start(SpringExpressionDemo.class, new BeanBuilder() {
|
||||
@Override
|
||||
public Object getBean(Class type) {
|
||||
return context.getBean(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package cn.edu.scau.biubiusuisui.example.springExpressionDemo;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXBind;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXData;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
|
||||
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
||||
import cn.edu.scau.biubiusuisui.example.Student;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.stage.StageStyle;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/4 11:36
|
||||
*/
|
||||
@FXController(path = "SpringExpressionDemo.fxml")
|
||||
@Component
|
||||
@FXWindow(title = "hello", resizable = true, style = StageStyle.UNDECORATED,draggable = true)
|
||||
public class SpringExpressionDemoController extends FXBaseController {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@FXData
|
||||
@Autowired
|
||||
@FXBind(
|
||||
{
|
||||
"name=${usr.text}",
|
||||
"password=${psw.text}"
|
||||
}
|
||||
)
|
||||
Student student;
|
||||
|
||||
|
||||
@FXML
|
||||
private Label label;
|
||||
|
||||
@FXML
|
||||
private TextField usr;
|
||||
|
||||
@FXML
|
||||
private Button resetBtn;
|
||||
|
||||
@FXML
|
||||
private Button loginBtn;
|
||||
|
||||
@FXML
|
||||
private Label usrMsg;
|
||||
|
||||
@FXML
|
||||
private PasswordField psw;
|
||||
|
||||
@FXML
|
||||
private Label pswMsg;
|
||||
|
||||
@FXML
|
||||
void login(ActionEvent event) {
|
||||
System.out.println("user:" + student.getName());
|
||||
System.out.println("psw:"+student.getPassword());
|
||||
if("admin".equals(student.getName())&&"admin".equals(student.getPassword())){
|
||||
System.out.println("Ok");
|
||||
}else{
|
||||
System.out.println("fail");
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
void reset(ActionEvent event) {
|
||||
psw.setText("");
|
||||
usr.setText("");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.edu.scau.biubiusuisui.exception;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/27 3:00
|
||||
*/
|
||||
public class NoSuchChangeMethod extends Exception {
|
||||
|
||||
public NoSuchChangeMethod() {
|
||||
super("No such change method");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.edu.scau.biubiusuisui.expression;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/27 2:02
|
||||
*/
|
||||
public interface BindParser {
|
||||
public void parse(Object target,String expression);
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package cn.edu.scau.biubiusuisui.expression;
|
||||
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.javafx.fxml.expression.Expression;
|
||||
import com.sun.javafx.fxml.expression.ExpressionValue;
|
||||
import javafx.beans.property.Property;
|
||||
|
||||
/**
|
||||
* 将FXBind中表达式建立绑定
|
||||
* 格式如下
|
||||
* 语法如下:
|
||||
* FXBind("S")
|
||||
* S -> left=right
|
||||
* left -> property
|
||||
* right -> ${expression}
|
||||
* expression -> bean.field
|
||||
*
|
||||
* FXBind("text=${bean.field})
|
||||
* textProperty 通过 adapter.getModelProeprty --> textProperty实例
|
||||
* bean 通过namespace 获取,因为bean有FXEntity标签,所以返回包装过后的bean的property
|
||||
* 最后
|
||||
* left.bind(right)
|
||||
*
|
||||
* @Author jack
|
||||
* @Date:2019/7/23 15:05
|
||||
*/
|
||||
public class ExpressionParser {
|
||||
|
||||
private Object namespace;
|
||||
private static final String BIND_PREFIX = "${";
|
||||
private static final String BIND_SUFIX = "}";
|
||||
private static final String PROEPRTY = "Property";
|
||||
|
||||
|
||||
|
||||
public ExpressionParser(Object namespace) {
|
||||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
private Property getLeftProperty(MyBeanAdapter myBeanAdapter, String key) {
|
||||
return (Property) myBeanAdapter.getPropertyModel(key);
|
||||
}
|
||||
|
||||
private MyExpressionValue getRightExpreesion(MyBeanAdapter myBeanAdapter,String key ,String rightExpression) {
|
||||
Expression expression = Expression.valueOf(rightExpression);
|
||||
Class clazz = myBeanAdapter.getType(key);
|
||||
MyExpressionValue myExpressionValue = new MyExpressionValue(namespace, expression, clazz);
|
||||
return myExpressionValue;
|
||||
}
|
||||
|
||||
public void parse(Object object, @NotNull String expression) {
|
||||
//check expression
|
||||
int index = expression.indexOf("=");
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
String[] items = expression.split("=");
|
||||
if (items.length != 2) {
|
||||
return;
|
||||
}
|
||||
String left = items[0];
|
||||
String right = items[1];
|
||||
if (left == null || right == null) {
|
||||
return;
|
||||
}
|
||||
right = right.trim();
|
||||
|
||||
if (right.startsWith(BIND_PREFIX) && right.endsWith(BIND_SUFIX)){
|
||||
int length = right.length();
|
||||
right = right.substring(2,length-1);
|
||||
}
|
||||
MyBeanAdapter myBeanAdapter = new MyBeanAdapter(object);
|
||||
Property leftProperty = getLeftProperty(myBeanAdapter, left);
|
||||
MyExpressionValue rightProperty = getRightExpreesion(myBeanAdapter,left,right);
|
||||
leftProperty.bind(rightProperty);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.edu.scau.biubiusuisui.expression.action;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.expression.BindParser;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/27 2:03
|
||||
*/
|
||||
public class ChangeParser implements BindParser {
|
||||
|
||||
@Override
|
||||
public void parse(Object target, String expression) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.edu.scau.biubiusuisui.expression.data;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/27 20:03
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ExpFunction<T,U,R>{
|
||||
R apply(T t, U u);
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package cn.edu.scau.biubiusuisui.expression.data;
|
||||
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXValue;
|
||||
import cn.edu.scau.biubiusuisui.exception.NoSuchChangeMethod;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.javafx.fxml.expression.Expression;
|
||||
import com.sun.javafx.fxml.expression.VariableExpression;
|
||||
import javafx.beans.property.Property;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
* 将FXBind中表达式建立绑定
|
||||
* 格式如下
|
||||
* 语法如下:
|
||||
* FXBind("S")
|
||||
* S -> left=right
|
||||
* left -> property
|
||||
* right -> ${expression}
|
||||
* expression -> bean.field
|
||||
* <p>
|
||||
* FXBind("text=${bean.field})
|
||||
* textProperty 通过 adapter.getModelProeprty --> textProperty实例
|
||||
* bean 通过namespace 获取,因为bean有FXEntity标签,所以返回包装过后的bean的property
|
||||
* 最后
|
||||
* left.bind(right)
|
||||
*
|
||||
* @Author jack
|
||||
* @Date:2019/7/23 15:05
|
||||
*/
|
||||
public class ExpressionParser {
|
||||
|
||||
private Object namespace;
|
||||
private Object targetController;
|
||||
private static final String BIND_PREFIX = "${";
|
||||
private static final String BIND_SUFIX = "}";
|
||||
private static final String PROEPRTY = "Property";
|
||||
|
||||
public enum ExpressionType {
|
||||
DataExpression,
|
||||
ActionExpression
|
||||
}
|
||||
|
||||
public ExpressionParser(Object namespace, Object targetController) {
|
||||
this.namespace = namespace;
|
||||
this.targetController = targetController;
|
||||
}
|
||||
|
||||
public ExpressionParser(Object namespace) {
|
||||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
private Property getLeftProperty(MyBeanAdapter myBeanAdapter, String key) {
|
||||
return (Property) myBeanAdapter.getPropertyModel(key);
|
||||
}
|
||||
|
||||
private static final String FUNCTION_PREFIX = "@";
|
||||
|
||||
private MyExpressionValue getRightExpreesion(MyBeanAdapter myBeanAdapter, String key, String rightExpression) {
|
||||
Expression expression = null;
|
||||
if (rightExpression.startsWith(FUNCTION_PREFIX)) {
|
||||
expression = getFunctionExpression(rightExpression);
|
||||
} else {
|
||||
expression = Expression.valueOf(rightExpression);
|
||||
}
|
||||
Class clazz = myBeanAdapter.getType(key);
|
||||
MyExpressionValue myExpressionValue = new MyExpressionValue(namespace, expression, clazz);
|
||||
return myExpressionValue;
|
||||
}
|
||||
|
||||
private Expression getFunctionExpression(String rightExpression) {
|
||||
Expression expression = null;
|
||||
int indexLeft = rightExpression.indexOf("(");
|
||||
String methodName = rightExpression.substring(1,indexLeft);
|
||||
int indexRight = rightExpression.indexOf(")");
|
||||
String argString = rightExpression.substring(indexLeft + 1, indexRight);
|
||||
String[] args = null;
|
||||
if(!"".equals(argString.trim())) {
|
||||
args = argString.split(",");
|
||||
}
|
||||
Class clazz = targetController.getClass();
|
||||
Method[] methods = clazz.getMethods();
|
||||
Expression[] expressions = null;
|
||||
if(args!=null) {
|
||||
expressions = new Expression[args.length];
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (!"".equals(args[i].trim())) {
|
||||
expressions[i] = Expression.valueOf(args[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals(methodName)) {
|
||||
expression = new FunctionExpression(method, targetController, expressions);
|
||||
}
|
||||
}
|
||||
return expression;
|
||||
}
|
||||
|
||||
public void parse(Object object, @NotNull String expression) throws NoSuchChangeMethod {
|
||||
//check expression
|
||||
int index = expression.indexOf("=");
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
String[] items = expression.split("=");
|
||||
if (items.length != 2) {
|
||||
return;
|
||||
}
|
||||
String left = items[0];
|
||||
String right = items[1];
|
||||
if (left == null || right == null) {
|
||||
return;
|
||||
}
|
||||
right = right.trim();
|
||||
ExpressionType expressionType;
|
||||
if (right.startsWith(BIND_PREFIX) && right.endsWith(BIND_SUFIX)) {
|
||||
int length = right.length();
|
||||
right = right.substring(2, length - 1);
|
||||
expressionType = ExpressionType.DataExpression;
|
||||
} else {
|
||||
right = right.substring(1); //#changeMethod -> changeMethod
|
||||
expressionType = ExpressionType.ActionExpression;
|
||||
}
|
||||
MyBeanAdapter myBeanAdapter = new MyBeanAdapter(object);
|
||||
Property leftProperty = getLeftProperty(myBeanAdapter, left);
|
||||
switch (expressionType) {
|
||||
case DataExpression:
|
||||
bindDataExpression(left, right, myBeanAdapter, leftProperty);
|
||||
break;
|
||||
case ActionExpression:
|
||||
//
|
||||
bindActionExpression(right, leftProperty);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void bindActionExpression(String right, Property leftProperty) throws NoSuchChangeMethod {
|
||||
Class clazz = targetController.getClass();
|
||||
Method[] methods = clazz.getMethods();
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals(right)) {
|
||||
leftProperty.addListener((observable, oldValue, newValue) -> {
|
||||
try {
|
||||
Object[] objects = getArgs(method, observable, newValue, oldValue);
|
||||
method.invoke(targetController, objects);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void bindDataExpression(String left, String right, MyBeanAdapter myBeanAdapter, Property leftProperty) {
|
||||
MyExpressionValue rightProperty = getRightExpreesion(myBeanAdapter, left, right);
|
||||
leftProperty.bind(rightProperty);
|
||||
}
|
||||
|
||||
public Object[] getArgs(Method method, Object... args) {
|
||||
Parameter[] parameters = method.getParameters();
|
||||
Object[] objects = new Object[parameters.length];
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
FXValue annotation = parameters[i].getAnnotation(FXValue.class);
|
||||
switch (annotation.value()) {
|
||||
case "target":
|
||||
objects[i] = args[0];
|
||||
break;
|
||||
case "newValue":
|
||||
objects[i] = args[1];
|
||||
break;
|
||||
case "oldValue":
|
||||
objects[i] = args[2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return objects;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package cn.edu.scau.biubiusuisui.expression.data;
|
||||
|
||||
import com.sun.javafx.fxml.expression.Expression;
|
||||
import com.sun.javafx.fxml.expression.KeyPath;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/27 20:00
|
||||
*/
|
||||
public class FunctionExpression extends Expression {
|
||||
|
||||
private Method method;
|
||||
private Object target;
|
||||
private Expression []args;
|
||||
|
||||
public FunctionExpression(Method method, Object target, Expression[]expressions) {
|
||||
this.method = method;
|
||||
this.target = target;
|
||||
this.args = expressions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KeyPath> getArguments() {
|
||||
List<KeyPath> list = new ArrayList<>();
|
||||
if(args !=null) {
|
||||
for (Expression expression : args) {
|
||||
list.addAll(expression.getArguments());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluate(Object namespace) {
|
||||
Object result = null;
|
||||
if(args!=null){
|
||||
Object[] values = new Object[args.length];
|
||||
for(int i = 0 ;i<args.length;i++){
|
||||
values[i] = args[i].evaluate(namespace);
|
||||
}
|
||||
try {
|
||||
result = method.invoke(target, values);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}else{
|
||||
try {
|
||||
result = method.invoke(target);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Object namespace, Object value) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefined(Object namespace) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLValue() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void getArguments(List arguments) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.edu.scau.biubiusuisui.expression;
|
||||
package cn.edu.scau.biubiusuisui.expression.data;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXEntity;
|
||||
import cn.edu.scau.biubiusuisui.entity.FXPlusContext;
|
||||
@@ -1,8 +1,7 @@
|
||||
package cn.edu.scau.biubiusuisui.expression;
|
||||
package cn.edu.scau.biubiusuisui.expression.data;
|
||||
|
||||
import com.sun.javafx.fxml.BeanAdapter;
|
||||
import com.sun.javafx.fxml.expression.Expression;
|
||||
import com.sun.javafx.fxml.expression.ExpressionValue;
|
||||
import com.sun.javafx.fxml.expression.KeyPath;
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
@@ -17,10 +16,6 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/24 0:37
|
||||
*/
|
||||
public class MyExpressionValue extends ObservableValueBase<Object> {
|
||||
|
||||
// Monitors a namespace for changes along a key path
|
||||
@@ -7,7 +7,8 @@ import cn.edu.scau.biubiusuisui.annotation.FXWindow;
|
||||
import cn.edu.scau.biubiusuisui.config.FXMLLoaderPlus;
|
||||
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
|
||||
import cn.edu.scau.biubiusuisui.entity.FXPlusContext;
|
||||
import cn.edu.scau.biubiusuisui.expression.ExpressionParser;
|
||||
import cn.edu.scau.biubiusuisui.exception.NoSuchChangeMethod;
|
||||
import cn.edu.scau.biubiusuisui.expression.data.ExpressionParser;
|
||||
import cn.edu.scau.biubiusuisui.function.FXWindowParser;
|
||||
import cn.edu.scau.biubiusuisui.messageQueue.MessageQueue;
|
||||
import cn.edu.scau.biubiusuisui.proxy.FXControllerProxy;
|
||||
@@ -16,7 +17,6 @@ import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
@@ -249,7 +249,7 @@ public class FXFactory {
|
||||
private static void parseBind(ObservableMap namespace, Object object, Field field) {
|
||||
FXBind fxBind = field.getAnnotation(FXBind.class);
|
||||
field.setAccessible(true);
|
||||
ExpressionParser expressionParser = new ExpressionParser(namespace);
|
||||
ExpressionParser expressionParser = new ExpressionParser(namespace,object);
|
||||
if (fxBind != null) {
|
||||
String[] expressions = fxBind.value();
|
||||
try {
|
||||
@@ -259,6 +259,8 @@ public class FXFactory {
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchChangeMethod noSuchChangeMethod) {
|
||||
noSuchChangeMethod.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.edu.scau.biubiusuisui.function;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/27 1:54
|
||||
*/
|
||||
public interface Draggale {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import cn.edu.scau.biubiusuisui.example.MainController?>
|
||||
<?import cn.edu.scau.biubiusuisui.example.actionDemo.MainController?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
|
||||
|
||||
17
src/main/resources/actionDemo.fxml
Normal file
17
src/main/resources/actionDemo.fxml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
|
||||
<fx:root prefHeight="191.0" prefWidth="607.0" type="Pane" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="cn.edu.scau.biubiusuisui.example.actionDemo.MainController">
|
||||
<children>
|
||||
<TextField fx:id="time" layoutX="108.0" layoutY="28.0" prefHeight="28.0" prefWidth="330.0" />
|
||||
<Label fx:id="us" layoutX="108.0" layoutY="75.0" prefHeight="24.0" prefWidth="330.0" text="US:" />
|
||||
<Label fx:id="jp" layoutX="108.0" layoutY="107.0" prefHeight="24.0" prefWidth="330.0" text="JP:" />
|
||||
<Label fx:id="uk" layoutX="108.0" layoutY="142.0" prefHeight="24.0" prefWidth="330.0" text="UK:" />
|
||||
<Label layoutX="67.0" layoutY="77.0" text="US" />
|
||||
<Label layoutX="69.0" layoutY="109.0" text="JP" />
|
||||
<Label layoutX="66.0" layoutY="144.0" text="UK" />
|
||||
</children>
|
||||
</fx:root>
|
||||
@@ -1,14 +1,19 @@
|
||||
import cn.edu.scau.biubiusuisui.example.Student;
|
||||
import cn.edu.scau.biubiusuisui.factory.FXEntityFactory;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/6/25 2:11
|
||||
*/
|
||||
public class MainTest {
|
||||
|
||||
public void testMethod(String a,int b){
|
||||
|
||||
}
|
||||
@Test
|
||||
public void test(){
|
||||
public void test() throws NoSuchMethodException {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +1,13 @@
|
||||
package cn.edu.scau.biubiusuisui.expression;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXEntity;
|
||||
import cn.edu.scau.biubiusuisui.example.Student;
|
||||
import cn.edu.scau.biubiusuisui.factory.FXEntityFactory;
|
||||
import javafx.application.Application;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableMap;
|
||||
import javafx.scene.control.Label;
|
||||
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.stage.Stage;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/24 11:55
|
||||
*/
|
||||
public class ExpressionParserTest extends Application{
|
||||
public class ExpressionParserTest {
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
// test - ok
|
||||
Label label = new Label("text");
|
||||
ObservableMap<String, Object> namespace = FXCollections.observableHashMap();
|
||||
Student student = new Student();
|
||||
Student studentProxy = (Student) FXEntityFactory.createJavaBeanProxy(student);
|
||||
studentProxy.setName("jack");
|
||||
namespace.put("student", studentProxy);
|
||||
ExpressionParser expressionParser = new ExpressionParser(namespace);
|
||||
expressionParser.parse(label,"text=${student.name}");
|
||||
System.out.println(label.textProperty());
|
||||
studentProxy.setName("jack-modified");
|
||||
System.out.println(label.textProperty());
|
||||
System.out.println(label.textProperty().getValue());
|
||||
}
|
||||
|
||||
public void testValueFactory(){
|
||||
new PropertyValueFactory("password");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.edu.scau.biubiusuisui.expression.data;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXValue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/7/27 3:13
|
||||
*/
|
||||
public class ExpressionParserTest {
|
||||
|
||||
private ExpressionParser expressionParser;
|
||||
@Before
|
||||
public void init(){
|
||||
expressionParser = new ExpressionParser(null);
|
||||
}
|
||||
@Test
|
||||
public void parse() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getArgs() throws NoSuchMethodException {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package cn.edu.scau.biubiusuisui.factory;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.entity.FXPlusContext;
|
||||
import cn.edu.scau.biubiusuisui.example.Student;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@@ -36,12 +34,12 @@ public class FXEntityFactoryTest {
|
||||
|
||||
@Test
|
||||
public void createJavaBeanProxy2() throws InstantiationException, IllegalAccessException {
|
||||
Student student1 = (Student) FXEntityFactory.createJavaBeanProxy(Student.class);
|
||||
System.out.println(student1);
|
||||
FXPlusContext.getProxyByBeanObject(student1).getStringPropertyMap().forEach((k, v)->{
|
||||
System.out.println("k " +k +"v" + v);
|
||||
});
|
||||
student1.setName("Jack");
|
||||
// Student student1 = (Student) FXEntityFactory.createJavaBeanProxy(Student.class);
|
||||
// System.out.println(student1);
|
||||
// FXPlusContext.getProxyByBeanObject(student1).getStringPropertyMap().forEach((k, v)->{
|
||||
// System.out.println("k " +k +"v" + v);
|
||||
// });
|
||||
// student1.setName("Jack");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user