| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| */ |
| package org.eclipse.osbp.ide.core.ui.softwarefactory.util; |
| |
| import java.util.Locale; |
| |
| import org.eclipse.core.resources.IProject; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.jdt.core.IJavaProject; |
| import org.eclipse.xtext.common.types.access.jdt.IJavaProjectProvider; |
| |
| import com.google.inject.Inject; |
| |
| /** |
| * Util class that offers convenient methods. |
| */ |
| public class CoreUiUtil { |
| |
| @Inject |
| private IJavaProjectProvider projectProvider; |
| |
| /** |
| * Returns the project where the xtextModel is located in. |
| * |
| * @param xtextElement |
| * @return |
| */ |
| public IProject getProject(EObject xtextElement) { |
| IJavaProject javaProject = getJavaProject(xtextElement); |
| if (javaProject == null) { |
| return null; |
| } |
| return javaProject.getProject(); |
| } |
| |
| /** |
| * Returns the javaProject where the xtextModel is located in. |
| * |
| * @param xtextElement |
| * @return |
| */ |
| public IJavaProject getJavaProject(EObject xtextElement) { |
| return projectProvider.getJavaProject(xtextElement.eResource() |
| .getResourceSet()); |
| } |
| |
| /** |
| * Returns the current locale. For now {@link Locale#getDefault()} is used. |
| * Later maybe a value from preferences is returned. |
| * |
| * @return |
| */ |
| public Locale getLocale() { |
| return Locale.getDefault(); |
| } |
| |
| } |
| |