/** * Evaluate the given expression within the given context and return * the result. Returns <code>true</code> iff result is either TRUE or NOT_LOADED. * This allows optimistic inclusion of shortcuts before plugins are loaded. * Returns <code>false</code> if exp is <code>null</code>. * * @param exp the enablement expression to evaluate or <code>null</code> * @param context the context of the evaluation. Usually, the * user's selection. * @return the result of evaluating the expression * @throws CoreException */ public boolean evalEnablementExpression(IEvaluationContext context, Expression exp) throws CoreException { return (exp != null) ? ((exp.evaluate(context)) != EvaluationResult.FALSE) : false; }
@Override public void collectExpressionInfo(ExpressionInfo info) { fExpression.collectExpressionInfo(info); }
/** * {@inheritDoc} */ @Override public int hashCode() { if (fHashCode != HASH_CODE_NOT_COMPUTED) return fHashCode; fHashCode= computeHashCode(); if (fHashCode == HASH_CODE_NOT_COMPUTED) fHashCode++; return fHashCode; } }
public static boolean isVisible(MCoreExpression exp, final ExpressionContext eContext) { final Expression ref; if (exp.getCoreExpression() instanceof Expression) { ref = (Expression) exp.getCoreExpression(); } else { ref = new ReferenceExpression(exp.getCoreExpressionId()); exp.setCoreExpression(ref); } // Creates dependency on a predefined value that can be "poked" by the evaluation // service ExpressionInfo info = ref.computeExpressionInfo(); String[] names = info.getAccessedPropertyNames(); for (String name : names) { eContext.getVariable(name + ".evaluationServiceLink"); //$NON-NLS-1$ } boolean ret = false; try { ret = ref.evaluate(eContext) != EvaluationResult.FALSE; } catch (Exception e) { trace("isVisible exception", e); //$NON-NLS-1$ } return ret; }
@Override protected int computeHashCode() { return HASH_INITIAL * HASH_FACTOR + fExpression.hashCode(); } }
@Override protected int computeHashCode() { return HASH_INITIAL * HASH_FACTOR + fExpression.hashCode(); }
/** * Evaluate the given expression within the given context and return * the result. Returns <code>true</code> iff result is either TRUE or NOT_LOADED. * This allows optimistic inclusion of shortcuts before plugins are loaded. * Returns <code>false</code> if exp is <code>null</code>. * * @param exp the enablement expression to evaluate or <code>null</code> * @param context the context of the evaluation. Usually, the * user's selection. * @return the result of evaluating the expression * @throws CoreException */ protected boolean evalEnablementExpression(IEvaluationContext context, Expression exp) throws CoreException { return (exp != null) ? ((exp.evaluate(context)) != EvaluationResult.FALSE) : false; }
@Override public void collectExpressionInfo(ExpressionInfo info) { fExpression.collectExpressionInfo(info); }
@Override protected int computeHashCode() { return HASH_INITIAL * HASH_FACTOR + fExpression.hashCode(); } }
@Override public int hashCode() { if (fHashCode != HASH_CODE_NOT_COMPUTED) return fHashCode; fHashCode= computeHashCode(); if (fHashCode == HASH_CODE_NOT_COMPUTED) fHashCode++; return fHashCode; } }
/** * Evaluate the given expression within the given context and return * the result. Returns <code>true</code> iff result is either TRUE or NOT_LOADED. * This allows optimistic inclusion of shortcuts before plugins are loaded. * Returns <code>false</code> if exp is <code>null</code>. * * @param exp the enablement expression to evaluate or <code>null</code> * @param context the context of the evaluation. Usually, the * user's selection. * @return the result of evaluating the expression * @throws CoreException */ protected boolean evalEnablementExpression(IEvaluationContext context, Expression exp) throws CoreException { return (exp != null) ? ((exp.evaluate(context)) != EvaluationResult.FALSE) : false; }
@Override public void collectExpressionInfo(ExpressionInfo info) { if (fExpressions == null) return; for (Expression expression : fExpressions) { expression.collectExpressionInfo(info); } }
protected int computeHashCode() { return HASH_INITIAL * HASH_FACTOR + fExpression.hashCode(); } }
/** * {@inheritDoc} */ public int hashCode() { if (fHashCode != HASH_CODE_NOT_COMPUTED) return fHashCode; fHashCode= computeHashCode(); if (fHashCode == HASH_CODE_NOT_COMPUTED) fHashCode++; return fHashCode; } }
@Override public final boolean evaluate(final IEvaluationContext context) { if (expression == null) { return true; } if (evaluationResult == null) { try { evaluationResult = expression.evaluate(context); } catch (final CoreException e) { /* * Swallow the exception. It simply means the variable is not * valid it some (most frequently, that the value is null). This * kind of information is not really useful to us, so we can * just treat it as null. */ evaluationResult = EvaluationResult.FALSE; return false; } } // return true if the result is FALSE or NOT_LOADED return evaluationResult != EvaluationResult.FALSE; }
@Override public void collectExpressionInfo(ExpressionInfo info) { fExpression.collectExpressionInfo(info); }
/** * Returns the hash code for the given array. This method handles * <code>null</code>. * * @param array the array for which the hash code is desired; may be * <code>null</code>. * @return the hash code of the array; zero if the object is * <code>null</code>. * * @since 3.2 */ protected static final int hashCode(final Object[] array) { if (array == null) { return 0; } int hashCode= array.getClass().getName().hashCode(); for (int i= 0; i < array.length; i++) { hashCode= hashCode * HASH_FACTOR + hashCode(array[i]); } return hashCode; }
/** * {@inheritDoc} */ @Override public int hashCode() { if (fHashCode != HASH_CODE_NOT_COMPUTED) return fHashCode; fHashCode= computeHashCode(); if (fHashCode == HASH_CODE_NOT_COMPUTED) fHashCode++; return fHashCode; } }
public boolean matches(IEvaluationContext context) throws CoreException { if (enablementRule == null) return false; return convert(enablementRule.evaluate(context)); }
public void collectExpressionInfo(ExpressionInfo info) { fExpression.collectExpressionInfo(info); }