修复了bug,调整了框架中类和函数命名

This commit is contained in:
billkiller
2019-07-28 02:00:14 +08:00
parent c74ea3039f
commit f731b73207
19 changed files with 761 additions and 656 deletions

963
.idea/workspace.xml generated
View File

File diff suppressed because it is too large Load Diff

View File

@@ -18,7 +18,7 @@ public @interface FXWindow {
double minHeight() default 0.0;
boolean resizable() default false;
boolean draggable() default false;
boolean mainStage() default false;
StageStyle style() default StageStyle.DECORATED;
String title () ;
}

View File

@@ -3,7 +3,7 @@ package cn.edu.scau.biubiusuisui.config;
import cn.edu.scau.biubiusuisui.entity.FXBaseController;
import cn.edu.scau.biubiusuisui.expression.data.MyBeanAdapter;
import cn.edu.scau.biubiusuisui.expression.data.MyExpressionValue;
import cn.edu.scau.biubiusuisui.factory.FXFactory;
import cn.edu.scau.biubiusuisui.factory.FXControllerFactory;
import com.sun.javafx.beans.IDProperty;
import com.sun.javafx.fxml.BeanAdapter;
import com.sun.javafx.fxml.LoadListener;
@@ -1001,7 +1001,7 @@ public class FXMLLoaderPlus {
if (value == null) {
try {
if (FXBaseController.class.isAssignableFrom(type)) {
value = FXFactory.getFXController(type, fx_id);
value = FXControllerFactory.getFXController(type, fx_id);
} else {
value = type.newInstance();
}

View File

@@ -4,7 +4,7 @@ import cn.edu.scau.biubiusuisui.annotation.FXScan;
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
import cn.edu.scau.biubiusuisui.factory.BeanBuilder;
import cn.edu.scau.biubiusuisui.factory.FXBuilder;
import cn.edu.scau.biubiusuisui.factory.FXFactory;
import cn.edu.scau.biubiusuisui.factory.FXControllerFactory;
import cn.edu.scau.biubiusuisui.function.FXWindowParser;
import cn.edu.scau.biubiusuisui.utils.ClassUtils;
@@ -61,7 +61,7 @@ public class FXPlusApplication {
private static void loadFXPlusClass(String className,BeanBuilder beanBuilder) throws ClassNotFoundException {
Class clazz = Class.forName(className);
if(clazz.getAnnotation(FXWindow.class)!=null) {
FXFactory.loadFXController(clazz, beanBuilder);
FXControllerFactory.loadMainStage(clazz, beanBuilder);
}
}
}

View File

@@ -4,6 +4,7 @@ import cn.edu.scau.biubiusuisui.annotation.FXController;
import cn.edu.scau.biubiusuisui.config.FXMLLoaderPlus;
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
import cn.edu.scau.biubiusuisui.utils.StringUtils;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
@@ -31,6 +32,7 @@ public class FXBaseController extends Pane {
private Stage stage;
private boolean isController = false;
private boolean isWindows = false;
@@ -107,5 +109,4 @@ public class FXBaseController extends Pane {
this.stage = stage;
}
}

View File

@@ -1,28 +0,0 @@
package cn.edu.scau.biubiusuisui.entity;
/**
* @Author jack
* @Date:2019/6/28 10:03
*/
public class FXFieldPropertyMapping {
private boolean readOnly;
private Class type;
public boolean isReadOnly() {
return readOnly;
}
public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
}
public Class getType() {
return type;
}
public void setType(Class type) {
this.type = type;
}
}

View File

@@ -0,0 +1,42 @@
package cn.edu.scau.biubiusuisui.entity;
import cn.edu.scau.biubiusuisui.annotation.FXField;
import javafx.beans.property.Property;
/**
* @Author jack
* @Date:2019/6/28 10:03
*/
public class FXFieldWarpper {
private FXField fxField;
private Property property;
private Class type;
public Class getType() {
return type;
}
public void setType(Class type) {
this.type = type;
}
public FXField getFxField() {
return fxField;
}
public void setFxField(FXField fxField) {
this.fxField = fxField;
}
public Property getProperty() {
return property;
}
public void setProperty(Property property){
this.property = property;
}
}

View File

@@ -22,17 +22,8 @@ public class FXPlusContext {
private static Map<String, List<FXBaseController>> controllerContext = new ConcurrentHashMap<>(); //FXController控制器注册表
private static Map<Object, FXEntityProxy> beanProxyMap = new ConcurrentHashMap<>(); // Object注册为FXEntityObject
private static Map<Object, FXEntityProxy> beanMap = new ConcurrentHashMap<>(); // Object注册为FXEntityObject
public static Property getEntityPropertyByName(Object object, String fieldName){
FXEntityProxy fxEntityProxy = FXPlusContext.getProxyByBeanObject(object);
if(fxEntityProxy == null){
return null;
}
return fxEntityProxy.getStringPropertyMap().get(fieldName);
}
private static Map<String, Object> session = new ConcurrentHashMap<>();
public static void addController(FXBaseController fxBaseController){
List<FXBaseController> controllers = controllerContext.get(fxBaseController.getName());
@@ -47,33 +38,11 @@ public class FXPlusContext {
}
public static FXEntityProxy getProxyByBeanObject(Object object){
return beanProxyMap.get(object);
return beanMap.get(object);
}
public static void setProxyByBeanObject(Object object,FXEntityProxy fxEntityProxy){
beanProxyMap.put(object,fxEntityProxy);
}
public static Map<Object, FXEntityProxy> getBeanProxyMap() {
return beanProxyMap;
beanMap.put(object,fxEntityProxy);
}
public static void setBeanProxyMap(Map<Object, FXEntityProxy> beanProxyMap) {
FXPlusContext.beanProxyMap = beanProxyMap;
}
public static Map<String, List<FXBaseController>> getControllerContext() {
return controllerContext;
}
public static void setControllerContext(Map<String, List<FXBaseController>> controllerContext) {
FXPlusContext.controllerContext = controllerContext;
}
public static Map<String, Object> getSession() {
return session;
}
public static void setSession(Map<String, Object> session) {
FXPlusContext.session = session;
}
}

View File

@@ -0,0 +1,18 @@
package cn.edu.scau.biubiusuisui.example.listDemo;
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.listDemo")
public class Demo extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
FXPlusApplication.start(Demo.class);
}
}

View File

@@ -0,0 +1,47 @@
package cn.edu.scau.biubiusuisui.example.listDemo;
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.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TextField;
import java.util.ArrayList;
/**
* @Author jack
* @Date:2019/7/27 1:43
*/
@FXController(path = "listDemo.fxml")
@FXWindow(title = "actionDemo",mainStage = true)
public class MainController extends FXBaseController {
@FXData
User user = new User();
@FXML
@FXBind("items=${@toList(user.names)}")
private ListView<String> list;
public ObservableList hello(){
return FXCollections.observableList(new ArrayList<String>(){{add("hello");}});
}
public ObservableList toList(ArrayList list){
return FXCollections.observableList(list);
}
@FXML
public void addName(){
user.addNames("hello");
}
}

View File

@@ -0,0 +1,57 @@
package cn.edu.scau.biubiusuisui.example.listDemo;
import cn.edu.scau.biubiusuisui.annotation.FXEntity;
import cn.edu.scau.biubiusuisui.annotation.FXField;
import java.util.ArrayList;
/**
* @Author jack
* @Date:2019/7/27 12:19
*/
@FXEntity
public class User {
@FXField
private String name;
@FXField
private String password;
public User() {
names.add("hello ");
names.add("test");
}
public void addNames(String name){
names.add(name);
}
@FXField
private ArrayList<String> names = new ArrayList<>();
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 ArrayList<String> getNames() {
return names;
}
public void setNames(ArrayList<String> names) {
this.names = names;
}
}

View File

@@ -2,6 +2,7 @@ package cn.edu.scau.biubiusuisui.expression.data;
import cn.edu.scau.biubiusuisui.annotation.FXEntity;
import cn.edu.scau.biubiusuisui.entity.FXPlusContext;
import cn.edu.scau.biubiusuisui.utils.BeanUtil;
import com.sun.javafx.fxml.BeanAdapter;
import javafx.beans.value.ObservableValue;
@@ -28,7 +29,7 @@ public class MyBeanAdapter extends BeanAdapter {
if (object.getClass().getAnnotation(FXEntity.class) == null) {
return super.getPropertyModel(key);
} else {
return FXPlusContext.getEntityPropertyByName(object, key);
return BeanUtil.getPropertyByName(object, key);
}
}

View File

@@ -18,6 +18,7 @@ import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.net.URL;
@@ -25,7 +26,7 @@ import java.net.URL;
* @Author jack
* @Date:2019/6/25 8:12
*/
public class FXFactory {
public class FXControllerFactory {
private static final BeanBuilder BEAN_BUILDER = new FXBuilder();
@@ -80,17 +81,16 @@ public class FXFactory {
* @return
*/
private static FXBaseController getFxBaseController(Class clazz, String controllerName, BeanBuilder beanBuilder) {
return getFxBaseController0(clazz, controllerName, beanBuilder);
}
private static FXBaseController getFxBaseController0(Class clazz, String controllerName, BeanBuilder beanBuilder) {
URL fxmlPath;
FXWindow fxWindow = null;
FXController fxController = null; //reflect and get FXController cn.edu.scau.biubiusuisui.annotation
fxController = (FXController) clazz.getDeclaredAnnotation(FXController.class);
fxWindow = (FXWindow) clazz.getDeclaredAnnotation(FXWindow.class);
Pane parent = null;
FXBaseController fxControllerProxy = null;
FXBaseController fxBaseController = null;
FXBaseController fxControllerProxy = null;
if (fxController != null) {
String name = fxController.path();
fxmlPath = clazz.getClassLoader().getResource(name);
@@ -101,23 +101,18 @@ public class FXFactory {
parseData(fxBaseController);
if (fxBaseController != null) {
FXControllerProxy controllerProxy = new FXControllerProxy();
fxControllerProxy = (FXBaseController) controllerProxy.getInstance(fxBaseController); //产生代理从而实现赋能
fxmlLoader.setRoot(fxControllerProxy);
fxmlLoader.setController(fxControllerProxy);
fxmlLoader.setBaseController(fxBaseController);
try {
parent = fxmlLoader.load();
if (controllerName != null) {
fxControllerProxy.setName(controllerName);
fxBaseController.setName(controllerName);
} else {
fxBaseController.setName(parent.getId());
}
ObservableMap namespace = fxmlLoader.getNamespace();
addDataInNameSpace(namespace, fxBaseController);
scanBind(namespace, fxBaseController);
@@ -129,14 +124,10 @@ public class FXFactory {
} else {
return null;
}
//register
if (fxWindow != null) {
createWindow(fxWindow, fxControllerProxy, fxBaseController);
}
return fxControllerProxy;
}
/**
* 将代理对象和目标对象注册
*
@@ -148,32 +139,26 @@ public class FXFactory {
MessageQueue.getInstance().registerCosumer(fxBaseController, fxBaseControllerProxy); // 添加进入消息队列 信号功能
}
private static void createWindow(FXWindow fxWindow, FXBaseController fxControllerProxy, FXBaseController fxBaseController) {
private static Stage createWindow(FXWindow fxWindow, FXBaseController fxControllerProxy) {
Stage stage = new Stage();
fxControllerProxy.setStage(stage);
fxBaseController.setStage(stage);
double preWidth = fxWindow.preWidth() == 0 ? fxControllerProxy.getPrefWidth() : fxWindow.preWidth();
double preHeight = fxWindow.preHeight() == 0 ? fxControllerProxy.getPrefHeight() : fxWindow.preHeight();
Scene scene = new Scene(fxControllerProxy, preWidth, preHeight);
stage.setScene(scene);
windowAnnotationParser.parse(stage, fxControllerProxy, fxWindow);
stage.show();
return stage;
}
private FXFactory() {
private FXControllerFactory() {
}
private static FXBaseController getFxBaseController(Class clazz, String controllerName) {
return null;
}
public static void loadFXController(Class clazz, BeanBuilder beanBuilder) {
if (clazz.getDeclaredAnnotation(FXWindow.class) != null) {
getFXController(clazz, null, beanBuilder);
public static void loadMainStage(Class clazz, BeanBuilder beanBuilder) {
FXWindow declaredAnnotation = (FXWindow) clazz.getDeclaredAnnotation(FXWindow.class);
if ( declaredAnnotation != null && declaredAnnotation.mainStage() == true ) {
getFXWindow(clazz, null, beanBuilder);
}
}
@@ -194,7 +179,43 @@ public class FXFactory {
FXBaseController fxBaseController = getFxBaseController(clazz, controllerName, beanBuilder);
return fxBaseController;
}
public static Stage getFXWindow(Class clazz){
FXWindow fxWindow = (FXWindow) clazz.getDeclaredAnnotation(FXWindow.class);
if(fxWindow !=null){
FXBaseController fxController = getFXController(clazz, null, BEAN_BUILDER);
return createWindow(fxWindow, fxController);
}else{
return null;
}
}
public static Stage getFXWindow(Class clazz, BeanBuilder beanBuilder) {
FXWindow fxWindow = (FXWindow) clazz.getDeclaredAnnotation(FXWindow.class);
if(fxWindow !=null){
FXBaseController fxController = getFXController(clazz, null, beanBuilder);
return createWindow(fxWindow, fxController);
}else{
return null;
}
}
public static Stage getFXWindow(Class clazz, String controllerName) {
FXWindow fxWindow = (FXWindow) clazz.getDeclaredAnnotation(FXWindow.class);
if(fxWindow !=null){
FXBaseController fxController = getFXController(clazz, controllerName, BEAN_BUILDER);
return createWindow(fxWindow, fxController);
}else{
return null;
}
}
public static Stage getFXWindow(Class clazz, String controllerName, BeanBuilder beanBuilder){
FXWindow fxWindow = (FXWindow) clazz.getDeclaredAnnotation(FXWindow.class);
if(fxWindow !=null){
FXBaseController fxController = getFXController(clazz, controllerName, beanBuilder);
return createWindow(fxWindow, fxController);
}else{
return null;
}
}
private static void parseData(Object object) {
Class clazz = object.getClass();
Field[] fields = clazz.getDeclaredFields();
@@ -205,7 +226,7 @@ public class FXFactory {
//建立代理
try {
Object fieldValue = field.get(object);
Object objectProxy = FXEntityFactory.createJavaBeanProxy(fieldValue);
Object objectProxy = FXEntityFactory.warpFxBean(fieldValue);
field.set(object, objectProxy);
} catch (IllegalAccessException e) {
e.printStackTrace();
@@ -264,4 +285,12 @@ public class FXFactory {
}
}
}
private boolean isFXWindow(Class clazz){
if(clazz.getDeclaredAnnotation(FXWindow.class)!=null){
return true;
}else{
return false;
}
}
}

View File

@@ -1,7 +1,7 @@
package cn.edu.scau.biubiusuisui.factory;
import cn.edu.scau.biubiusuisui.annotation.FXField;
import cn.edu.scau.biubiusuisui.entity.FXFieldPropertyMapping;
import cn.edu.scau.biubiusuisui.entity.FXFieldWarpper;
import cn.edu.scau.biubiusuisui.entity.FXPlusContext;
import cn.edu.scau.biubiusuisui.proxy.FXEntityProxy;
import cn.edu.scau.biubiusuisui.utils.ClassUtils;
@@ -22,21 +22,21 @@ public class FXEntityFactory {
private FXEntityFactory(){}
public static Object createJavaBeanProxy(Class clazz){
return createJavaBeanProxy(clazz, new FXBuilder());
public static Object warpFxBean(Class clazz){
return warpFxBean(clazz, new FXBuilder());
}
public static Object createJavaBeanProxy(Class clazz,BeanBuilder beanBuilder) {
public static Object warpFxBean(Class clazz, BeanBuilder beanBuilder) {
Object object = null;
object = beanBuilder.getBean(clazz);
if(object !=null){
return createJavaBeanProxy(object);
return warpFxBean(object);
}else {
return null;
}
}
public static Object createJavaBeanProxy(Object object){
public static Object warpFxBean(Object object){
FXEntityProxy fxEntityProxy = new FXEntityProxy();
Object objectProxy = null;
try {
@@ -49,10 +49,8 @@ public class FXEntityFactory {
return objectProxy;
}
public static void processFXEntityProxy(Object entity, Object proxy,FXEntityProxy fxEntityProxy) throws IllegalAccessException {
Map<String, Property> stringPropertyMap = new HashMap<>();
Map<String, FXFieldPropertyMapping> fxFieldPropertyMappingHashMap = new HashMap<>();
private static void processFXEntityProxy(Object entity, Object proxy,FXEntityProxy fxEntityProxy) throws IllegalAccessException {
Map<String, FXFieldWarpper> fxFieldWarpperMap = new HashMap<>();
Field []fields = entity.getClass().getDeclaredFields();
for(Field field:fields){
Annotation annotation = ClassUtils.getAnnotationInList( FXField.class,field.getDeclaredAnnotations());
@@ -60,14 +58,9 @@ public class FXEntityFactory {
Property property = null;
field.setAccessible(true);
FXField fxField = (FXField)annotation;
FXFieldPropertyMapping fieldPropertyMapping = new FXFieldPropertyMapping();
fieldPropertyMapping.setReadOnly(fxField.readOnly());
fieldPropertyMapping.setType(field.getType());
fxFieldPropertyMappingHashMap.put(field.getName(), fieldPropertyMapping);
FXFieldWarpper fieldWarpper = new FXFieldWarpper();
fieldWarpper.setFxField(fxField);
fieldWarpper.setType(field.getType());
if(field.get(entity) == null){
property = getFieldDefalutProperty(field);
@@ -75,10 +68,9 @@ public class FXEntityFactory {
property = getFieldProperty(entity, field);
}
if(property !=null) {
//添加时间;
property.addListener((object,oldVal,newVal)->{
if(!fxField.readOnly()) {
if(!field.getType().equals(List.class)) {
if(!List.class.isAssignableFrom(field.getType())) {
try {
field.set(proxy, newVal);
} catch (IllegalAccessException e) {
@@ -87,12 +79,12 @@ public class FXEntityFactory {
}
}
});
stringPropertyMap.put(field.getName(), property);
}
fieldWarpper.setProperty(property);
fxFieldWarpperMap.put(field.getName(), fieldWarpper);
}
}
fxEntityProxy.setStringPropertyMap(stringPropertyMap);
fxEntityProxy.setFxFieldPropertyMappingMap(fxFieldPropertyMappingHashMap);
fxEntityProxy.setFxFieldWarpperMap(fxFieldWarpperMap);
}
@@ -115,9 +107,9 @@ public class FXEntityFactory {
property = new SimpleLongProperty((Long) value);
}else if(String.class.equals(type)){
property = new SimpleStringProperty((String) value);
}else if(List.class.equals(type)){
}else if(List.class.isAssignableFrom(type)){
property = new SimpleListProperty(FXCollections.observableList((List)value));
}else if(Object.class.equals(type)){
}else if(Object.class.isAssignableFrom(type)){
property = new SimpleObjectProperty(value);
}
return property;
@@ -137,12 +129,14 @@ public class FXEntityFactory {
property = new SimpleLongProperty();
}else if(String.class.equals(type)){
property = new SimpleStringProperty();
}else if(List.class.equals(type)){
}else if(List.class.isAssignableFrom(type)){
property = new SimpleListProperty();
}else if(Object.class.equals(type)){
}else if(Object.class.isAssignableFrom(type)){
property = new SimpleObjectProperty();
}
return property;
}
}

View File

@@ -59,7 +59,6 @@ public class MessageQueue {
for (FXMethodEntity fxMethodEntity : lists) {
Method method = fxMethodEntity.getMethod();
method.setAccessible(true);
FXBaseController fxBaseController = fxMethodEntity.getFxBaseController();
if (method.getParameterCount() == 0) {
try {

View File

@@ -1,6 +1,6 @@
package cn.edu.scau.biubiusuisui.proxy;
import cn.edu.scau.biubiusuisui.entity.FXFieldPropertyMapping;
import cn.edu.scau.biubiusuisui.entity.FXFieldWarpper;
import cn.edu.scau.biubiusuisui.utils.StringUtils;
import javafx.beans.property.*;
import net.sf.cglib.proxy.Enhancer;
@@ -17,9 +17,7 @@ import java.util.Map;
public class FXEntityProxy implements MethodInterceptor {
Object target;
private Map<String, Property> stringPropertyMap;
private Map<String, FXFieldPropertyMapping> fxFieldPropertyMappingMap;
private Map<String, FXFieldWarpper> fxFieldWarpperMap;
public Object getInstance(Object target) {
this.target = target;
@@ -41,7 +39,6 @@ public class FXEntityProxy implements MethodInterceptor {
*/
@Override
public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
Object o1 = methodProxy.invokeSuper(o, objects);
String methodName = method.getName();
String fieldName = null;
@@ -50,12 +47,12 @@ public class FXEntityProxy implements MethodInterceptor {
} else {
return o1;
}
FXFieldPropertyMapping fxFieldPropertyMapping = fxFieldPropertyMappingMap.get(fieldName);
Property property = stringPropertyMap.get(fieldName);
if(fxFieldPropertyMapping == null || property == null){
FXFieldWarpper fxFieldWarpper = fxFieldWarpperMap.get(fieldName);
Property property = getPropertyByFieldName(fieldName);
if(fxFieldWarpper == null || property == null){
return o1;
}
Class type = fxFieldPropertyMapping.getType();
Class type = fxFieldWarpper.getType();
if (methodName.startsWith("set")) {
if(Boolean.class.equals(type) || boolean.class.equals(type)){
((SimpleBooleanProperty)property).set((Boolean)objects[0]);
@@ -77,8 +74,6 @@ public class FXEntityProxy implements MethodInterceptor {
}else if(methodName.startsWith("cls")){
((SimpleListProperty)(property)).clear();
}
//修改
return o1;
}
@@ -91,22 +86,17 @@ public class FXEntityProxy implements MethodInterceptor {
}
public Property getPropertyByFieldName(String name) {
return stringPropertyMap.get(name);
if(fxFieldWarpperMap.get(name) ==null){
return null;
}
return fxFieldWarpperMap.get(name).getProperty() ;
}
public Map<String, Property> getStringPropertyMap() {
return stringPropertyMap;
public Map<String, FXFieldWarpper> getFxFieldWarpperMap() {
return fxFieldWarpperMap;
}
public void setStringPropertyMap(Map<String, Property> stringPropertyMap) {
this.stringPropertyMap = stringPropertyMap;
}
public Map<String, FXFieldPropertyMapping> getFxFieldPropertyMappingMap() {
return fxFieldPropertyMappingMap;
}
public void setFxFieldPropertyMappingMap(Map<String, FXFieldPropertyMapping> fxFieldPropertyMappingMap) {
this.fxFieldPropertyMappingMap = fxFieldPropertyMappingMap;
public void setFxFieldWarpperMap(Map<String, FXFieldWarpper> fxFieldWarpperMap) {
this.fxFieldWarpperMap = fxFieldWarpperMap;
}
}

View File

@@ -0,0 +1,19 @@
package cn.edu.scau.biubiusuisui.utils;
import cn.edu.scau.biubiusuisui.entity.FXPlusContext;
import cn.edu.scau.biubiusuisui.proxy.FXEntityProxy;
import javafx.beans.property.Property;
/**
* @Author jack
* @Date:2019/7/28 1:52
*/
public class BeanUtil {
public static Property getPropertyByName(Object entity, String fieldName){
FXEntityProxy fxEntityProxy = FXPlusContext.getProxyByBeanObject(entity);
if(fxEntityProxy == null){
return null;
}
return fxEntityProxy.getFxFieldWarpperMap().get(fieldName).getProperty();
}
}

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.layout.Pane?>
<fx:root prefHeight="600.0" prefWidth="800.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.listDemo.MainController">
<children>
<ListView fx:id="list" layoutX="32.0" layoutY="62.0" prefHeight="489.0" prefWidth="728.0" />
<Button layoutX="691.0" layoutY="564.0" mnemonicParsing="false" onAction="#addName" text="Button" />
</children>
</fx:root>

View File

@@ -34,7 +34,7 @@ public class FXEntityFactoryTest {
@Test
public void createJavaBeanProxy2() throws InstantiationException, IllegalAccessException {
// Student student1 = (Student) FXEntityFactory.createJavaBeanProxy(Student.class);
// Student student1 = (Student) FXEntityFactory.warpFxBean(Student.class);
// System.out.println(student1);
// FXPlusContext.getProxyByBeanObject(student1).getStringPropertyMap().forEach((k, v)->{
// System.out.println("k " +k +"v" + v);