本文整理汇总了Java中org.eclipse.core.runtime.RegistryFactory类的典型用法代码示例。如果您正苦于以下问题:Java RegistryFactory类的具体用法?Java RegistryFactory怎么用?Java RegistryFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RegistryFactory类属于org.eclipse.core.runtime包,在下文中一共展示了RegistryFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
/**
* Reads information from extensions defined in plugin.xml files.
*/
private void initialize() {
if (isInitialized)
throw new IllegalStateException("may invoke method initialize() only once");
isInitialized = true;
final IExtensionRegistry registry = RegistryFactory.getRegistry();
if (registry != null) {
final IConfigurationElement[] configElems = registry
.getConfigurationElementsFor(TESTERS_EXTENSION_POINT_ID);
for (IConfigurationElement elem : configElems) {
try {
final EclipseTesterDescriptor descriptor = new EclipseTesterDescriptor(elem);
injector.injectMembers(descriptor);
register(descriptor);
} catch (Exception ex) {
log.error("Error while reading extensions for extension point " + TESTERS_EXTENSION_POINT_ID, ex);
}
}
}
}
示例2: initialize
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
/**
* Reads information from extensions defined in plugin.xml files.
*/
private void initialize() {
if (isInitialized)
throw new IllegalStateException("may invoke method initialize() only once");
isInitialized = true;
final IExtensionRegistry registry = RegistryFactory.getRegistry();
if (registry != null) {
final IConfigurationElement[] configElems = registry
.getConfigurationElementsFor(RUNNERS_EXTENSION_POINT_ID);
for (IConfigurationElement elem : configElems) {
try {
final EclipseRunnerDescriptor descriptor = new EclipseRunnerDescriptor(elem);
injector.injectMembers(descriptor);
register(descriptor);
} catch (Exception ex) {
log.error("Error while reading extensions for extension point " + RUNNERS_EXTENSION_POINT_ID, ex);
}
}
}
}
示例3: testValidExtensionPoints
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
@Test
public final void testValidExtensionPoints() {
NodeList extensions = getDocument().getElementsByTagName("extension");
Assert.assertTrue(
"plugin.xml must contain at least one extension point", extensions.getLength() > 0);
IExtensionRegistry registry = RegistryFactory.getRegistry();
Assert.assertNotNull("Make sure you're running this as a plugin test", registry);
for (int i = 0; i < extensions.getLength(); i++) {
Element extension = (Element) extensions.item(i);
String point = extension.getAttribute("point");
Assert.assertNotNull("Could not load " + extension.getAttribute("id"), point);
IExtensionPoint extensionPoint = registry.getExtensionPoint(point);
Assert.assertNotNull("Could not load " + extension.getAttribute("id"), extensionPoint);
}
}
示例4: mockRegistry
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
/**
* Mocks the extension registry.
*
* @throws CoreException
*/
@SuppressWarnings("restriction") // for accessing RegistryProviderFactory
public static synchronized void mockRegistry() {
if (registrySpy == null) {
registry = RegistryFactory.getRegistry();
registrySpy = spy(registry);
org.eclipse.core.internal.registry.RegistryProviderFactory.releaseDefault();
try {
RegistryFactory.setDefaultRegistryProvider(() -> {
return registrySpy;
});
} catch (CoreException e) {
// This shouldn't happen as the default was released.
throw new WrappedException(e);
}
}
}
示例5: unMockRegistry
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
/**
* Unmocks the extension registry.
*/
@SuppressWarnings("restriction") // for accessing RegistryProviderFactory
public static void unMockRegistry() {
configurationElements.clear();
configurationAnswers.clear();
registrySpy = null;
org.eclipse.core.internal.registry.RegistryProviderFactory.releaseDefault(); // restricted
try {
RegistryFactory.setDefaultRegistryProvider(() -> {
return registry;
});
} catch (CoreException e) {
// This shouldn't happen as the default was released.
throw new WrappedException(e);
}
}
示例6: WidgetFactory
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
private WidgetFactory()
{
final IExtensionRegistry registry = RegistryFactory.getRegistry();
if (registry == null)
registerKnownWidgets();
else
{ // Load available widgets from registry, which allows
// other plugins to contribute widgets
for (IConfigurationElement config : registry.getConfigurationElementsFor(EXTENSION_POINT_ID))
{
final WidgetDescriptor descriptor = WidgetDescriptor.fromRegistryEntry(config);
logger.log(Level.CONFIG, "{0} contributes {1}", new Object[] { config.getContributor().getName(), descriptor});
addWidgetType(descriptor);
}
}
}
示例7: contributesToExtensionPoint
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
/**
* Returns <code>true</code> if this bundle implements the extension point
* with the given <code>extensionPointId</code>.
*
* @param bundle the bundle to test
* @param extensionSimpleId the simple id of the extension point
* @param extensionPointId extension id to search for
*
* @return <code>true</code> if this bundle implements the extension point
* with the given <code>extensionPointId</code>
*/
public static boolean contributesToExtensionPoint(Bundle bundle,
String extensionSimpleId, String extensionPointId) {
IExtensionRegistry registry = RegistryFactory.getRegistry();
IContributor contributor = ContributorFactoryOSGi.createContributor(bundle);
for (IExtension extension : registry.getExtensions(contributor.getName())) {
if (extension.getExtensionPointUniqueIdentifier().equals(extensionPointId)) {
if (extensionSimpleId != null
&& !extensionSimpleId.equals(extension.getSimpleIdentifier())) {
continue;
}
return true;
}
}
return false;
}
示例8: CodeTextHover
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
CodeTextHover(ISourceViewer sourceViewer) {
this.sourceViewer = sourceViewer;
IExtensionRegistry registry = RegistryFactory.getRegistry();
for (IConfigurationElement extension : registry.getConfigurationElementsFor(BUNDLE_SYMBOLIC_NAME, ANNOTATION_HOVER_ID)) {
if (extension.isValid()) {
String annotationType = extension.getAttribute(ANNOTATION_TYPE_ATTRIBUTE);
try {
AnnotationHover hover = (AnnotationHover) extension.createExecutableExtension(CLASS_ATTRIBUTE);
if (annotationType != null && hover != null) {
this.hoverContributions.put(annotationType, hover);
}
}
catch (CoreException | ClassCastException ex) {
BfActivator.getDefault().logError("AnnotationHover coud not be created", ex);
}
}
}
}
示例9: getProviders
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
/**
* Provides a standard mean of getting an instances of interface. It uses
* Eclipse/OSGI extension registry.
*/
private static Collection<IPredefinedSourceWrapProvider> getProviders() {
List<IPredefinedSourceWrapProvider> result = new ArrayList<IPredefinedSourceWrapProvider>();
IExtensionPoint extensionPoint = RegistryFactory.getRegistry().getExtensionPoint(
EXTENSION_POINT_ID);
IExtension[] extensions = extensionPoint.getExtensions();
for (IExtension extension : extensions) {
for (IConfigurationElement element : extension.getConfigurationElements()) {
if (!ELEMENT_NAME.equals(element.getName())) {
continue;
}
Object obj;
try {
obj = element.createExecutableExtension(CLASS_PROPERTY);
} catch (CoreException e) {
throw new RuntimeException(e);
}
IPredefinedSourceWrapProvider provider = (IPredefinedSourceWrapProvider) obj;
result.add(provider);
}
}
return result;
}
示例10: getInstance
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
/**
* @return an instance of (any random) implementation of {@link JavaScriptFormatter} or null
*/
public static JavaScriptFormatter getInstance() {
IExtensionPoint extensionPoint = RegistryFactory.getRegistry().getExtensionPoint(
EXTENSION_POINT_ID);
IExtension[] extensions = extensionPoint.getExtensions();
for (IExtension extension : extensions) {
for (IConfigurationElement element : extension.getConfigurationElements()) {
if (!ELEMENT_NAME.equals(element.getName())) {
continue;
}
Object obj;
try {
obj = element.createExecutableExtension(CLASS_PROPERTY);
} catch (CoreException e) {
throw new RuntimeException(e);
}
return (JavaScriptFormatter) obj;
}
}
return null;
}
示例11: getBackends
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
public List<? extends WipBackend> getBackends() {
IExtensionPoint extensionPoint = RegistryFactory.getRegistry().getExtensionPoint(
WipBackExtensionPoint.ID);
IExtension[] extensions = extensionPoint.getExtensions();
List<WipBackend> result = new ArrayList<WipBackend>(extensions.length);
for (IExtension extension : extensions) {
for (IConfigurationElement element : extension.getConfigurationElements()) {
if (!WipBackExtensionPoint.ELEMENT_NAME.equals(element.getName())) {
continue;
}
Object obj;
try {
obj = element.createExecutableExtension(WipBackExtensionPoint.CLASS_PROPERTY);
} catch (CoreException e) {
throw new RuntimeException(e);
}
WipBackend backend = (WipBackend) obj;
result.add(backend);
}
}
return result;
}
示例12: registerOverlays
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
public static void registerOverlays(final Map map) {
final IExtensionRegistry registry = RegistryFactory.getRegistry();
final IExtensionPoint point = registry.getExtensionPoint("net.tourbook.mapOverlay"); //$NON-NLS-1$
final IExtension[] extensions = point.getExtensions();
for (final IExtension extension : extensions) {
final IConfigurationElement[] elements = extension.getConfigurationElements();
final IConfigurationElement element = elements[elements.length - 1];
Object o = null;
try {
o = element.createExecutableExtension("class"); //$NON-NLS-1$
} catch (final CoreException e) {
e.printStackTrace();
}
if (o != null && o instanceof MapPainter) {
map.addOverlayPainter((MapPainter) o);
}
}
}
示例13: registerOverlays
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
public static void registerOverlays(final Map map) {
final IExtensionRegistry registry = RegistryFactory.getRegistry();
final IExtensionPoint point = registry.getExtensionPoint("de.byteholder.geoclipse.mapOverlay"); //$NON-NLS-1$
final IExtension[] extensions = point.getExtensions();
for (final IExtension extension : extensions) {
final IConfigurationElement[] elements = extension.getConfigurationElements();
final IConfigurationElement element = elements[elements.length - 1];
Object o = null;
try {
o = element.createExecutableExtension("class"); //$NON-NLS-1$
} catch (final CoreException e) {
e.printStackTrace();
}
if (o != null && o instanceof MapPainter) {
map.addOverlayPainter((MapPainter) o);
}
}
}
示例14: createFeatureProviders
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
protected Collection<FeatureProvider> createFeatureProviders() throws ResourceException {
IExtensionPoint point = RegistryFactory.getRegistry().getExtensionPoint(PLUGIN_ID, "features");
Collection<FeatureProvider> providers = new HashSet<FeatureProvider>();
providers.add(resourceProvider);
Set<Class<?>> knownFeatures = new HashSet<Class<?>>();
IConfigurationElement[] configurationElements = point.getConfigurationElements();
for (int i = 0; i < configurationElements.length; i++) {
try {
FeatureProvider currentFeatureProvider = (FeatureProvider) configurationElements[i]
.createExecutableExtension("provider");
if (!currentFeatureProvider.isEnabled())
continue;
Set<Class<?>> provided = new HashSet<Class<?>>(Arrays.asList(currentFeatureProvider
.getProvidedFeatureTypes()));
provided.retainAll(knownFeatures);
if (!provided.isEmpty())
throw new ResourceException("Provider " + currentFeatureProvider.getClass().getSimpleName()
+ " provides redundant features: " + provided);
knownFeatures.addAll(Arrays.asList(currentFeatureProvider.getProvidedFeatureTypes()));
providers.add(currentFeatureProvider);
} catch (CoreException e) {
throw new ResourceException(e);
}
}
return providers;
}
示例15: initialize
import org.eclipse.core.runtime.RegistryFactory; //导入依赖的package包/类
public static void initialize(Scheduler scheduler){
try {
IExtensionPoint refDataExtensionPoint =
RegistryFactory.getRegistry().getExtensionPoint(SCHEDULED_JOB_EXTENSION_POINT);
IConfigurationElement[] extensionPoints =
refDataExtensionPoint.getConfigurationElements();
for (IConfigurationElement ePoint : extensionPoints) {
Object o = ePoint.createExecutableExtension(CLASS_PROPERTY);
if (o instanceof AbstractElexisSchedulerJob) {
AbstractElexisSchedulerJob aesj = (AbstractElexisSchedulerJob) o;
log.debug("Found AbstractElexisSchedulerJob for " + aesj.getJob());
addJob(aesj, scheduler);
}
}
} catch (CoreException e) {
log.error("Exception occured trying to load AstractElexisScheduler extension points", e);
}
}