changeset 5165:ac217689464d

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/8.0/MASTER/jfx/rt
author David Grieve<david.grieve@oracle.com>
date Tue, 24 Sep 2013 11:45:49 -0700
parents 5de952a29ea8 047354976850
children dbcbfaf3abb4
files
diffstat 7 files changed, 67 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ComboBoxBaseBehavior.java	Thu Sep 19 07:57:58 2013 -0700
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ComboBoxBaseBehavior.java	Tue Sep 24 11:45:49 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/DatePickerSkin.java	Thu Sep 19 07:57:58 2013 -0700
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/DatePickerSkin.java	Tue Sep 24 11:45:49 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	Thu Sep 19 07:57:58 2013 -0700
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ScrollPaneSkin.java	Tue Sep 24 11:45:49 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/javafx/scene/control/ChoiceBox.java	Thu Sep 19 07:57:58 2013 -0700
+++ b/modules/controls/src/main/java/javafx/scene/control/ChoiceBox.java	Tue Sep 24 11:45:49 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/resources/com/sun/javafx/scene/control/skin/modena/modena.css	Thu Sep 19 07:57:58 2013 -0700
+++ b/modules/controls/src/main/resources/com/sun/javafx/scene/control/skin/modena/modena.css	Tue Sep 24 11:45:49 2013 -0700
@@ -1054,7 +1054,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 +1691,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 +1707,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 +1736,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 +2937,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 +2951,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 +3034,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 +3046,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 +3060,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 +3119,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	Thu Sep 19 07:57:58 2013 -0700
+++ b/modules/controls/src/test/java/javafx/scene/control/ChoiceBoxTest.java	Tue Sep 24 11:45:49 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/web/src/main/java/com/sun/javafx/scene/web/skin/HTMLEditorSkin.java	Thu Sep 19 07:57:58 2013 -0700
+++ b/modules/web/src/main/java/com/sun/javafx/scene/web/skin/HTMLEditorSkin.java	Tue Sep 24 11:45:49 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)));
                         }
                     }
                 };