changeset 2307:e729dbc9372e

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/8.0/scrum/controls/jfx/rt
author jgiles
date Fri, 18 Jan 2013 12:26:27 +1300
parents a79d62fc73e2 94e17a82ab82
children 5ff2565312e6
files javafx-ui-controls/src/com/sun/javafx/scene/control/FocusableTextField.java javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableColumnHeader.java
diffstat 7 files changed, 117 insertions(+), 167 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/FocusableTextField.java	Thu Jan 17 15:29:36 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.sun.javafx.scene.control;
-
-import com.sun.javafx.event.EventDispatchChainImpl;
-import javafx.event.EventDispatchChain;
-import javafx.scene.control.TextField;
-
-/**
- * Used by ComboBox - makes it possible to call setFocused from external classes.
- */
-public final class FocusableTextField extends TextField {
-    
-    public void setFakeFocus(boolean focus) {
-        setFocused(focus);
-    }
-
-    @Override
-    public EventDispatchChain buildEventDispatchChain(EventDispatchChain tail) {
-        EventDispatchChain chain = new EventDispatchChainImpl();
-        chain.append(getEventDispatcher());
-        return chain;
-    }
-}
\ No newline at end of file
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxBaseSkin.java	Thu Jan 17 15:29:36 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxBaseSkin.java	Fri Jan 18 12:26:27 2013 +1300
@@ -146,7 +146,7 @@
                 snapSpace(arrowButtonPadding.getRight()));
         
         if (displayNode != null) {
-            displayNode.resizeRelocate(x, y, w, h);
+            displayNode.resizeRelocate(x, y, w - arrowButtonWidth, h);
         }
         
         if (isButton()) return;
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java	Thu Jan 17 15:29:36 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java	Fri Jan 18 12:26:27 2013 +1300
@@ -38,6 +38,7 @@
 import javafx.beans.value.ObservableValue;
 import javafx.collections.ListChangeListener;
 import javafx.collections.ObservableList;
+import javafx.css.PseudoClass;
 import javafx.event.EventHandler;
 import javafx.event.EventTarget;
 import javafx.scene.Node;
@@ -125,8 +126,12 @@
         // move focus in to the textfield if the comboBox is editable
         comboBox.focusedProperty().addListener(new ChangeListener<Boolean>() {
             @Override public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean hasFocus) {
-                if (comboBox.isEditable()) {
-                    updateFakeFocus(hasFocus);
+                if (comboBox.isEditable() && hasFocus) {
+                    Platform.runLater(new Runnable() {
+                        @Override public void run() {
+                            textField.requestFocus();
+                        }
+                    });
                 }
             }
         });
@@ -347,17 +352,6 @@
         textField.setFocusTraversable(true);
         textField.promptTextProperty().bind(comboBox.promptTextProperty());
         
-//        // focus always goes to the comboBox, which then forwards events down 
-//        // to the TextField. This ensures that the ComboBox appears focused
-//        // externally for people listening to the focus property.
-//        // Also, (for RT-21454) set the currently typed text as the value when focus 
-//        // is lost from the ComboBox
-//        textField.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
-//            @Override public void handle(MouseEvent t) {
-//                comboBox.requestFocus();
-//                t.consume();
-//            }
-//        });
         textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
             @Override public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean hasFocus) {
                 if (! comboBox.isEditable()) return;
@@ -365,6 +359,9 @@
                 // RT-21454 starts here
                 if (! hasFocus) {
                     setTextFromTextFieldIntoComboBoxValue();
+                    pseudoClassStateChanged(CONTAINS_FOCUS_PSEUDOCLASS_STATE, false);
+                } else {
+                    pseudoClassStateChanged(CONTAINS_FOCUS_PSEUDOCLASS_STATE, true);
                 }
             }
         });
@@ -372,12 +369,6 @@
         return textField;
     }
     
