1
1
/*
2
- * Copyright (c) 2010, 2017 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2010, 2020 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
32
32
import java .util .WeakHashMap ;
33
33
34
34
import com .sun .javafx .scene .control .behavior .BehaviorBase ;
35
- import javafx .beans .InvalidationListener ;
36
- import javafx .beans .Observable ;
37
35
import javafx .beans .property .DoubleProperty ;
38
36
import javafx .beans .value .WritableValue ;
39
37
import javafx .geometry .HPos ;
40
38
import javafx .geometry .VPos ;
41
39
import javafx .scene .Node ;
42
40
import javafx .scene .control .Control ;
43
- import javafx .scene .control .ListView ;
44
41
import javafx .scene .control .TreeCell ;
45
42
import javafx .scene .control .TreeItem ;
46
43
import javafx .scene .control .TreeView ;
44
+ import javafx .scene .layout .Region ;
47
45
import javafx .css .StyleableDoubleProperty ;
48
46
import javafx .css .StyleableProperty ;
49
47
import javafx .css .CssMetaData ;
@@ -85,7 +83,6 @@ public class TreeCellSkin<T> extends CellSkinBase<TreeCell<T>> {
85
83
private static final Map <TreeView <?>, Double > maxDisclosureWidthMap = new WeakHashMap <TreeView <?>, Double >();
86
84
87
85
88
-
89
86
/***************************************************************************
90
87
* *
91
88
* Private fields *
@@ -96,10 +93,6 @@ public class TreeCellSkin<T> extends CellSkinBase<TreeCell<T>> {
96
93
private TreeItem <?> treeItem ;
97
94
private final BehaviorBase <TreeCell <T >> behavior ;
98
95
99
- private double fixedCellSize ;
100
- private boolean fixedCellSizeEnabled ;
101
-
102
-
103
96
104
97
/***************************************************************************
105
98
* *
@@ -129,31 +122,9 @@ public TreeCellSkin(TreeCell<T> control) {
129
122
getSkinnable ().requestLayout ();
130
123
});
131
124
registerChangeListener (control .textProperty (), e -> getSkinnable ().requestLayout ());
132
-
133
- setupTreeViewListeners ();
134
- }
135
-
136
- private void setupTreeViewListeners () {
137
- TreeView <T > treeView = getSkinnable ().getTreeView ();
138
- if (treeView == null ) {
139
- getSkinnable ().treeViewProperty ().addListener (new InvalidationListener () {
140
- @ Override public void invalidated (Observable observable ) {
141
- getSkinnable ().treeViewProperty ().removeListener (this );
142
- setupTreeViewListeners ();
143
- }
144
- });
145
- } else {
146
- this .fixedCellSize = treeView .getFixedCellSize ();
147
- this .fixedCellSizeEnabled = fixedCellSize > 0 ;
148
- registerChangeListener (treeView .fixedCellSizeProperty (), e -> {
149
- this .fixedCellSize = getSkinnable ().getTreeView ().getFixedCellSize ();
150
- this .fixedCellSizeEnabled = fixedCellSize > 0 ;
151
- });
152
- }
153
125
}
154
126
155
127
156
-
157
128
/***************************************************************************
158
129
* *
159
130
* Properties *
@@ -277,7 +248,8 @@ public final DoubleProperty indentProperty() {
277
248
278
249
/** {@inheritDoc} */
279
250
@ Override protected double computeMinHeight (double width , double topInset , double rightInset , double bottomInset , double leftInset ) {
280
- if (fixedCellSizeEnabled ) {
251
+ double fixedCellSize = getFixedCellSize ();
252
+ if (fixedCellSize > 0 ) {
281
253
return fixedCellSize ;
282
254
}
283
255
@@ -288,7 +260,8 @@ public final DoubleProperty indentProperty() {
288
260
289
261
/** {@inheritDoc} */
290
262
@ Override protected double computePrefHeight (double width , double topInset , double rightInset , double bottomInset , double leftInset ) {
291
- if (fixedCellSizeEnabled ) {
263
+ double fixedCellSize = getFixedCellSize ();
264
+ if (fixedCellSize > 0 ) {
292
265
return fixedCellSize ;
293
266
}
294
267
@@ -305,7 +278,8 @@ public final DoubleProperty indentProperty() {
305
278
306
279
/** {@inheritDoc} */
307
280
@ Override protected double computeMaxHeight (double width , double topInset , double rightInset , double bottomInset , double leftInset ) {
308
- if (fixedCellSizeEnabled ) {
281
+ double fixedCellSize = getFixedCellSize ();
282
+ if (fixedCellSize > 0 ) {
309
283
return fixedCellSize ;
310
284
}
311
285
@@ -340,6 +314,10 @@ public final DoubleProperty indentProperty() {
340
314
return pw ;
341
315
}
342
316
317
+ private double getFixedCellSize () {
318
+ TreeView <?> treeView = getSkinnable ().getTreeView ();
319
+ return treeView != null ? treeView .getFixedCellSize () : Region .USE_COMPUTED_SIZE ;
320
+ }
343
321
344
322
345
323
/***************************************************************************
0 commit comments