changeset 94:b8d5a05a415b

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/2.1/scrum/controls/jfx/rt
author Jonathan Giles
date Thu, 01 Dec 2011 08:01:11 +1000
parents 87f489a5e00a c6375310e143
children 1136e747223c ad9c4f1b10f6
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css
diffstat 6 files changed, 226 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ComboBoxBaseBehavior.java	Wed Nov 30 15:57:21 2011 -0500
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ComboBoxBaseBehavior.java	Thu Dec 01 08:01:11 2011 +1000
@@ -83,27 +83,27 @@
     private static final String PRESS_ACTION = "Press";
     private static final String RELEASE_ACTION = "Release";
 
-    protected static final List<KeyBinding> BUTTON_BINDINGS = new ArrayList<KeyBinding>();
+    protected static final List<KeyBinding> COMBO_BOX_BASE_BINDINGS = new ArrayList<KeyBinding>();
     static {
-        BUTTON_BINDINGS.add(new KeyBinding(F4, "togglePopup"));
-        BUTTON_BINDINGS.add(new KeyBinding(UP, "togglePopup").alt());
-        BUTTON_BINDINGS.add(new KeyBinding(DOWN, "togglePopup").alt());
+        COMBO_BOX_BASE_BINDINGS.add(new KeyBinding(F4, "togglePopup"));
+        COMBO_BOX_BASE_BINDINGS.add(new KeyBinding(UP, "togglePopup").alt());
+        COMBO_BOX_BASE_BINDINGS.add(new KeyBinding(DOWN, "togglePopup").alt());
         
         if (Utils.isWindows()) {
-            BUTTON_BINDINGS.add(new KeyBinding(ENTER, KEY_PRESSED, PRESS_ACTION));
-            BUTTON_BINDINGS.add(new KeyBinding(ENTER, KEY_RELEASED, RELEASE_ACTION));
-            BUTTON_BINDINGS.add(new KeyBinding(SPACE, KEY_PRESSED, PRESS_ACTION));
-            BUTTON_BINDINGS.add(new KeyBinding(SPACE, KEY_RELEASED, RELEASE_ACTION));
+            COMBO_BOX_BASE_BINDINGS.add(new KeyBinding(ENTER, KEY_PRESSED, PRESS_ACTION));
+            COMBO_BOX_BASE_BINDINGS.add(new KeyBinding(ENTER, KEY_RELEASED, RELEASE_ACTION));
+            COMBO_BOX_BASE_BINDINGS.add(new KeyBinding(SPACE, KEY_PRESSED, PRESS_ACTION));
+            COMBO_BOX_BASE_BINDINGS.add(new KeyBinding(SPACE, KEY_RELEASED, RELEASE_ACTION));
         } else {
-            BUTTON_BINDINGS.add(new KeyBinding(SPACE, KEY_PRESSED, PRESS_ACTION));
-            BUTTON_BINDINGS.add(new KeyBinding(SPACE, KEY_RELEASED, RELEASE_ACTION));
+            COMBO_BOX_BASE_BINDINGS.add(new KeyBinding(SPACE, KEY_PRESSED, PRESS_ACTION));
+            COMBO_BOX_BASE_BINDINGS.add(new KeyBinding(SPACE, KEY_RELEASED, RELEASE_ACTION));
         }
         
-        BUTTON_BINDINGS.addAll(TRAVERSAL_BINDINGS);
+        COMBO_BOX_BASE_BINDINGS.addAll(TRAVERSAL_BINDINGS);
     }
 
     @Override protected List<KeyBinding> createKeyBindings() {
-        return BUTTON_BINDINGS;
+        return COMBO_BOX_BASE_BINDINGS;
     }
 
     @Override protected void callAction(String name) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/behavior/ComboBoxListViewBehavior.java	Thu Dec 01 08:01:11 2011 +1000
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2010, 2011, 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.behavior;
+
+import com.javafx.preview.control.ComboBox;
+import com.javafx.preview.control.ComboBoxBase;
+import javafx.beans.Observable;
+import static javafx.scene.input.KeyCode.*;
+import static javafx.scene.input.KeyEvent.*;
+
+import com.sun.javafx.Utils;
+
+import javafx.scene.input.MouseEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javafx.beans.InvalidationListener;
+import javafx.scene.control.SelectionModel;
+import javafx.scene.input.MouseButton;
+
+public class ComboBoxListViewBehavior<T> extends ComboBoxBaseBehavior<T> {
+
+    /***************************************************************************
+     *                                                                         *
+     * Constructors                                                            *
+     *                                                                         *
+     **************************************************************************/
+    
+    /**
+     * 
+     */
+    public ComboBoxListViewBehavior(final ComboBox<T> comboBox) {
+        super(comboBox);
+    }
+
+    /***************************************************************************
+     *                                                                         *
+     * Key event handling                                                      *
+     *                                                                         *
+     **************************************************************************/
+
+    protected static final List<KeyBinding> COMBO_BOX_BINDINGS = new ArrayList<KeyBinding>();
+    static {
+        COMBO_BOX_BINDINGS.add(new KeyBinding(UP, KEY_PRESSED, "selectPrevious"));
+        COMBO_BOX_BINDINGS.add(new KeyBinding(DOWN, "selectNext"));
+        COMBO_BOX_BINDINGS.addAll(COMBO_BOX_BASE_BINDINGS);
+    }
+
+    @Override protected List<KeyBinding> createKeyBindings() {
+        return COMBO_BOX_BINDINGS;
+    }
+
+    @Override protected void callAction(String name) {
+        if ("selectPrevious".equals(name)) {
+            selectPrevious();
+        } else if ("selectNext".equals(name)) {
+            selectNext();
+        } else {
+            super.callAction(name);
+        }
+    }
+    
+    private ComboBox<T> getComboBox() {
+        return (ComboBox<T>) getControl();
+    }
+
+    private void selectPrevious() {
+        SelectionModel sm = getComboBox().getSelectionModel();
+        if (sm == null) return;
+        sm.selectPrevious();
+    }
+    
+    private void selectNext() {
+        SelectionModel sm = getComboBox().getSelectionModel();
+        if (sm == null) return;
+        sm.selectNext();
+    }
+}
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxBaseSkin.java	Wed Nov 30 15:57:21 2011 -0500
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxBaseSkin.java	Thu Dec 01 08:01:11 2011 +1000
@@ -42,10 +42,10 @@
     protected StackPane arrowButton;
     protected StackPane arrow;
     
