use of org.eclipse.e4.core.di.annotations.Evaluate in project whole by wholeplatform.
the class AbstractSelectionConstrainedVisibleWhen method evaluate.
@Override
public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
ESelectionService selectionService = (ESelectionService) context.getVariable(ESelectionService.class.getName());
Object selection = selectionService.getSelection();
if (selection instanceof IBindingManager) {
if (isVisible((IBindingManager) selection))
return EvaluationResult.TRUE;
}
return EvaluationResult.FALSE;
}
use of org.eclipse.e4.core.di.annotations.Evaluate in project aero.minova.rcp by minova-afis.
the class PrintDetailHandler method visible.
/**
* Button nur anzeigen, wenn in xbs definiert ist, dass gedruckt werden kann
*
* @param part
* @return
*/
@Evaluate
public boolean visible(MPerspective mPerspective) {
String maskName = mPerspective.getPersistedState().get(Constants.FORM_NAME);
Preferences preferences = (Preferences) mApplication.getTransientData().get(Constants.XBS_FILE_NAME);
Node maskNode = XBSUtil.getNodeWithName(preferences, maskName);
return maskNode != null;
}
use of org.eclipse.e4.core.di.annotations.Evaluate in project eclipse.platform.ui by eclipse-platform.
the class ContributionsAnalyzer method isImperativeExpressionVisible.
private static boolean isImperativeExpressionVisible(MImperativeExpression exp, final ExpressionContext eContext) {
Object imperativeExpressionObject = exp.getObject();
if (imperativeExpressionObject == null) {
IContributionFactory contributionFactory = eContext.eclipseContext.get(IContributionFactory.class);
Object newImperativeExpression = contributionFactory.create(exp.getContributionURI(), eContext.eclipseContext);
exp.setObject(newImperativeExpression);
imperativeExpressionObject = newImperativeExpression;
}
if (imperativeExpressionObject == null) {
return false;
}
Object result = null;
// $NON-NLS-1$
IEclipseContext staticContext = EclipseContextFactory.create("Evaluation-Static");
staticContext.set(MImperativeExpression.class, exp);
try {
if (exp.isTracking()) {
result = invoke(imperativeExpressionObject, Evaluate.class, eContext.eclipseContext, staticContext, missingEvaluate);
} else {
result = ContextInjectionFactory.invoke(imperativeExpressionObject, Evaluate.class, eContext.eclipseContext, staticContext, missingEvaluate);
}
} finally {
staticContext.dispose();
}
if (result == missingEvaluate) {
// $NON-NLS-1$
String className = "null";
if (imperativeExpressionObject != null) {
className = imperativeExpressionObject.getClass().getName();
}
throw new IllegalStateException(// $NON-NLS-1$ //$NON-NLS-2$
"There is no method annotated with @Evaluate in the " + className + " imperative expression class ");
}
return (boolean) result;
}
use of org.eclipse.e4.core.di.annotations.Evaluate in project eclipse.platform.ui by eclipse-platform.
the class SaveAllHandler method evaluate.
@Override
protected EvaluationResult evaluate(IEvaluationContext context) {
IWorkbenchWindow window = InternalHandlerUtil.getActiveWorkbenchWindow(context);
// no window? not active
if (window == null)
return EvaluationResult.FALSE;
WorkbenchPage page = (WorkbenchPage) window.getActivePage();
// no page? not active
if (page == null)
return EvaluationResult.FALSE;
// if at least one dirty part, then we are active
if (page.getDirtyParts().length > 0)
return EvaluationResult.TRUE;
EPartService partService = getPartService(window);
if (partService != null && (partService.getDirtyParts().size() > 0)) {
return EvaluationResult.TRUE;
}
// Since Save All also saves saveables from non-part sources,
// look if any such saveables exist and are dirty.
SaveablesList saveablesList = (SaveablesList) window.getWorkbench().getService(ISaveablesLifecycleListener.class);
if (saveablesList == null) {
return EvaluationResult.FALSE;
}
for (ISaveablesSource nonPartSource : saveablesList.getNonPartSources()) {
Saveable[] saveables = nonPartSource.getSaveables();
for (Saveable saveable : saveables) {
if (saveable.isDirty()) {
return EvaluationResult.TRUE;
}
}
}
// if nothing, then we are not active
return EvaluationResult.FALSE;
}
use of org.eclipse.e4.core.di.annotations.Evaluate in project eclipse.platform.ui by eclipse-platform.
the class SaveAsHandler method evaluate.
@Override
protected EvaluationResult evaluate(IEvaluationContext context) {
IWorkbenchWindow window = InternalHandlerUtil.getActiveWorkbenchWindow(context);
// no window? not active
if (window == null)
return EvaluationResult.FALSE;
WorkbenchPage page = (WorkbenchPage) window.getActivePage();
// no page? not active
if (page == null)
return EvaluationResult.FALSE;
MPart activeMPart = getActivePart(window);
IWorkbenchPart activePart = InternalHandlerUtil.getActivePart(context);
ISaveablePart part = SaveableHelper.getSaveable(activePart);
if (part == null && activeMPart != null && activeMPart.isDirty()) {
return EvaluationResult.FALSE;
}
// get saveable part
ISaveablePart saveablePart = getSaveablePart(context);
if (saveablePart == null)
return EvaluationResult.FALSE;
// if its available, return whatever it says
return saveablePart.isSaveAsAllowed() ? EvaluationResult.TRUE : EvaluationResult.FALSE;
}
Aggregations