changeset 5172:8a99b06d9c22

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/8.0/MASTER/jfx/rt
author David Grieve<david.grieve@oracle.com>
date Wed, 25 Sep 2013 15:09:58 -0700
parents ad10ea1df81d b97f4a5bcfb2
children d67eca687eef
files
diffstat 14 files changed, 101 insertions(+), 94 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ComboBoxBaseBehavior.java	Tue Sep 24 10:09:57 2013 -0700
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ComboBoxBaseBehavior.java	Wed Sep 25 15:09:58 2013 -0700
@@ -191,9 +191,10 @@
     
     @Override public void mouseReleased(MouseEvent e) {
         super.mousePressed(e);
-        
+
+        boolean wasArmed = getControl().isArmed();
         disarm();
-        
+
         // The wasComboBoxButtonClickedForAutoHide boolean was added to resolve
         // RT-18151: namely, clicking on the comboBox button shouldn't hide, 
         // and then immediately show the popup, which was occuring because we 
@@ -203,7 +204,8 @@
             hide();
         } else if (! wasComboBoxButtonClickedForAutoHide 
                 && getControl().contains(e.getX(), e.getY())
-                && e.getButton() == MouseButton.PRIMARY) {
+                && e.getButton() == MouseButton.PRIMARY
+                && wasArmed) {
             show();
         } else {
             wasComboBoxButtonClickedForAutoHide = false;
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java	Tue Sep 24 10:09:57 2013 -0700
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java	Wed Sep 25 15:09:58 2013 -0700
@@ -334,7 +334,13 @@
         
         super.layoutChildren(x,y,w,h);
     }