-    public ComboBoxBaseSkin(final ComboBoxBase<T> comboBox) {
+    public ComboBoxBaseSkin(final ComboBoxBase<T> comboBox, final ComboBoxBaseBehavior behavior) {
         // Call the super method with the button we were just given in the 
         // constructor, as well as an instance of the behavior class.
-        super(comboBox, new ComboBoxBaseBehavior(comboBox));
+        super(comboBox, behavior);//new ComboBoxBaseBehavior(comboBox));
         
         // open button / arrow
         arrow = new StackPane();
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java	Wed Nov 30 15:57:21 2011 -0500
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java	Thu Dec 01 08:01:11 2011 +1000
@@ -26,6 +26,7 @@
 package com.sun.javafx.scene.control.skin;
 
 import com.javafx.preview.control.ComboBox;
+import com.sun.javafx.scene.control.behavior.ComboBoxListViewBehavior;
 import javafx.beans.InvalidationListener;
 import javafx.beans.Observable;
 import javafx.beans.value.ChangeListener;
@@ -49,7 +50,7 @@
     private final ListView<T> listView;
     
     public ComboBoxListViewSkin(final ComboBox<T> comboBox) {
-        super(comboBox);
+        super(comboBox, new ComboBoxListViewBehavior<T>(comboBox));
         this.comboBox = comboBox;
         this.listView = createListView();
         
@@ -217,6 +218,11 @@
                 int index = listView.getSelectionModel().getSelectedIndex();
                 comboBox.getSelectionModel().select(index);
                 comboBox.setValue(listView.getSelectionModel().getSelectedItem());
+            }
+        });
+        
+        listView.addEventFilter(MouseEvent.MOUSE_RELEASED, new EventHandler<MouseEvent>() {
+            @Override public void handle(MouseEvent t) {
                 comboBox.hide();
             }
         });
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxPopupControl.java	Wed Nov 30 15:57:21 2011 -0500
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxPopupControl.java	Thu Dec 01 08:01:11 2011 +1000
@@ -26,6 +26,7 @@
 package com.sun.javafx.scene.control.skin;
 
 import com.javafx.preview.control.ComboBoxBase;
+import com.sun.javafx.scene.control.behavior.ComboBoxBaseBehavior;
 import javafx.event.Event;
 import javafx.event.EventHandler;
 import javafx.geometry.HPos;
@@ -40,8 +41,8 @@
     
     private PopupControl popup;
 
