use of org.eclipse.ui.internal.services.WorkbenchLocationService in project eclipse.platform.ui by eclipse-platform.
the class WorkbenchWindow method initializeDefaultServices.
/**
* Initializes all of the default command-based services for the workbench
* window.
*/
private final void initializeDefaultServices() {
IEclipseContext windowContext = model.getContext();
serviceLocator.registerService(IWorkbenchLocationService.class, new WorkbenchLocationService(IServiceScopes.WINDOW_SCOPE, getWorkbench(), this, null, null, null, 1));
// added back for legacy reasons
serviceLocator.registerService(IWorkbenchWindow.class, this);
final ActionCommandMappingService mappingService = new ActionCommandMappingService();
serviceLocator.registerService(IActionCommandMappingService.class, mappingService);
selectionService = ContextInjectionFactory.make(SelectionService.class, model.getContext());
serviceLocator.registerService(ISelectionService.class, selectionService);
LegacyHandlerService hs = new LegacyHandlerService(windowContext);
windowContext.set(IHandlerService.class.getName(), hs);
final LegacyActionPersistence actionPersistence = new LegacyActionPersistence(this);
serviceLocator.registerService(LegacyActionPersistence.class, actionPersistence);
actionPersistence.read();
ICommandService cmdService = workbench.getService(ICommandService.class);
SlaveCommandService slaveCmdService = new SlaveCommandService(cmdService, IServiceScopes.WINDOW_SCOPE, this, model.getContext());
serviceLocator.registerService(ICommandService.class, slaveCmdService);
serviceLocator.registerService(IUpdateService.class, slaveCmdService);
IContextService cxs = ContextInjectionFactory.make(ContextService.class, model.getContext());
serviceLocator.registerService(IContextService.class, cxs);
IMenuService parent = getWorkbench().getService(IMenuService.class);
IMenuService msvs = new SlaveMenuService(parent, model);
serviceLocator.registerService(IMenuService.class, msvs);
}
use of org.eclipse.ui.internal.services.WorkbenchLocationService in project eclipse.platform.ui by eclipse-platform.
the class PartSite method initializeDefaultServices.
/**
* Initialize the local services.
*/
private void initializeDefaultServices() {
IHandlerService handlerService = new LegacyHandlerService(e4Context, new ActivePartExpression(part));
e4Context.set(IHandlerService.class, handlerService);
serviceLocator.registerService(IWorkbenchLocationService.class, new WorkbenchLocationService(IServiceScopes.PARTSITE_SCOPE, getWorkbenchWindow().getWorkbench(), getWorkbenchWindow(), this, null, null, 2));
// added back for legacy reasons
serviceLocator.registerService(IWorkbenchPartSite.class, this);
serviceLocator.registerService(IWorkbenchPart.class, getPart());
e4Context.set(IWorkbenchSiteProgressService.class.getName(), new ContextFunction() {
@Override
public Object compute(IEclipseContext context, String contextKey) {
if (progressService == null) {
progressService = new WorkbenchSiteProgressService(PartSite.this);
}
return progressService;
}
});
e4Context.set(IProgressService.class.getName(), new ContextFunction() {
@Override
public Object compute(IEclipseContext context, String contextKey) {
if (progressService == null) {
progressService = new WorkbenchSiteProgressService(PartSite.this);
}
return progressService;
}
});
e4Context.set(IKeyBindingService.class.getName(), new ContextFunction() {
@Override
public Object compute(IEclipseContext context, String contextKey) {
if (keyBindingService == null) {
keyBindingService = new KeyBindingService(PartSite.this);
}
return keyBindingService;
}
});
e4Context.set(IPageService.class.getName(), new ContextFunction() {
@Override
public Object compute(IEclipseContext context, String contextKey) {
if (pageService == null) {
pageService = new SlavePageService(context.getParent().get(IPageService.class));
}
return pageService;
}
});
e4Context.set(IPartService.class.getName(), new ContextFunction() {
@Override
public Object compute(IEclipseContext context, String contextKey) {
if (partService == null) {
partService = new SlavePartService(context.getParent().get(IPartService.class));
}
return partService;
}
});
e4Context.set(ISelectionService.class.getName(), new ContextFunction() {
@Override
public Object compute(IEclipseContext context, String contextKey) {
if (selectionService == null) {
selectionService = new SlaveSelectionService(context.getParent().get(ISelectionService.class));
}
return selectionService;
}
});
e4Context.set(IContextService.class.getName(), new ContextFunction() {
@Override
public Object compute(IEclipseContext context, String contextKey) {
if (contextService == null) {
contextService = new SlaveContextService(context.getParent().get(IContextService.class), new ActivePartExpression(part));
}
return contextService;
}
});
e4Context.set(IMenuService.class.getName(), new ContextFunction() {
@Override
public Object compute(IEclipseContext context, String contextKey) {
if (menuService == null) {
menuService = new SlaveMenuService(context.getParent().get(IMenuService.class), model);
}
return menuService;
}
});
}
use of org.eclipse.ui.internal.services.WorkbenchLocationService in project eclipse.platform.ui by eclipse-platform.
the class MultiPageEditorSite method initializeDefaultServices.
/**
* Initialize the slave services for this site.
*/
private void initializeDefaultServices() {
serviceLocator.registerService(IWorkbenchLocationService.class, new WorkbenchLocationService(IServiceScopes.MPESITE_SCOPE, getWorkbenchWindow().getWorkbench(), getWorkbenchWindow(), getNestedEditorSite(), this, null, 3));
serviceLocator.registerService(IMultiPageEditorSiteHolder.class, (IMultiPageEditorSiteHolder) () -> MultiPageEditorSite.this);
context.set(IContextService.class.getName(), new ContextFunction() {
@Override
public Object compute(IEclipseContext ctxt, String contextKey) {
if (contextService == null) {
contextService = new NestableContextService(ctxt.getParent().get(IContextService.class), new ActivePartExpression(multiPageEditor));
}
return contextService;
}
});
// create a local handler service so that when this page
// activates/deactivates, its handlers will also be taken into/out of
// consideration during handler lookups
IHandlerService handlerService = new LegacyHandlerService(context);
context.set(IHandlerService.class, handlerService);
}
use of org.eclipse.ui.internal.services.WorkbenchLocationService in project eclipse.platform.ui by eclipse-platform.
the class PageSite method initializeDefaultServices.
/**
* Initialize the slave services for this site.
*/
private void initializeDefaultServices() {
serviceLocator.registerService(IWorkbenchLocationService.class, new WorkbenchLocationService(IServiceScopes.PAGESITE_SCOPE, getWorkbenchWindow().getWorkbench(), getWorkbenchWindow(), parentSite, null, this, 3));
serviceLocator.registerService(IPageSiteHolder.class, (IPageSiteHolder) () -> PageSite.this);
// create a local handler service so that when this page
// activates/deactivates, its handlers will also be taken into/out of
// consideration during handler lookups
IHandlerService handlerService = new LegacyHandlerService(e4Context);
e4Context.set(IHandlerService.class, handlerService);
e4Context.set(IContextService.class.getName(), new ContextFunction() {
@Override
public Object compute(IEclipseContext context, String contextKey) {
if (contextService == null) {
contextService = new NestableContextService(context.getParent().get(IContextService.class), new ActivePartExpression(parentSite.getPart()));
}
return contextService;
}
});
}
use of org.eclipse.ui.internal.services.WorkbenchLocationService in project eclipse.platform.ui by eclipse-platform.
the class ContributedServiceTest method testLocalDialogService.
@Test
// TODO
@Ignore
public void testLocalDialogService() throws Exception {
IServiceLocator parent = getWorkbench();
IServiceLocatorCreator lc = parent.getService(IServiceLocatorCreator.class);
IServiceLocator locator = lc.createServiceLocator(parent, new AbstractServiceFactory() {
@Override
public Object create(Class serviceInterface, IServiceLocator parentLocator, IServiceLocator locator) {
if (IWorkbenchLocationService.class.equals(serviceInterface)) {
IWorkbenchLocationService wls = parentLocator.getService(IWorkbenchLocationService.class);
return new WorkbenchLocationService(IServiceScopes.DIALOG_SCOPE, wls.getWorkbench(), null, null, null, null, wls.getServiceLevel() + 1);
}
return null;
}
}, () -> {
});
IWorkbenchLocationService wls = locator.getService(IWorkbenchLocationService.class);
assertNotNull(wls.getWorkbench());
assertNull(wls.getWorkbenchWindow());
assertEquals(1, wls.getServiceLevel());
assertEquals(IServiceScopes.DIALOG_SCOPE, wls.getServiceScope());
}
Aggregations