1 11 12 package org.eclipse.ui.internal.menus; 13 14 import java.util.List ; 15 16 import org.eclipse.core.expressions.Expression; 17 import org.eclipse.core.expressions.IEvaluationContext; 18 import org.eclipse.jface.action.ContributionManager; 19 import org.eclipse.jface.action.IContributionItem; 20 import org.eclipse.ui.ISourceProvider; 21 import org.eclipse.ui.IWorkbenchWindow; 22 import org.eclipse.ui.internal.expressions.WorkbenchWindowExpression; 23 import org.eclipse.ui.menus.AbstractContributionFactory; 24 import org.eclipse.ui.menus.IMenuService; 25 import org.eclipse.ui.services.IServiceLocator; 26 27 39 public final class WindowMenuService extends InternalMenuService { 40 41 45 private final WorkbenchMenuService parent; 46 private IServiceLocator serviceLocator; 47 private Expression restrictionExpression; 48 49 58 public WindowMenuService(final IServiceLocator serviceLocator) { 59 IMenuService menuService = (IMenuService) serviceLocator 60 .getService(IMenuService.class); 61 if (menuService == null 62 || !(menuService instanceof WorkbenchMenuService)) { 63 throw new NullPointerException ( 64 "The parent service must not be null"); } 66 IWorkbenchWindow window = (IWorkbenchWindow) serviceLocator 67 .getService(IWorkbenchWindow.class); 68 if (window == null) 69 throw new NullPointerException ("Window cannot be null"); 71 restrictionExpression = new WorkbenchWindowExpression(window); 72 73 this.parent = (WorkbenchMenuService) menuService; 74 this.serviceLocator = serviceLocator; 75 } 76 77 83 public void populateContributionManager(ContributionManager mgr, String uri) { 84 parent.populateContributionManager(serviceLocator, 85 restrictionExpression, mgr, uri, true); 86 } 87 88 public void populateContributionManager(ContributionManager mgr, 89 String uri, boolean recurse) { 90 parent.populateContributionManager(serviceLocator, 91 restrictionExpression, mgr, uri, recurse); 92 } 93 94 99 public IEvaluationContext getCurrentState() { 100 return parent.getCurrentState(); 101 } 102 103 109 public void addContributionFactory(AbstractContributionFactory cache) { 110 parent.addContributionFactory(cache); 111 } 112 113 118 public void releaseContributions(ContributionManager mgr) { 119 parent.releaseContributions(mgr); 120 } 121 122 127 public void removeContributionFactory(AbstractContributionFactory factory) { 128 parent.removeContributionFactory(factory); 129 } 130 131 136 public void dispose() { 137 } 138 139 144 public void addSourceProvider(ISourceProvider provider) { 145 throw new RuntimeException ("addSourceProvider"); } 147 148 153 public void removeSourceProvider(ISourceProvider provider) { 154 throw new RuntimeException ("removeSourceProvider"); } 156 157 public List getAdditionsForURI(MenuLocationURI uri) { 158 return parent.getAdditionsForURI(uri); 159 } 160 161 public void registerVisibleWhen(final IContributionItem item, 162 final Expression visibleWhen, final Expression restriction, 163 String identifierID) { 164 parent 165 .registerVisibleWhen(item, visibleWhen, restriction, 166 identifierID); 167 } 168 169 public void unregisterVisibleWhen(IContributionItem item) { 170 parent.unregisterVisibleWhen(item); 171 } 172 } 173 | Popular Tags |