01: /*******************************************************************************
02: * Copyright (c) 2005, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.services;
11:
12: import org.eclipse.core.expressions.Expression;
13: import org.eclipse.core.expressions.IEvaluationContext;
14: import org.eclipse.ui.ISources;
15:
16: /**
17: * <p>
18: * A cache of the result of an expression. This also provides the source
19: * priority for the expression.
20: * </p>
21: * <p>
22: * This interface is not intended to be implemented or extended by clients.
23: * </p>
24: *
25: * @since 3.2
26: * @see org.eclipse.ui.ISources
27: * @see org.eclipse.ui.ISourceProvider
28: */
29: public interface IEvaluationResultCache {
30:
31: /**
32: * Clears the cached computation of the <code>evaluate</code> method, if
33: * any. This method is only intended for internal use. It provides a
34: * mechanism by which <code>ISourceProvider</code> events can invalidate
35: * state on a <code>IEvaluationResultCache</code> instance.
36: */
37: public void clearResult();
38:
39: /**
40: * Returns the expression controlling the activation or visibility of this
41: * item.
42: *
43: * @return The expression associated with this item; may be
44: * <code>null</code>.
45: */
46: public Expression getExpression();
47:
48: /**
49: * Returns the priority that has been given to this expression.
50: *
51: * @return The priority.
52: * @see ISources
53: */
54: public int getSourcePriority();
55:
56: /**
57: * Evaluates the expression -- given the current state of the workbench.
58: * This method should cache its computation. The cache will be cleared by a
59: * call to <code>clearResult</code>.
60: *
61: * @param context
62: * The context in which this state should be evaluated; must not
63: * be <code>null</code>.
64: * @return <code>true</code> if the expression currently evaluates to
65: * <code>true</code>; <code>false</code> otherwise.
66: */
67: public boolean evaluate(IEvaluationContext context);
68:
69: /**
70: * Forces the cached result to be a particular value. This will <b>not</b>
71: * notify any users of the cache that it has changed.
72: *
73: * @param result
74: * The cached result to use.
75: * @since 3.3
76: */
77: public void setResult(boolean result);
78: }
|