-    
+
+    // Added to allow subclasses to prevent the popup from hiding when the
+    // ListView is clicked on (e.g when the list cells have checkboxes).
+    protected boolean isHideOnClickEnabled() {
+        return true;
+    }
+
     
     
     /***************************************************************************
@@ -609,7 +615,9 @@
                     }
                 }
                 
-                comboBox.hide();
+                if (isHideOnClickEnabled()) {
+                    comboBox.hide();
+                }
             }
         });
 
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/DatePickerSkin.java	Tue Sep 24 10:09:57 2013 -0700
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/DatePickerSkin.java	Wed Sep 25 15:09:58 2013 -0700
@@ -33,11 +33,14 @@
 import java.time.format.DateTimeParseException;
 
 import javafx.application.Platform;
+import javafx.beans.InvalidationListener;
+import javafx.beans.Observable;
 import javafx.beans.value.ChangeListener;
 import javafx.beans.value.ObservableValue;
 import javafx.css.PseudoClass;
 // import javafx.event.ActionEvent;
 import javafx.event.EventHandler;
+import javafx.geometry.Insets;
 import javafx.scene.Node;
 import javafx.scene.control.DatePicker;
 import javafx.scene.control.TextField;
@@ -75,6 +78,25 @@
             });
         }
 
+        // The "arrow" is actually a rectangular svg icon resembling a calendar.
+        // Round the size of the icon to whole integers to get sharp edges.
+        arrow.paddingProperty().addListener(new InvalidationListener() {
+            // This boolean protects against unwanted recursion.
+            private boolean rounding = false;
+            @Override public void invalidated(Observable observable) {
+                if (!rounding) {
+                    Insets padding = arrow.getPadding();
+                    Insets rounded = new Insets(Math.round(padding.getTop()), Math.round(padding.getRight()), 
+                                                Math.round(padding.getBottom()), Math.round(padding.getLeft()));
+                    if (!rounded.equals(padding)) {
+                        rounding = true;
+                        arrow.setPadding(rounded);
+                        rounding = false;
+                    }
+                }
+            }
+        });
+
         // Move fake focus in to the textfield.
         // Note: DatePicker uses TextField for both editable and non-editable modes
         datePicker.focusedProperty().addListener(new ChangeListener<Boolean>() {
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ScrollPaneSkin.java	Tue Sep 24 10:09:57 2013 -0700
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ScrollPaneSkin.java	Wed Sep 25 15:09:58 2013 -0700
@@ -245,6 +245,7 @@
         // prevent requestLayout requests from within scrollNode from percolating up
         viewRect.setManaged(false);
         viewRect.setCache(true);
+        viewRect.getStyleClass().add("viewport");
 
         clipRect = new Rectangle();
         viewRect.setClip(clipRect);
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualFlow.java	Tue Sep 24 10:09:57 2013 -0700
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualFlow.java	Wed Sep 25 15:09:58 2013 -0700
@@ -1467,7 +1467,9 @@
                 // only a single row and it is bigger than the viewport
                 lengthBar.setVisibleAmount(flowLength / sumCellLength);
             } else {
-                lengthBar.setVisibleAmount(numCellsVisibleOnScreen / (float) cellCount);
+                // Changed the calculation here due to RT-25059. This new approach
+                // ensures the thumb does not resize unexpectedly.
+                lengthBar.setVisibleAmount(cellCount / viewportLength);
             }
             
 
@@ -2082,11 +2084,23 @@
                 positionCell(cell, getCellPosition(cell) - delta);
             }
 
-            // Now throw away any cells that don't fit
-            cull();
+            // Fix for RT-32908
+            T firstCell = cells.getFirst();
+            double layoutY = firstCell == null ? 0 : getCellPosition(firstCell);
+            for (int i = 0; i < cells.size(); i++) {
+                T cell = cells.get(i);
+                assert cell != null;
+                double actualLayoutY = getCellPosition(cell);
+                if (actualLayoutY != layoutY) {
+                    // we need to shift the cell to layoutY
+                    positionCell(cell, layoutY);
+                }
+
+                layoutY += getCellLength(cell);
+            }
+            // end of fix for RT-32908
 
             // Add any necessary leading cells
-            T firstCell = cells.getFirst();
             if (firstCell != null) {
                 int firstIndex = getCellIndex(firstCell);
                 double prevIndexSize = getCellLength(firstIndex - 1);
@@ -2130,6 +2144,9 @@
             }
         }
 
+        // Now throw away any cells that don't fit
+        cull();
+
         // Finally, update the scroll bars
         updateScrollBarsAndCells();
         lastPosition = getPosition();
--- a/modules/controls/src/main/java/javafx/scene/control/ChoiceBox.java	Tue Sep 24 10:09:57 2013 -0700
+++ b/modules/controls/src/main/java/javafx/scene/control/ChoiceBox.java	Wed Sep 25 15:09:58 2013 -0700
@@ -195,7 +195,8 @@
                 final SingleSelectionModel<T> sm = getSelectionModel();
                 if (sm != null) {
                     if (newItems != null && newItems.isEmpty()) {
-                        sm.setSelectedIndex(-1);
+                        // RT-29433 - clear selection.
+                        sm.clearSelection();
                     } else if (sm.getSelectedIndex() == -1 && sm.getSelectedItem() != null) {
                         int newIndex = getItems().indexOf(sm.getSelectedItem());
                         if (newIndex != -1) {
--- a/modules/controls/src/main/java/javafx/scene/control/TitledPane.java	Tue Sep 24 10:09:57 2013 -0700
+++ b/modules/controls/src/main/java/javafx/scene/control/TitledPane.java	Wed Sep 25 15:09:58 2013 -0700
@@ -57,7 +57,6 @@
  * <p>Example:</p>
  * <pre><code>
  *  TitledPane t1 = new TitledPane("T1", new Button("B1"));
- *  t1.setMode(TitledPaneMode.FADE);
  * </code></pre>
  *
  * @since JavaFX 2.0
--- a/modules/controls/src/main/resources/com/sun/javafx/scene/control/skin/modena/modena.css	Tue Sep 24 10:09:57 2013 -0700
+++ b/modules/controls/src/main/resources/com/sun/javafx/scene/control/skin/modena/modena.css	Wed Sep 25 15:09:58 2013 -0700
@@ -409,6 +409,9 @@
     -fx-alignment: CENTER;
     -fx-content-display: LEFT;
 }
+.menu-button > .label {
+    -fx-alignment: CENTER_LEFT;
+}
 .button:hover,
 .toggle-button:hover,
 .radio-button:hover > .radio,
@@ -1054,7 +1057,9 @@
  * ScrollPane                                                                  *
  *                                                                             *
  ******************************************************************************/
-
+.scroll-pane > .viewport {
+    -fx-background-color: -fx-background;
+}
 .scroll-pane > .scroll-bar:horizontal {
     -fx-background-insets: 0 1 1 1, 1;
     -fx-padding: 0 1 0 1;
@@ -1689,7 +1694,7 @@
     -fx-text-fill: -fx-text-base-color;
     -fx-padding: 0.333333em 0.666667em 0.333333em 0.666667em; /* 4 8 4 8 */
 }
