/** * Returns default bundle-based translation provider. * * @param context * the context for the translation provider * @return bundle-based translation provider */ static public TranslationService bundleTranslationService(IEclipseContext context) { return ContextInjectionFactory.make(BundleTranslationProvider.class, context); }
@Override public Object call() throws Exception { return ContextInjectionFactory.invoke(AbstractE4Application.this.lcManager, PostContextCreate.class, appContext, Boolean.TRUE); } }, null);
protected void initRenderer(AbstractPartRenderer renderer) { renderer.init(context); ContextInjectionFactory.inject(renderer, context); }
@Nullable public E4Workbench createE4Workbench(IApplicationContext applicationContext, final IEclipseContext appContext) { ContextInjectionFactory.setDefault(appContext); if( startupProgressTrackerService != null ) { try { ContextInjectionFactory.inject(startupProgressTrackerService, appContext); } catch( Throwable t ) { LOGGER.error("Could not fully initialize the startup tracker", t); //$NON-NLS-1$ RestartPreferenceUtil prefUtil = ContextInjectionFactory.make(RestartPreferenceUtil.class, appContext); prefUtil.setClearPersistedStateOnRestart(true); case RESTART: ContextInjectionFactory.invoke(this.lcManager, ProcessAdditions.class, appContext, null); ContextInjectionFactory.invoke(this.lcManager, ProcessRemovals.class, appContext, null); appContext.set(RestartService.class, ContextInjectionFactory.make(RestartServiceImpl.class, appContext));
if (parentContext != null && client != null) { try { ContextInjectionFactory.invoke(client, PersistState.class, parentContext, null); } catch (Exception e) { e.printStackTrace(); if (parentContext != null && client != null) { try { ContextInjectionFactory.uninject(client, parentContext); } catch (Exception e) { e.printStackTrace();
public void widgetDisposed(DisposeEvent e) { ContextInjectionFactory.uninject(tcImpl, parentContext); model.setObject(null); } });
/** * Disposes of the 3.x part's site if it has one. Subclasses may override * but must call <code>super.disposeSite()</code> in its implementation. */ void disposeSite(PartSite site) { site.dispose(); if (part.getTags().contains(IWorkbenchConstants.TAG_USE_DEPENDENCY_INJECTION)) { ContextInjectionFactory.uninject(legacyPart, part.getContext()); } legacyPart = null; }
@Override public Object compute(IEclipseContext context, String contextKey) { if (perspRegistry == null) { perspRegistry = ContextInjectionFactory.make( PerspectiveRegistry.class, e4Context); } return perspRegistry; } });
@SuppressWarnings("unchecked") @Override public <O> @Nullable O invoke(@NonNull Object instance) throws IllegalStateException { try { return (@Nullable O) ContextInjectionFactory.invoke(instance, Invoke.class, this.context); } catch(InjectionException e) { throw new IllegalStateException(e); } }
@PreDestroy public void contextDisposed() { eventBroker.unsubscribe(itemUpdater); eventBroker.unsubscribe(selectionUpdater); eventBroker.unsubscribe(enabledUpdater); eventBroker.unsubscribe(toBeRenderedUpdater); ContextInjectionFactory.uninject(MenuManagerEventHelper.showHelper, context); MenuManagerEventHelper.showHelper = null; ContextInjectionFactory.uninject(MenuManagerEventHelper.hideHelper, context); MenuManagerEventHelper.hideHelper = null; context.remove(MenuManagerRendererFilter.class); Display display = context.get(Display.class); if (display != null && !display.isDisposed() && rendererFilter != null) { display.removeFilter(SWT.Show, rendererFilter); display.removeFilter(SWT.Hide, rendererFilter); display.removeFilter(SWT.Dispose, rendererFilter); } if (rendererFilter != null) { ContextInjectionFactory.uninject(rendererFilter, context); rendererFilter = null; } context.remove(MenuManagerRenderer.class); }
protected void initRenderer(AbstractPartRenderer renderer) { renderer.init(context); ContextInjectionFactory.inject(renderer, context); }
@Override public Object compute(IEclipseContext context, String contextKey) { if (commandHelpService == null) { commandHelpService = ContextInjectionFactory.make(CommandHelpServiceImpl.class, e4Context); } return commandHelpService; } });
public void widgetSelected(SelectionEvent e) { lclContext.set(MItem.class.getName(), item); ContextInjectionFactory.invoke(contrib.getObject(), Execute.class, lclContext); lclContext.remove(MItem.class.getName()); }
@PreDestroy public void contextDisposed() { eventBroker.unsubscribe(selectionUpdater); ContextInjectionFactory.uninject(MenuManagerEventHelper.getInstance().getShowHelper(), context); MenuManagerEventHelper.getInstance().setShowHelper(null); ContextInjectionFactory.uninject(MenuManagerEventHelper.getInstance().getHideHelper(), context); MenuManagerEventHelper.getInstance().setHideHelper(null); context.remove(MenuManagerRendererFilter.class); Display display = context.get(Display.class); if (display != null && !display.isDisposed() && rendererFilter != null) { display.removeFilter(SWT.Show, rendererFilter); display.removeFilter(SWT.Hide, rendererFilter); display.removeFilter(SWT.Dispose, rendererFilter); } if (rendererFilter != null) { ContextInjectionFactory.uninject(rendererFilter, context); rendererFilter = null; } context.remove(MenuManagerRenderer.class); if (Policy.DEBUG_RENDERER) { logger.debug("\nMMR:dispose: modelToManager size = {0}, managerToModel size = {1}", //$NON-NLS-1$ modelToManager.size(), managerToModel.size()); } }
private IWorkbenchPage busyOpenPage(String perspectiveId, IAdaptable input) throws WorkbenchException { IPerspectiveDescriptor descriptor = workbench.getPerspectiveRegistry() .findPerspectiveWithId(perspectiveId); if (descriptor == null) { throw new WorkbenchException(NLS.bind( WorkbenchMessages.WorkbenchPage_ErrorCreatingPerspective, perspectiveId)); } if (page == null) { page = new WorkbenchPage(this, input); model.getContext().set(IWorkbenchPage.class.getName(), page); try { ContextInjectionFactory.inject(page, model.getContext()); } catch (InjectionException e) { throw new WorkbenchException(e.getMessage(), e); } firePageOpened(); partService.setPage(page); } else { IWorkbenchWindow window = getWorkbench().openWorkbenchWindow(perspectiveId, input); return window.getActivePage(); } perspective = descriptor; page.setPerspective(perspective); firePageActivated(); return page; }
@Override public Object compute(IEclipseContext context, String contextKey) { if (viewRegistry == null) { viewRegistry = ContextInjectionFactory.make(ViewRegistry.class, e4Context); } return viewRegistry; } });
@PersistState void persistState() { ContextInjectionFactory.invoke(wrapped, PersistState.class, part.getContext(), null); }
@Override protected Control createControl(Composite parent) { IEclipseContext localContext = EclipseContextFactory.create(); final Composite newComposite = new Composite(parent, SWT.NONE); newComposite.setLayout(new FillLayout()); localContext.set(Composite.class, newComposite); localContext.set(MToolControl.class, model); final IEclipseContext parentContext = modelService.getContainingContext(model); if (model.getObject() == null) { final Object tcImpl = contribFactory.create(model.getContributionURI(), parentContext, localContext); model.setObject(tcImpl); newComposite.addDisposeListener(e -> { ContextInjectionFactory.uninject(tcImpl, parentContext); model.setObject(null); }); } model.setWidget(newComposite); newComposite.setData(AbstractPartRenderer.OWNING_ME, model); newComposite.setData(this); return newComposite; }
application.setSelectedElement(window); ContextInjectionFactory.inject(result, windowContext); windowContext.set(IWorkbenchWindow.class, result); } finally {
@Override public Object compute(IEclipseContext context, String contextKey) { return ContextInjectionFactory.make(HandlerServiceImpl.class, context); } }