1 11 package org.eclipse.ui.internal.part.multiplexer; 12 13 import org.eclipse.swt.widgets.Composite; 14 import org.eclipse.ui.IWorkbenchPage; 15 import org.eclipse.ui.internal.components.ComponentUtil; 16 import org.eclipse.ui.internal.components.framework.ComponentException; 17 import org.eclipse.ui.internal.components.framework.Container; 18 import org.eclipse.ui.internal.components.framework.FactoryMap; 19 import org.eclipse.ui.internal.components.framework.IDisposable; 20 import org.eclipse.ui.internal.components.framework.IServiceProvider; 21 import org.eclipse.ui.internal.components.framework.ServiceFactory; 22 import org.eclipse.ui.internal.part.IWorkbenchScopeConstants; 23 import org.osgi.framework.Bundle; 24 25 30 public class SiteServices implements IServiceProvider, IDisposable { 31 32 private ServiceFactory args; 33 private Container container; 34 35 private static FactoryMap createContext(ServiceFactory args) { 36 return new FactoryMap() 37 .add(args) 38 .add(ComponentUtil.getContext(IWorkbenchScopeConstants.SITE_SCOPE)) 39 .add(ComponentUtil.getContext(IWorkbenchScopeConstants.PLUGIN_SCOPE)); 40 } 41 42 47 public SiteServices(ServiceFactory args) { 48 container = new Container(createContext(args)); 49 } 50 51 59 public SiteServices(Composite composite, Bundle pluginBundle, IWorkbenchPage page, ServiceFactory args) { 60 container = new Container(createContext(args) 61 .mapInstance(Composite.class, composite) 62 .mapInstance(Bundle.class, pluginBundle) 63 .mapInstance(IWorkbenchPage.class, page)); 64 } 65 66 69 public Object getService(Object key) throws ComponentException { 70 return container.getService(key); 71 } 72 73 76 public boolean hasService(Object key) { 77 return container.hasService(key); 78 } 79 80 83 public void dispose() { 84 container.dispose(); 85 } 86 87 } 88 | Popular Tags |