changeset 6240:a649f412d78b

RT-34446: TableView -fx-alignment: center-left in TableCell doesn't work Thanks to David for the StyleOrigin pointer!
author jgiles
date Tue, 04 Feb 2014 11:12:09 +1300
parents 0745342829aa
children 9ee9a265338c
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TableRowSkinBase.java
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TableRowSkinBase.java	Mon Feb 03 14:24:56 2014 +1300
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TableRowSkinBase.java	Tue Feb 04 11:12:09 2014 +1300
@@ -35,6 +35,8 @@
 import javafx.collections.ListChangeListener;
 import javafx.collections.ObservableList;
 import javafx.collections.WeakListChangeListener;
+import javafx.css.StyleOrigin;
+import javafx.css.StyleableObjectProperty;
 import javafx.geometry.HPos;
 import javafx.geometry.Pos;
 import javafx.geometry.VPos;
@@ -355,9 +357,15 @@
                 // alignment has not been manually changed, but for now this will
                 // do.
                 final boolean centreContent = h <= 24.0;
-                if (! centreContent && tableCell.getAlignment() == Pos.CENTER_LEFT) {
+
+                // if the style origin is null then the property has not been
+                // set (or it has been reset to its default), which means that
+                // we can set it without overwriting someone elses settings.
+                final StyleOrigin origin = ((StyleableObjectProperty) tableCell.alignmentProperty()).getStyleOrigin();
+                if (! centreContent && origin == null) {
                     tableCell.setAlignment(Pos.TOP_LEFT);
                 }
+                // --- end of RT-32700 fix
 
                 ///////////////////////////////////////////
                 // further indentation code starts here