Java Code Examples for org.eclipse.core.runtime.IExtensionRegistry#getExtensionPoint()

The following examples show how to use org.eclipse.core.runtime.IExtensionRegistry#getExtensionPoint() . 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: 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 2
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 3
Source File: BasePluginXmlTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@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);
  }
}
 
Example 4
Source File: Extensions.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Eine Liste von IConfigurationElements (=komplette Definition) liefern, die an einem
 * bestimmten Extensionpoint hängen, und den entsprechenden Elementnamen haben
 * 
 * @param ext
 * @param elementName
 * @return
 * @since 3.3
 */
public static List<IConfigurationElement> getExtensions(String ext, String elementName){
	List<IConfigurationElement> ret = new LinkedList<IConfigurationElement>();
	IExtensionRegistry exr = Platform.getExtensionRegistry();
	IExtensionPoint exp = exr.getExtensionPoint(ext);
	if (exp != null) {
		IExtension[] extensions = exp.getExtensions();
		for (IExtension ex : extensions) {
			IConfigurationElement[] elems = ex.getConfigurationElements();
			for (IConfigurationElement el : elems) {
				if (elementName != null) {
					if (elementName.equals(el.getName())) {
						ret.add(el);
					}
				} else {
					ret.add(el);
				}
			}
		}
		
	}
	return ret;
}
 
Example 5
Source File: SidebarPreferences.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent){
	list = new List(parent, SWT.BORDER | SWT.SINGLE);
	list.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
	IExtensionRegistry exr = Platform.getExtensionRegistry();
	IExtensionPoint exp = exr.getExtensionPoint(ExtensionPointConstantsUi.SIDEBAR);
	if (exp != null) {
		IExtension[] extensions = exp.getExtensions();
		for (IExtension ex : extensions) {
			IConfigurationElement[] elems = ex.getConfigurationElements();
			for (IConfigurationElement el : elems) {
				String name = el.getAttribute("name"); //$NON-NLS-1$
				String ID = el.getAttribute("ID"); //$NON-NLS-1$
				list.add(name + ":" + ID); //$NON-NLS-1$
			}
		}
	}
	
	return list;
}
 
Example 6
Source File: BirtWizardUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Find Configuration Elements from Extension Registry by Extension ID
 * 
 * @param extensionId
 * @return
 */
public static IConfigurationElement[] findConfigurationElementsByExtension(
		String extensionId )
{
	if ( extensionId == null )
		return null;

	// find Extension Point entry
	IExtensionRegistry registry = Platform.getExtensionRegistry( );
	IExtensionPoint extensionPoint = registry
			.getExtensionPoint( extensionId );

	if ( extensionPoint == null )
	{
		return null;
	}

	return extensionPoint.getConfigurationElements( );
}
 
Example 7
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 8
Source File: NewICEItemProjectWizard.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a new wizard element for the definition of the java code
 * templates
 * 
 * @return the wizard element corresponding to the project's template
 */
private WizardElement getTemplateWizard() {
	IExtensionRegistry registry = Platform.getExtensionRegistry();
	IExtensionPoint point = registry.getExtensionPoint("org.eclipse.ice.projectgeneration", PLUGIN_POINT);
	if (point == null)
		return null;
	IExtension[] extensions = point.getExtensions();
	for (int i = 0; i < extensions.length; i++) {
		IConfigurationElement[] elements = extensions[i].getConfigurationElements();
		for (int j = 0; j < elements.length; j++) {
			if (elements[j].getName().equals(TAG_WIZARD)) {
				if (TEMPLATE_ID.equals(elements[j].getAttribute(WizardElement.ATT_ID))) {
					return WizardElement.create(elements[j]);
				}
			}
		}
	}
	return null;
}
 
Example 9
Source File: BirtWizardUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Find Configuration Elements from Extension Registry by Extension ID
 * 
 * @param extensionId
 * @return
 */
public static IConfigurationElement[] findConfigurationElementsByExtension(
		String extensionId )
{
	if ( extensionId == null )
		return null;

	// find Extension Point entry
	IExtensionRegistry registry = Platform.getExtensionRegistry( );
	IExtensionPoint extensionPoint = registry.getExtensionPoint( extensionId );

	if ( extensionPoint == null )
	{
		return null;
	}

	return extensionPoint.getConfigurationElements( );
}
 
