/** * 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); } } } }
/** * 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); } } } }
@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); } }
/** * 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); } } }
/** * 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); } }
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); } } }
/** * 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; }
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); } } } }
/** * 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; }
/** * @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; }
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; }
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); } } }
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); } } }
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; }
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); } }
/** * Read 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 IExtension[] extensions = registry.getExtensionPoint(FILE_EXTENSIONS_POINT_ID).getExtensions(); for (IExtension extension : extensions) { final IConfigurationElement[] configElems = extension.getConfigurationElements(); for (IConfigurationElement elem : configElems) { try { List<String> fileExtensions = Splitter.on(',').trimResults().omitEmptyStrings() .splitToList(elem.getAttribute(ATT_FILE_EXTENSION)); String elementName = elem.getName(); if (ATT_TRANSPILABLE_FILE_EXTENSIONS.equals(elementName)) { transpilableFileExtensions.addAll(fileExtensions); } else if (ATT_TEST_FILE_EXTENSIONS.equals(elementName)) { testFileExtensions.addAll(fileExtensions); } else if (ATT_RUNNABLE_FILE_EXTENSIONS.equals(elementName)) { runnableFileExtensions.addAll(fileExtensions); } else if (ATT_TYPABLE_FILE_EXTENSIONS.equals(elementName)) { typableFileExtensions.addAll(fileExtensions); } else if (ATT_RAW_FILE_EXTENSIONS.equals(elementName)) { rawFileExtensions.addAll(fileExtensions); } else { LOGGER.error(new UnsupportedOperationException( "This file extension type " + elementName + " is not supported yet")); } } catch (Exception ex) { LOGGER.error("Error while reading extensions for extension point " + FILE_EXTENSIONS_POINT_ID, ex); } } } } }
/** * Read 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 IExtension[] extensions = registry.getExtensionPoint(SUBGENERATORS_EXTENSIONS_POINT_ID) .getExtensions(); for (IExtension extension : extensions) { final IConfigurationElement[] configElems = extension.getConfigurationElements(); for (IConfigurationElement elem : configElems) { try { String fileExtensions = elem.getAttribute(ATT_FILE_EXTENSIONS); List<String> fileExtensionList = Splitter.on(',').trimResults().omitEmptyStrings() .splitToList(fileExtensions); ISubGenerator generator = (ISubGenerator) elem .createExecutableExtension(ATT_SUB_GENERATOR_CLASS); for (String fileExtension : fileExtensionList) { register(generator, fileExtension); } } catch (Exception ex) { LOGGER.error( "Error while reading extensions for extension point " + SUBGENERATORS_EXTENSIONS_POINT_ID, ex); } } } } }
@Before public void setUp() { IExtensionRegistry registry = RegistryFactory.getRegistry(); IExtension extension = registry.getExtension("org.eclipse.ui.console.consolePatternMatchListeners", "com.google.cloud.tools.eclipse.appengine.localserver.urlLinker"); assertNotNull("URL linking extension not found", extension); assertEquals("Should only have a single URL linker", 1, extension.getConfigurationElements().length); IConfigurationElement definition = extension.getConfigurationElements()[0]; assertEquals("consolePatternMatchListener", definition.getName()); assertNotNull(definition.getAttribute("regex")); regexp = Pattern.compile(".*(" + definition.getAttribute("regex") + ").*"); }
/** Initialize available runtimes */ private WidgetRuntimeFactory() { final IExtensionRegistry registry = RegistryFactory.getRegistry(); if (registry == null) { // Fall back to hardcoded runtimes runtimes.put(DisplayModel.WIDGET_TYPE, () -> new DisplayRuntime()); runtimes.put(ArrayWidget.WIDGET_DESCRIPTOR.getType(), () -> new ArrayWidgetRuntime()); runtimes.put(EmbeddedDisplayWidget.WIDGET_DESCRIPTOR.getType(), () -> new EmbeddedDisplayRuntime()); runtimes.put(GroupWidget.WIDGET_DESCRIPTOR.getType(), () -> new GroupWidgetRuntime()); runtimes.put(KnobWidget.WIDGET_DESCRIPTOR.getType(), () -> new KnobWidgetRuntime()); runtimes.put(ImageWidget.WIDGET_DESCRIPTOR.getType(), () -> new ImageWidgetRuntime()); runtimes.put(NavigationTabsWidget.WIDGET_DESCRIPTOR.getType(), () -> new NavigationTabsRuntime()); runtimes.put(ScaledSliderWidget.WIDGET_DESCRIPTOR.getType(), () -> new SliderWidgetRuntime()); runtimes.put(ScrollBarWidget.WIDGET_DESCRIPTOR.getType(), () -> new SliderWidgetRuntime()); runtimes.put(TableWidget.WIDGET_DESCRIPTOR.getType(), () -> new TableWidgetRuntime()); runtimes.put(TabsWidget.WIDGET_DESCRIPTOR.getType(), () -> new TabsWidgetRuntime()); runtimes.put(XYPlotWidget.WIDGET_DESCRIPTOR.getType(), () -> new XYPlotWidgetRuntime()); } else { // Locate runtimes in registry for (IConfigurationElement config : registry.getConfigurationElementsFor(WidgetRuntime.EXTENSION_POINT)) { final String type = config.getAttribute("type"); runtimes.put(type, createSupplier(config)); } } }
@Override protected void initialize() { final Map<String, WidgetRepresentationFactory<Parent, Node>> factories = new HashMap<>(); registerKnownRepresentations(factories); final IExtensionRegistry registry = RegistryFactory.getRegistry(); if (registry != null) { // Load available representations from registry, // which allows other plugins to contribute new widgets. for (IConfigurationElement config : registry.getConfigurationElementsFor(WidgetRepresentation.EXTENSION_POINT)) { final String type = config.getAttribute("type"); final String clazz = config.getAttribute("class"); logger.log(Level.CONFIG, "{0} contributes {1}", new Object[] { config.getContributor().getName(), clazz }); factories.put(type, createFactory(config)); } } for (Map.Entry<String, WidgetRepresentationFactory<Parent, Node>> entry : factories.entrySet()) register(entry.getKey(), entry.getValue()); if (! initialized_colormaps) { for (PredefinedColorMaps.Predefined map : PredefinedColorMaps.PREDEFINED) NamedColorMappings.add(new NamedColorMapping(map.getName(), intensity -> ColorMappingFunction.getRGB(map.getColor(intensity)))); initialized_colormaps = true; } }
/** * @return Returns a list with all available map/tile factories */ public List<MPPlugin> readFactories() { if (_tileFactories != null) { return _tileFactories; } final IExtensionRegistry registry = RegistryFactory.getRegistry(); final IExtensionPoint point = registry.getExtensionPoint("net.tourbook.tilefactory"); //$NON-NLS-1$ final IExtension[] extensions = point.getExtensions(); _tileFactories = new ArrayList<MPPlugin>(); 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 MPPlugin) { _tileFactories.add((MPPlugin) o); } } return _tileFactories; }
/** * @return Returns a list with all available map/tile factories */ public List<MPPlugin> readFactories() { if (_tileFactories != null) { return _tileFactories; } final IExtensionRegistry registry = RegistryFactory.getRegistry(); final IExtensionPoint point = registry.getExtensionPoint("de.byteholder.geoclipse.tilefactory"); //$NON-NLS-1$ final IExtension[] extensions = point.getExtensions(); _tileFactories = new ArrayList<MPPlugin>(); 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 MPPlugin) { _tileFactories.add((MPPlugin) o); } } return _tileFactories; }
@Override public void loadTransportExtensions() { final IExtensionPoint point = RegistryFactory.getRegistry().getExtensionPoint( KarafWorkbenchActivator.PLUGIN_ID, KarafWorkbenchActivator.JMX_CONNECTOR_PROVIDER_EXTENSION_ID); final IExtension[] types = point.getExtensions(); for (int i = 0; i < types.length; i++) { loadTransportConfigurationElements(types[i].getConfigurationElements()); } }
private void initWeaver() { String weaverName = getProperties().getProperty(WEAVER); IExtensionPoint point = RegistryFactory.getRegistry().getExtensionPoint(MDDCore.PLUGIN_ID, "modelWeaver"); IConfigurationElement[] elements = point.getConfigurationElements(); for (IConfigurationElement current : elements) if (weaverName.equals(current.getAttribute("name"))) { try { weaver = (IModelWeaver) current.createExecutableExtension("class"); } catch (CoreException e) { LogUtils.logError(MDDCore.PLUGIN_ID, "Could not instantiate weaver: " + weaverName, e); } return; } }
/** * Populates the language catalog from the extension registry. */ private void initLanguages() { IExtensionPoint point = RegistryFactory.getRegistry().getExtensionPoint(FrontEnd.PLUGIN_ID, "frontEndLanguage"); IConfigurationElement[] elements = point.getConfigurationElements(); languages = new HashMap<String, FrontEndLanguage>(); for (int i = 0; i < elements.length; i++) { FrontEndLanguage current = FrontEndLanguage.build(elements[i]); languages.put(current.fileExtension, current); } }
private void build() { IExtensionRegistry registry = RegistryFactory.getRegistry(); new RegistryReader() { @Override protected String getNamespace() { return ContentSupport.PLUGIN_ID; } @Override protected boolean readElement(IConfigurationElement element) { addProvider(element); return true; } }.readRegistry(registry, CONTENT_PROVIDER_XP); }
public URIMappingRegistryReader() { super (RegistryFactory.getRegistry(), EcorePlugin.INSTANCE.getSymbolicName(), EcorePlugin.URI_MAPPING_PPID); }
public ContentParserRegistryReader() { super (RegistryFactory.getRegistry(), EcorePlugin.INSTANCE.getSymbolicName(), EcorePlugin.CONTENT_PARSER_PPID); }
public GeneratedPackageRegistryReader() { super (RegistryFactory.getRegistry(), EcorePlugin.INSTANCE.getSymbolicName(), EcorePlugin.GENERATED_PACKAGE_PPID); }
public ContentHandlerRegistryReader() { super (RegistryFactory.getRegistry(), EcorePlugin.INSTANCE.getSymbolicName(), EcorePlugin.CONTENT_HANDLER_PPID); }
public DynamicPackageRegistryReader() { super (RegistryFactory.getRegistry(), EcorePlugin.INSTANCE.getSymbolicName(), EcorePlugin.DYNAMIC_PACKAGE_PPID); }
public ProtocolParserRegistryReader() { super (RegistryFactory.getRegistry(), EcorePlugin.INSTANCE.getSymbolicName(), EcorePlugin.PROTOCOL_PARSER_PPID); }
public FactoryOverrideRegistryReader() { super (RegistryFactory.getRegistry(), EcorePlugin.INSTANCE.getSymbolicName(), EcorePlugin.FACTORY_OVERRIDE_PPID); }
public ExtensionParserRegistryReader() { super (RegistryFactory.getRegistry(), EcorePlugin.INSTANCE.getSymbolicName(), EcorePlugin.EXTENSION_PARSER_PPID); }
/** * Creates and adds a "heavy" editor type to the repository. * * @param extensionType * The extension info for the new editor type. * @param modelTypeUri * The uri of the model type handled by the new editor type. * @param editorId * The id of the corresponding Eclipse editor. * @param wizardId * The wizard id of the corresponding Eclipse editor. * @param wizardDialogClassName * The fully qualified name of a Java class that handles the * creation of the model type through the new editor type. * @param isDiagram * True if the new editor type is a diagram, false otherwise. * @return The created editor type. * @throws MMINTException * If the uri of the new editor type is already registered in * the repository. */ public Editor createHeavyEditorType(ExtensionPointType extensionType, String modelTypeUri, String editorId, String wizardId, String wizardDialogClassName, boolean isDiagram) throws MMINTException { Editor newEditorType; if (extensionType.getNewType() == null) { newEditorType = (isDiagram) ? EditorFactory.eINSTANCE.createDiagram() : EditorFactory.eINSTANCE.createEditor(); } else { newEditorType = (Editor) extensionType.getNewType(); } Editor editorType = getSupertype(newEditorType, extensionType.getUri(), extensionType.getSupertypeUri()); addHeavyType(newEditorType, editorType, extensionType.getUri(), extensionType.getName()); addEditorType(newEditorType, modelTypeUri, editorId, wizardId, wizardDialogClassName, MMINT.cachedTypeMID); //TODO MMINT[MISC] this can be optimized to run once instead of for each editor, if needed IExtensionRegistry registry = RegistryFactory.getRegistry(); if (registry != null) { IConfigurationElement[] config = registry.getConfigurationElementsFor(MMINT.ECLIPSE_EDITORS_EXT_POINT); for (IConfigurationElement elem : config) { if (elem.getAttribute(MMINT.ECLIPSE_EDITORS_ATTR_ID).equals(editorId)) { String fileExtensions = elem.getAttribute(MMINT.ECLIPSE_EDITORS_ATTR_EXTENSIONS); if (fileExtensions != null) { for (String fileExtension : fileExtensions.split(",")) { newEditorType.getFileExtensions().add(fileExtension); } } break; } } } return newEditorType; }
/** * Constructor: initializes the settings, initializes the repository and * registers listeners for dynamic installation/unistallation of extensions. */ private MMINT() { IExtensionRegistry registry = RegistryFactory.getRegistry(); if (registry != null) { initTypeMID(registry); registry.addListener(new ModelExtensionPointListener(), MODELS_EXT_POINT); registry.addListener(new ModelRelExtensionPointListener(), MODELRELS_EXT_POINT); registry.addListener(new EditorExtensionPointListener(), EDITORS_EXT_POINT); registry.addListener(new OperatorExtensionPointListener(), OPERATORS_EXT_POINT); } initPreferences(); }
/** * loads all ExtensionPoints of type {@code ExtensionPointConstantsData.REFERENCE_DATA_IMPORTER} * and adds them to a list of available importers */ private static void initialize(){ try { importers = new HashMap<String, AbstractReferenceDataImporter>(); // load reference-data-extensionpoint IExtensionPoint refDataExtensionPoint = RegistryFactory.getRegistry().getExtensionPoint( ExtensionPointConstantsData.REFERENCE_DATA_IMPORTER); IConfigurationElement[] extensionPoints = refDataExtensionPoint.getConfigurationElements(); // add all found extensionPoints to the importer list for (IConfigurationElement ePoint : extensionPoints) { Object o = ePoint.createExecutableExtension(CLASS_PROPERTY); String refDataId = ePoint.getAttribute(ATTRIBUTE_REFDATA_ID); if (o instanceof AbstractReferenceDataImporter) { AbstractReferenceDataImporter importer = (AbstractReferenceDataImporter) o; importers.put(refDataId, importer); log.debug("Added ReferenceDataImporter for... " + refDataId); } } } catch (CoreException e) { log.error("Exception occured trying to load ReferenceDataImporter ExtensionPoints", e); } }
/** * Launch the Eclipse 4 Application */ @Before public void launchApplication() { EventHandler handler = new EventHandler() { public void handleEvent(final Event event) { Platform.runLater(() -> { condition.release(null); }); } }; Dictionary<String, String> properties = new Hashtable<String, String>(); properties.put(EventConstants.EVENT_TOPIC, Constants.APPLICATION_LAUNCHED); registerService = getBundleContext().registerService(EventHandler.class, handler, properties); final List<String> brandingArgs = new ArrayList<>(); if (productId != null) { IConfigurationElement[] elements = RegistryFactory.getRegistry() .getConfigurationElementsFor("org.eclipse.core.runtime", "products", productId); if (elements != null && elements.length > 0) { for (IConfigurationElement prop : elements[0].getChildren("property")) { brandingArgs.add("-" + prop.getAttribute("name")); brandingArgs.add(prop.getAttribute("value")); } } } runningApplication = new E4TestFXApplication(); runningApplication.launch(new ApplicationContext() { @Override public Optional<Splash> getSplashImage() { return Optional.empty(); } @Override public Optional<ApplicationLocation> getInstanceLocation() { BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext(); try { Collection<ServiceReference<Location>> references = context.getServiceReferences(Location.class, Location.INSTANCE_FILTER); if (!references.isEmpty()) { return Optional .of(new ApplicationLocationImpl(context.getService(references.iterator().next()))); } else { LoggerCreator.createLogger(getClass()).error("Could not find an instance location service"); //$NON-NLS-1$ } } catch (InvalidSyntaxException e) { LoggerCreator.createLogger(getClass()) .error("Failed to create a filter '" + Location.INSTANCE_FILTER + "'", e); //$NON-NLS-1$//$NON-NLS-2$ } return Optional.empty(); } @Override public Object getApplicationProperty(String key) { return null; } @Override public String[] getApplicationArguments() { return brandingArgs.toArray(new String[0]); } @Override public void applicationRunning() { } }).whenComplete((s, t) -> { if (t != null) { t.printStackTrace(); } }); ThreadSynchronize service = ServiceUtils.getService(ThreadSynchronize.class).get(); service.block(condition); controller = FACTORY.create(window.getContext().get(Scene.class)); controller.waitForRender(); }
private IExtensionRegistry getRegistry() { return RegistryFactory.getRegistry(); }
public BaseContributionFactory() { super(); registry = RegistryFactory.getRegistry(); key = ((ExtensionRegistry) registry).getTemporaryUserToken(); contributor = ContributorFactoryOSGi.createContributor(getBundle()); }