Search in sources :

Example 56 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project linuxtools by eclipse.

the class RemoteProxyManager method getRemoteManager.

/**
 * @param schemeId The protocol scheme to be used.
 * @return The {@link IRemoteProxyManager} for the given scheme.
 * @throws CoreException If a problem getting remote proxy manager for this scheme occurred.
 * @since 2.1
 */
protected IRemoteProxyManager getRemoteManager(String schemeId) throws CoreException {
    IRemoteProxyManager remoteManager = remoteManagers.get(schemeId);
    if (remoteManager == null) {
        IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(ProfileLaunchPlugin.PLUGIN_ID, IRemoteProxyManager.EXTENSION_POINT_ID);
        IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
        for (int i = 0; i < infos.length; i++) {
            IConfigurationElement configurationElement = infos[i];
            if (configurationElement.getName().equals(IRemoteProxyManager.MANAGER_NAME)) {
                if (configurationElement.getAttribute(IRemoteProxyManager.SCHEME_ID).equals(schemeId)) {
                    Object obj = configurationElement.createExecutableExtension(EXT_ATTR_CLASS);
                    if (obj instanceof IRemoteProxyManager) {
                        remoteManager = (IRemoteProxyManager) obj;
                        remoteManagers.put(schemeId, remoteManager);
                        break;
                    }
                }
            }
        }
    }
    return remoteManager;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 57 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project linuxtools by eclipse.

the class RemoteProxyNatureMapping method getSchemeFromNature.

public String getSchemeFromNature(IProject project) throws CoreException {
    IProjectDescription description = project.getDescription();
    String[] natures = description.getNatureIds();
    IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(ProfileLaunchPlugin.PLUGIN_ID, EXTENSION_POINT_ID);
    IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
    for (int i = 0; i < infos.length; i++) {
        IConfigurationElement configurationElement = infos[i];
        if (configurationElement.getName().equals(MANAGER_NAME)) {
            for (int j = 0; j < natures.length; j++) {
                if (configurationElement.getAttribute(NATURE_ID).equals(natures[j])) {
                    return configurationElement.getAttribute(SCHEME_ID);
                }
            }
        }
    }
    return null;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IProjectDescription(org.eclipse.core.resources.IProjectDescription) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 58 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project linuxtools by eclipse.

the class FileSystemSelectionArea method getSchemes.

private FileSystemElement[] getSchemes() {
    if (fsElements == null) {
        fsElements = new LinkedList<>();
        // Add all of the ones declared by the registry.
        IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(ProfileLaunchPlugin.PLUGIN_ID, EXTENSION_POINT_ID);
        IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
        for (int i = 0; i < infos.length; i++) {
            IConfigurationElement configurationElement = infos[i];
            if (configurationElement.getName().equals(RESOURCE_SELECTOR_PROXY_NAME)) {
                IRemoteResourceSelectorProxy remoteSelector = null;
                try {
                    Object obj = configurationElement.createExecutableExtension(EXT_ATTR_CLASS);
                    if (obj instanceof IRemoteResourceSelectorProxy) {
                        remoteSelector = (IRemoteResourceSelectorProxy) obj;
                    }
                } catch (CoreException e) {
                    ProfileLaunchPlugin.log(IStatus.ERROR, ResourceSelectorWidgetMessages.FileSystemSelectionArea_exception_while_creating_runnable_class + configurationElement.getAttribute(EXT_ATTR_CLASS), e);
                }
                FileSystemElement element = new FileSystemElement(configurationElement.getAttribute(SCHEME_ID), configurationElement.getAttribute(SCHEME_LABEL_ID), Boolean.valueOf(configurationElement.getAttribute(IS_DEFAULT_ID)), remoteSelector);
                fsElements.addLast(element);
            }
        }
    }
    return fsElements.toArray(new FileSystemElement[fsElements.size()]);
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 59 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project linuxtools by eclipse.

the class ValgrindLaunchPlugin method getToolDelegate.

public IValgrindLaunchDelegate getToolDelegate(String id) throws CoreException {
    IValgrindLaunchDelegate delegate = null;
    IConfigurationElement config = getToolMap().get(id);
    if (config != null) {
        Object obj = config.createExecutableExtension(EXT_ATTR_DELEGATE);
        if (obj instanceof IValgrindLaunchDelegate) {
            delegate = (IValgrindLaunchDelegate) obj;
        }
    }
    if (delegate == null) {
        // $NON-NLS-1$
        throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, Messages.getString("ValgrindLaunchPlugin.Cannot_retrieve_delegate")));
    }
    return delegate;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IValgrindLaunchDelegate(org.eclipse.linuxtools.valgrind.launch.IValgrindLaunchDelegate) CoreException(org.eclipse.core.runtime.CoreException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 60 with IConfigurationElement

use of org.eclipse.core.runtime.IConfigurationElement in project linuxtools by eclipse.

the class ValgrindUIPlugin method getToolView.

/**
 * Returns the view specialized of a tool.
 *
 * @param id The valgrind view identifier
 * @return IValgrindToolView The valgrind view
 * @throws CoreException The view cannot be retrieved
 */
public IValgrindToolView getToolView(String id) throws CoreException {
    IValgrindToolView view = null;
    IConfigurationElement config = getToolMap().get(id);
    if (config != null) {
        Object obj = config.createExecutableExtension(EXT_ATTR_CLASS);
        if (obj instanceof IValgrindToolView) {
            view = (IValgrindToolView) obj;
        }
    }
    if (view == null) {
        // $NON-NLS-1$
        throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, Messages.getString("ValgrindUIPlugin.Cannot_retrieve_view")));
    }
    return view;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IValgrindToolView(org.eclipse.linuxtools.valgrind.ui.IValgrindToolView) CoreException(org.eclipse.core.runtime.CoreException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Aggregations

IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)189 CoreException (org.eclipse.core.runtime.CoreException)75 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)64 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)50 ArrayList (java.util.ArrayList)39 IExtension (org.eclipse.core.runtime.IExtension)30 IStatus (org.eclipse.core.runtime.IStatus)24 Status (org.eclipse.core.runtime.Status)24 HashMap (java.util.HashMap)16 HashSet (java.util.HashSet)16 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)11 List (java.util.List)9 Map (java.util.Map)9 Platform (org.eclipse.core.runtime.Platform)9 File (java.io.File)8 Collection (java.util.Collection)8 Stream (java.util.stream.Stream)8 LinkedList (java.util.LinkedList)7 Optional (java.util.Optional)5 IFile (org.eclipse.core.resources.IFile)5