Example 10
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 11
Source File: EditorContributorManager.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private List getExtensionElements( String id )
{
	IExtensionRegistry registry = Platform.getExtensionRegistry( );
	if ( registry == null )
	{// extension registry cannot be resolved
		return Collections.EMPTY_LIST;
	}
	IExtensionPoint extensionPoint = registry.getExtensionPoint( id );
	if ( extensionPoint == null )
	{// extension point cannot be resolved
		return Collections.EMPTY_LIST;
	}
	return Arrays.asList( extensionPoint.getExtensions( ) );
}
 
Example 12
Source File: ExtensionPointManager.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private List<IExtension> getExtensionElements( String id )
{
	IExtensionRegistry registry = Platform.getExtensionRegistry( );
	if ( registry == null )
	{// extension registry cannot be resolved
		return Collections.emptyList( );
	}
	IExtensionPoint extensionPoint = registry.getExtensionPoint( id );
	if ( extensionPoint == null )
	{// extension point cannot be resolved
		return Collections.emptyList( );
	}
	return Arrays.asList( extensionPoint.getExtensions( ) );
}
 
Example 13
Source File: RegistryReader.java    From eclipsegraphviz with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Start the registry reading process using the supplied plugin ID and
 * extension point.
 * 
 * @param registry
 *            the registry to read from
 * @param extensionPoint
 *            the fully qualified extension point id
 */
public void readRegistry(IExtensionRegistry registry, String extensionPoint) {
    IExtensionPoint point = registry.getExtensionPoint(extensionPoint);
    if (point == null) {
        return;
    }
    IExtension[] extensions = point.getExtensions();
    extensions = orderExtensions(extensions);
    for (int i = 0; i < extensions.length; i++) {
        readExtension(extensions[i]);
    }
}
 
Example 14
Source File: TextContainer.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Der Konstruktor sucht nach dem in den Settings definierten Textplugin Wenn er kein Textplugin
 * findet, wählt er ein rudimentäres Standardplugin aus (das in der aktuellen Version nur eine
 * Fehlermeldung ausgibt)
 */
public TextContainer(){
	if (plugin == null) {
		String ExtensionToUse = CoreHub.localCfg.get(Preferences.P_TEXTMODUL, null);
		IExtensionRegistry exr = Platform.getExtensionRegistry();
		IExtensionPoint exp =
			exr.getExtensionPoint(ExtensionPointConstantsUi.TEXTPROCESSINGPLUGIN);
		if (exp != null) {
			IExtension[] extensions = exp.getExtensions();
			for (IExtension ex : extensions) {
				IConfigurationElement[] elems = ex.getConfigurationElements();
				for (IConfigurationElement el : elems) {
					if ((ExtensionToUse == null) || el.getAttribute("name").equals( //$NON-NLS-1$
						ExtensionToUse)) {
						try {
							plugin = (ITextPlugin) el.createExecutableExtension("Klasse"); //$NON-NLS-1$
						} catch (/* Core */Exception e) {
							ExHandler.handle(e);
						}
					}
					
				}
			}
		}
	}
	if (plugin == null) {
		plugin = new DefaultTextPlugin();
	}
}
 
Example 15
Source File: EclipseUtil.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Find all elements of a given name for an extension point and delegate processing to an
 * IConfigurationElementProcessor.
 * 
 * @param pluginId
 * @param extensionPointId
 * @param processor
 * @param elementNames
 */
