1 11 package org.eclipse.ui.internal; 12 13 import org.eclipse.jface.action.IContributionItem; 14 import org.eclipse.jface.action.IMenuManager; 15 import org.eclipse.jface.action.SubContributionItem; 16 import org.eclipse.jface.action.SubMenuManager; 17 18 22 public class ActionSetMenuManager extends SubMenuManager { 23 private String actionSetId; 24 25 28 public ActionSetMenuManager(IMenuManager mgr, String actionSetId) { 29 super(mgr); 30 this.actionSetId = actionSetId; 31 } 32 33 40 public IContributionItem find(String id) { 41 IContributionItem item = getParentMenuManager().find(id); 42 if (item instanceof SubContributionItem) { 43 item = unwrap(item); 45 } 46 47 if (item instanceof IMenuManager) { 48 IMenuManager menu = (IMenuManager) item; 50 if (menu instanceof SubMenuManager) { 51 menu = (IMenuManager) ((SubMenuManager) menu).getParent(); 55 } 56 item = getWrapper(menu); 57 } 58 59 return item; 60 } 61 62 65 public IContributionItem[] getItems() { 66 return getParentMenuManager().getItems(); 67 } 68 69 72 protected SubContributionItem wrap(IContributionItem item) { 73 return new ActionSetContributionItem(item, actionSetId); 74 } 75 76 79 protected SubMenuManager wrapMenu(IMenuManager menu) { 80 return new ActionSetMenuManager(menu, actionSetId); 81 } 82 } 83 | Popular Tags |