Java Code Examples for org.eclipse.core.runtime.Platform#getExtensionRegistry()

The following examples show how to use org.eclipse.core.runtime.Platform#getExtensionRegistry() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IDEResourcesManager.java    From typescript.java with MIT License 6 votes vote down vote up
private synchronized void loadExtensionResourceParticipants() {
	if (extensionResourceParticipantsLoaded)
		return;
	// Immediately set the flag, as to ensure that this method is never
	// called twice
	extensionResourceParticipantsLoaded = true;

	Trace.trace(Trace.EXTENSION_POINT, "->- Loading .typeScriptResourceParticipants extension point ->-");

	IExtensionRegistry registry = Platform.getExtensionRegistry();
	IConfigurationElement[] cf = registry.getConfigurationElementsFor(TypeScriptCorePlugin.PLUGIN_ID,
			EXTENSION_TYPESCRIPT_RESOURCE_PARTICIPANTS);
	
	addExtensionResourceParticipants(cf);
	addRegistryListenerIfNeeded();

	Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .typeScriptResourceParticipants extension point -<-");
}
 
Example 2
Source File: IDETypeScriptRepositoryManager.java    From typescript.java with MIT License 6 votes vote down vote up
private synchronized void loadExtensionRepositories() {
	if (extensionRepositoriesLoaded)
		return;

	// Immediately set the flag, as to ensure that this method is never
	// called twice
	extensionRepositoriesLoaded = true;

	Trace.trace(Trace.EXTENSION_POINT, "->- Loading .typeScriptRepositories extension point ->-");

	IExtensionRegistry registry = Platform.getExtensionRegistry();
	IConfigurationElement[] cf = registry.getConfigurationElementsFor(TypeScriptCorePlugin.PLUGIN_ID,
			EXTENSION_TYPESCRIPT_REPOSITORIES);
	addExtensionRepositories(cf);
	resetDefaultRepository();
	addRegistryListenerIfNeeded();

	Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .typeScriptRepositories extension point -<-");
}
 
Example 3
Source File: ExtendPopupMenu.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * plugin.xml����^�O��ǂݍ���.
 * 
 * @throws CoreException
 * 
 * @throws CoreException
 */
public static List<ExtendPopupMenu> loadExtensions(ERDiagramEditor editor)
		throws CoreException {
	List<ExtendPopupMenu> extendPopupMenuList = new ArrayList<ExtendPopupMenu>();

	IExtensionRegistry registry = Platform.getExtensionRegistry();
	IExtensionPoint extensionPoint = registry
			.getExtensionPoint(EXTENSION_POINT_ID);

	if (extensionPoint != null) {
		for (IExtension extension : extensionPoint.getExtensions()) {
			for (IConfigurationElement configurationElement : extension
					.getConfigurationElements()) {

				ExtendPopupMenu extendPopupMenu = ExtendPopupMenu
						.createExtendPopupMenu(configurationElement, editor);

				if (extendPopupMenu != null) {
					extendPopupMenuList.add(extendPopupMenu);
				}
			}
		}
	}

	return extendPopupMenuList;
}
 
Example 4
Source File: ITextEngine.java    From ganttproject with GNU General Public License v3.0 6 votes vote down vote up
protected void registerFontDirectories() {
  myFontCache.registerDirectory(System.getProperty("java.home") + "/lib/fonts");
  IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
  IConfigurationElement[] configElements = extensionRegistry.getConfigurationElementsFor("org.ganttproject.impex.htmlpdf.FontDirectory");
  for (int i = 0; i < configElements.length; i++) {
    final String dirName = configElements[i].getAttribute("name");
    if (Boolean.TRUE.toString().equalsIgnoreCase(configElements[i].getAttribute("absolute"))) {
      myFontCache.registerDirectory(dirName);
    } else {
      String namespace = configElements[i].getDeclaringExtension().getNamespaceIdentifier();
      URL dirUrl = Platform.getBundle(namespace).getResource(dirName);
      if (dirUrl == null) {
        GPLogger.getLogger(ITextEngine.class).warning(
            "Failed to find directory " + dirName + " in plugin " + namespace);
        continue;
      }
      try {
        URL resolvedDir = Platform.resolve(dirUrl);
        myFontCache.registerDirectory(resolvedDir.getPath());
      } catch (IOException e) {
        GPLogger.getLogger(ITextEngine.class).log(Level.WARNING, e.getMessage(), e);
        continue;
      }
    }
  }
}
 
