use of org.eclipse.core.expressions.EvaluationResult in project polymap4-core by Polymap4.
the class CustomAndExpression method evaluate.
public EvaluationResult evaluate(IEvaluationContext scope) {
if (fExpressions == null) {
return EvaluationResult.TRUE;
}
NavigatorPlugin.Evaluator evaluator = new NavigatorPlugin.Evaluator();
EvaluationResult result = EvaluationResult.TRUE;
for (Iterator iter = fExpressions.iterator(); iter.hasNext(); ) {
Expression expression = (Expression) iter.next();
evaluator.expression = expression;
evaluator.scope = scope;
SafeRunner.run(evaluator);
result = result.and(evaluator.result);
// that we find a false which will result in a better result.
if (result == EvaluationResult.FALSE) {
return result;
}
}
return result;
}
use of org.eclipse.core.expressions.EvaluationResult in project hale by halestudio.
the class ActionUIWizardPage method acceptWizard.
/**
* @see ViewerWizardSelectionPage#acceptWizard(IWizardNode)
*/
@Override
protected String acceptWizard(IWizardNode wizardNode) {
if (wizardNode instanceof ActionUIWizardNode) {
ActionUI actionUI = ((ActionUIWizardNode) wizardNode).getActionUI();
Expression enabledWhen = actionUI.getEnabledWhen();
if (enabledWhen == null) {
return null;
}
IEvaluationService ies = PlatformUI.getWorkbench().getService(IEvaluationService.class);
try {
EvaluationResult evalResult = enabledWhen.evaluate(ies.getCurrentState());
if (evalResult == EvaluationResult.FALSE) {
// disabled
return actionUI.getDisabledReason();
}
// enabled
return null;
} catch (CoreException e) {
String message = "Could not evaluate enabledWhen expression";
log.error(message, e);
return message;
}
}
return super.acceptWizard(wizardNode);
}
use of org.eclipse.core.expressions.EvaluationResult in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testCountExpressionFailure.
public void testCountExpressionFailure() throws Exception {
// $NON-NLS-1$
CountExpression exp = new CountExpression("!");
EvaluationContext context = new EvaluationContext(null, new Object());
try {
EvaluationResult result = exp.evaluate(context);
fail("Count should've failed for non-Collection variable. Result = " + result.toString());
} catch (CoreException e) {
assertEquals(ExpressionStatus.VARIABLE_IS_NOT_A_COLLECTION, e.getStatus().getCode());
}
}
use of org.eclipse.core.expressions.EvaluationResult in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testAdaptExpressionFail2.
public void testAdaptExpressionFail2() throws Exception {
// $NON-NLS-1$
AdaptExpression expression = new AdaptExpression("org.eclipse.core.internal.expressions.tests.Adapter");
// $NON-NLS-1$
expression.add(new InstanceofExpression("org.eclipse.core.internal.expressions.tests.NotExisting"));
EvaluationResult result = expression.evaluate(new EvaluationContext(null, new Adaptee()));
assertTrue(result == EvaluationResult.FALSE);
}
use of org.eclipse.core.expressions.EvaluationResult in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testSystemProperty.
public void testSystemProperty() throws Exception {
// $NON-NLS-1$ //$NON-NLS-2$
SystemTestExpression expression = new SystemTestExpression("os.name", System.getProperty("os.name"));
EvaluationResult result = expression.evaluate(new EvaluationContext(null, new Object()));
assertTrue(result == EvaluationResult.TRUE);
}
Aggregations