Java Code Examples for org.eclipse.core.runtime.IConfigurationElement#getDeclaringExtension()

The following examples show how to use org.eclipse.core.runtime.IConfigurationElement#getDeclaringExtension() . 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: AboutDialog.java    From devstudio-tooling-ei with Apache License 2.0 6 votes vote down vote up
private void addProductIcons(Composite parent) {

		IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXT_POINT);
		for (IConfigurationElement element : config) {
			IExtension extension = element.getDeclaringExtension();
			if ("product".equals(element.getName())) {

				String version = element.getAttribute("version");
				String icon = element.getAttribute("icon");
				String name = element.getAttribute("name");
				String bundle_id = element.getAttribute("bundle_id");

				Image logoImage = ResourceManager.getPluginImage(bundle_id, icon);
				Label iconLable = new Label(parent, SWT.NONE);
				iconLable.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
				iconLable.setImage(logoImage);
				iconLable.setTouchEnabled(true);
				iconLable.setToolTipText(name + " " + version);
			}

		}

	}
 
Example 2
Source File: AboutDialog.java    From developer-studio with Apache License 2.0 6 votes vote down vote up
private void addProductIcons(Composite parent) {

		IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(EXT_POINT);
		for (IConfigurationElement element : config) {
			IExtension extension = element.getDeclaringExtension();
			if ("product".equals(element.getName())) {

				String version = element.getAttribute("version");
				String icon = element.getAttribute("icon");
				String name = element.getAttribute("name");
				String bundle_id = element.getAttribute("bundle_id");

				Image logoImage = ResourceManager.getPluginImage(bundle_id, icon);
				Label iconLable = new Label(parent, SWT.NONE);
				iconLable.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
				iconLable.setImage(logoImage);
				iconLable.setTouchEnabled(true);
				iconLable.setToolTipText(name + " " + version);
			}

		}

	}
 
Example 3
Source File: DataSetProvider.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @param dataSetType
 * @param dataSourceType
 * @return
 */
public static IConfigurationElement findDataSetElement( String dataSetType,
		String dataSourceType )
{
	// NOTE: multiple data source types can support the same data set type
	IConfigurationElement dataSourceElem = findDataSourceElement( dataSourceType );
	if ( dataSourceElem != null )
	{
		// Find data set declared in the same extension
		IExtension ext = dataSourceElem.getDeclaringExtension( );
		IConfigurationElement[] elements = ext.getConfigurationElements( );
		for ( int n = 0; n < elements.length; n++ )
		{
			if ( elements[n].getAttribute( "id" ).equals( dataSetType ) ) //$NON-NLS-1$
			{
				return elements[n];
			}
		}
	}
	return null;
}
 
Example 4
Source File: AbstractRegistryReader.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void logError(IConfigurationElement element, String text) {
	IExtension extension = element.getDeclaringExtension();
	log.error("Plugin " + extension.getContributor().getName() + ", extension "
			+ extension.getExtensionPointUniqueIdentifier());
	log.error(text);
}
 
