< prev index next >

modules/javafx.base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanIntegerProperty.java

Print this page
rev 10445 : [mq]: doc-v1-8177566-trampoline


  27 
  28 import com.sun.javafx.property.MethodHelper;
  29 import com.sun.javafx.property.adapter.Disposer;
  30 import com.sun.javafx.property.adapter.ReadOnlyPropertyDescriptor;
  31 import javafx.beans.property.ReadOnlyIntegerPropertyBase;
  32 
  33 import java.lang.reflect.InvocationTargetException;
  34 import java.lang.reflect.UndeclaredThrowableException;
  35 
  36 import java.security.AccessController;
  37 import java.security.AccessControlContext;
  38 import java.security.PrivilegedAction;
  39 
  40 /**
  41  * A {@code ReadOnlyJavaBeanIntegerProperty} provides an adapter between a regular
  42  * read only Java Bean property of type {@code int} or {@code Integer} and a JavaFX
  43  * {@code ReadOnlyIntegerProperty}. It cannot be created directly, but a
  44  * {@link ReadOnlyJavaBeanIntegerPropertyBuilder} has to be used.
  45  * <p>
  46  * As a minimum, the Java Bean class must implement a getter for the
  47  * property. If the getter of an instance of this class is called, the property of


  48  * the Java Bean is returned. If the Java Bean property is bound (i.e. it supports
  49  * PropertyChangeListeners), this {@code ReadOnlyJavaBeanIntegerProperty} will be
  50  * aware of changes in the Java Bean. Otherwise it can be notified about
  51  * changes by calling {@link #fireValueChangedEvent()}.
  52  * </p>

  53  * <p>
  54  * The Java Bean class must be declared public. If that class is in a named
  55  * module, then the module must {@link Module#isOpen(String,Module) open}
  56  * the containing package to at least the {@code javafx.base} module
  57  * (or {@link Module#isExported(String) export} the containing package
  58  * unconditionally).















  59  * </p>
  60  *
  61  * @see javafx.beans.property.ReadOnlyIntegerProperty
  62  * @see ReadOnlyJavaBeanIntegerPropertyBuilder
  63  * @since JavaFX 2.1
  64  */
  65 public final class ReadOnlyJavaBeanIntegerProperty extends ReadOnlyIntegerPropertyBase implements ReadOnlyJavaBeanProperty<Number> {
  66 
  67     private final ReadOnlyPropertyDescriptor descriptor;
  68     private final ReadOnlyPropertyDescriptor.ReadOnlyListener<Number> listener;
  69 
  70     private final AccessControlContext acc = AccessController.getContext();
  71 
  72     ReadOnlyJavaBeanIntegerProperty(ReadOnlyPropertyDescriptor descriptor, Object bean) {
  73         this.descriptor = descriptor;
  74         this.listener = descriptor.new ReadOnlyListener<Number>(bean, this);
  75         descriptor.addListener(listener);
  76         Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
  77     }
  78 




  27 
  28 import com.sun.javafx.property.MethodHelper;
  29 import com.sun.javafx.property.adapter.Disposer;
  30 import com.sun.javafx.property.adapter.ReadOnlyPropertyDescriptor;
  31 import javafx.beans.property.ReadOnlyIntegerPropertyBase;
  32 
  33 import java.lang.reflect.InvocationTargetException;
  34 import java.lang.reflect.UndeclaredThrowableException;
  35 
  36 import java.security.AccessController;
  37 import java.security.AccessControlContext;
  38 import java.security.PrivilegedAction;
  39 
  40 /**
  41  * A {@code ReadOnlyJavaBeanIntegerProperty} provides an adapter between a regular
  42  * read only Java Bean property of type {@code int} or {@code Integer} and a JavaFX
  43  * {@code ReadOnlyIntegerProperty}. It cannot be created directly, but a
  44  * {@link ReadOnlyJavaBeanIntegerPropertyBuilder} has to be used.
  45  * <p>
  46  * As a minimum, the Java Bean class must implement a getter for the
  47  * property.
  48  * The class, as well as the getter method, must be declared public.
  49  * If the getter of an instance of this class is called, the property of
  50  * the Java Bean is returned. If the Java Bean property is bound (i.e. it supports
  51  * PropertyChangeListeners), this {@code ReadOnlyJavaBeanIntegerProperty} will be
  52  * aware of changes in the Java Bean. Otherwise it can be notified about
  53  * changes by calling {@link #fireValueChangedEvent()}.
  54  * </p>
  55  * <p><b>Deploying an Application as a Module</b></p>
  56  * <p>
  57  * If the Java Bean class is in a named module, then it must be reflectively
  58  * accessible to the {@code javafx.base} module.
  59  * A class is reflectively accessible if the module
  60  * {@link Module#isOpen(String,Module) opens} the containing package to at
  61  * least the {@code javafx.base} module.
  62  * </p>
  63  * <p>
  64  * For example, if {@code com.foo.MyBeanClass} is in the {@code foo.app} module,
  65  * the {@code module-info.java} might
  66  * look like this:
  67  * </p>
  68  *
  69 <pre>{@code module foo.app {
  70     opens com.foo to javafx.base;
  71 }}</pre>
  72  *
  73  * <p>
  74  * Alternatively, a class is reflectively accessible if the module
  75  * {@link Module#isExported(String) exports} the containing package
  76  * unconditionally.
  77  * </p>
  78  *
  79  * @see javafx.beans.property.ReadOnlyIntegerProperty
  80  * @see ReadOnlyJavaBeanIntegerPropertyBuilder
  81  * @since JavaFX 2.1
  82  */
  83 public final class ReadOnlyJavaBeanIntegerProperty extends ReadOnlyIntegerPropertyBase implements ReadOnlyJavaBeanProperty<Number> {
  84 
  85     private final ReadOnlyPropertyDescriptor descriptor;
  86     private final ReadOnlyPropertyDescriptor.ReadOnlyListener<Number> listener;
  87 
  88     private final AccessControlContext acc = AccessController.getContext();
  89 
  90     ReadOnlyJavaBeanIntegerProperty(ReadOnlyPropertyDescriptor descriptor, Object bean) {
  91         this.descriptor = descriptor;
  92         this.listener = descriptor.new ReadOnlyListener<Number>(bean, this);
  93         descriptor.addListener(listener);
  94         Disposer.addRecord(this, new DescriptorListenerCleaner(descriptor, listener));
  95     }
  96 


< prev index next >