1 11 12 package org.eclipse.ui.internal.contexts; 13 14 import org.eclipse.core.expressions.Expression; 15 import org.eclipse.core.expressions.IEvaluationContext; 16 import org.eclipse.ui.ISources; 17 import org.eclipse.ui.contexts.IContextActivation; 18 import org.eclipse.ui.contexts.IContextService; 19 import org.eclipse.ui.internal.services.EvaluationResultCache; 20 21 37 final class ContextActivation extends EvaluationResultCache implements 38 IContextActivation { 39 40 44 private final String contextId; 45 46 50 private final IContextService contextService; 51 52 67 public ContextActivation(final String contextId, 68 final Expression expression, final IContextService contextService) { 69 super(expression); 70 71 if (contextId == null) { 72 throw new NullPointerException ( 73 "The context identifier for a context activation cannot be null"); } 75 76 if (contextService == null) { 77 throw new NullPointerException ( 78 "The context service for an activation cannot be null"); } 80 81 this.contextId = contextId; 82 this.contextService = contextService; 83 } 84 85 public final void clearActive() { 86 clearResult(); 87 } 88 89 public final String getContextId() { 90 return contextId; 91 } 92 93 public final IContextService getContextService() { 94 return contextService; 95 } 96 97 public final boolean isActive(final IEvaluationContext context) { 98 return evaluate(context); 99 } 100 101 public final String toString() { 102 final StringBuffer buffer = new StringBuffer (); 103 104 buffer.append("ContextActivation(contextId="); buffer.append(contextId); 106 buffer.append(",sourcePriority="); buffer.append(getSourcePriority()); 108 buffer.append(')'); 109 110 return buffer.toString(); 111 } 112 113 } 114 | Popular Tags |