Java Code Examples for org.eclipse.core.expressions.IEvaluationContext#getDefaultVariable()

The following examples show how to use org.eclipse.core.expressions.IEvaluationContext#getDefaultVariable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropertiesHandler.java    From tlaplus with MIT License 6 votes vote down vote up
/**
    * {@inheritDoc}
    */
@Override
public void setEnabled(final Object evaluationContext) {
	final IEvaluationContext context = (IEvaluationContext)evaluationContext;
	final Object defaultVariable = context.getDefaultVariable();
	Spec spec = null;
	
	if (defaultVariable instanceof List) {
		final List<?> list = (List<?>)defaultVariable;
		
		if (list.size() == 1) {
			final Object o = list.get(0);
			
			if (o instanceof Spec) {
				spec = (Spec)o;
			}
		}
	}
	
	m_enabled = (spec != null);
}
 
Example 2
Source File: DeleteModuleHandler.java    From tlaplus with MIT License 6 votes vote down vote up
private Module getModuleFromContext(final IEvaluationContext context) {
	final Object defaultVariable = context.getDefaultVariable();
	
	if (defaultVariable instanceof List) {
		final List<?> list = (List<?>)defaultVariable;
		
		if (list.size() == 1) {
			final Object o = list.get(0);
			
			if (o instanceof Module) {
				return (Module)o;
			}
		}
	}
	
	return null;
}
 
Example 3
Source File: EvalExpressionAction.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Object applicationContext = event.getApplicationContext();
    if (applicationContext instanceof IEvaluationContext) {
        IEvaluationContext evalCtx = (IEvaluationContext) applicationContext;
        Object obj = evalCtx.getDefaultVariable();
        if (obj instanceof Set) {
            Set set = (Set) obj;
            if (set.size() > 0) {
                Object sel = set.iterator().next();
                if (sel instanceof TextSelection) {
                    String expr = ((TextSelection) sel).getText();
                    if (expr != null && expr.trim().length() > 0) {
                        eval(expr);
                    }
                }
            }
        }
    } else {
        Log.log("Expected IEvaluationContext. Received: " + applicationContext.getClass());
    }
    return null;
}