changeset 1054:c6d0fedcdca2

RT-19709 API to enable accelerators lazily - finish implementation for mac menu.
author Paru Somashekar <paru.somashekar@oracle.com>
date Wed, 16 May 2012 00:55:20 -0700
parents 0e266969dcbf
children 3f79febcea11
files javafx-ui-common/src/com/sun/javafx/menu/MenuItemBase.java javafx-ui-controls/src/com/sun/javafx/scene/control/GlobalMenuAdapter.java
diffstat 2 files changed, 78 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/com/sun/javafx/menu/MenuItemBase.java	Wed May 16 11:37:44 2012 +1200
+++ b/javafx-ui-common/src/com/sun/javafx/menu/MenuItemBase.java	Wed May 16 00:55:20 2012 -0700
@@ -116,5 +116,10 @@
      * Fires a new ActionEvent.
      */
     public void fire();
+    
+    /**
+     * Fires when the accelerator for this MenuItem is invoked.
+     */
+    public void fireValidation();
 
 }
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/GlobalMenuAdapter.java	Wed May 16 11:37:44 2012 +1200
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/GlobalMenuAdapter.java	Wed May 16 00:55:20 2012 -0700
@@ -161,6 +161,19 @@
         });
     }
 
+    @Override
+    public void fireValidation() {
+        if (menu.getOnMenuValidation() != null) {
+            Event.fireEvent(menu, new Event(GlobalMenuAdapter.this.MENU_VALIDATION_EVENT));
+        }
+        Menu target = (Menu)menu.getParentMenu();
+        if(target != null && target.getOnMenuValidation() != null) {
+            Event.fireEvent(target, new Event(target.MENU_VALIDATION_EVENT));
+        }
+        if (!menu.isDisable()) menu.fire();
+        
+    }
+
 
     private class MenuItemAdapter extends MenuItem implements MenuItemBase {
         private MenuItem menuItem;
@@ -173,6 +186,18 @@
             bindMenuItemProperties(this, menuItem);
         }
 
+        @Override
+        public void fireValidation() {
+            if (menuItem.getOnMenuValidation() != null) {
+                Event.fireEvent(menuItem, new Event(menuItem.MENU_VALIDATION_EVENT));
+            }
+            Menu target = (Menu)menuItem.getParentMenu();
+            if(target.getOnMenuValidation() != null) {
+                Event.fireEvent(target, new Event(target.MENU_VALIDATION_EVENT));
+            }
+            if (!menuItem.isDisable()) menuItem.fire();
+        }
+
     }
 
     private class CheckMenuItemAdapter extends CheckMenuItem implements CheckMenuItemBase {
@@ -180,7 +205,6 @@
 
         private CheckMenuItemAdapter(final CheckMenuItem menuItem) {
             super(menuItem.getText());
-
             this.menuItem = menuItem;
 
             bindMenuItemProperties(this, menuItem);
@@ -188,6 +212,18 @@
             selectedProperty().bindBidirectional(menuItem.selectedProperty());
         }
 
+        @Override
+        public void fireValidation() {
+            if (getOnMenuValidation() != null) {
+                Event.fireEvent(menuItem, new Event(CheckMenuItemAdapter.this.MENU_VALIDATION_EVENT));
+            }
+            Menu target = (Menu)menuItem.getParentMenu();
+            if(target.getOnMenuValidation() != null) {
+                Event.fireEvent(target, new Event(target.MENU_VALIDATION_EVENT));
+            }
+            if (!menuItem.isDisable()) menuItem.fire();
+        }
+
     }
 
     private class RadioMenuItemAdapter extends RadioMenuItem implements RadioMenuItemBase {
@@ -203,6 +239,18 @@
             selectedProperty().bindBidirectional(menuItem.selectedProperty());
         }
 
+        @Override
+        public void fireValidation() {
+            if (getOnMenuValidation() != null) {
+                Event.fireEvent(menuItem, new Event(RadioMenuItemAdapter.this.MENU_VALIDATION_EVENT));
+            }
+            Menu target = (Menu)menuItem.getParentMenu();
+            if(target.getOnMenuValidation() != null) {
+                Event.fireEvent(target, new Event(target.MENU_VALIDATION_EVENT));
+            }
+            if (!menuItem.isDisable()) menuItem.fire();
+        }
+
     }
 
     private class SeparatorMenuItemAdapter extends SeparatorMenuItem implements SeparatorMenuItemBase {
@@ -214,6 +262,18 @@
             bindMenuItemProperties(this, menuItem);
         }
 
+        @Override
+        public void fireValidation() {
+            if (getOnMenuValidation() != null) {
+                Event.fireEvent(menuItem, new Event(SeparatorMenuItemAdapter.this.MENU_VALIDATION_EVENT));
+            }
+            Menu target = (Menu)menuItem.getParentMenu();
+            if(target.getOnMenuValidation() != null) {
+                Event.fireEvent(target, new Event(target.MENU_VALIDATION_EVENT));
+            }
+            if (!menuItem.isDisable()) menuItem.fire();
+        }
+
     }
 
     private class CustomMenuItemAdapter extends CustomMenuItem implements CustomMenuItemBase {
@@ -225,5 +285,17 @@
             bindMenuItemProperties(this, menuItem);
         }
 
+        @Override
+        public void fireValidation() {
+            if (getOnMenuValidation() != null) {
+                Event.fireEvent(menuItem, new Event(CustomMenuItemAdapter.this.MENU_VALIDATION_EVENT));
+            }
+            Menu target = (Menu)menuItem.getParentMenu();
+            if(target.getOnMenuValidation() != null) {
+                Event.fireEvent(target, new Event(target.MENU_VALIDATION_EVENT));
+            }
+            if (!menuItem.isDisable()) menuItem.fire();
+        }
+
     }
 }