Example #1
0
 /**
  * Recursively find the menu item for a menu shortcut
  *
  * @param ms - the shortcut
  * @return the menu item; or null if the item is not available for this shortcut
  */
 MenuItem getShortcutMenuItemImpl(MenuShortcut ms) {
   if (ms == null) {
     return null;
   }
   for (int i = 0; i < getItemCount(); i++) {
     MenuItem mi = getItem(i);
     if (mi instanceof Menu) {
       mi = ((Menu) mi).getShortcutMenuItemImpl(ms);
       if (mi != null) {
         return mi;
       }
     } else if (ms.equals(mi.getShortcut())) {
       return mi;
     }
   }
   return null;
 }
Example #2
0
 /**
  * Change the selected item to the next one in the requested direction moving cyclically, skipping
  * separators
  *
  * @param forward - the direction to move the selection
  * @param showSubMenu - if new selected item has a sub-menu, should that sub-menu be displayed
  */
 void selectNextItem(boolean forward, boolean showSubMenu) {
   int selected = getSelectedItemIndex();
   int count = getItemCount();
   if (count == 0) {
     return;
   }
   if (selected < 0) {
     selected = (forward ? count - 1 : 0);
   }
   int i = selected;
   do {
     i = (forward ? (i + 1) : (i + count - 1)) % count;
     i %= count;
     MenuItem item = getItem(i);
     if (!"-".equals(item.getLabel())) { // $NON-NLS-1$
       selectItem(i, showSubMenu);
       return;
     }
   } while (i != selected);
 }
Example #3
0
 /**
  * Post the ActionEvent or ItemEvent, depending on type of the menu item.
  *
  * @param item - the index of menu item
  * @param when - event time
  * @param modifiers - input event modifiers
  */
 void fireItemAction(int item, long when, int modifiers) {
   MenuItem mi = getItem(item);
   mi.itemSelected(when, modifiers);
 }