/* * Copyright (c) 2012 Data Harmonisation Panel * * All rights reserved. This program and the accompanying materials are made * available under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of the License, * or (at your option) any later version. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * HUMBOLDT EU Integrated Project #030962 * Data Harmonisation Panel <http://www.dhpanel.eu> */ package eu.esdihumboldt.cst.doc.functions.internal.toc; import org.eclipse.core.expressions.IEvaluationContext; import org.eclipse.help.IHelpResource; import org.eclipse.help.ITopic; import org.eclipse.help.IUAElement; import eu.esdihumboldt.cst.doc.functions.FunctionReferenceConstants; import eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition; /** * Topic representing a function. * * @author Simon Templer */ public class FunctionTopic implements ITopic, FunctionReferenceConstants { private final FunctionDefinition<?> function; /** * Create the function topic. * * @param function the associated function */ public FunctionTopic(FunctionDefinition<?> function) { super(); this.function = function; } /** * @see IUAElement#isEnabled(IEvaluationContext) */ @Override public boolean isEnabled(IEvaluationContext context) { return true; } /** * @see IUAElement#getChildren() */ @Override public IUAElement[] getChildren() { return getSubtopics(); } /** * @see IHelpResource#getHref() */ @Override public String getHref() { return PLUGINS_ROOT + "/" + PLUGIN_ID + "/" + FUNCTION_TOPIC_PATH + function.getId() + ".html"; } /** * @see IHelpResource#getLabel() */ @Override public String getLabel() { return function.getDisplayName(); } /** * @see ITopic#getSubtopics() */ @Override public ITopic[] getSubtopics() { return NO_TOPICS; } /** * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((function == null) ? 0 : function.getId().hashCode()); return result; } /** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; FunctionTopic other = (FunctionTopic) obj; if (function == null) { if (other.function != null) return false; } else if (!function.getId().equals(other.function.getId())) return false; return true; } }