Example 5
Source File: SVNUIPlugin.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public static ISVNRepositorySourceProvider[] getRepositorySourceProviders() throws Exception {
	if (repositorySourceProviders == null) {
		List<ISVNRepositorySourceProvider> repositorySourceProviderList = new ArrayList<ISVNRepositorySourceProvider>();
		IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
		IConfigurationElement[] configurationElements = extensionRegistry.getConfigurationElementsFor(REPOSITORY_SOURCE_PROVIDERS);
		for (int i = 0; i < configurationElements.length; i++) {
			IConfigurationElement configurationElement = configurationElements[i];
			ISVNRepositorySourceProvider repositorySourceProvider = (ISVNRepositorySourceProvider)configurationElement.createExecutableExtension("class"); //$NON-NLS-1$
			repositorySourceProvider.setId(configurationElement.getAttribute("id")); //$NON-NLS-1$
			repositorySourceProviderList.add(repositorySourceProvider);
		}
		repositorySourceProviders = new ISVNRepositorySourceProvider[repositorySourceProviderList.size()];
		repositorySourceProviderList.toArray(repositorySourceProviders);
		Arrays.sort(repositorySourceProviders, new Comparator<ISVNRepositorySourceProvider>() {
			public int compare(ISVNRepositorySourceProvider o1, ISVNRepositorySourceProvider o2) {
				return o1.getName().compareTo(o2.getName());
			}		
		});
	}
	return repositorySourceProviders;
}
 
Example 6
Source File: AppContextUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns all configuration elements of appcontext extension point
 * 
 * @return
 */
private static IConfigurationElement[] getConfigurationElements( )
{
	// load extension point entry
	IExtensionRegistry registry = Platform.getExtensionRegistry( );
	IExtensionPoint extensionPoint = registry
			.getExtensionPoint( APPCONTEXT_EXTENSION_ID );

	if ( extensionPoint != null )
	{
		// get all configuration elements
		return extensionPoint.getConfigurationElements( );
	}

	return null;
}
 
Example 7
Source File: SVNUIPlugin.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public static WorkspaceAction[] getMergeProviders() throws Exception {
	if (mergeProviders == null) {
		ArrayList mergeProviderList = new ArrayList();
		IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
		IConfigurationElement[] configurationElements = extensionRegistry.getConfigurationElementsFor(MERGE_PROVIDERS);
		for (int i = 0; i < configurationElements.length; i++) {
			IConfigurationElement configurationElement = configurationElements[i];
			WorkspaceAction mergeProvider = (WorkspaceAction)configurationElement.createExecutableExtension("class"); //$NON-NLS-1$
			mergeProvider.setName(configurationElement.getAttribute("name")); //$NON-NLS-1$
			mergeProviderList.add(mergeProvider);
		}
		mergeProviders = new WorkspaceAction[mergeProviderList.size()];
		mergeProviderList.toArray(mergeProviders);
	}
	return mergeProviders;
}
 
Example 8
Source File: ExtendPopupMenu.java    From erflute with Apache License 2.0 6 votes vote down vote up
public static List<ExtendPopupMenu> loadExtensions(MainDiagramEditor editor) throws CoreException {
    final List<ExtendPopupMenu> extendPopupMenuList = new ArrayList<>();

    final IExtensionRegistry registry = Platform.getExtensionRegistry();
    final IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_POINT_ID);

    if (extensionPoint != null) {
        for (final IExtension extension : extensionPoint.getExtensions()) {
            for (final IConfigurationElement configurationElement : extension.getConfigurationElements()) {
                final ExtendPopupMenu extendPopupMenu = ExtendPopupMenu.createExtendPopupMenu(configurationElement, editor);
                if (extendPopupMenu != null) {
                    extendPopupMenuList.add(extendPopupMenu);
                }
            }
        }
    }
    return extendPopupMenuList;
}
 
Example 9
Source File: ScriptEngineFactoryManagerImpl.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public ScriptEngineFactoryManagerImpl( )
{
	super( );
	configs = new HashMap<String, IConfigurationElement>( );
	IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry( );
	IExtensionPoint extensionPoint = extensionRegistry
			.getExtensionPoint( "org.eclipse.birt.core.ScriptEngineFactory" );

	IExtension[] extensions = extensionPoint.getExtensions( );
	for ( IExtension extension : extensions )
	{
		IConfigurationElement[] configurations = extension
				.getConfigurationElements( );
		for ( IConfigurationElement configuration : configurations )
		{
			String scriptName = configuration.getAttribute( "scriptName" );
			configs.put( scriptName, configuration );
		}
	}
}
 