-    public ComboBoxPopupControl(ComboBoxBase<T> comboBox) {
-        super(comboBox);
+    public ComboBoxPopupControl(ComboBoxBase<T> comboBox, final ComboBoxBaseBehavior behavior) {
+        super(comboBox, behavior);
     }
     
     /**
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Wed Nov 30 15:57:21 2011 -0500
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Thu Dec 01 08:01:11 2011 +1000
@@ -325,6 +325,8 @@
     
     /* The color to use in ListView/TreeView/TableView to indicate hover. */
     -fx-cell-hover-color: #cce3f4;
+    
+    -fx-cell-focus-inner-border: #85b9de;
 }
 
 .mnemonic-underline {
@@ -1696,19 +1698,19 @@
 }
 
 .list-view:focused .list-cell:focused {
-    -fx-background-color: -fx-focus-color, -fx-control-inner-background;
-    -fx-background-insets: 0, 1.4;
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-control-inner-background;
+    -fx-background-insets: 0, 1, 2;
 }
 
 .list-view:focused .list-cell:focused:odd {
-    -fx-background-color: -fx-focus-color, derive(-fx-control-inner-background,-5%);
-    -fx-background-insets: 0, 1.4;
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, derive(-fx-control-inner-background,-5%);
+    -fx-background-insets: 0, 1, 2;
 }
 
 /* When the list-cell is selected and focused */
 .list-view:focused .list-cell:filled:focused:selected {
-    -fx-background-color: -fx-focus-color, -fx-selection-bar;
-    -fx-background-insets: 0, 1.4;
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
+    -fx-background-insets: 0, 1, 2;
     -fx-background: -fx-accent;
     -fx-text-fill: -fx-selection-bar-text;
 }
@@ -1721,8 +1723,8 @@
 
 .list-view:focused .list-cell:filled:focused:selected:hover {
     -fx-background: -fx-accent;
-    -fx-background-color: -fx-focus-color, -fx-selection-bar;
-    -fx-background-insets: 0, 1.4;
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
+    -fx-background-insets: 0, 1, 2;
     -fx-text-fill: -fx-selection-bar-text;
 }
 
@@ -1742,8 +1744,8 @@
 }
 
 .list-view:focused .list-cell:filled:focused:hover {
-    -fx-background-color: -fx-focus-color, -fx-cell-hover-color;
-    -fx-background-insets: 0, 1.4;
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-cell-hover-color;
+    -fx-background-insets: 0, 1, 2;
     -fx-text-fill: -fx-text-inner-color;
 }
 
@@ -1809,28 +1811,33 @@
     -fx-padding: 0.0em 0.0em 0.0em 0.25em; /* 0 0 0 3 */
 }
 
-.tree-cell:focused {
-    -fx-background-color: -fx-focus-color, -fx-control-inner-background;
-    -fx-background-insets: 0, 1.4;
-}
-
-/*
-.tree-cell:odd {
-    -fx-background-color: derive(-fx-control-inner-background,-5%);
-}
-
-.tree-cell:focused:odd {
-    -fx-background-color: -fx-focus-color, derive(-fx-control-inner-background,-5%);
-    -fx-background-insets: 0, 1.4;
-}
-*/
-
-.tree-view:focused .tree-cell:filled:selected:focused, .tree-view:focused .tree-cell:filled:selected, .tree-view:focused .tree-cell:filled:selected:hover {
+
+
+.tree-view:focused .tree-cell:focused {
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-control-inner-background;
+    -fx-background-insets: 0, 1, 2;
+}
+
+.tree-view:focused .tree-cell:filled:focused:selected {
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
+    -fx-background-insets: 0, 1, 2;
+    -fx-background: -fx-accent;
+    -fx-text-fill: -fx-selection-bar-text;
+}
+
+.tree-view:focused .tree-cell:filled:selected, .tree-view:focused .tree-cell:filled:selected:hover {
     -fx-background: -fx-accent;
     -fx-background-color: -fx-selection-bar;
     -fx-text-fill: -fx-selection-bar-text;
 }
 
+.tree-view:focused .tree-cell:filled:focused:selected:hover {
+    -fx-background: -fx-accent;
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
+    -fx-background-insets: 0, 1, 2;
+    -fx-text-fill: -fx-selection-bar-text;
+}
+
 /* When the TreeView is _not_ focused, we show alternate selection colors */
 .tree-cell:filled:selected:focused, .tree-cell:filled:selected {
     -fx-background-color: lightgray;
@@ -1874,6 +1881,12 @@
     -fx-background-color: -fx-mark-color;
 }
 
+.tree-view:focused .tree-cell:filled:focused:hover {
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-cell-hover-color;
+    -fx-background-insets: 0, 1, 2;
+    -fx-text-fill: -fx-text-inner-color;
+}
+
 .tree-cell:filled:selected:hover .tree-disclosure-node .arrow {
     -fx-background-color: -fx-selection-bar-text;
 }
@@ -2286,12 +2299,37 @@
     -fx-background-insets: 0, 0 0 1 0;
 }
 
