Search in sources :

Example 1 with SlaveMenuService

use of org.eclipse.ui.internal.menus.SlaveMenuService 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);
}
Also used : SelectionService(org.eclipse.ui.internal.e4.compatibility.SelectionService) ISelectionService(org.eclipse.ui.ISelectionService) LegacyActionPersistence(org.eclipse.ui.internal.menus.LegacyActionPersistence) LegacyHandlerService(org.eclipse.ui.internal.handlers.LegacyHandlerService) IHandlerService(org.eclipse.ui.handlers.IHandlerService) IMenuService(org.eclipse.ui.menus.IMenuService) IActionCommandMappingService(org.eclipse.ui.internal.handlers.IActionCommandMappingService) ActionCommandMappingService(org.eclipse.ui.internal.handlers.ActionCommandMappingService) IWorkbenchLocationService(org.eclipse.ui.internal.services.IWorkbenchLocationService) WorkbenchLocationService(org.eclipse.ui.internal.services.WorkbenchLocationService) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IContextService(org.eclipse.ui.contexts.IContextService) ICommandService(org.eclipse.ui.commands.ICommandService) SlaveCommandService(org.eclipse.ui.internal.commands.SlaveCommandService) SlaveMenuService(org.eclipse.ui.internal.menus.SlaveMenuService)

Example 2 with SlaveMenuService

use of org.eclipse.ui.internal.menus.SlaveMenuService 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;
        }
    });
}
Also used : IWorkbenchLocationService(org.eclipse.ui.internal.services.IWorkbenchLocationService) WorkbenchLocationService(org.eclipse.ui.internal.services.WorkbenchLocationService) SlaveContextService(org.eclipse.ui.internal.contexts.SlaveContextService) IPartService(org.eclipse.ui.IPartService) SlaveMenuService(org.eclipse.ui.internal.menus.SlaveMenuService) ContextFunction(org.eclipse.e4.core.contexts.ContextFunction) IPageService(org.eclipse.ui.IPageService) IHandlerService(org.eclipse.ui.handlers.IHandlerService) LegacyHandlerService(org.eclipse.ui.internal.handlers.LegacyHandlerService) IWorkbenchSiteProgressService(org.eclipse.ui.progress.IWorkbenchSiteProgressService) WorkbenchSiteProgressService(org.eclipse.ui.internal.progress.WorkbenchSiteProgressService) IWorkbenchSiteProgressService(org.eclipse.ui.progress.IWorkbenchSiteProgressService) IKeyBindingService(org.eclipse.ui.IKeyBindingService) IMenuService(org.eclipse.ui.menus.IMenuService) IProgressService(org.eclipse.ui.progress.IProgressService) IKeyBindingService(org.eclipse.ui.IKeyBindingService) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) ISelectionService(org.eclipse.ui.ISelectionService) EObject(org.eclipse.emf.ecore.EObject) IContextService(org.eclipse.ui.contexts.IContextService) ActivePartExpression(org.eclipse.ui.internal.expressions.ActivePartExpression)

Aggregations

IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)2 ISelectionService (org.eclipse.ui.ISelectionService)2 IContextService (org.eclipse.ui.contexts.IContextService)2 IHandlerService (org.eclipse.ui.handlers.IHandlerService)2 LegacyHandlerService (org.eclipse.ui.internal.handlers.LegacyHandlerService)2 SlaveMenuService (org.eclipse.ui.internal.menus.SlaveMenuService)2 IWorkbenchLocationService (org.eclipse.ui.internal.services.IWorkbenchLocationService)2 WorkbenchLocationService (org.eclipse.ui.internal.services.WorkbenchLocationService)2 IMenuService (org.eclipse.ui.menus.IMenuService)2 ContextFunction (org.eclipse.e4.core.contexts.ContextFunction)1 EObject (org.eclipse.emf.ecore.EObject)1 IKeyBindingService (org.eclipse.ui.IKeyBindingService)1 IPageService (org.eclipse.ui.IPageService)1 IPartService (org.eclipse.ui.IPartService)1 ICommandService (org.eclipse.ui.commands.ICommandService)1 SlaveCommandService (org.eclipse.ui.internal.commands.SlaveCommandService)1 SlaveContextService (org.eclipse.ui.internal.contexts.SlaveContextService)1 SelectionService (org.eclipse.ui.internal.e4.compatibility.SelectionService)1 ActivePartExpression (org.eclipse.ui.internal.expressions.ActivePartExpression)1 ActionCommandMappingService (org.eclipse.ui.internal.handlers.ActionCommandMappingService)1