use of org.eclipse.mylyn.internal.wikitext.ui.editor.help.CheatSheetContent in project mylyn.docs by eclipse.
the class WikiTextUiPlugin method getCheatSheets.
public SortedMap<String, HelpContent> getCheatSheets() {
if (cheatSheets == null) {
SortedMap<String, HelpContent> cheatSheets = new TreeMap<>();
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(getPluginId(), EXTENSION_POINT_CHEAT_SHEET);
if (extensionPoint != null) {
IConfigurationElement[] configurationElements = extensionPoint.getConfigurationElements();
for (IConfigurationElement element : configurationElements) {
String declaringPluginId = element.getDeclaringExtension().getContributor().getName();
Bundle bundle = Platform.getBundle(declaringPluginId);
// $NON-NLS-1$
String markupLanguage = element.getAttribute("markupLanguage");
// $NON-NLS-1$
String contentLanguage = element.getAttribute("contentLanguage");
// $NON-NLS-1$
String resource = element.getAttribute("resource");
try {
if (markupLanguage == null) {
throw new Exception(Messages.WikiTextUiPlugin_markupLanguageRequired);
} else if (!WikiText.getMarkupLanguageNames().contains(markupLanguage)) {
throw new Exception(NLS.bind(Messages.WikiTextUiPlugin_invalidMarkupLanguage, new Object[] { markupLanguage }));
}
if (resource == null || resource.length() == 0) {
throw new Exception(Messages.WikiTextUiPlugin_resourceRequired);
}
HelpContent cheatSheet = new CheatSheetContent(bundle, resource, contentLanguage, markupLanguage);
HelpContent previous = cheatSheets.put(cheatSheet.getMarkupLanguageName(), cheatSheet);
if (previous != null) {
cheatSheets.put(previous.getMarkupLanguageName(), previous);
throw new Exception(NLS.bind(Messages.WikiTextUiPlugin_markupLanguageContentAlreadyDeclared, new Object[] { previous.getMarkupLanguageName(), previous.getProvider().getSymbolicName() }));
}
} catch (Exception e) {
log(IStatus.ERROR, NLS.bind(Messages.WikiTextUiPlugin_invalidExtension, new Object[] { declaringPluginId, EXTENSION_POINT_CHEAT_SHEET, e.getMessage() }), e);
}
}
}
this.cheatSheets = Collections.unmodifiableSortedMap(cheatSheets);
}
return cheatSheets;
}
Aggregations