Search in sources :

Example 1 with LegacyHandlerService

use of org.eclipse.ui.internal.handlers.LegacyHandlerService in project eclipse.platform.ui by eclipse-platform.

the class WorkbenchWindow method hardClose.

/**
 * Unconditionally close this window. Assumes the proper flags have been set
 * correctly (e.i. closing and updateDisabled)
 *
 * @param remove <code>true</code> if this window should be removed from the
 *               application model
 */
private boolean hardClose(boolean remove) {
    try {
        if (!remove) {
            // we're in a shutdown case so we need to hide views that should
            // not be restored
            hideNonRestorableViews();
        }
        // clear some lables
        // Remove the handler submissions. Bug 64024.
        final IWorkbench workbench = getWorkbench();
        LegacyHandlerService windowHs = (LegacyHandlerService) model.getContext().get(IHandlerService.class);
        windowHs.dispose();
        final IHandlerService handlerService = workbench.getService(IHandlerService.class);
        handlerService.deactivateHandlers(handlerActivations);
        final Iterator<IHandlerActivation> activationItr = handlerActivations.iterator();
        while (activationItr.hasNext()) {
            final IHandlerActivation activation = activationItr.next();
            activation.getHandler().dispose();
        }
        handlerActivations.clear();
        globalActionHandlersByCommandId.clear();
        // Remove the enabled submissions. Bug 64024.
        final IContextService contextService = workbench.getService(IContextService.class);
        contextService.unregisterShell(getShell());
        // time to wipe our our populate
        // IMenuService menuService = (IMenuService)
        // workbench.getService(IMenuService.class);
        // menuService.releaseContributions(((ContributionManager)
        // getActionBars()
        // .getMenuManager()));
        // ICoolBarManager coolbar = getActionBars().getCoolBarManager();
        // if (coolbar != null) {
        // menuService.releaseContributions(((ContributionManager)
        // coolbar));
        // }
        getActionBarAdvisor().dispose();
        getWindowAdvisor().dispose();
        // Null out the progress region. Bug 64024.
        progressRegion = null;
        // Opposite of setup() and fill()
        MWindow window = model;
        if (window.getMainMenu() != null) {
            MMenu mainMenu = window.getMainMenu();
            final MenuManagerRenderer renderer = (MenuManagerRenderer) rendererFactory.getRenderer(mainMenu, null);
            cleanupMenuManagerRec(renderer, mainMenu);
        }
        engine.removeGui(model);
        coolbarToTrim.dispose();
        MElementContainer<MUIElement> parent = window.getParent();
        if (remove) {
            parent.getChildren().remove(window);
            if (parent.getSelectedElement() == window) {
                if (!parent.getChildren().isEmpty()) {
                    parent.setSelectedElement(parent.getChildren().get(0));
                }
            }
        }
        // is fully functional during this call
        if (getActivePage() != null) {
            firePageClosed();
        }
        // now it is safe to close the page and release all references
        if (page != null) {
            page.close();
            page = null;
        }
        menuOverride = null;
        toolbarOverride = null;
        fireWindowClosed();
    } finally {
        try {
            // Bring down all of the services ... after the window goes away
            serviceLocator.dispose();
        } catch (Exception ex) {
            WorkbenchPlugin.log(ex);
        }
        menuRestrictions.clear();
    }
    return true;
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) LegacyHandlerService(org.eclipse.ui.internal.handlers.LegacyHandlerService) IHandlerService(org.eclipse.ui.handlers.IHandlerService) IHandlerActivation(org.eclipse.ui.handlers.IHandlerActivation) IContextService(org.eclipse.ui.contexts.IContextService) MUIElement(org.eclipse.e4.ui.model.application.ui.MUIElement) MWindow(org.eclipse.e4.ui.model.application.ui.basic.MWindow) MMenu(org.eclipse.e4.ui.model.application.ui.menu.MMenu) MenuManagerRenderer(org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer) InvocationTargetException(java.lang.reflect.InvocationTargetException) WorkbenchException(org.eclipse.ui.WorkbenchException) InjectionException(org.eclipse.e4.core.di.InjectionException)

Example 2 with LegacyHandlerService

use of org.eclipse.ui.internal.handlers.LegacyHandlerService 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 3 with LegacyHandlerService

use of org.eclipse.ui.internal.handlers.LegacyHandlerService 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)

Example 4 with LegacyHandlerService

use of org.eclipse.ui.internal.handlers.LegacyHandlerService 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);
}
Also used : ContextFunction(org.eclipse.e4.core.contexts.ContextFunction) NestableContextService(org.eclipse.ui.internal.contexts.NestableContextService) IHandlerService(org.eclipse.ui.handlers.IHandlerService) LegacyHandlerService(org.eclipse.ui.internal.handlers.LegacyHandlerService) 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) ActivePartExpression(org.eclipse.ui.internal.expressions.ActivePartExpression)

Example 5 with LegacyHandlerService

use of org.eclipse.ui.internal.handlers.LegacyHandlerService 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;
        }
    });
}
Also used : ContextFunction(org.eclipse.e4.core.contexts.ContextFunction) NestableContextService(org.eclipse.ui.internal.contexts.NestableContextService) IHandlerService(org.eclipse.ui.handlers.IHandlerService) LegacyHandlerService(org.eclipse.ui.internal.handlers.LegacyHandlerService) 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) ActivePartExpression(org.eclipse.ui.internal.expressions.ActivePartExpression)

Aggregations

IContextService (org.eclipse.ui.contexts.IContextService)5 IHandlerService (org.eclipse.ui.handlers.IHandlerService)5 LegacyHandlerService (org.eclipse.ui.internal.handlers.LegacyHandlerService)5 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)4 IWorkbenchLocationService (org.eclipse.ui.internal.services.IWorkbenchLocationService)4 WorkbenchLocationService (org.eclipse.ui.internal.services.WorkbenchLocationService)4 ContextFunction (org.eclipse.e4.core.contexts.ContextFunction)3 ActivePartExpression (org.eclipse.ui.internal.expressions.ActivePartExpression)3 ISelectionService (org.eclipse.ui.ISelectionService)2 NestableContextService (org.eclipse.ui.internal.contexts.NestableContextService)2 SlaveMenuService (org.eclipse.ui.internal.menus.SlaveMenuService)2 IMenuService (org.eclipse.ui.menus.IMenuService)2 ULocale (com.ibm.icu.util.ULocale)1 Category (com.ibm.icu.util.ULocale.Category)1 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1