1 11 package org.eclipse.help; 12 13 import org.eclipse.core.expressions.EvaluationContext; 14 import org.eclipse.core.expressions.IEvaluationContext; 15 import org.eclipse.core.runtime.Platform; 16 import org.eclipse.help.internal.HelpPlugin; 17 18 28 public class UAContentFilter { 29 30 private static final String VARIABLE_PLATFORM = "platform"; private static IEvaluationContext defaultContext; 32 33 50 public static boolean isFiltered(Object element) { 51 if (defaultContext == null) { 52 defaultContext = new EvaluationContext(null, Platform.class) { 53 public Object getVariable(String name) { 54 if (VARIABLE_PLATFORM.equals(name)) { 55 return Platform.class; 56 } 57 return null; 58 } 59 }; 60 } 61 return isFiltered(element, defaultContext); 62 } 63 64 78 public static boolean isFiltered(Object element, IEvaluationContext context) { 79 if (element instanceof IUAElement) { 80 try { 81 return !((IUAElement)element).isEnabled(context); 82 } 83 catch (Throwable t) { 84 String msg = "Error while checking element filter"; HelpPlugin.logError(msg, t); 86 } 87 } 88 return false; 89 } 90 } 91 | Popular Tags |