Search in sources :

Example 1 with Property

use of javafx.beans.property.Property in project Gargoyle by callakrsos.

the class PropertyChangeExam method propertyCopy.

public void propertyCopy(Node from, Node to) throws Exception {
    Method[] fromMethods = from.getClass().getMethods();
    Class<? extends Node> class1 = to.getClass();
    for (Method fromMethod : fromMethods) {
        String methodName = fromMethod.getName();
        if (methodName.endsWith("Property")) {
            Method targetMethod = class1.getMethod(methodName);
            targetMethod.setAccessible(true);
            if (targetMethod != null) {
                Object fromPropertValue = fromMethod.invoke(from);
                Object toPropertValue = targetMethod.invoke(from);
                if (Property.class.isAssignableFrom(fromPropertValue.getClass())) {
                    if (WritableValue.class.isAssignableFrom(fromPropertValue.getClass())) {
                        // System.out.println("Writable : " +
                        // fromPropertValue);
                        // if
                        // (StyleConverter.class.isAssignableFrom(fromPropertValue.getClass()))
                        // {
                        Property fromProp = (Property) fromPropertValue;
                        Property toProp = (Property) toPropertValue;
                        Object value = fromProp.getValue();
                        if (value == null)
                            continue;
                        System.out.println("set value : " + fromProp.getValue());
                        toProp.setValue(fromProp.getValue());
                    }
                // }
                }
            }
        }
    }
}
Also used : Method(java.lang.reflect.Method) Property(javafx.beans.property.Property) DoubleProperty(javafx.beans.property.DoubleProperty) BooleanProperty(javafx.beans.property.BooleanProperty)

Aggregations

Method (java.lang.reflect.Method)1 BooleanProperty (javafx.beans.property.BooleanProperty)1 DoubleProperty (javafx.beans.property.DoubleProperty)1 Property (javafx.beans.property.Property)1