modules/controls/src/main/java/javafx/scene/control/ListView.java

Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization


  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javafx.scene.control;
  27 
  28 import java.util.ArrayList;
  29 import java.util.Collections;
  30 import java.util.HashMap;
  31 import java.util.List;
  32 

  33 import com.sun.javafx.scene.control.behavior.ListCellBehavior;
  34 import com.sun.javafx.scene.control.skin.TableViewSkinBase;
  35 import javafx.beans.InvalidationListener;
  36 import javafx.beans.Observable;
  37 import javafx.beans.WeakInvalidationListener;
  38 import javafx.beans.property.BooleanProperty;
  39 import javafx.beans.property.DoubleProperty;
  40 import javafx.beans.property.ObjectProperty;
  41 import javafx.beans.property.ObjectPropertyBase;
  42 import javafx.beans.property.ReadOnlyIntegerProperty;
  43 import javafx.beans.property.ReadOnlyIntegerWrapper;
  44 import javafx.beans.property.SimpleBooleanProperty;
  45 import javafx.beans.property.SimpleObjectProperty;
  46 import javafx.beans.value.ChangeListener;
  47 import javafx.beans.value.WeakChangeListener;
  48 import javafx.beans.value.WritableValue;
  49 import javafx.collections.FXCollections;
  50 import javafx.collections.ListChangeListener;
  51 import javafx.collections.ListChangeListener.Change;
  52 import javafx.collections.MapChangeListener;
  53 import javafx.collections.ObservableList;
  54 import javafx.css.StyleableDoubleProperty;
  55 import javafx.event.Event;
  56 import javafx.event.EventHandler;
  57 import javafx.event.EventType;
  58 import javafx.geometry.Orientation;
  59 import javafx.scene.layout.Region;
  60 import javafx.util.Callback;
  61 import javafx.css.StyleableObjectProperty;
  62 import javafx.css.CssMetaData;
  63 
  64 import com.sun.javafx.css.converters.EnumConverter;
  65 
  66 import javafx.collections.WeakListChangeListener;
  67 
  68 import com.sun.javafx.css.converters.SizeConverter;
  69 import com.sun.javafx.scene.control.skin.ListViewSkin;
  70 
  71 import java.lang.ref.WeakReference;
  72 
  73 import javafx.css.PseudoClass;
  74 import javafx.beans.DefaultProperty;
  75 import javafx.css.Styleable;
  76 import javafx.css.StyleableProperty;
  77 import javafx.scene.AccessibleAttribute;
  78 import javafx.scene.AccessibleRole;
  79 import javafx.scene.Node;
  80 
  81 /**
  82  * A ListView displays a horizontal or vertical list of items from which the
  83  * user may select, or with which the user may interact. A ListView is able to
  84  * have its generic type set to represent the type of data in the backing model.
  85  * Doing this has the benefit of making various methods in the ListView, as well
  86  * as the supporting classes (mentioned below), type-safe. In addition, making 
  87  * use of the generic supports substantially simplifies development of applications
  88  * making use of ListView, as all modern IDEs are able to auto-complete far
  89  * more successfully with the additional type information.


 947             };
 948         }
 949         return onScrollTo;
 950     }
 951 
 952     /** {@inheritDoc} */
 953     @Override protected Skin<?> createDefaultSkin() {
 954         return new ListViewSkin<T>(this);
 955     }
 956 
 957     /**
 958      * Calling {@code refresh()} forces the ListView control to recreate and
 959      * repopulate the cells necessary to populate the visual bounds of the control.
 960      * In other words, this forces the ListView to update what it is showing to
 961      * the user. This is useful in cases where the underlying data source has
 962      * changed in a way that is not observed by the ListView itself.
 963      *
 964      * @since JavaFX 8u60
 965      */
 966     public void refresh() {
 967         getProperties().put(ListViewSkin.RECREATE, Boolean.TRUE);
 968     }
 969 
 970 
 971     
 972     /***************************************************************************
 973      *                                                                         *
 974      * Private Implementation                                                  *
 975      *                                                                         *
 976      **************************************************************************/  
 977 
 978 
 979 
 980     /***************************************************************************
 981      *                                                                         *
 982      * Stylesheet Handling                                                     *
 983      *                                                                         *
 984      **************************************************************************/
 985 
 986     private static final String DEFAULT_STYLE_CLASS = "list-view";
 987 




  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javafx.scene.control;
  27 
  28 import java.util.ArrayList;
  29 import java.util.Collections;
  30 import java.util.HashMap;
  31 import java.util.List;
  32 
  33 import com.sun.javafx.scene.control.Properties;
  34 import com.sun.javafx.scene.control.behavior.ListCellBehavior;

  35 import javafx.beans.InvalidationListener;
  36 import javafx.beans.Observable;
  37 import javafx.beans.WeakInvalidationListener;
  38 import javafx.beans.property.BooleanProperty;
  39 import javafx.beans.property.DoubleProperty;
  40 import javafx.beans.property.ObjectProperty;
  41 import javafx.beans.property.ObjectPropertyBase;
  42 import javafx.beans.property.ReadOnlyIntegerProperty;
  43 import javafx.beans.property.ReadOnlyIntegerWrapper;
  44 import javafx.beans.property.SimpleBooleanProperty;
  45 import javafx.beans.property.SimpleObjectProperty;


  46 import javafx.beans.value.WritableValue;
  47 import javafx.collections.FXCollections;
  48 import javafx.collections.ListChangeListener;
  49 import javafx.collections.ListChangeListener.Change;
  50 import javafx.collections.MapChangeListener;
  51 import javafx.collections.ObservableList;
  52 import javafx.css.StyleableDoubleProperty;
  53 import javafx.event.Event;
  54 import javafx.event.EventHandler;
  55 import javafx.event.EventType;
  56 import javafx.geometry.Orientation;
  57 import javafx.scene.layout.Region;
  58 import javafx.util.Callback;
  59 import javafx.css.StyleableObjectProperty;
  60 import javafx.css.CssMetaData;
  61 
  62 import javafx.css.converter.EnumConverter;
  63 
  64 import javafx.collections.WeakListChangeListener;
  65 
  66 import javafx.css.converter.SizeConverter;
  67 import javafx.scene.control.skin.ListViewSkin;
  68 
  69 import java.lang.ref.WeakReference;
  70 
  71 import javafx.css.PseudoClass;
  72 import javafx.beans.DefaultProperty;
  73 import javafx.css.Styleable;
  74 import javafx.css.StyleableProperty;
  75 import javafx.scene.AccessibleAttribute;
  76 import javafx.scene.AccessibleRole;
  77 import javafx.scene.Node;
  78 
  79 /**
  80  * A ListView displays a horizontal or vertical list of items from which the
  81  * user may select, or with which the user may interact. A ListView is able to
  82  * have its generic type set to represent the type of data in the backing model.
  83  * Doing this has the benefit of making various methods in the ListView, as well
  84  * as the supporting classes (mentioned below), type-safe. In addition, making 
  85  * use of the generic supports substantially simplifies development of applications
  86  * making use of ListView, as all modern IDEs are able to auto-complete far
  87  * more successfully with the additional type information.


 945             };
 946         }
 947         return onScrollTo;
 948     }
 949 
 950     /** {@inheritDoc} */
 951     @Override protected Skin<?> createDefaultSkin() {
 952         return new ListViewSkin<T>(this);
 953     }
 954 
 955     /**
 956      * Calling {@code refresh()} forces the ListView control to recreate and
 957      * repopulate the cells necessary to populate the visual bounds of the control.
 958      * In other words, this forces the ListView to update what it is showing to
 959      * the user. This is useful in cases where the underlying data source has
 960      * changed in a way that is not observed by the ListView itself.
 961      *
 962      * @since JavaFX 8u60
 963      */
 964     public void refresh() {
 965         getProperties().put(Properties.RECREATE, Boolean.TRUE);
 966     }
 967 
 968 
 969     
 970     /***************************************************************************
 971      *                                                                         *
 972      * Private Implementation                                                  *
 973      *                                                                         *
 974      **************************************************************************/  
 975 
 976 
 977 
 978     /***************************************************************************
 979      *                                                                         *
 980      * Stylesheet Handling                                                     *
 981      *                                                                         *
 982      **************************************************************************/
 983 
 984     private static final String DEFAULT_STYLE_CLASS = "list-view";
 985