-    private void updateFakeFocus(boolean b) {
-        if (textField == null) return;
-        if (! (textField instanceof FocusableTextField)) return;
-        ((FocusableTextField)textField).setFakeFocus(b);
-    }
-    
     private void updateDisplayNode() {
         StringConverter<T> c = comboBox.getConverter();
         if (c == null) return;
@@ -615,4 +606,15 @@
     public ListView<T> getListView() {
         return listView;
     }
+    
+    
+    
+
+    /***************************************************************************
+     *                                                                         *
+     * Stylesheet Handling                                                     *
+     *                                                                         *
+     **************************************************************************/
+    
+    private static PseudoClass CONTAINS_FOCUS_PSEUDOCLASS_STATE = PseudoClass.getPseudoClass("contains-focus");    
 }
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableColumnHeader.java	Thu Jan 17 15:29:36 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableColumnHeader.java	Fri Jan 18 12:26:27 2013 +1300
@@ -55,20 +55,7 @@
 import javafx.css.StyleableDoubleProperty;
 import javafx.css.CssMetaData;
 import javafx.css.PseudoClass;
-import com.sun.javafx.css.converters.SizeConverter;
-import com.sun.javafx.scene.control.MultiplePropertyChangeListenerHandler;
-import javafx.collections.WeakListChangeListener;
 import javafx.css.StyleableProperty;
-import javafx.scene.control.TableColumnBase;
-import com.sun.javafx.css.converters.SizeConverter;
-import com.sun.javafx.scene.control.MultiplePropertyChangeListenerHandler;
-import javafx.collections.WeakListChangeListener;
-import javafx.scene.control.TableColumnBase;
-import com.sun.javafx.css.converters.SizeConverter;
-import com.sun.javafx.scene.control.MultiplePropertyChangeListenerHandler;
-import javafx.collections.WeakListChangeListener;
-import javafx.css.StyleableProperty;
-import javafx.scene.control.TableColumnBase;
 import com.sun.javafx.css.converters.SizeConverter;
 import com.sun.javafx.scene.control.MultiplePropertyChangeListenerHandler;
 import javafx.collections.WeakListChangeListener;
@@ -469,6 +456,7 @@
             } else if (showSortOrderDots) {
                 if (sortOrderDots == null) {
                     sortOrderDots = new HBox(1);
+                    sortOrderDots.getStyleClass().add("sort-order-dots-container");
                 }
 
                 // show the sort order dots
@@ -508,17 +496,19 @@
         
         sortOrderDots.getChildren().clear();
         
-        double rectWidth = (arrowWidth) / 3.0;
-        double rectHeight = rectWidth * 0.618033987;
-        
         for (int i = 0; i <= sortPos; i++) {
-            Rectangle r = new Rectangle(rectWidth, rectHeight, Color.BLACK);
+            Region r = new Region();
+            r.getStyleClass().add("sort-order-dot");
+            
+            TableColumnBase.SortType sortType = getTableColumn().getSortType();
+            if (sortType != null) {
+                r.getStyleClass().add(sortType.name().toLowerCase());
+            }
+            
             sortOrderDots.getChildren().add(r);
         }
         
-        sortOrderDots.setPadding(new Insets(1, 0, 1, 0));
         sortOrderDots.setAlignment(Pos.TOP_CENTER);
-        sortOrderDots.setMaxHeight(rectHeight + 2);
         sortOrderDots.setMaxWidth(arrowWidth);
     }
     
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkinBase.java	Thu Jan 17 15:29:36 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkinBase.java	Fri Jan 18 12:26:27 2013 +1300
@@ -68,7 +68,7 @@
      * disclosureNode width per TreeView. We use WeakHashMap to help prevent
      * any memory leaks.
      */
