コード例 #1
0
 public static void collectInfo(ExpressionInfo info, MExpression exp) {
   if (!(exp instanceof MCoreExpression)) {
     return;
   }
   MCoreExpression expr = (MCoreExpression) exp;
   Expression ref = null;
   if (expr.getCoreExpression() instanceof Expression) {
     ref = (Expression) expr.getCoreExpression();
   } else {
     ref = new ReferenceExpression(expr.getCoreExpressionId());
     expr.setCoreExpression(ref);
   }
   ref.collectExpressionInfo(info);
 }
コード例 #2
0
 public boolean isEnabled() {
   try {
     Expression enablementExpression = getEnablementExpression();
     if (enablementExpression == null) {
       return true;
     }
     EvaluationContext context = new EvaluationContext(null, this);
     EvaluationResult evaluationResult = enablementExpression.evaluate(context);
     return evaluationResult != EvaluationResult.FALSE;
   } catch (CoreException e) {
     ConsolePlugin.log(e);
     return false;
   }
 }
コード例 #3
0
 public static boolean isVisible(MCoreExpression exp, ExpressionContext eContext) {
   Expression ref = null;
   if (exp.getCoreExpression() instanceof Expression) {
     ref = (Expression) exp.getCoreExpression();
   } else {
     ref = new ReferenceExpression(exp.getCoreExpressionId());
     exp.setCoreExpression(ref);
   }
   try {
     // 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$
     }
     return ref.evaluate(eContext) != EvaluationResult.FALSE;
   } catch (CoreException e) {
     trace("isVisible exception", e); // $NON-NLS-1$
   }
   return false;
 }
コード例 #4
0
  @Override
  protected boolean isPreservedFilter(ViewerFilter filter) {
    if (filter instanceof CoreExpressionFilter) {
      CoreExpressionFilter expressionFilter = (CoreExpressionFilter) filter;

      Set<String> preservedIds =
          ContextUiPlugin.getDefault().getPreservedFilterIds(viewPart.getSite().getId());
      if (!preservedIds.isEmpty()) {
        try {
          Expression expression2 = (Expression) filterExpressionField1.get(expressionFilter);

          for (CommonFilterDescriptor commonFilterDescriptor : filterDescriptors) {
            if (preservedIds.contains(commonFilterDescriptor.getId())) {
              Expression expression1 =
                  (Expression) filterExpressionField2.get(commonFilterDescriptor);
              if (expression1 != null && expression1.equals(expression2)) {
                return true;
              }
            }
          }
        } catch (IllegalArgumentException e) {
          StatusHandler.log(
              new Status(
                  IStatus.ERROR,
                  ResourcesUiBridgePlugin.ID_PLUGIN,
                  "Could not determine filter",
                  e)); //$NON-NLS-1$
        } catch (IllegalAccessException e) {
          StatusHandler.log(
              new Status(
                  IStatus.ERROR,
                  ResourcesUiBridgePlugin.ID_PLUGIN,
                  "Could not determine filter",
                  e)); //$NON-NLS-1$
        }
      }
    }
    return false;
  }
  public boolean matches(IJavaProject javaProject) {
    if (fStatus != null) {
      return fStatus.booleanValue();
    }

    IConfigurationElement[] children =
        fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
    if (children.length == 1) {
      try {
        ExpressionConverter parser = ExpressionConverter.getDefault();
        Expression expression = parser.perform(children[0]);
        EvaluationContext evalContext = new EvaluationContext(null, javaProject);
        evalContext.addVariable("project", javaProject); // $NON-NLS-1$
        evalContext.addVariable(
            "sourceLevel", javaProject.getOption(JavaCore.COMPILER_SOURCE, true)); // $NON-NLS-1$
        return expression.evaluate(evalContext) == EvaluationResult.TRUE;
      } catch (CoreException e) {
        JavaPlugin.log(e);
      }
      return false;
    }
    fStatus = Boolean.FALSE;
    return false;
  }