1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-25 17:23:56 +02:00

Do not use internal E4Workbench class.

Rather fetch the context from the factory.

Change-Id: I12e1b94d070feeebcee9298f544ab2fc9c5cb3ec
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
Alexander Kurtakov 2019-01-24 13:03:09 +02:00
parent bb02738761
commit 04ad3ec06f

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext; 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.MApplication;
import org.eclipse.e4.ui.model.application.ui.menu.MToolControl; import org.eclipse.e4.ui.model.application.ui.menu.MToolControl;
import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.osgi.framework.FrameworkUtil;
public class OpenLaunchSelector extends AbstractHandler { public class OpenLaunchSelector extends AbstractHandler {
@Override @Override
public Object execute(ExecutionEvent event) throws ExecutionException { 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); MApplication application = serviceContext.get(MApplication.class);
EModelService service = application.getContext().get(EModelService.class); EModelService service = application.getContext().get(EModelService.class);
List<Object> findElements = service.findElements(application, LaunchBarControl.ID, List<Object> findElements = service.findElements(application, LaunchBarControl.ID, null, null);
null, null); if (!findElements.isEmpty()) {
if (findElements.size() > 0) {
MToolControl mpart = (MToolControl) findElements.get(0); MToolControl mpart = (MToolControl) findElements.get(0);
Object bar = mpart.getObject(); Object bar = mpart.getObject();
if (bar instanceof LaunchBarControl) { if (bar instanceof LaunchBarControl) {