Search in sources :

Example 1 with SelectionService

use of org.eclipse.ui.internal.e4.compatibility.SelectionService 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 SelectionService

use of org.eclipse.ui.internal.e4.compatibility.SelectionService in project eclipse.platform.ui by eclipse-platform.

the class WorkbenchPage method setup.

@PostConstruct
public void setup(MApplication application, EModelService modelService, IEventBroker broker, MWindow window, EPartService partService) {
    this.application = application;
    this.modelService = modelService;
    this.broker = broker;
    this.window = window;
    this.partService = partService;
    selectionService = ContextInjectionFactory.make(SelectionService.class, window.getContext());
    partService.addPartListener(e4PartListener);
    // create editor references for all editors
    List<MPart> editors = modelService.findElements(window, CompatibilityEditor.MODEL_ELEMENT_ID, MPart.class, null, EModelService.IN_ANY_PERSPECTIVE | EModelService.OUTSIDE_PERSPECTIVE | EModelService.IN_SHARED_AREA);
    for (MPart editor : editors) {
        createEditorReferenceForPart(editor, null, editor.getElementId(), null);
    }
    // create view references for rendered view placeholders
    List<MPlaceholder> placeholders = modelService.findElements(window, null, MPlaceholder.class, null, EModelService.IN_ANY_PERSPECTIVE | EModelService.OUTSIDE_PERSPECTIVE);
    for (MPlaceholder placeholder : placeholders) {
        if (placeholder.isToBeRendered()) {
            MUIElement ref = placeholder.getRef();
            if (ref instanceof MPart) {
                MPart part = (MPart) ref;
                String uri = part.getContributionURI();
                if (CompatibilityPart.COMPATIBILITY_VIEW_URI.equals(uri)) {
                    createViewReferenceForPart(part, part.getElementId());
                }
            }
        }
    }
    broker.subscribe(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT, selectionHandler);
    broker.subscribe(UIEvents.UIElement.TOPIC_WIDGET, widgetHandler);
    broker.subscribe(UIEvents.UIElement.TOPIC_TOBERENDERED, referenceRemovalEventHandler);
    broker.subscribe(UIEvents.Contribution.TOPIC_OBJECT, firingHandler);
    broker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN, childrenHandler);
    // Bug 479126 PERSPECTIVE_BAR_EXTRAS setting not taken into account
    createPerspectiveBarExtras();
    MPerspectiveStack perspectiveStack = getPerspectiveStack();
    if (perspectiveStack != null) {
        extendPerspectives(perspectiveStack);
    }
    IPerspectiveRegistry registry = getWorkbenchWindow().getWorkbench().getPerspectiveRegistry();
    for (MPerspective perspective : perspectiveStack.getChildren()) {
        IPerspectiveDescriptor desc = registry.findPerspectiveWithId(perspective.getElementId());
        if (desc != null) {
            sortedPerspectives.add(desc);
        }
    }
    MPerspective selectedPerspective = perspectiveStack.getSelectedElement();
    if (selectedPerspective != null) {
        IPerspectiveDescriptor desc = registry.findPerspectiveWithId(selectedPerspective.getElementId());
        if (desc != null) {
            sortedPerspectives.remove(desc);
            sortedPerspectives.add(desc);
        }
    }
    restoreWorkingSets();
    restoreShowInMruPartIdsList();
    configureExistingWindows();
}
Also used : SelectionService(org.eclipse.ui.internal.e4.compatibility.SelectionService) ISelectionService(org.eclipse.ui.ISelectionService) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MPerspective(org.eclipse.e4.ui.model.application.ui.advanced.MPerspective) IPerspectiveRegistry(org.eclipse.ui.IPerspectiveRegistry) MPlaceholder(org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder) MUIElement(org.eclipse.e4.ui.model.application.ui.MUIElement) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) MPerspectiveStack(org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack) PostConstruct(javax.annotation.PostConstruct)

Aggregations

ISelectionService (org.eclipse.ui.ISelectionService)2 SelectionService (org.eclipse.ui.internal.e4.compatibility.SelectionService)2 PostConstruct (javax.annotation.PostConstruct)1 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)1 MUIElement (org.eclipse.e4.ui.model.application.ui.MUIElement)1 MPerspective (org.eclipse.e4.ui.model.application.ui.advanced.MPerspective)1 MPerspectiveStack (org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack)1 MPlaceholder (org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder)1 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)1 IPerspectiveDescriptor (org.eclipse.ui.IPerspectiveDescriptor)1 IPerspectiveRegistry (org.eclipse.ui.IPerspectiveRegistry)1 ICommandService (org.eclipse.ui.commands.ICommandService)1 IContextService (org.eclipse.ui.contexts.IContextService)1 IHandlerService (org.eclipse.ui.handlers.IHandlerService)1 SlaveCommandService (org.eclipse.ui.internal.commands.SlaveCommandService)1 ActionCommandMappingService (org.eclipse.ui.internal.handlers.ActionCommandMappingService)1 IActionCommandMappingService (org.eclipse.ui.internal.handlers.IActionCommandMappingService)1 LegacyHandlerService (org.eclipse.ui.internal.handlers.LegacyHandlerService)1 LegacyActionPersistence (org.eclipse.ui.internal.menus.LegacyActionPersistence)1 SlaveMenuService (org.eclipse.ui.internal.menus.SlaveMenuService)1