Example 5
Source File: AbstractCheckRegistryReader.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
protected void logError(final IConfigurationElement element, final String text) {
  IExtension extension = element.getDeclaringExtension();
  getLogger().error("Plugin " + extension.getContributor().getName() + ", extension " + extension.getExtensionPointUniqueIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$
  getLogger().error(text);
}
 
Example 6
Source File: BuildPathManager.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void processElement(IConfigurationElement element)
{
	// get extension pt's bundle
	IExtension extension = element.getDeclaringExtension();
	String pluginId = extension.getNamespaceIdentifier();
	Bundle bundle = Platform.getBundle(pluginId);

	// grab the item's display name
	String name = element.getAttribute(ATTR_NAME);

	// get the item's URI, resolved to a local file
	String resource = element.getAttribute(ATTR_PATH);
	URL url = FileLocator.find(bundle, new Path(resource), null);

	// add item to master list
	URI localFileURI = ResourceUtil.resourcePathToURI(url);

	if (localFileURI != null)
	{
		addBuildPath(name, localFileURI);
	}
	else
	{
		// @formatter:off
		String message = MessageFormat.format(
			Messages.BuildPathManager_UnableToConvertURLToURI,
			url.toString(),
			ELEMENT_BUILD_PATH,
			BUILD_PATHS_ID,
			pluginId
		);
		// @formatter:on

		IdeLog.logError(BuildPathCorePlugin.getDefault(), message);
	}
}
 
Example 7
Source File: RegistryReader.java    From eclipsegraphviz with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Logs the error in the workbench log using the provided text and the
 * information in the configuration element.
 */
protected void logError(IConfigurationElement element, String text) {
    IExtension extension = element.getDeclaringExtension();
    StringBuffer buf = new StringBuffer();
    buf.append("Plugin " + extension.getContributor().getName() + ", extension " + extension.getExtensionPointUniqueIdentifier());//$NON-NLS-2$//$NON-NLS-1$
    buf.append("\n" + text);//$NON-NLS-1$
    LogUtils.logError(getNamespace(), buf.toString(), null);
}
 
Example 8
Source File: RegistryBuilderParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private static void doLogError(IConfigurationElement element, String text) {
	IExtension extension = element.getDeclaringExtension();
	readerLog.error("Plugin " + extension.getContributor().getName() + ", extension " + extension.getExtensionPointUniqueIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$
	readerLog.error(text);
}
 
Example 9
Source File: CompletionProposalComputerDescriptor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates a new descriptor.
 *
 * @param element the configuration element to read
 * @param registry the computer registry creating this descriptor
 * @param categories the categories
 * @throws InvalidRegistryObjectException if this extension is no longer valid
 * @throws CoreException if the extension contains invalid values
 */
CompletionProposalComputerDescriptor(IConfigurationElement element, CompletionProposalComputerRegistry registry, List<CompletionProposalCategory> categories) throws InvalidRegistryObjectException, CoreException {
	Assert.isLegal(registry != null);
	Assert.isLegal(element != null);

	fRegistry= registry;
	fElement= element;
	IExtension extension= element.getDeclaringExtension();
	fId= extension.getUniqueIdentifier();
	checkNotNull(fId, "id"); //$NON-NLS-1$

	String name= extension.getLabel();
	if (name.length() == 0)
		fName= fId;
	else
		fName= name;

	Set<String> partitions= new HashSet<String>();
	IConfigurationElement[] children= element.getChildren(PARTITION);
	if (children.length == 0) {
		fPartitions= PARTITION_SET; // add to all partition types if no partition is configured
	} else {
		for (int i= 0; i < children.length; i++) {
			String type= children[i].getAttribute(TYPE);
			checkNotNull(type, TYPE);
			partitions.add(type);
		}
		fPartitions= Collections.unmodifiableSet(partitions);
	}

	String activateAttribute= element.getAttribute(ACTIVATE);
	fActivate= Boolean.valueOf(activateAttribute).booleanValue();

	String needsSortingAfterFilteringAttribute= element.getAttribute(NEEDS_SORTING_AFTER_FILTERING);
	fNeedsSortingAfterFiltering= Boolean.valueOf(needsSortingAfterFilteringAttribute).booleanValue();

	fClass= element.getAttribute(CLASS);
	checkNotNull(fClass, CLASS);

	String categoryId= element.getAttribute(CATEGORY_ID);
	if (categoryId == null)
		categoryId= DEFAULT_CATEGORY_ID;
	CompletionProposalCategory category= null;
	for (Iterator<CompletionProposalCategory> it= categories.iterator(); it.hasNext();) {
		CompletionProposalCategory cat= it.next();
		if (cat.getId().equals(categoryId)) {
			category= cat;
			break;
		}
	}
	if (category == null) {
		// create a category if it does not exist
		fCategory= new CompletionProposalCategory(categoryId, fName, registry);
		categories.add(fCategory);
	} else {
		fCategory= category;
	}
}