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

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


   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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 com.sun.javafx.collections.NonIterableChange;
  29 import com.sun.javafx.css.converters.SizeConverter;

  30 import com.sun.javafx.scene.control.behavior.TreeCellBehavior;
  31 import com.sun.javafx.scene.control.skin.ListViewSkin;
  32 import com.sun.javafx.scene.control.skin.TreeViewSkin;
  33 
  34 import javafx.application.Platform;
  35 import javafx.beans.DefaultProperty;
  36 import javafx.beans.property.BooleanProperty;
  37 import javafx.beans.property.DoubleProperty;
  38 import javafx.beans.property.ObjectProperty;
  39 import javafx.beans.property.ObjectPropertyBase;
  40 import javafx.beans.property.ReadOnlyIntegerProperty;
  41 import javafx.beans.property.ReadOnlyIntegerWrapper;
  42 import javafx.beans.property.ReadOnlyObjectProperty;
  43 import javafx.beans.property.ReadOnlyObjectWrapper;
  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.ListChangeListener;
  50 import javafx.css.CssMetaData;
  51 import javafx.css.Styleable;
  52 import javafx.css.StyleableDoubleProperty;


1010         }
1011 
1012         return level;
1013     }
1014 
1015     /** {@inheritDoc} */
1016     @Override protected Skin<?> createDefaultSkin() {
1017         return new TreeViewSkin<T>(this);
1018     }
1019 
1020     /**
1021      * Calling {@code refresh()} forces the TreeView control to recreate and
1022      * repopulate the cells necessary to populate the visual bounds of the control.
1023      * In other words, this forces the TreeView to update what it is showing to
1024      * the user. This is useful in cases where the underlying data source has
1025      * changed in a way that is not observed by the TreeView itself.
1026      *
1027      * @since JavaFX 8u60
1028      */
1029     public void refresh() {
1030         getProperties().put(TreeViewSkin.RECREATE, Boolean.TRUE);
1031     }
1032 
1033 
1034     
1035     /***************************************************************************
1036      *                                                                         *
1037      * Private Implementation                                                  *
1038      *                                                                         *
1039      **************************************************************************/  
1040     
1041     private void updateExpandedItemCount(TreeItem<T> treeItem) {
1042         setExpandedItemCount(TreeUtil.updateExpandedItemCount(treeItem, expandedItemCountDirty, isShowRoot()));
1043 
1044         if (expandedItemCountDirty) {
1045             // this is a very inefficient thing to do, but for now having a cache
1046             // is better than nothing at all...
1047             treeItemCacheMap.clear();
1048         }
1049 
1050         expandedItemCountDirty = false;




   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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 com.sun.javafx.collections.NonIterableChange;
  29 import javafx.css.converter.SizeConverter;
  30 import com.sun.javafx.scene.control.Properties;
  31 import com.sun.javafx.scene.control.behavior.TreeCellBehavior;
  32 import javafx.scene.control.skin.TreeViewSkin;

  33 
  34 import javafx.application.Platform;
  35 import javafx.beans.DefaultProperty;
  36 import javafx.beans.property.BooleanProperty;
  37 import javafx.beans.property.DoubleProperty;
  38 import javafx.beans.property.ObjectProperty;
  39 import javafx.beans.property.ObjectPropertyBase;
  40 import javafx.beans.property.ReadOnlyIntegerProperty;
  41 import javafx.beans.property.ReadOnlyIntegerWrapper;
  42 import javafx.beans.property.ReadOnlyObjectProperty;
  43 import javafx.beans.property.ReadOnlyObjectWrapper;
  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.ListChangeListener;
  50 import javafx.css.CssMetaData;
  51 import javafx.css.Styleable;
  52 import javafx.css.StyleableDoubleProperty;


1010         }
1011 
1012         return level;
1013     }
1014 
1015     /** {@inheritDoc} */
1016     @Override protected Skin<?> createDefaultSkin() {
1017         return new TreeViewSkin<T>(this);
1018     }
1019 
1020     /**
1021      * Calling {@code refresh()} forces the TreeView control to recreate and
1022      * repopulate the cells necessary to populate the visual bounds of the control.
1023      * In other words, this forces the TreeView to update what it is showing to
1024      * the user. This is useful in cases where the underlying data source has
1025      * changed in a way that is not observed by the TreeView itself.
1026      *
1027      * @since JavaFX 8u60
1028      */
1029     public void refresh() {
1030         getProperties().put(Properties.RECREATE, Boolean.TRUE);
1031     }
1032 
1033 
1034     
1035     /***************************************************************************
1036      *                                                                         *
1037      * Private Implementation                                                  *
1038      *                                                                         *
1039      **************************************************************************/  
1040     
1041     private void updateExpandedItemCount(TreeItem<T> treeItem) {
1042         setExpandedItemCount(TreeUtil.updateExpandedItemCount(treeItem, expandedItemCountDirty, isShowRoot()));
1043 
1044         if (expandedItemCountDirty) {
1045             // this is a very inefficient thing to do, but for now having a cache
1046             // is better than nothing at all...
1047             treeItemCacheMap.clear();
1048         }
1049 
1050         expandedItemCountDirty = false;