use of eu.esdihumboldt.hale.doc.util.context.SingleTopicContext in project hale by halestudio.
the class FunctionContextProvider method getContext.
/**
* @see AbstractContextProvider#getContext(String, String)
*/
@Override
public IContext getContext(String contextId, String locale) {
// It is not possible to use dots (.) in the context id to identify the
// function, because it will be treated as part of the bundle name. So
// the function identifier is encoded using ONameUtil
int index = contextId.lastIndexOf('.');
String pluginId = contextId.substring(0, index);
String shortContextId = contextId.substring(index + 1);
if (pluginId.equals(PLUGIN_ID)) {
try {
String functionId = ONameUtil.decodeName(shortContextId);
FunctionDefinition<?> function = FunctionUtil.getFunction(functionId, null);
if (function != null) {
FunctionTopic topic = new ContextFunctionTopic(function);
String description = function.getDescription();
if (description == null) {
description = function.getDisplayName();
}
return new SingleTopicContext(function.getDisplayName(), description, topic);
// XXX add more info to context (e.g. title?)
}
} catch (DecoderException e) {
// no valid function ID
}
}
return null;
}
Aggregations