use of org.eclipse.core.runtime.IExtensionPoint in project jbosstools-hibernate by jbosstools.
the class HSearchServiceLookup method initializeServices.
private static void initializeServices() {
services = new HashMap<String, IHSearchService>();
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(SERVICES_EXTENSION_ID);
for (IExtension extension : extensionPoint.getExtensions()) {
for (IConfigurationElement configurationElement : extension.getConfigurationElements()) {
try {
Object object = configurationElement.createExecutableExtension("class");
String name = configurationElement.getAttribute("name");
if (object != null && name != null && object instanceof IHSearchService) {
services.put(name, (IHSearchService) object);
}
} catch (CoreException e) {
}
}
}
ArrayList<String> list = new ArrayList<String>(services.keySet());
Collections.sort(list);
versions = list.toArray(new String[list.size()]);
}
use of org.eclipse.core.runtime.IExtensionPoint in project mylyn.docs by eclipse.
the class WikiTextUiPlugin method getTemplates.
/**
* get templates mapped by their markup language name
*
* @return the templates
*/
public Map<String, Templates> getTemplates() {
if (templates == null) {
Map<String, Templates> templates = new HashMap<>();
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(getPluginId(), EXTENSION_POINT_CONTENT_ASSIST);
if (extensionPoint != null) {
IConfigurationElement[] configurationElements = extensionPoint.getConfigurationElements();
for (IConfigurationElement element : configurationElements) {
String declaringPluginId = element.getDeclaringExtension().getContributor().getName();
if (EXTENSION_POINT_TEMPLATES.equals(element.getName())) {
try {
// $NON-NLS-1$
String markupLanguage = element.getAttribute("markupLanguage");
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 }));
}
Templates markupLanguageTemplates = new Templates();
markupLanguageTemplates.setMarkupLanguageName(markupLanguage);
for (IConfigurationElement templatesChild : element.getChildren()) {
if (EXTENSION_POINT_TEMPLATE.equals(templatesChild.getName())) {
try {
// process the template
// $NON-NLS-1$
String name = templatesChild.getAttribute("name");
// $NON-NLS-1$
String description = templatesChild.getAttribute("description");
// $NON-NLS-1$
String content = templatesChild.getAttribute("content");
// $NON-NLS-1$
String autoInsert = templatesChild.getAttribute("autoInsert");
// $NON-NLS-1$
String block = templatesChild.getAttribute("block");
if (name == null || name.length() == 0) {
throw new Exception(NLS.bind(Messages.WikiTextUiPlugin_nameRequired, new Object[] { EXTENSION_POINT_TEMPLATE }));
}
if (description == null || description.length() == 0) {
throw new Exception(NLS.bind(Messages.WikiTextUiPlugin_descriptionRequired, new Object[] { EXTENSION_POINT_TEMPLATE }));
}
if (content == null || content.length() == 0) {
throw new Exception(NLS.bind(Messages.WikiTextUiPlugin_contentRequired, new Object[] { EXTENSION_POINT_TEMPLATE }));
}
// $NON-NLS-1$//$NON-NLS-2$
content = content.replace("\\t", "\t");
content = // $NON-NLS-1$
content.replace("\\r\\n", Text.DELIMITER).replace(// $NON-NLS-1$
"\\r", Text.DELIMITER).replace("\\n", // $NON-NLS-1$
Text.DELIMITER).replace("\\\\", // $NON-NLS-1$ //$NON-NLS-2$
"\\");
if (// $NON-NLS-1$
content.endsWith("$") && !(content.endsWith("\\$") || content.endsWith("$$"))) {
// $NON-NLS-1$ //$NON-NLS-2$
content = content.substring(0, content.length() - 1);
}
if (content.startsWith("^")) {
// $NON-NLS-1$
content = content.substring(1);
}
// $NON-NLS-1$ //$NON-NLS-2$
content = content.replace("\\$", "$$");
markupLanguageTemplates.addTemplate(new Template(name, description, MarkupTemplateCompletionProcessor.CONTEXT_ID, content, autoInsert == null || // $NON-NLS-1$
!"false".equalsIgnoreCase(autoInsert)), // $NON-NLS-1$
block != null && "true".equalsIgnoreCase(block));
} catch (Exception e) {
log(IStatus.ERROR, NLS.bind(Messages.WikiTextUiPlugin_invalidExtension, new Object[] { declaringPluginId, EXTENSION_POINT_CONTENT_ASSIST, e.getMessage() }), e);
}
} else {
log(IStatus.ERROR, NLS.bind(Messages.WikiTextUiPlugin_unexpectedExtensionElement, new Object[] { declaringPluginId, EXTENSION_POINT_CONTENT_ASSIST, templatesChild.getName() }), null);
}
}
Templates previous = templates.put(markupLanguageTemplates.getMarkupLanguageName(), markupLanguageTemplates);
if (previous != null) {
markupLanguageTemplates.addAll(previous);
}
} catch (Exception e) {
log(IStatus.ERROR, NLS.bind(Messages.WikiTextUiPlugin_invalidExtension, new Object[] { declaringPluginId, EXTENSION_POINT_TEMPLATES, e.getMessage() }), e);
}
} else {
log(IStatus.ERROR, NLS.bind(Messages.WikiTextUiPlugin_unexpectedExtensionElement, new Object[] { declaringPluginId, EXTENSION_POINT_CONTENT_ASSIST, element.getName() }), null);
}
}
}
// now that we have the basic templates, check for language extensions and connect the hierarchy
// first ensure that all language names have templates defined
Set<String> languageNames = WikiText.getMarkupLanguageNames();
for (String languageName : languageNames) {
Templates languageTemplates = templates.get(languageName);
if (languageTemplates == null) {
languageTemplates = new Templates();
templates.put(languageName, languageTemplates);
}
}
// next connect the hierarchy
for (String languageName : languageNames) {
MarkupLanguage markupLanguage = WikiText.getMarkupLanguage(languageName);
if (markupLanguage != null && markupLanguage.getExtendsLanguage() != null) {
Templates languageTemplates = templates.get(languageName);
Templates parentLanguageTemplates = templates.get(markupLanguage.getExtendsLanguage());
languageTemplates.setParent(parentLanguageTemplates);
}
}
this.templates = Collections.unmodifiableMap(templates);
}
return templates;
}
use of org.eclipse.core.runtime.IExtensionPoint in project mylyn.docs by eclipse.
the class WikiTextUiPlugin method getHyperlinkDectectorFileRefRegexes.
public Map<String, List<String>> getHyperlinkDectectorFileRefRegexes() {
if (fileRefRegexes == null) {
com.google.common.collect.ImmutableMap.Builder<String, List<String>> markupLanguageToFileRefRegexes = ImmutableMap.builder();
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(getPluginId(), EXTENSION_POINT_RELATIVE_FILE_PATH_HYPERLINK_DECTOR);
if (extensionPoint != null) {
IConfigurationElement[] configurationElements = extensionPoint.getConfigurationElements();
for (IConfigurationElement element : configurationElements) {
String declaringPluginId = element.getDeclaringExtension().getContributor().getName();
if (EXTENSION_POINT_RELATIVE_FILE_PATH_HYPERLINK_DECTOR.equals(element.getName())) {
try {
String markupLanguage = validateAndGetMarkupLanguage(element);
List<String> regexes = createFielRefRegexes(element, declaringPluginId);
markupLanguageToFileRefRegexes.put(markupLanguage, regexes);
} catch (Exception e) {
log(IStatus.ERROR, NLS.bind(Messages.WikiTextUiPlugin_invalidExtension, new Object[] { declaringPluginId, EXTENSION_POINT_RELATIVE_FILE_PATH_HYPERLINK_DECTOR, e.getMessage() }), e);
}
} else {
log(IStatus.ERROR, NLS.bind(Messages.WikiTextUiPlugin_unexpectedExtensionElement, new Object[] { declaringPluginId, EXTENSION_POINT_RELATIVE_FILE_PATH_HYPERLINK_DECTOR, element.getName() }), null);
}
}
}
fileRefRegexes = markupLanguageToFileRefRegexes.build();
}
return fileRefRegexes;
}
use of org.eclipse.core.runtime.IExtensionPoint 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;
}
use of org.eclipse.core.runtime.IExtensionPoint in project mylyn.docs by eclipse.
the class WikiTextExtensionPointReader method initializeMarkupLanguages.
private void initializeMarkupLanguages() {
synchronized (this) {
if (this.languageByName == null) {
SortedMap<String, Class<? extends MarkupLanguage>> markupLanguageByName = new TreeMap<>();
Map<String, Class<? extends MarkupLanguage>> languageByFileExtension = new HashMap<>();
Map<String, String> languageExtensionByLanguage = new HashMap<>();
Map<Class<? extends MarkupLanguage>, String> languageNameByLanguage = new HashMap<>();
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(getExtensionPointNamespace(), EXTENSION_MARKUP_LANGUAGE);
if (extensionPoint != null) {
IConfigurationElement[] configurationElements = extensionPoint.getConfigurationElements();
for (IConfigurationElement element : configurationElements) {
// $NON-NLS-1$
String name = element.getAttribute("name");
if (name == null || name.length() == 0) {
log(IStatus.ERROR, MessageFormat.format(EXTENSION_MARKUP_LANGUAGE + // $NON-NLS-1$
Messages.getString("WikiTextExtensionPointReader.10"), element.getDeclaringExtension().getContributor().getName()));
continue;
}
// $NON-NLS-1$
String extendsLanguage = element.getAttribute("extends");
Object markupLanguage;
try {
// $NON-NLS-1$
markupLanguage = element.createExecutableExtension("class");
} catch (CoreException e) {
getLog().log(e.getStatus());
continue;
}
if (!(markupLanguage instanceof MarkupLanguage)) {
log(IStatus.ERROR, // $NON-NLS-1$
MessageFormat.format(// $NON-NLS-1$
Messages.getString("WikiTextExtensionPointReader.13"), markupLanguage.getClass().getName()));
continue;
}
MarkupLanguage d = (MarkupLanguage) markupLanguage;
{
Class<? extends MarkupLanguage> previous = markupLanguageByName.put(name, d.getClass());
if (previous != null) {
log(IStatus.ERROR, MessageFormat.format(EXTENSION_MARKUP_LANGUAGE + // $NON-NLS-1$
Messages.getString("WikiTextExtensionPointReader.14"), name, element.getDeclaringExtension().getContributor().getName(), name));
markupLanguageByName.put(name, previous);
continue;
} else {
languageNameByLanguage.put(d.getClass(), name);
}
}
if (extendsLanguage != null) {
languageExtensionByLanguage.put(name, extendsLanguage);
}
// $NON-NLS-1$
String fileExtensions = element.getAttribute("fileExtensions");
if (fileExtensions != null) {
// $NON-NLS-1$
String[] parts = fileExtensions.split("\\s*,\\s*");
for (String part : parts) {
if (part.length() != 0) {
part = part.toLowerCase();
Class<? extends MarkupLanguage> previous = languageByFileExtension.put(part, d.getClass());
if (previous != null) {
log(IStatus.ERROR, MessageFormat.format(EXTENSION_MARKUP_LANGUAGE + // $NON-NLS-1$
Messages.getString("WikiTextExtensionPointReader.17"), part, element.getDeclaringExtension().getContributor().getName(), part));
languageByFileExtension.put(part, previous);
continue;
}
}
}
}
}
}
this.languageByFileExtension = languageByFileExtension;
this.languageByName = markupLanguageByName;
this.languageExtensionByLanguage = languageExtensionByLanguage;
this.languageNameByLanguage = languageNameByLanguage;
}
}
}
Aggregations