public static void processConfigurationElements(String pluginId, String extensionPointId,
		IConfigurationElementProcessor processor)
{
	if (!StringUtil.isEmpty(pluginId) && !StringUtil.isEmpty(extensionPointId) && processor != null
			&& !processor.getSupportElementNames().isEmpty())
	{
		IExtensionRegistry registry = Platform.getExtensionRegistry();

		if (registry != null)
		{
			IExtensionPoint extensionPoint = registry.getExtensionPoint(pluginId, extensionPointId);

			if (extensionPoint != null)
			{
				Set<String> elementNames = processor.getSupportElementNames();
				IExtension[] extensions = extensionPoint.getExtensions();
				for (String elementName : elementNames)
				{
					for (IExtension extension : extensions)
					{
						IConfigurationElement[] elements = extension.getConfigurationElements();

						for (IConfigurationElement element : elements)
						{
							if (element.getName().equals(elementName))
							{
								processor.processElement(element);
								if (IdeLog.isTraceEnabled(CorePlugin.getDefault(), IDebugScopes.EXTENSION_POINTS))
								{
									IdeLog.logTrace(
											CorePlugin.getDefault(),
											MessageFormat
													.format("Processing extension element {0} with attributes {1}", element.getName(), //$NON-NLS-1$
															collectElementAttributes(element)),
											IDebugScopes.EXTENSION_POINTS);
								}
							}
						}
					}
				}
			}
		}
	}
}
 
Example 16
Source File: NewItemWizardPage.java    From ice with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * This operation creates the view that shows the list of Items that can be
 * created by the user.
 */
@Override
public void createControl(Composite parent) {

	// Set the parent reference
	parentComposite = parent;

	// Create the composite for file selection pieces
	Composite itemSelectionComposite = new Composite(parentComposite,
			SWT.NONE);
	// Set its layout
	GridLayout layout = new GridLayout(1, true);
	itemSelectionComposite.setLayout(layout);
	// Set its layout data
	GridData data = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
	itemSelectionComposite.setLayoutData(data);

	// Get the extension registry and retrieve the client.
	IExtensionRegistry registry = Platform.getExtensionRegistry();
	IExtensionPoint point = registry
			.getExtensionPoint("org.eclipse.ice.client.clientInstance");
	IExtension[] extensions = point.getExtensions();
	// Get the configuration element. The extension point can only have one
	// extension by default, so no need for a loop or check.
	IConfigurationElement[] elements = extensions[0]
			.getConfigurationElements();
	IConfigurationElement element = elements[0];

	// Get the client
	try {
		IClient client = (IClient) element
				.createExecutableExtension("class");
		// Draw the list of Items and present the selection wizard.
		drawWizard(itemSelectionComposite, client);
	} catch (CoreException e) {
		// Otherwise throw an error
		MessageBox errorMessage = new MessageBox(parent.getShell(), ERROR);
		errorMessage.setMessage("The ICE Client is not available. "
				+ "Please file a bug report.");
		errorMessage.open();
		// Log the error
		logger.error("ICEClient Extension not found.",e);
	}

	// Set the control
	setControl(itemSelectionComposite);
	// Disable the finished condition to start
	setPageComplete(false);

	return;

}
 
Example 17
Source File: JDBCDriverInfoManager.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Returns a list of JDBC drivers discovered in the driverInfo extensions,
 * as an array of JDBCDriverInformation objects
 */
public JDBCDriverInformation[] getDriversInfo( )
{
	if( jdbcDriverInfo!= null )
		return jdbcDriverInfo;
	
	synchronized( this )
	{
		if( jdbcDriverInfo!= null )
			return jdbcDriverInfo;			

		IExtensionRegistry extReg = Platform.getExtensionRegistry();
		IExtensionPoint extPoint = 
			extReg.getExtensionPoint( OdaJdbcDriver.Constants.DRIVER_INFO_EXTENSION );
		
		if ( extPoint == null )
			return new JDBCDriverInformation[0];
		
		IExtension[] exts = extPoint.getExtensions();
		if ( exts == null )
			return new JDBCDriverInformation[0];
		
		ArrayList<JDBCDriverInformation> drivers = new ArrayList<JDBCDriverInformation>( );
		
		for ( int e = 0; e < exts.length; e++)
		{
			IConfigurationElement[] configElems = exts[e].getConfigurationElements(); 
			if ( configElems == null )
				continue;
			
			for ( int i = 0; i < configElems.length; i++ )
			{
				if ( configElems[i].getName().equals( 
						OdaJdbcDriver.Constants.DRIVER_INFO_ELEM_JDBCDRIVER) )
				{
					drivers.add( newJdbcDriverInfo( configElems[i] ) );
				}
			}
		}

		jdbcDriverInfo = (JDBCDriverInformation[])drivers.toArray( new JDBCDriverInformation[0]);
	}
	return jdbcDriverInfo;
}
 