-.combo-box-base > .arrow-button  {
+.combo-box-base > .arrow-button {
     -fx-background-radius: 0 3 3 0, 0 2 2 0, 0 1 1 0;
     -fx-padding: 0.5em 0.667em 0.5em 0.833333em; /* 6 8 6 10 */
     -fx-background-color: transparent;
@@ -1705,23 +1710,28 @@
  *                                                                             *
  ******************************************************************************/
 
-.combo-box-base:editable > .arrow-button  {
+.combo-box-base:editable > .arrow-button,
+.date-picker > .arrow-button {
     -fx-background-color: -fx-outer-border, -fx-inner-border, -fx-body-color;
     -fx-background-insets: 1 1 1 0, 1, 2;
     -fx-background-radius: 0 3 3 0, 0 2 2 0, 0 1 1 0;
 }
-.combo-box-base:editable > .text-field {
+.combo-box-base:editable > .text-field,
+.date-picker > .text-field {
     -fx-background-color: -fx-control-inner-background;
     -fx-background-insets: 1 0 1 1;
     -fx-background-radius: 2 0 0 2;
 }
-.combo-box-base:editable:contains-focus {
+.combo-box-base:editable:contains-focus,
+.date-picker:contains-focus {
     -fx-background-color: -fx-focus-color;
     -fx-background-insets: -0.2;
     -fx-background-radius: 3;
 }
 .combo-box-base:editable:focused > .text-field,
-.combo-box-base:editable > .text-field:focused  {
+.combo-box-base:editable > .text-field:focused,
+.date-picker:focused > .text-field,
+.date-picker > .text-field:focused {
     -fx-background-color: 
         -fx-control-inner-background,
         -fx-faint-focus-color,
@@ -1729,7 +1739,8 @@
     -fx-background-insets: 1 0 1 1, 1 0 1 1, 3 2 3 3;
     -fx-background-radius: 2 0 0 2, 1 0 0 1, 0;
 }
-.combo-box-base:editable:contains-focus > .arrow-button {
+.combo-box-base:editable:contains-focus > .arrow-button,
+.date-picker:contains-focus > .arrow-button {
     -fx-background-color: -fx-inner-border, -fx-body-color, -fx-faint-focus-color, -fx-body-color;
     -fx-background-insets: 1, 2, 1, 2.6;
     -fx-background-radius: 0 2 2 0, 0 1 1 0, 0 1 1 0, 0 1 1 0;
@@ -2929,32 +2940,12 @@
     -fx-padding: 0.8em;
 }
 
-
-
-
 /*******************************************************************************
  *                                                                             *
  * DatePicker                                                                  *
  *                                                                             *
  ******************************************************************************/
 
-/* Merge the following rules with ComboBox rules whenever possible */
-/* Note that DatePicker uses same style for editable and non-editable text */
-/* This style is for non-editable ComboBox and does not apply to DatePicker
- * .date-picker > .date-picker-display-node {
- *    -fx-background: transparent;
- *    -fx-background-color: transparent;
- *    -fx-text-fill: -fx-text-base-color;
- *    -fx-padding: 0.333333em 0.5em 0.333333em 0.75em;
- * }
- * .date-picker > .arrow-button  {
- *    -fx-background-radius: 0 3 3 0, 0 2 2 0, 0 1 1 0;
- *    -fx-padding: 0.5em 0.583333em 0.5em 0.666667em;
- *    -fx-background-color: transparent;
- * }
- */
-/* END */
-
 .date-picker > .arrow-button > .arrow {
     -fx-shape: "M0,0v9h9V0H0z M2,8H1V7h1V8z M2,6H1V5h1V6z M2,4H1V3h1V4z M4,8H3V7h1V8z M4,6H3V5h1V6z M4,4H3V3h1V4z M6,8H5V7h1V8z M6,6H5 V5h1V6z M6,4H5V3h1V4z M8,8H7V7h1V8z M8,6H7V5h1V6z M8,4H7V3h1V4z";
     -fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
@@ -2963,39 +2954,6 @@
     -fx-scale-shape: true;
 }
 
-/* Merge the following rules with Editable ComboBox rules */
-/* Note that DatePicker uses same style for editable and non-editable text */
-.date-picker > .arrow-button  {
-    -fx-background-color: -fx-outer-border, -fx-inner-border, -fx-body-color;
-    -fx-background-insets: 1 1 1 0, 1, 2;
-    -fx-background-radius: 0 3 3 0, 0 2 2 0, 0 1 1 0;
-}
-.date-picker > .text-field {
-    -fx-background-color: -fx-control-inner-background;
-    -fx-background-insets: 1 0 1 1;
-    -fx-background-radius: 2 0 0 2;
-}
-.date-picker:contains-focus {
-    -fx-background-color: -fx-focus-color;
-    -fx-background-insets: -0.2;
-    -fx-background-radius: 3;
-}
-.date-picker:focused > .text-field,
-.date-picker > .text-field:focused  {
-    -fx-background-color:
-        -fx-control-inner-background,
-        -fx-faint-focus-color,
-        linear-gradient(from 0px 0px to 0px 5px, derive(-fx-control-inner-background, -9%), -fx-control-inner-background);
-    -fx-background-insets: 1 0 1 1, 1 0 1 1, 3 2 3 3;
-    -fx-background-radius: 2 0 0 2, 1 0 0 1, 0;
-}
-.date-picker:contains-focus > .arrow-button {
-    -fx-background-color: -fx-inner-border, -fx-body-color, -fx-faint-focus-color, -fx-body-color;
-    -fx-background-insets: 1, 2, 1, 2.6;
-    -fx-background-radius: 0 2 2 0, 0 1 1 0, 0 1 1 0, 0 1 1 0;
-}
-/* END */
-
 .date-picker-popup {
      -fx-background-color:
         linear-gradient(to bottom,
@@ -3079,9 +3037,10 @@
 
 .date-picker-popup > .calendar-grid {
     -fx-background-color: derive(-fx-selection-bar-non-focused, 60%);
-    -fx-background-insets: 1 0 0 0;
-}
-.date-picker-popup > * > .date-cell {
+    /*-fx-background-insets: 1 0 0 0;*/
+    -fx-padding: 0;
+}
+.date-picker-popup > * > .date-cell { 
     -fx-background-color: transparent;
     -fx-background-insets: 1, 2;
     -fx-padding: 0;
@@ -3090,7 +3049,7 @@
 }
 .date-picker-popup > * > .day-name-cell,
 .date-picker-popup > * > .week-number-cell {
-    -fx-font-size: 0.916667em;
+    -fx-font-size: 0.916667em; 
 }
 .date-picker-popup > * > .week-number-cell {
     -fx-padding: 0.333333em 0.583333em 0.333333em 0.583333em; /* 4 7 4 7 */
@@ -3104,6 +3063,7 @@
     -fx-padding: 0.333333em 0.583333em 0.333333em 0.583333em; /* 4 7 4 7 */
     -fx-border-color: derive(-fx-selection-bar-non-focused, 60%);
     -fx-border-width: 1px;
+    -fx-font-size: 1em;
     -fx-background: -fx-control-inner-background;
     -fx-background-color: -fx-background;
     -fx-text-fill: -fx-text-background-color;
@@ -3162,5 +3122,5 @@
 
 .date-picker-popup > * > .previous-month.today:hover,
 .date-picker-popup > * > .next-month.today:hover {
-    -fx-background-color: lightgrey, derive(-fx-base, -10%), lightgrey;
-}
+    -fx-background-color: -fx-selection-bar-non-focused, derive(-fx-selection-bar-non-focused, -20%), -fx-selection-bar-non-focused;
+}
--- a/modules/controls/src/test/java/javafx/scene/control/ChoiceBoxTest.java	Tue Sep 24 10:09:57 2013 -0700
+++ b/modules/controls/src/test/java/javafx/scene/control/ChoiceBoxTest.java	Wed Sep 25 15:09:58 2013 -0700
@@ -459,4 +459,15 @@
         assertEquals("Apple", ChoiceBoxSkinNodesRetriever.getChoiceBoxSelectedText(skin));
         
     }
+    
+    @Test public void checkSelectedItemAfterReplacingDataWithEmptyList() {
+        StackPane pane = new StackPane();
+        pane.getChildren().add(box);
+        box.getItems().addAll("Apple", "Orange", "Banana");
+        box.getSelectionModel().select("Orange");
+        startApp(pane);
+        box.getItems().clear();
+        // make sure the selected item is null
+        assertEquals(null, box.getSelectionModel().getSelectedItem());
+    }
 }
--- a/modules/controls/src/test/java/javafx/scene/control/ListViewTest.java	Tue Sep 24 10:09:57 2013 -0700
+++ b/modules/controls/src/test/java/javafx/scene/control/ListViewTest.java	Wed Sep 25 15:09:58 2013 -0700
@@ -570,10 +570,6 @@
         assertTrue(scrollBar.isVisible());
         assertTrue(scrollBar.getVisibleAmount() > 0.0);
         assertTrue(scrollBar.getVisibleAmount() < 1.0);
-
-        // this next test is likely to be brittle, but we'll see...If it is the
-        // cause of failure then it can be commented out
-        assertEquals(0.125, scrollBar.getVisibleAmount(), 0.0);
     }
 
     @Test public void test_rt30400() {
--- a/modules/controls/src/test/java/javafx/scene/control/TableViewTest.java	Tue Sep 24 10:09:57 2013 -0700
+++ b/modules/controls/src/test/java/javafx/scene/control/TableViewTest.java	Wed Sep 25 15:09:58 2013 -0700
@@ -1307,10 +1307,6 @@
         assertTrue(scrollBar.isVisible());
         assertTrue(scrollBar.getVisibleAmount() > 0.0);
         assertTrue(scrollBar.getVisibleAmount() < 1.0);
-        
-        // this next test is likely to be brittle, but we'll see...If it is the
-        // cause of failure then it can be commented out
-        assertEquals(0.0625, scrollBar.getVisibleAmount(), 0.0);
     }
 
     @Test public void test_rt30400() {
--- a/modules/controls/src/test/java/javafx/scene/control/TreeTableViewTest.java	Tue Sep 24 10:09:57 2013 -0700
+++ b/modules/controls/src/test/java/javafx/scene/control/TreeTableViewTest.java	Wed Sep 25 15:09:58 2013 -0700
@@ -1871,10 +1871,6 @@
         assertTrue(scrollBar.isVisible());
         assertTrue(scrollBar.getVisibleAmount() > 0.0);
         assertTrue(scrollBar.getVisibleAmount() < 1.0);
-        
-        // this next test is likely to be brittle, but we'll see...If it is the
-        // cause of failure then it can be commented out
-        assertEquals(0.0625, scrollBar.getVisibleAmount(), 0.0);
     }
     
     @Test public void test_rt29676_withText() {
--- a/modules/controls/src/test/java/javafx/scene/control/TreeViewTest.java	Tue Sep 24 10:09:57 2013 -0700
+++ b/modules/controls/src/test/java/javafx/scene/control/TreeViewTest.java	Wed Sep 25 15:09:58 2013 -0700
@@ -903,10 +903,6 @@
         assertTrue(scrollBar.isVisible());
         assertTrue(scrollBar.getVisibleAmount() > 0.0);
         assertTrue(scrollBar.getVisibleAmount() < 1.0);
-        
-        // this next test is likely to be brittle, but we'll see...If it is the
-        // cause of failure then it can be commented out
-        assertEquals(0.125, scrollBar.getVisibleAmount(), 0.0);
     }
     
     @Test public void test_rt27180_collapseBranch_childSelected_singleSelection() {
--- a/modules/web/src/main/java/com/sun/javafx/scene/web/skin/HTMLEditorSkin.java	Tue Sep 24 10:09:57 2013 -0700
+++ b/modules/web/src/main/java/com/sun/javafx/scene/web/skin/HTMLEditorSkin.java	Wed Sep 25 15:09:58 2013 -0700
@@ -696,7 +696,9 @@
                         super.updateItem(item, empty);
                         if (item != null) {
                             setText(item);
-                            setFont(new Font((String)fontFamilyComboBox.getValue(), Double.valueOf(item.substring(0, item.indexOf(" ")))));
+                            // Remove trailing non-digits to get the size (don't assume there's a space).
+                            String size = item.replaceFirst("[^0-9.]*$", "");
+                            setFont(new Font((String)fontFamilyComboBox.getValue(), Double.valueOf(size)));
                         }
                     }
                 };