/******************************************************************************* | |
* Copyright (c) 2020 RBEI and others. | |
* | |
* This program and the accompanying materials | |
* are made available under the terms of the Eclipse Public License v. 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: | |
* Adhith Gopal - Initial contribution and API | |
*******************************************************************************/ | |
package org.eclipse.blockchain.ui.property.testers; | |
import org.eclipse.blockchain.core.BlockchainCore; | |
import org.eclipse.blockchain.core.EthereumNature; | |
import org.eclipse.blockchain.ui.Activator; | |
import org.eclipse.core.expressions.PropertyTester; | |
import org.eclipse.core.resources.IProject; | |
import org.eclipse.core.runtime.CoreException; | |
/** | |
* Property tester to test whether the project is an Ethereum Project. | |
*/ | |
public class EthereumProjectPropertyTester extends PropertyTester { | |
/** | |
* {@inheritDoc} | |
*/ | |
@Override | |
public boolean test(final Object receiver, final String property, | |
final Object[] args, final Object expectedValue) { | |
try { | |
if ((receiver instanceof IProject) && ((IProject) receiver) | |
.getProject().getDescription().getNatureIds()[0] | |
.equals(EthereumNature.ETHEREUM_NATURE)) { | |
return true; | |
} | |
} catch (CoreException e) { | |
BlockchainCore.getInstance().logException(Activator.PLUGIN_ID, | |
e.getMessage(), e); | |
} | |
return false; | |
} | |
} |