From 04ad3ec06fccab42c23d59bf29ac13213553a565 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Thu, 24 Jan 2019 13:03:09 +0200 Subject: [PATCH] Do not use internal E4Workbench class. Rather fetch the context from the factory. Change-Id: I12e1b94d070feeebcee9298f544ab2fc9c5cb3ec Signed-off-by: Alexander Kurtakov --- .../ui/controls/internal/OpenLaunchSelector.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/OpenLaunchSelector.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/OpenLaunchSelector.java index e24f46084f7..7d6c80f3b56 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/OpenLaunchSelector.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/OpenLaunchSelector.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 QNX Software Systems and others. + * Copyright (c) 2015, 2019 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,21 +16,22 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.Status; +import org.eclipse.e4.core.contexts.EclipseContextFactory; import org.eclipse.e4.core.contexts.IEclipseContext; -import org.eclipse.e4.ui.internal.workbench.E4Workbench; import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.model.application.ui.menu.MToolControl; import org.eclipse.e4.ui.workbench.modeling.EModelService; +import org.osgi.framework.FrameworkUtil; public class OpenLaunchSelector extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { - IEclipseContext serviceContext = E4Workbench.getServiceContext(); + IEclipseContext serviceContext = EclipseContextFactory.getServiceContext( + FrameworkUtil.getBundle(org.eclipse.e4.ui.workbench.IWorkbench.class).getBundleContext()); MApplication application = serviceContext.get(MApplication.class); EModelService service = application.getContext().get(EModelService.class); - List findElements = service.findElements(application, LaunchBarControl.ID, - null, null); - if (findElements.size() > 0) { + List findElements = service.findElements(application, LaunchBarControl.ID, null, null); + if (!findElements.isEmpty()) { MToolControl mpart = (MToolControl) findElements.get(0); Object bar = mpart.getObject(); if (bar instanceof LaunchBarControl) {