Example 18
Source File: JDBCDriverManager.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void loadDriverExtensions()
{
	if ( loadedDriver )
		// Already loaded
		return;
	
	synchronized( this )
	{
		if( loadedDriver )
			return;
		// First time: load all driverinfo extensions
		driverExtensions = new HashMap();
		IExtensionRegistry extReg = Platform.getExtensionRegistry();

		/* 
		 * getConfigurationElementsFor is not working for server Platform. 
		 * I have to work around this by walking the extension list
		IConfigurationElement[] configElems = 
			extReg.getConfigurationElementsFor( OdaJdbcDriver.Constants.DRIVER_INFO_EXTENSION );
		*/
		IExtensionPoint extPoint = 
			extReg.getExtensionPoint( OdaJdbcDriver.Constants.DRIVER_INFO_EXTENSION );
		
		if ( extPoint == null )
			return;
		
		IExtension[] exts = extPoint.getExtensions();
		if ( exts == null )
			return;
		
		for ( int e = 0; e < exts.length; e++)
		{
			IConfigurationElement[] configElems = exts[e].getConfigurationElements(); 
			if ( configElems == null )
				continue;
			
			for ( int i = 0; i < configElems.length; i++ )
			{
				if ( configElems[i].getName().equals( 
						OdaJdbcDriver.Constants.DRIVER_INFO_ELEM_JDBCDRIVER) )
				{
					String driverClass = configElems[i].getAttribute( 
							OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_DRIVERCLASS );
					String connectionFactory = configElems[i].getAttribute( 
							OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_CONNFACTORY );
					logger.info("Found JDBC driverinfo extension: driverClass=" + driverClass + //$NON-NLS-1$
							", connectionFactory=" + connectionFactory ); //$NON-NLS-1$
					if ( driverClass != null && driverClass.length() > 0 &&
						 connectionFactory != null && connectionFactory.length() > 0 )
					{
						// This driver class has its own connection factory; cache it
						// Note that the instantiation of the connection factory can wait
						// until we actually need it
						driverExtensions.put( driverClass, configElems[i] );
					}
				}
			}
		}
		loadedDriver = true;
	}
}
 
Example 19
Source File: ExpressionSupportManager.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * !! this method is experimental and should be replaced by API from
 * birt.core later
 * 
 * @return
 */
private static String[] getScriptExtensions( )
{
	IExtensionRegistry registry = Platform.getExtensionRegistry( );

	if ( registry == null )
	{
		return null;
	}

	IExtensionPoint extensionPoint = registry.getExtensionPoint( "org.eclipse.birt.core.ScriptEngineFactory" ); //$NON-NLS-1$

	if ( extensionPoint == null )
	{
		return null;
	}

	List<String> exts = new ArrayList<String>( );

	for ( IExtension extension : extensionPoint.getExtensions( ) )
	{
		if ( extension != null )
		{
			IConfigurationElement[] elements = extension.getConfigurationElements( );

			if ( elements != null )
			{
				for ( IConfigurationElement element : elements )
				{
					if ( element != null )
					{
						//final String id = element.getAttribute( "scriptID" ); //$NON-NLS-1$
						String name = element.getAttribute( "scriptName" ); //$NON-NLS-1$

						if ( name != null && name.length( ) > 0 )
						{
							exts.add( name );
						}
					}
				}
			}
		}
	}

	if ( exts.size( ) == 0 )
	{
		return null;
	}

	return exts.toArray( new String[exts.size( )] );

}
 
Example 20
Source File: OsgiPongoFactoryContributor.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
public void discoverExtensions() {
	
	cache = new HashMap<String, IConfigurationElement>();
	
	IExtensionRegistry registry = Platform.getExtensionRegistry();
	if (registry == null) {
		return;
	}

	IExtensionPoint extenstionPoint = registry.getExtensionPoint(extensionPoint);
	
	IConfigurationElement[] configurationElements = extenstionPoint.getConfigurationElements();
	
	for (int i=0;i<configurationElements.length;i++) {
		cache.put(configurationElements[i].getAttribute("name"), configurationElements[i]);			
	}

}