KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > internal > base > HelpEvaluationContext


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.help.internal.base;
12
13 import org.eclipse.core.expressions.EvaluationContext;
14 import org.eclipse.core.runtime.Platform;
15
16 /*
17  * Supplies en evaluation context for filtering help documents. This is used for
18  * resolving variables in enablement expressions.
19  */

20 public final class HelpEvaluationContext {
21
22     private static final String JavaDoc VARIABLE_PLATFORM = "platform"; //$NON-NLS-1$
23

24     private static EvaluationContext context;
25     
26     /*
27      * Returns the evaluation context to use in help documents.
28      */

29     public static EvaluationContext getContext() {
30         if (context == null) {
31             context = new EvaluationContext(null, Platform.class) {
32                 public Object JavaDoc getVariable(String JavaDoc name) {
33                     if (VARIABLE_PLATFORM.equals(name)) {
34                         return Platform.class;
35                     }
36                     return null;
37                 }
38             };
39         }
40         return context;
41     }
42
43     /*
44      * Sets the evaluation context to use in help documents. If help is running in
45      * workbench mode, the UI plug-in will contribute a context that also handles
46      * UI-related variables.
47      */

48     public static void setContext(EvaluationContext context) {
49         HelpEvaluationContext.context = context;
50     }
51
52     /*
53      * Not meant to be instantiated.
54      */

55     private HelpEvaluationContext() {
56     }
57 }
58
Popular Tags