-.table-view:focused .table-row-cell:selected:focused, .table-view:focused .table-row-cell:selected, .table-view:row-selection .table-row-cell:filled:hover:selected {
+.table-row-cell:focused {
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-control-inner-background;
+    -fx-background-insets: 0, 1, 2;
+}
+
+.table-row-cell:focused:odd {
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, derive(-fx-control-inner-background,-5%);
+    -fx-background-insets: 0, 1, 2;
+}
+
+/* When the table-row-cell is selected and focused */
+.table-view:focused .table-row-cell:filled:focused:selected {
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
+    -fx-background-insets: 0, 1, 2;
+    -fx-background: -fx-accent;
+    -fx-text-fill: -fx-selection-bar-text;
+}
+
+.table-view:focused .table-row-cell:filled:selected, .table-view:row-selection .table-row-cell:filled:hover:selected {
     -fx-background: -fx-accent;
     -fx-background-color: -fx-selection-bar;
     -fx-text-fill: -fx-selection-bar-text;
 }
 
+.table-view:focused .table-row-cell:filled:focused:selected:hover {
+    -fx-background: -fx-accent;
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
+    -fx-background-insets: 0, 1, 2;
+    -fx-text-fill: -fx-selection-bar-text;
+}
+
 /* When the TableView is _not_ focused, we show alternate selection colors */
 .table-row-cell:filled:selected:focused, .table-row-cell:filled:selected {
     -fx-background-color: lightgray;
@@ -2302,17 +2340,18 @@
     -fx-opacity: -fx-disabled-opacity;
 }
 
-.table-row-cell:focused {
-    -fx-background-color: -fx-focus-color, -fx-control-inner-background;
-    -fx-background-insets: 0, 1.4;
-}
-
 .table-view:row-selection .table-row-cell:filled:hover { 
     -fx-background-color: -fx-table-cell-border-color, -fx-cell-hover-color;
     -fx-background-insets: 0, 0 0 1 0;
     -fx-text-fill: -fx-text-inner-color;
 }
 
+.table-view:row-selection .table-row-cell:filled:focused:hover { 
+    -fx-background-color: -fx-table-cell-border-color, -fx-focus-color, -fx-cell-focus-inner-border, -fx-cell-hover-color;
+    -fx-background-insets: 0, 0 0 1 0, 1 1 2 1, 2 2 3 2, 3 3 4 3;
+    -fx-text-fill: -fx-text-inner-color;
+}
+
 .table-cell {
     -fx-skin: "com.sun.javafx.scene.control.skin.TableCellSkin";
     -fx-padding: 0.166667em; /* 2px, plus border adds 1px */
@@ -2343,12 +2382,31 @@
     -fx-border-insets: 0 1 1 1, 0 0 0 0;
 }
 
-.table-view:focused .table-cell:selected:focused, .table-view:focused .table-cell:selected, .table-view:cell-selection .table-cell:filled:hover:selected {
+.table-view:focused .table-cell:focused {
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-control-inner-background;
+    -fx-background-insets: 0 1 0 0, 1 2 1 1, 2 3 2 2;
+}
+
+.table-view:focused .table-cell:filled:focused:selected {
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
+    -fx-background-insets: 0 1 0 0, 1 2 1 1, 2 3 2 2;
+    -fx-background: -fx-accent;
+    -fx-text-fill: -fx-selection-bar-text;
+}
+
+.table-view:focused .table-cell:filled:selected, .table-view:cell-selection .table-cell:filled:hover:selected {
     -fx-background: -fx-accent;
     -fx-background-color: -fx-selection-bar;
     -fx-text-fill: -fx-selection-bar-text;
 }
 
+.table-view:focused .table-cell:filled:focused:selected:hover {
+    -fx-background: -fx-accent;
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
+    -fx-background-insets: 0 1 0 0, 1 2 1 1, 2 3 2 2;
+    -fx-text-fill: -fx-selection-bar-text;
+}
+
 /* When the TableView is _not_ focused, we show alternate selection colors */
 .table-cell:filled:selected:focused, .table-cell:filled:selected {
     -fx-background-color: lightgray;
@@ -2359,16 +2417,22 @@
     -fx-opacity: -fx-disabled-opacity;
 }
 
-.table-cell:focused {
+/*.table-cell:focused {
     -fx-background-color: -fx-focus-color, -fx-control-inner-background;
     -fx-background-insets: 0, 1.4;
-}
+}*/
 
 .table-view:cell-selection .table-cell:filled:hover {
     -fx-background-color: -fx-cell-hover-color;
     -fx-text-fill: -fx-text-inner-color;
 }
 
+.table-view:cell-selection .table-cell:filled:focused:hover {
+    -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-cell-hover-color;
+    -fx-background-insets: 0 1 0 0, 1 2 1 1, 2 3 2 2;
+    -fx-text-fill: -fx-text-inner-color;
+}
+
 /* The column-resize-line is shown when the user is attempting to resize a column. */
 .table-view .column-resize-line {
     -fx-background: -fx-accent;