Example 10
Source File: BaseExtensionHelper.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
public static IExtension[] getExtensions(String type) {
    IExtension[] extensions = extensionsCache.get(type);
    if (extensions == null) {
        IExtensionRegistry registry = Platform.getExtensionRegistry();
        if (registry != null) { // we may not be in eclipse env when testing
            try {
                IExtensionPoint extensionPoint = registry.getExtensionPoint(type);
                extensions = extensionPoint.getExtensions();
                extensionsCache.put(type, extensions);
            } catch (Exception e) {
                Log.log(IStatus.ERROR, "Error getting extension for:" + type, e);
                throw new RuntimeException(e);
            }
        } else {
            extensions = new IExtension[0];
        }
    }
    return extensions;
}
 
Example 11
Source File: ClassProviderRegistryListener.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Though this listener reacts to the extension point changes, there could have been contributions before
 * it's been registered. This will parse these initial contributions.
 */
public void parseInitialContributions() {
    final IExtensionRegistry registry = Platform.getExtensionRegistry();

    for (IExtension extension : registry.getExtensionPoint(CLASS_PROVIDER_EXTENSION_POINT).getExtensions()) {
        parseClassProviderExtension(extension);
    }
}
 
Example 12
Source File: ContributionRegistry.java    From depan with Apache License 2.0 5 votes vote down vote up
/**
 * Load the plugins from the extension point, and fill the lists of entries.
 */
protected void load(String extensionId) {
  IExtensionRegistry registry = Platform.getExtensionRegistry();
  IExtensionPoint point = registry.getExtensionPoint(extensionId);
  if (null == point) {
    return;
  }
  for (IExtension extension: point.getExtensions()) {
    IContributor contrib = extension.getContributor();
    String bundleId = contrib.getName();
    // ... and for each elements
    for (IConfigurationElement element :
        extension.getConfigurationElements()) {

      // obtain an object on the entry
      ContributionEntry<T> entry = buildEntry(bundleId, element);
      String entryId = entry.getId();
      if (Strings.isNullOrEmpty(entryId)) {
        LOG.warn("Empty entry id in {} for {}", bundleId, extensionId);
      }
      entries.put(entryId, entry);

      // Try to instantiate the contribution and install it.
      try {
        T plugin = entry.prepareInstance();
        installContribution(entryId, plugin);
      } catch (CoreException err) {
        reportException(entryId, err);
        throw new RuntimeException(err);
      }
    }
  }
}
 
Example 13
Source File: NodejsInstallManager.java    From typescript.java with MIT License 5 votes vote down vote up
private void addRegistryListenerIfNeeded() {
	if (registryListenerIntialized)
		return;

	IExtensionRegistry registry = Platform.getExtensionRegistry();
	registry.addRegistryChangeListener(this, TypeScriptCorePlugin.PLUGIN_ID);
	registryListenerIntialized = true;
}
 
Example 14
Source File: ExtensionQuery.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
protected List<Data<T>> getDataImpl(DataRetriever<T> c) {
  List<Data<T>> classes = new ArrayList<Data<T>>();

  IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
  IExtensionPoint extensionPoint = pluginId == null ? extensionRegistry.getExtensionPoint(extensionPointName) :
    extensionRegistry.getExtensionPoint(pluginId, extensionPointName);
  // try old names: these need to be rewritten
  if(extensionPoint == null && pluginId != null && pluginId.startsWith("com.gwtplugins")) {
    String rewritten = pluginId.replace("com.gwtplugins", "com.google");
    extensionPoint = extensionRegistry.getExtensionPoint(rewritten, extensionPointName);
    if(extensionPoint != null) {
      System.err.println(">>>> OLD EXTENSION POINT REFERENCE: " + pluginId);
      new Throwable(">>>> OLD EXTENSION POINT REFERENCE: " + pluginId + " : " + extensionPointName).printStackTrace();
    }
  }
  if (extensionPoint != null) {
    IExtension[] extensions = extensionPoint.getExtensions();
    for (IExtension extension : extensions) {
      IConfigurationElement[] configurationElements = extension.getConfigurationElements();
      for (IConfigurationElement configurationElement : configurationElements) {
        T value = c.getData(configurationElement, attributeName);
        if (value != null) {
          classes.add(new Data<T>(value, configurationElement));
        }
      }
    }
  }
  return classes;
}
 