-    private static final Map<Control, Double> maxDisclosureWidthMap = new WeakHashMap<Control, Double>();
+    static final Map<Control, Double> maxDisclosureWidthMap = new WeakHashMap<Control, Double>();
     
     protected int getIndentationLevel(C control) {
         // TreeTableView.getNodeLevel(control.getTreeTable)
@@ -369,7 +369,7 @@
     }
 
     @Override protected void layoutChildren(double x, final double y,
-            double w, final double h) {
+            final double w, final double h) {
         
         if (isDirty) {
             recreateCells();
@@ -483,8 +483,6 @@
                     // further indentation code starts here
                     ///////////////////////////////////////////
                     if (indentationRequired && column == indentationColumnIndex) {
-                        x += leftMargin;
-                        
                         if (disclosureVisible) {
                             double ph = disclosureNode.prefHeight(disclosureWidth);
                             
@@ -493,16 +491,16 @@
                             } else {
                                 fadeIn(disclosureNode);
                                 disclosureNode.resize(disclosureWidth, ph);
-                                positionInArea(disclosureNode, x, y,
+                                positionInArea(disclosureNode, x + leftMargin, y,
                                         disclosureWidth, h, /*baseline ignored*/0,
                                         HPos.CENTER, VPos.CENTER);
+                                disclosureNode.toFront();
                             }
                         }
                         
                         // determine starting point of the graphic or cell node, and the
                         // remaining width available to them
                         Node graphic = getGraphic();
-                        x += disclosureWidth;
                         
                         if (graphic != null) {
                             graphicWidth = graphic.prefWidth(-1) + 3;
@@ -511,16 +509,12 @@
                                 fadeOut(graphic);
                             } else {
                                 fadeIn(graphic);
-                                positionInArea(graphic, x, y,
+                                positionInArea(graphic, x + leftMargin + disclosureWidth, y,
                                             disclosureWidth, h, /*baseline ignored*/0,
                                             HPos.CENTER, VPos.CENTER);
+                                graphic.toFront();
                             }
-                            
-                            x += graphicWidth;
-                            w -= graphicWidth;
                         }
-                        
-                        w -= (leftMargin + disclosureWidth + graphicWidth);
                     }
                     ///////////////////////////////////////////
                     // further indentation code ends here
@@ -578,27 +572,16 @@
                     // cell spanning code ends here
                     ///////////////////////////////////////////
                     
-                    // a little bit more special code for indentation purposes.
-                    // we use j here to prevent the table cells being sized as
-                    // negative or 0 widths. If this is allowed, the vertical 
-                    // lines for that column are removed from view, which 
-                    // doesn't look right.
-                    double j = width - (leftMargin + disclosureWidth + graphicWidth);
+                    tableCell.resize(width, height);
+
                     if (indentationRequired && column == indentationColumnIndex) {
-                        // the min width of a table cell is now 1 pixel
-                        tableCell.resize(Math.max(1, j), height);
-                    } else {
-                        tableCell.resize(width, height);
-                    }
-
-                    if (indentationRequired && column > indentationColumnIndex) {
-                        tableCell.relocate(x - leftMargin - disclosureWidth - graphicWidth, insets.getTop());
+                        tableCell.relocate(x, insets.getTop());
                     } else {
                         // if j is a negative number (because the width is smaller
                         // that the left margin and disclosure node), we relocate
                         // the cell to the left (and subtract 1 to take into 
                         // account the minimum 1px width we resize cells to above).
-                        tableCell.relocate(x + Math.min(0, j - 1), insets.getTop());
+                        tableCell.relocate(x, insets.getTop());
                     }
                 } else {
                     if (fixedCellLengthEnabled) {
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeTableCellSkin.java	Thu Jan 17 15:29:36 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeTableCellSkin.java	Fri Jan 18 12:26:27 2013 +1300
@@ -25,9 +25,11 @@
 package com.sun.javafx.scene.control.skin;
 
 import com.sun.javafx.scene.control.behavior.TreeTableCellBehavior;
+import java.util.Map;
 import javafx.beans.property.BooleanProperty;
 import javafx.beans.property.ReadOnlyDoubleProperty;
 import javafx.scene.Node;
+import javafx.scene.control.Control;
 import javafx.scene.control.TreeItem;
 import javafx.scene.control.TreeTableCell;
 import javafx.scene.control.TreeTableColumn;
@@ -58,56 +60,61 @@
     @Override protected ReadOnlyDoubleProperty columnWidthProperty() {
         return tableColumn.widthProperty();
     }
-    
+
+    @Override protected double leftLabelPadding() {
+        double leftPadding = super.leftLabelPadding();
+        
+        // RT-27167: we must take into account the disclosure node and the
+        // indentation (which is not taken into account by the LabeledSkinBase.
+        final double height = getCellSize();
+
+        TreeTableCell cell = getSkinnable();
+
+        TreeTableColumn tableColumn = cell.getTableColumn();
+        if (tableColumn == null) return leftPadding;
+
+        // check if this column is the TreeTableView treeColumn (i.e. the 
+        // column showing the disclosure node and graphic).
+        TreeTableView treeTable = cell.getTreeTableView();
+        if (treeTable == null) return leftPadding;
+
+        int columnIndex = treeTable.getVisibleLeafIndex(tableColumn);
+
+        TreeTableColumn treeColumn = treeTable.getTreeColumn();
+        if ((treeColumn == null && columnIndex != 0) || (treeColumn != null && ! tableColumn.equals(treeColumn))) {
+            return leftPadding;
+        }
+
+        TreeTableRow treeTableRow = cell.getTreeTableRow();
+        if (treeTableRow == null) return leftPadding;
+
+        TreeItem treeItem = treeTableRow.getTreeItem();
+        if (treeItem == null) return leftPadding;
+        
+        int nodeLevel = TreeTableView.getNodeLevel(treeItem);
+        if (! treeTable.isShowRoot()) nodeLevel--;
+
+        // FIXME we're assuming an indent of 10px here, which is not
+        // necessarily accurate as it is configurable via -fx-indent.
+        // Unfortunately this value is stored in TreeTableRowSkin.
+        leftPadding += nodeLevel * 10;
+
+        // add in the width of the disclosure node, if one exists
+        Map<Control, Double> mdwp = TableRowSkinBase.maxDisclosureWidthMap;
+        leftPadding += mdwp.containsKey(treeTable) ? mdwp.get(treeTable) : 0;
+
+        // adding in the width of the graphic on the tree item
+        Node graphic = treeItem.getGraphic();
+        leftPadding += graphic == null ? 0 : graphic.prefWidth(height);
+        
+        return leftPadding;
+    }
+
     @Override protected double computePrefWidth(double height) {
         if (isDeferToParentForPrefWidth) {
             // RT-27167: we must take into account the disclosure node and the
             // indentation (which is not taken into account by the LabeledSkinBase.
-            double pw = super.computePrefWidth(height);
-            
-            TreeTableCell cell = getSkinnable();
-            
-            TreeTableColumn tableColumn = cell.getTableColumn();
-            if (tableColumn == null) return pw;
-            
-            // check if this column is the TreeTableView treeColumn (i.e. the 
-            // column showing the disclosure node and graphic).
-            TreeTableView treeTable = cell.getTreeTableView();
-            if (treeTable == null) return pw;
-            
-            int columnIndex = treeTable.getVisibleLeafIndex(tableColumn);
-            
-            TreeTableColumn treeColumn = treeTable.getTreeColumn();
-            if ((treeColumn == null && columnIndex != 0) || (treeColumn != null && ! tableColumn.equals(treeColumn))) {
-                return pw;
-            }
-            
-            TreeTableRow treeTableRow = cell.getTreeTableRow();
-            if (treeTableRow == null) return pw;
-            
-            TreeItem treeItem = treeTableRow.getTreeItem();
-            if (treeItem == null) return pw;
-            
-            int nodeLevel = TreeTableView.getNodeLevel(treeItem);
-            if (! treeTable.isShowRoot()) nodeLevel--;
-
-            // FIXME we're assuming an indent of 10px here, which is not
-            // necessarily accurate as it is configurable via -fx-indent.
-            // Unfortunately this value is stored in TreeTableRowSkin.
-            pw += nodeLevel * 10;
-            
-            // add in the width of the disclosure node, if one exists
-            Node disclosureNode = treeTableRow.getDisclosureNode();
-            pw += disclosureNode == null ? 0 : disclosureNode.prefWidth(height);
-
-            // Adding a little extra for padding
-            pw += 13;
-
-            // adding in the width of the graphic on the tree item
-            Node graphic = treeItem.getGraphic();
-            pw += graphic == null ? 0 : graphic.prefWidth(height);
-
-            return pw;
+            return super.computePrefWidth(height);
         }
         return columnWidthProperty().get();
     }
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Thu Jan 17 15:29:36 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Fri Jan 18 12:26:27 2013 +1300
@@ -2373,12 +2373,32 @@
     -fx-border-width: 0.083333em, 0.083333em 0 0.083333em 0.083333em;
 }
 
+.table-view .column-header .sort-order-dots-container,
+.tree-table-view .column-header .sort-order-dots-container{
+    -fx-padding: 2 0 2 0;
+}
 
 .table-view .column-header .sort-order,
 .tree-table-view .column-header .sort-order{
     -fx-font-size: 0.916667em; /* 11pt - 1 less than the default font */
 }
 
+.table-view .column-header .sort-order-dot,
+.tree-table-view .column-header .sort-order-dot {
+    -fx-background-color: derive(-fx-mark-highlight-color, 40%), -fx-mark-color;
+    -fx-padding: 0.0625em 0.104em 0.0625em 0.104em;
+}
+
+.table-view .column-header .sort-order-dot.ascending,
+.tree-table-view .column-header .sort-order-dot.ascending {
+    -fx-background-insets: -1 0 1 0, 0; 
+}
+
+.table-view .column-header .sort-order-dot.descending,
+.tree-table-view .column-header .sort-order-dot.descending {
+    -fx-background-insets: 1 0 -1 0, 0; 
+}
+
 .table-view > .column-header-background > .show-hide-columns-button,
 .tree-table-view > .column-header-background > .show-hide-columns-button{
     -fx-background-color: -fx-body-color;
@@ -3152,24 +3172,18 @@
 
 .combo-box-base:editable > .text-field {
     -fx-padding: 3 5 2 5;
-    -fx-background-radius: 4 5 5 4, 3 4 4 3, 2 3 3 2;
-    -fx-background-insets: 0 0 -1 0, 0, 1;
+    -fx-background-radius: 4 0 0 4, 3 0 0 3, 2 0 0 2;
+    -fx-background-insets: 0 0 -1 0, 0, 1 0 1 1;
     -fx-vpos: CENTER;
     -fx-content-display: LEFT;
 }
 
-.combo-box-base:editable > .text-field:focused {
+.combo-box-base:editable:contains-focus {
     -fx-background-color: -fx-focus-color, -fx-outer-border, -fx-control-inner-background;
     -fx-background-radius: 5.4, 3, 2;
     -fx-background-insets: -1.4, 0, 1;
 }
 
-.combo-box-base:editable:focused {
-    -fx-background-color: -fx-shadow-highlight-color, -fx-outer-border, -fx-inner-border, -fx-control-inner-background;
-    -fx-background-radius: 5, 5, 4, 3;
-    -fx-background-insets: 0 0 -1 0, 0, 1, 2;
-}
-
 /* -------------- STYLES FOR THE DEFAULT LISTVIEW-BASED COMBOBOX ------------- */
 
 /* Customie the ListCell that appears in the ComboBox button itself */