1 11 package org.eclipse.ui.internal.console; 12 13 import org.eclipse.core.expressions.EvaluationContext; 14 import org.eclipse.core.expressions.EvaluationResult; 15 import org.eclipse.core.expressions.Expression; 16 import org.eclipse.core.expressions.ExpressionConverter; 17 import org.eclipse.core.expressions.ExpressionTagNames; 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.core.runtime.IConfigurationElement; 20 import org.eclipse.ui.IPluginContribution; 21 import org.eclipse.ui.console.IConsole; 22 import org.eclipse.ui.console.IConsolePageParticipant; 23 24 public class ConsolePageParticipantExtension implements IPluginContribution { 25 26 private IConfigurationElement fConfig; 27 private Expression fEnablementExpression; 28 29 public ConsolePageParticipantExtension(IConfigurationElement config) { 30 fConfig = config; 31 } 32 33 36 public String getLocalId() { 37 return fConfig.getAttribute("id"); } 39 40 43 public String getPluginId() { 44 return fConfig.getContributor().getName(); 45 } 46 47 public boolean isEnabledFor(IConsole console) throws CoreException { 48 EvaluationContext context = new EvaluationContext(null, console); 49 EvaluationResult evaluationResult = getEnablementExpression().evaluate(context); 50 return evaluationResult == EvaluationResult.TRUE; 51 } 52 53 public Expression getEnablementExpression() throws CoreException { 54 if (fEnablementExpression == null) { 55 IConfigurationElement[] elements = fConfig.getChildren(ExpressionTagNames.ENABLEMENT); 56 IConfigurationElement enablement = elements.length > 0 ? elements[0] : null; 57 58 if (enablement != null) { 59 fEnablementExpression = ExpressionConverter.getDefault().perform(enablement); 60 } 61 } 62 return fEnablementExpression; 63 } 64 65 public IConsolePageParticipant createDelegate() throws CoreException { 66 return (IConsolePageParticipant) fConfig.createExecutableExtension("class"); } 68 69 } 70 | Popular Tags |