Search in sources :

Example 66 with EvaluationContext

use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.

the class ExpressionTests method testIterateExpressionWithAdapterManagerEmptyOr.

public void testIterateExpressionWithAdapterManagerEmptyOr() throws Exception {
    // $NON-NLS-1$
    IterateExpression exp = new IterateExpression("or");
    final List<String> input = new ArrayList<>();
    CollectionWrapper wrapper = new CollectionWrapper();
    wrapper.collection = input;
    EvaluationContext context = new EvaluationContext(null, wrapper);
    assertTrue(EvaluationResult.FALSE == exp.evaluate(context));
}
Also used : ArrayList(java.util.ArrayList) IterateExpression(org.eclipse.core.internal.expressions.IterateExpression) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext)

Example 67 with EvaluationContext

use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.

the class ExpressionTests method testIterateExpressionWithAdapterManagerEmptyAnd.

public void testIterateExpressionWithAdapterManagerEmptyAnd() throws Exception {
    // $NON-NLS-1$
    IterateExpression exp = new IterateExpression("and");
    final List<String> input = new ArrayList<>();
    CollectionWrapper wrapper = new CollectionWrapper();
    wrapper.collection = input;
    EvaluationContext context = new EvaluationContext(null, wrapper);
    assertTrue(EvaluationResult.TRUE == exp.evaluate(context));
}
Also used : ArrayList(java.util.ArrayList) IterateExpression(org.eclipse.core.internal.expressions.IterateExpression) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext)

Example 68 with EvaluationContext

use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.

the class ExpressionTests method testIterateExpressionAnd_IfEmptyTrue.

public void testIterateExpressionAnd_IfEmptyTrue() throws Exception {
    // $NON-NLS-1$
    IterateExpression exp = new IterateExpression("and", "true");
    List<?> input = new ArrayList<>();
    EvaluationContext context = new EvaluationContext(null, input);
    assertTrue(EvaluationResult.TRUE == exp.evaluate(context));
}
Also used : ArrayList(java.util.ArrayList) IterateExpression(org.eclipse.core.internal.expressions.IterateExpression) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext)

Example 69 with EvaluationContext

use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.

the class PropertyTesterTests method testPluginActivation.

public void testPluginActivation() throws Exception {
    if (TEST_DYNAMIC_AND_ACTIVATION) {
        // $NON-NLS-1$
        Bundle bundle = Platform.getBundle("org.eclipse.core.expressions.tests.forceActivation");
        assertEquals(Bundle.STARTING, bundle.getState());
        A receiver = new A();
        TestExpression exp = new TestExpression("org.eclipse.core.expressions.tests.forceActivation", "testing", null, null, true);
        EvaluationContext context = new EvaluationContext(null, receiver);
        EvaluationResult result = exp.evaluate(context);
        assertEquals(EvaluationResult.NOT_LOADED, result);
        assertEquals(Bundle.STARTING, bundle.getState());
        // $NON-NLS-1$ //$NON-NLS-2$
        Property p = TestExpression.testGetTypeExtensionManager().getProperty(receiver, "org.eclipse.core.expressions.tests.forceActivation", "testing", false);
        assertTrue(!p.isInstantiated());
        context.setAllowPluginActivation(true);
        exp.evaluate(context);
        assertEquals(Bundle.ACTIVE, bundle.getState());
        // $NON-NLS-1$ //$NON-NLS-2$
        p = TestExpression.testGetTypeExtensionManager().getProperty(receiver, "org.eclipse.core.expressions.tests.forceActivation", "testing", false);
        assertTrue(p.isInstantiated());
    }
}
Also used : Bundle(org.osgi.framework.Bundle) TestExpression(org.eclipse.core.internal.expressions.TestExpression) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) Property(org.eclipse.core.internal.expressions.Property) EvaluationResult(org.eclipse.core.expressions.EvaluationResult)

Example 70 with EvaluationContext

use of org.eclipse.core.expressions.EvaluationContext in project jbosstools-hibernate by jbosstools.

the class JPAMapToolActionDelegate method setEnabled.

public void setEnabled(Object context) {
    if (context instanceof EvaluationContext) {
        EvaluationContext ec = (EvaluationContext) context;
        Object obj = ec.getDefaultVariable();
        refContextObject = new WeakReference<Object>(obj);
    } else if (context instanceof ExpressionContext) {
        ExpressionContext ec = (ExpressionContext) context;
        Object obj = ec.getDefaultVariable();
        refContextObject = new WeakReference<Object>(obj);
    } else {
        refContextObject = null;
    }
    setBaseEnabled(checkEnabled());
}
Also used : ExpressionContext(org.eclipse.e4.core.commands.ExpressionContext) WeakReference(java.lang.ref.WeakReference) EvaluationContext(org.eclipse.core.expressions.EvaluationContext)

Aggregations

EvaluationContext (org.eclipse.core.expressions.EvaluationContext)71 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)56 ArrayList (java.util.ArrayList)26 IterateExpression (org.eclipse.core.internal.expressions.IterateExpression)22 CountExpression (org.eclipse.core.internal.expressions.CountExpression)14 InstanceofExpression (org.eclipse.core.internal.expressions.InstanceofExpression)13 AdaptExpression (org.eclipse.core.internal.expressions.AdaptExpression)12 Command (org.eclipse.core.commands.Command)11 WithExpression (org.eclipse.core.internal.expressions.WithExpression)11 ICommandService (org.eclipse.ui.commands.ICommandService)11 EvaluationResult (org.eclipse.core.expressions.EvaluationResult)10 EqualsExpression (org.eclipse.core.internal.expressions.EqualsExpression)10 CoreException (org.eclipse.core.runtime.CoreException)10 EnablementExpression (org.eclipse.core.internal.expressions.EnablementExpression)9 TestExpression (org.eclipse.core.internal.expressions.TestExpression)9 IHandlerService (org.eclipse.ui.handlers.IHandlerService)9 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)8 Expression (org.eclipse.core.expressions.Expression)8 SystemTestExpression (org.eclipse.core.internal.expressions.SystemTestExpression)8 AndExpression (org.eclipse.core.internal.expressions.AndExpression)7