blob: b7e537a581888dc62b4f8909a53f8b89ceea8d2e [file] [log] [blame]
/**
*
* 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.api;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.eclipse.osbp.ide.core.ui.softwarefactory.constants.Constants;
public class CoreUtil {
private static final Logger LOGGER = LoggerFactory
.getLogger(CoreUtil.class);
public static final String EVENT_TOPIC__BUILDER = "org/eclipse/osbp/ide/core/ui/softwarefactory/builder";
/**
* Returns true, if the given project contains the OSBP Nature.
*
* @param project
* @return
*/
public static boolean hasNature(IProject project) {
try {
if (project.isAccessible()) {
return project.hasNature(Constants.NATURE_ID);
}
} catch (CoreException e) {
LOGGER.error(e.getMessage(), e);
}
return false;
}
/**
* Returns true, if the given project contains the OSBP Builder.
*
* @param project
* @return
*/
public static boolean hasBuilder(IProject project) {
if (project.isAccessible()) {
try {
for (ICommand command : project.getDescription().getBuildSpec()) {
if (Constants.BUILDER_ID.equals(command.getBuilderName())) {
return true;
}
}
} catch (CoreException e) {
LOGGER.error("Can't build due to an exception.", e);
}
}
return false;
}
}