/** * Return whether or not object fails the enabledWhen enablement criterea. * For multi-select pages, evaluate the enabledWhen expression using the * structured selection as a Collection (which should be iterated over). * @return boolean <code>true</code> if it fails the enablement test */ private boolean failsEnablement(Object[] objs) { if (enablementExpression == null) return false; try { // If multi-select property page, always pass a collection for iteration Object object = (supportsMultiSelect) ? Arrays.asList(objs) : objs[0]; EvaluationContext context = new EvaluationContext(null, object); context.setAllowPluginActivation(true); return enablementExpression.evaluate( context).equals( EvaluationResult.FALSE); } catch (CoreException e) { WorkbenchPlugin.log(e); return false; } }
private boolean isFacetEnabled(ValidatorMetaData vmd, IProject project) { try { Expression expression = vmd.getEnablementExpresion(); if (expression != null) { EvaluationContext context = new EvaluationContext(null, project); context.setAllowPluginActivation(true); EvaluationResult result = expression.evaluate(context); return result == EvaluationResult.TRUE; } } catch (CoreException ce) { } return false; }
private static EvaluationContext createEvaluationContext(RefactoringProcessor processor, Object element, String[] affectedNatures) { EvaluationContext result= new EvaluationContext(null, element); result.setAllowPluginActivation(true); result.addVariable("element", element); //$NON-NLS-1$ result.addVariable("affectedNatures", Arrays.asList(affectedNatures)); //$NON-NLS-1$ result.addVariable("processorIdentifier", processor.getIdentifier()); //$NON-NLS-1$ return result; } }
private static EvaluationContext createEvaluationContext(RefactoringProcessor processor, Object element, String[] affectedNatures) { EvaluationContext result= new EvaluationContext(null, element); result.setAllowPluginActivation(true); result.addVariable("element", element); //$NON-NLS-1$ result.addVariable("affectedNatures", Arrays.asList(affectedNatures)); //$NON-NLS-1$ result.addVariable("processorIdentifier", processor.getIdentifier()); //$NON-NLS-1$ return result; } }
/** * Determine if this content extension is enabled for the given element. * * @param anElement * The element that should be used for the evaluation. * @return True if and only if the extension is enabled for the element. */ public boolean isEnabledFor(Object anElement) { if (enablement == null) { return false; } try { EvaluationContext context = new EvaluationContext(null, anElement); context.setAllowPluginActivation(true); return (enablement.evaluate(context) == EvaluationResult.TRUE); } catch (CoreException e) { NavigatorPlugin.log(IStatus.ERROR, 0, e.getMessage(), e); } return false; }
/** * * @param anInput * The editor input from the editor that was activated. * @return True if this linkHelper descriptor can produce a selection from * the editor input. */ public boolean isEnabledFor(IEditorInput anInput) { if (editorInputEnablement == null || anInput == null) { return false; } try { EvaluationContext context = new EvaluationContext(null, anInput); context.setAllowPluginActivation(true); return (editorInputEnablement.evaluate(context) == EvaluationResult.TRUE); } catch (CoreException e) { NavigatorPlugin.log(IStatus.ERROR, 0, e.getMessage(), e); } return false; }
/** * Determine if this content extension would be able to provide children for * the given element. * * @param anElement * The element that should be used for the evaluation. * @return True if and only if the extension is enabled for the element. */ public boolean isTriggerPoint(Object anElement) { if (enablement == null || anElement == null) { return false; } try { EvaluationContext context = new EvaluationContext(null, anElement); context.setAllowPluginActivation(true); return (enablement.evaluate(context) == EvaluationResult.TRUE); } catch (CoreException e) { NavigatorPlugin.logError(0, e.getMessage(), e); } return false; }
/** * * @param anElement * The element from the set of elements benig dropped. * @return True if the element matches the drop expression from the * extension. */ public boolean isDropElementSupported(Object anElement) { if (dropExpr != null && anElement != null) { try { EvaluationContext context = new EvaluationContext(null, anElement); context.setAllowPluginActivation(true); return dropExpr .evaluate(context) == EvaluationResult.TRUE; } catch (CoreException e) { NavigatorPlugin.logError(0, e.getMessage(), e); } } return false; }
/** * Determine if this content extension is enabled for the given element. * * @param anElement * The element that should be used for the evaluation. * @return True if and only if the extension is enabled for the element. */ public boolean isEnabledFor(Object anElement) { if (enablement == null || anElement == null) { return false; } try { EvaluationContext context = new EvaluationContext(null, anElement); context.setAllowPluginActivation(true); return (enablement.evaluate(context) == EvaluationResult.TRUE); } catch (CoreException e) { NavigatorPlugin.log(IStatus.ERROR, 0, e.getMessage(), e); } return false; }
/** * * @param aParent * An element from the viewer * @return True if and only if this CommonSorter can sort the children of * the given parent. */ public boolean isEnabledForParent(Object aParent) { if(aParent == null) { return false; } if (parentExpression != null) { EvaluationContext context = new EvaluationContext(null, aParent); context.setAllowPluginActivation(true); try { return parentExpression.evaluate(context) == EvaluationResult.TRUE; } catch (CoreException e) { NavigatorPlugin.logError(0, e.getMessage(), e); } } return true; }
/** * Returns true if the given viewer, editor matches the enabledWhen expression * and false otherwise. * * @param viewer * the viewer * @param editor * the editor * @return true if the given viewer, editor matches the enabledWhen expression * and false otherwise. */ public boolean matches(ISourceViewer viewer, ITextEditor editor) { EvaluationContext context = new EvaluationContext(null, editor); context.setAllowPluginActivation(true); context.addVariable("viewer", viewer); //$NON-NLS-1$ context.addVariable("editor", editor); //$NON-NLS-1$ context.addVariable("editorInput", editor.getEditorInput()); //$NON-NLS-1$ try { return fEnabledWhen.evaluate(context) == EvaluationResult.TRUE; } catch (CoreException e) { TextEditorPlugin.getDefault().getLog().log( new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, "Error while 'enabledWhen' evaluation", e)); //$NON-NLS-1$ return false; } }
context.setAllowPluginActivation(true); if (possibleChildren != null) { return (possibleChildren.evaluate(context) == EvaluationResult.TRUE);