Skip to content

Package: EPartServiceHelper

EPartServiceHelper

nameinstructionbranchcomplexitylinemethod
getEPartService()
M: 16 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.ui.e4.util;
15:
16: import org.eclipse.e4.core.contexts.IEclipseContext;
17: import org.eclipse.e4.ui.internal.workbench.E4Workbench;
18: import org.eclipse.e4.ui.model.application.MApplication;
19: import org.eclipse.e4.ui.workbench.IWorkbench;
20: import org.eclipse.e4.ui.workbench.modeling.EPartService;
21:
22: /**
23: * This Helper allows to retrieve the {@link EPartService}.
24: *
25: * @author Eugen Neufeld
26: *
27: */
28: public final class EPartServiceHelper {
29:
30:         private EPartServiceHelper() {
31:         }
32:
33:         /**
34:          * Retrieves the part service.
35:          *
36:          * @return the part service of the current window.
37:          */
38:         public static EPartService getEPartService() {
39:                 final MApplication currentApplication = E4Workbench.getServiceContext().get(IWorkbench.class).getApplication();
40:                 final IEclipseContext selectedWindowContext = currentApplication.getSelectedElement().getContext();
41:                 return selectedWindowContext.get(EPartService.class);
42:         }
43: }