Example 15
Source File: DeclaredTemplatesListener.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Parses initial contributions.
 */
public void parseInitialContributions() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint extensionPoint = registry.getExtensionPoint(TEMPLATE_REGISTERY_EXTENSION_POINT);
    for (IExtension extension : extensionPoint.getExtensions()) {
        add(extension);
    }
}
 
Example 16
Source File: DeclaredTokensListener.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Parses initial contributions.
 */
public void parseInitialContributions() {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint extensionPoint = registry.getExtensionPoint(SERVICE_REGISTERY_EXTENSION_POINT);
    for (IExtension extension : extensionPoint.getExtensions()) {
        add(extension);
    }
}
 
Example 17
Source File: FilterDescriptor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns all contributed Java element filters.
 * @return all contributed Java element filters
 */
public static FilterDescriptor[] getFilterDescriptors() {
	if (fgFilterDescriptors == null) {
		IExtensionRegistry registry= Platform.getExtensionRegistry();
		IConfigurationElement[] elements= registry.getConfigurationElementsFor(JavaUI.ID_PLUGIN, EXTENSION_POINT_NAME);
		fgFilterDescriptors= createFilterDescriptors(elements);
	}
	return fgFilterDescriptors;
}
 
Example 18
Source File: JavaFoldingStructureProviderRegistry.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Reads all extensions.
 * <p>
 * This method can be called more than once in
 * order to reload from a changed extension registry.
 * </p>
 */
public void reloadExtensions() {
	IExtensionRegistry registry= Platform.getExtensionRegistry();
	Map<String, JavaFoldingStructureProviderDescriptor> map= new HashMap<String, JavaFoldingStructureProviderDescriptor>();

	IConfigurationElement[] elements= registry.getConfigurationElementsFor(JavaPlugin.getPluginId(), EXTENSION_POINT);
	for (int i= 0; i < elements.length; i++) {
		JavaFoldingStructureProviderDescriptor desc= new JavaFoldingStructureProviderDescriptor(elements[i]);
		map.put(desc.getId(), desc);
	}

	synchronized(this) {
		fDescriptors= Collections.unmodifiableMap(map);
	}
}
 
Example 19
Source File: ReportPlugin.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Returns all available extension names for report design files.
 * 
 * @return the extension name lisr
 */
public List<String> getReportExtensionNameList( )
{
	if ( reportExtensionNames == null )
	{
		reportExtensionNames = new ArrayList<String>( );

		IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry( );
		IConfigurationElement[] elements = extensionRegistry.getConfigurationElementsFor( "org.eclipse.ui.editors" ); //$NON-NLS-1$
		for ( int i = 0; i < elements.length; i++ )
		{

			String id = elements[i].getAttribute( "id" ); //$NON-NLS-1$
			if ( "org.eclipse.birt.report.designer.ui.editors.ReportEditor".equals( id ) ) //$NON-NLS-1$
			{
				if ( elements[i].getAttribute( "extensions" ) != null ) //$NON-NLS-1$
				{
					String[] extensionNames = elements[i].getAttribute( "extensions" ) //$NON-NLS-1$
							//$NON-NLS-1$
							.split( "," ); //$NON-NLS-1$
					for ( int j = 0; j < extensionNames.length; j++ )
					{
						extensionNames[j] = extensionNames[j].trim( );
						if ( !reportExtensionNames.contains( extensionNames[j] ) )
						{
							reportExtensionNames.add( extensionNames[j] );
						}
					}
				}
			}
		}

		IContentTypeManager contentTypeManager = Platform.getContentTypeManager( );
		IContentType contentType = contentTypeManager.getContentType( "org.eclipse.birt.report.designer.ui.editors.reportdesign" ); //$NON-NLS-1$
		String[] fileSpecs = contentType.getFileSpecs( IContentType.FILE_EXTENSION_SPEC );
		for ( int i = 0; i < fileSpecs.length; i++ )
		{
			reportExtensionNames.add( fileSpecs[i] );
		}
	}
	return reportExtensionNames;
}
 
Example 20
Source File: EclipsePlatform.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public IExtensionRegistry getExtensionRegistry( )
{
	return new EclipseExtensionRegistry( Platform.getExtensionRegistry( ) );
}