31 import com.sun.javafx.property.adapter.PropertyDescriptor;
32 import javafx.beans.InvalidationListener;
33 import javafx.beans.property.LongProperty;
34 import javafx.beans.value.ChangeListener;
35 import javafx.beans.value.ObservableValue;
36
37 import java.lang.reflect.InvocationTargetException;
38 import java.lang.reflect.UndeclaredThrowableException;
39
40 import java.security.AccessControlContext;
41 import java.security.AccessController;
42 import java.security.PrivilegedAction;
43
44 /**
45 * A {@code JavaBeanLongProperty} provides an adapter between a regular
46 * Java Bean property of type {@code long} or {@code Long} and a JavaFX
47 * {@code LongProperty}. It cannot be created directly, but a
48 * {@link JavaBeanLongPropertyBuilder} has to be used.
49 * <p>
50 * As a minimum, the Java Bean class must implement a getter and a setter for the
51 * property. If the getter of an instance of this class is called, the property of
52 * the Java Bean is returned. If the setter is called, the value will be passed
53 * to the Java Bean property. If the Java Bean property is bound (i.e. it supports
54 * PropertyChangeListeners), this {@code JavaBeanLongProperty} will be
55 * aware of changes in the Java Bean. Otherwise it can be notified about
56 * changes by calling {@link #fireValueChangedEvent()}. If the Java Bean property
57 * is also constrained (i.e. it supports VetoableChangeListeners), this
58 * {@code JavaBeanLongProperty} will reject changes, if it is bound to an
59 * {@link javafx.beans.value.ObservableValue ObservableValue<Long>}.
60 * </p>
61 * <p>
62 * The Java Bean class must be declared public. If that class is in a named
63 * module, then the module must {@link Module#isOpen(String,Module) open}
64 * the containing package to at least the {@code javafx.base} module
65 * (or {@link Module#isExported(String) export} the containing package
66 * unconditionally).
67 * </p>
68 *
69 * @see javafx.beans.property.LongProperty
70 * @see JavaBeanLongPropertyBuilder
71 * @since JavaFX 2.1
72 */
73 public final class JavaBeanLongProperty extends LongProperty implements JavaBeanProperty<Number> {
74
75 private final PropertyDescriptor descriptor;
76 private final PropertyDescriptor.Listener<Number> listener;
77
78 private ObservableValue<? extends Number> observable = null;
79 private ExpressionHelper<Number> helper = null;
80
81 private final AccessControlContext acc = AccessController.getContext();
82
83 JavaBeanLongProperty(PropertyDescriptor descriptor, Object bean) {
84 this.descriptor = descriptor;
85 this.listener = descriptor.new Listener<Number>(bean, this);
86 descriptor.addListener(listener);
|
31 import com.sun.javafx.property.adapter.PropertyDescriptor;
32 import javafx.beans.InvalidationListener;
33 import javafx.beans.property.LongProperty;
34 import javafx.beans.value.ChangeListener;
35 import javafx.beans.value.ObservableValue;
36
37 import java.lang.reflect.InvocationTargetException;
38 import java.lang.reflect.UndeclaredThrowableException;
39
40 import java.security.AccessControlContext;
41 import java.security.AccessController;
42 import java.security.PrivilegedAction;
43
44 /**
45 * A {@code JavaBeanLongProperty} provides an adapter between a regular
46 * Java Bean property of type {@code long} or {@code Long} and a JavaFX
47 * {@code LongProperty}. It cannot be created directly, but a
48 * {@link JavaBeanLongPropertyBuilder} has to be used.
49 * <p>
50 * As a minimum, the Java Bean class must implement a getter and a setter for the
51 * property.
52 * The class, as well as the getter and a setter methods, must be declared public.
53 * If the getter of an instance of this class is called, the property of
54 * the Java Bean is returned. If the setter is called, the value will be passed
55 * to the Java Bean property. If the Java Bean property is bound (i.e. it supports
56 * PropertyChangeListeners), this {@code JavaBeanLongProperty} will be
57 * aware of changes in the Java Bean. Otherwise it can be notified about
58 * changes by calling {@link #fireValueChangedEvent()}. If the Java Bean property
59 * is also constrained (i.e. it supports VetoableChangeListeners), this
60 * {@code JavaBeanLongProperty} will reject changes, if it is bound to an
61 * {@link javafx.beans.value.ObservableValue ObservableValue<Long>}.
62 * </p>
63 * <p><b>Deploying an Application as a Module</b></p>
64 * <p>
65 * If the Java Bean class is in a named module, then it must be reflectively
66 * accessible to the {@code javafx.base} module.
67 * A class is reflectively accessible if the module
68 * {@link Module#isOpen(String,Module) opens} the containing package to at
69 * least the {@code javafx.base} module.
70 * </p>
71 * <p>
72 * For example, if {@code com.foo.MyBeanClass} is in the {@code foo.app} module,
73 * the {@code module-info.java} might
74 * look like this:
75 * </p>
76 *
77 <pre>{@code module foo.app {
78 opens com.foo to javafx.base;
79 }}</pre>
80 *
81 * <p>
82 * Alternatively, a class is reflectively accessible if the module
83 * {@link Module#isExported(String) exports} the containing package
84 * unconditionally.
85 * </p>
86 *
87 * @see javafx.beans.property.LongProperty
88 * @see JavaBeanLongPropertyBuilder
89 * @since JavaFX 2.1
90 */
91 public final class JavaBeanLongProperty extends LongProperty implements JavaBeanProperty<Number> {
92
93 private final PropertyDescriptor descriptor;
94 private final PropertyDescriptor.Listener<Number> listener;
95
96 private ObservableValue<? extends Number> observable = null;
97 private ExpressionHelper<Number> helper = null;
98
99 private final AccessControlContext acc = AccessController.getContext();
100
101 JavaBeanLongProperty(PropertyDescriptor descriptor, Object bean) {
102 this.descriptor = descriptor;
103 this.listener = descriptor.new Listener<Number>(bean, this);
104 descriptor.addListener(listener);
|