changeset 1314:49d2f59fb14e

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/2.2/scrum/controls/jfx/rt
author jgiles
date Fri, 15 Jun 2012 15:05:36 +1200
parents 217cede187d0 0f2fba17c263
children 109bddc14dde
files
diffstat 7 files changed, 154 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ContextMenuContent.java	Thu Jun 14 16:24:06 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ContextMenuContent.java	Fri Jun 15 15:05:36 2012 +1200
@@ -130,8 +130,8 @@
         setUpBinds();
     }
     
-       //For testing purpose only
-    VBox getItemsContainer() {
+    //For access from controls
+    public VBox getItemsContainer() {
         return itemsContainer;
     }
     //For testing purpose only
@@ -198,7 +198,7 @@
             }
         }
     }
-
+    
     private void updateVisualItems() {
         itemsContainer.getChildren().clear();
         for (int row = 0; row < getItems().size(); row++) {
@@ -981,7 +981,7 @@
      * words, this contains and lays out a single MenuItem, regardless of it's 
      * specific subtype.
      */
-    class MenuItemContainer extends Pane {
+    public class MenuItemContainer extends Pane {
 
         private final MenuItem item;
 
@@ -994,7 +994,7 @@
             return (Label) label;
         }
         
-        protected MenuItem getItem() {
+        public MenuItem getItem() {
             return item;
         }
 
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/NestedTableColumnHeader.java	Thu Jun 14 16:24:06 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/NestedTableColumnHeader.java	Fri Jun 15 15:05:36 2012 +1200
@@ -51,7 +51,7 @@
  * TableHeaderRow class consists of just one instance of a NestedTableColumnHeader.
  *
  */
-class NestedTableColumnHeader extends TableColumnHeader {
+public class NestedTableColumnHeader extends TableColumnHeader {
     
     /***************************************************************************
      *                                                                         *
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableHeaderRow.java	Thu Jun 14 16:24:06 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableHeaderRow.java	Fri Jun 15 15:05:36 2012 +1200
@@ -58,7 +58,7 @@
 /**
  * Region responsible for painting the entire row of column headers.
  */
-class TableHeaderRow extends StackPane {
+public class TableHeaderRow extends StackPane {
     
     private static final String MENU_SEPARATOR = 
             ControlResources.getString("TableView.nestedColumnControlMenuSeparator");
@@ -157,6 +157,10 @@
      * at that level.
      */
     private final NestedTableColumnHeader header;
+    
+    public NestedTableColumnHeader getRootHeader() {
+        return header;
+    }
 
     private Region filler;
 
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkin.java	Thu Jun 14 16:24:06 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkin.java	Fri Jun 15 15:05:36 2012 +1200
@@ -311,7 +311,14 @@
      *                                                                         *
      * Public API                                                              *
      *                                                                         *
-     **************************************************************************/    
+     **************************************************************************/  
+    
+    /**
+     * 
+     */
+    public TableHeaderRow getTableHeaderRow() {
+        return tableHeaderRow;
+    }
     
     /** {@inheritDoc} */
     @Override public int getItemCount() {
--- a/javafx-ui-controls/src/javafx/scene/control/MenuItem.java	Thu Jun 14 16:24:06 2012 -0700
+++ b/javafx-ui-controls/src/javafx/scene/control/MenuItem.java	Fri Jun 15 15:05:36 2012 +1200
@@ -47,12 +47,16 @@
 import javafx.scene.input.KeyCombination;
 
 import com.sun.javafx.event.EventHandlerManager;
+import com.sun.javafx.scene.control.skin.ContextMenuContent;
+import com.sun.javafx.scene.control.skin.ContextMenuSkin;
+import com.sun.webpane.platform.ContextMenuItem;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import javafx.beans.property.ReadOnlyObjectProperty;
 import javafx.beans.property.ReadOnlyObjectWrapper;
 import javafx.collections.ObservableMap;
+import javafx.scene.Parent;
 
 /**
  * <p>
@@ -572,13 +576,16 @@
 
                 @Override
                 public Styleable getStyleableParent() {
-                    if(MenuItem.this.getParentMenu() == null) {
-                        return MenuItem.this.getParentPopup() != null 
-                            ? MenuItem.this.getParentPopup().impl_getStyleable()
+                    Menu parentMenu = MenuItem.this.getParentMenu();
+                    ContextMenu parentPopup = MenuItem.this.getParentPopup();
+                    
+                    if(parentMenu == null) {
+                        return parentPopup != null 
+                            ? parentPopup.impl_getStyleable()
                             : null;
                     } else {
-                        return MenuItem.this.getParentMenu() != null 
-                            ? MenuItem.this.getParentMenu().impl_getStyleable()
+                        return parentMenu != null 
+                            ? parentMenu.impl_getStyleable()
                             : null;
                     }
                 }
@@ -591,6 +598,30 @@
 
                 @Override
                 public Node getNode() {
+                    // Fix for RT-20582. We dive into the visual representation
+                    // of this MenuItem so that we may return it to the caller.
+                    ContextMenu parentPopup = MenuItem.this.getParentPopup();
+                    if (! (parentPopup.getSkin() instanceof ContextMenuSkin)) return null;
+                    
+                    ContextMenuSkin skin = (ContextMenuSkin) parentPopup.getSkin();
+                    if (! (skin.getNode() instanceof ContextMenuContent)) return null;
+                    
+                    ContextMenuContent content = (ContextMenuContent) skin.getNode();
+                    Parent nodes = content.getItemsContainer();
+                    
+                    MenuItem desiredMenuItem = MenuItem.this;
+                    List<Node> childrenNodes = nodes.getChildrenUnmodifiable();
+                    for (int i = 0; i < childrenNodes.size(); i++) {
+                        if (! (childrenNodes.get(i) instanceof ContextMenuContent.MenuItemContainer)) continue;
+                        
+                        ContextMenuContent.MenuItemContainer MenuRow = 
+                                (ContextMenuContent.MenuItemContainer) childrenNodes.get(i);
+                        
+                        if (desiredMenuItem.equals(MenuRow.getItem())) {
+                            return MenuRow;
+                        }
+                    }
+                    
                     return null;
                 }
 
--- a/javafx-ui-controls/src/javafx/scene/control/Tab.java	Thu Jun 14 16:24:06 2012 -0700
+++ b/javafx-ui-controls/src/javafx/scene/control/Tab.java	Fri Jun 15 15:05:36 2012 +1200
@@ -681,7 +681,14 @@
 
     private static final String DEFAULT_STYLE_CLASS = "tab";
     
+    /**
+     * RT-19263
+     * @treatAsPrivate implementation detail
+     * @deprecated This is an experimental API that is not intended for general 
+     * use and is subject to change in future versions
+     */
     protected Styleable styleable; 
+    
     /**
      * RT-19263
      * @treatAsPrivate implementation detail
--- a/javafx-ui-controls/src/javafx/scene/control/TableColumn.java	Thu Jun 14 16:24:06 2012 -0700
+++ b/javafx-ui-controls/src/javafx/scene/control/TableColumn.java	Fri Jun 15 15:05:36 2012 +1200
@@ -24,6 +24,8 @@
  */
 package javafx.scene.control;
 
+import com.sun.javafx.css.Styleable;
+import com.sun.javafx.css.StyleableProperty;
 import java.text.Collator;
 import java.util.Comparator;
 import javafx.beans.Observable;
@@ -52,6 +54,8 @@
 import com.sun.javafx.scene.control.skin.Utils;
 import com.sun.javafx.event.EventHandlerManager;
 import com.sun.javafx.scene.control.WeakListChangeListener;
+import com.sun.javafx.scene.control.skin.*;
+import java.util.Collections;
 import java.util.HashMap;
 
 import java.util.List;
@@ -269,6 +273,8 @@
      * onEditCommit implementation.
      */
     public TableColumn() {
+        getStyleClass().add(DEFAULT_STYLE_CLASS);
+        
         setOnEditCommit(DEFAULT_EDIT_COMMIT_HANDLER);
 
         // we listen to the columns list here to ensure that widths are
@@ -1221,6 +1227,7 @@
     }
 
     
+    
     /***************************************************************************
      *                                                                         *
      * Private Implementation                                                  *
@@ -1237,7 +1244,92 @@
     }
 
 
+    
+    /***************************************************************************
+     *                                                                         *
+     * Stylesheet Handling                                                     *
+     *                                                                         *
+     **************************************************************************/
 
+    private static final String DEFAULT_STYLE_CLASS = "table-column";
+
+    /**
+     * RT-19263
+     * @treatAsPrivate implementation detail
+     * @deprecated This is an experimental API that is not intended for general 
+     * use and is subject to change in future versions
+     */
+    protected Styleable styleable; 
+        
+    @Deprecated // SB-dependency: RT-21094 has been filed to track this
+    public Styleable impl_getStyleable() {
+        
+        if (styleable == null) {
+            styleable = new Styleable() {
+
+                @Override
+                public String getId() {
+                    return TableColumn.this.getId();
+                }
+
+                @Override
+                public List<String> getStyleClass() {
+                    return TableColumn.this.getStyleClass();
+                }
+
+                @Override
+                public String getStyle() {
+                    return TableColumn.this.getStyle();
+                }
+
+                @Override
+                public Styleable getStyleableParent() {
+                    return getTableView() == null ? null : getTableView().impl_getStyleable();
+                }
+
+                
+                @Override
+                public List<StyleableProperty> getStyleableProperties() {
+                    return Collections.EMPTY_LIST;
+                }                
+
+                @Override
+                public Node getNode() {
+                    if (! (getTableView().getSkin() instanceof TableViewSkin)) return null;
+                    TableViewSkin skin = (TableViewSkin) getTableView().getSkin();
+                    
+                    TableHeaderRow tableHeader = skin.getTableHeaderRow();
+                    NestedTableColumnHeader rootHeader = tableHeader.getRootHeader();
+                    
+                    // we now need to do a search for the header. We'll go depth-first.
+                    return scan(rootHeader);
+                }
+                
+                private TableColumnHeader scan(TableColumnHeader header) {
+                    // firstly test that the parent isn't what we are looking for
+                    if (TableColumn.this.equals(header.getTableColumn())) {
+                        return header;
+                    }
+                    
+                    if (header instanceof NestedTableColumnHeader) {
+                        NestedTableColumnHeader parent = (NestedTableColumnHeader) header;
+                        for (int i = 0; i < parent.getColumnHeaders().size(); i++) {
+                            TableColumnHeader result = scan(parent.getColumnHeaders().get(i));
+                            if (result != null) {
+                                return result;
+                            }
+                        }
+                    }
+                    
+                    return null;
+                }
+            };
+        }
+        return styleable;
+    }   
+    
+    
+    
     /***************************************************************************
      *                                                                         *
      * Support Interfaces                                                      *