Java 类org.eclipse.core.runtime.IContributor 实例源码

项目:gwt-eclipse-plugin    文件:BundleUtilities.java   
/**
 * 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;
}
项目:cmake-eclipse-helper    文件:CMakeLauncher.java   
private String retrieveEclipseVersionString() {
    String product = System.getProperty("eclipse.product");
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point = registry.getExtensionPoint("org.eclipse.core.runtime.products");
    if (point != null) {
        IExtension[] extensions = point.getExtensions();
        for (IExtension ext : extensions) {
            if (product.equals(ext.getUniqueIdentifier())) {
                IContributor contributor = ext.getContributor();
                if (contributor != null) {
                    Bundle bundle = Platform.getBundle(contributor.getName());
                    if (bundle != null) {
                        Version version = bundle.getVersion();
                        return version.getMajor() + "." + version.getMinor();
                    }
                }
            }
        }
    }
    return null;
}
项目:OpenSPIFe    文件:TestJSConstraint.java   
@SuppressWarnings("restriction")
@BeforeClass
public static void setupExtensions() throws Exception {
    final IExtensionRegistry registry = Platform.getExtensionRegistry();
    Object key = ((ExtensionRegistry) registry).getTemporaryUserToken();
    Bundle bundle = Activator.getDefault().getBundle();
    IContributor contributor = ContributorFactoryOSGi.createContributor(bundle);
    InputStream inputStream = null;
    try {
        inputStream = FileLocator.openStream(bundle, new Path("datafiles/TestJSConstraintExtension.xml"), false);
        registry.addContribution(inputStream, contributor, false, null, null, key);
    } finally {
        if (inputStream != null) {
            inputStream.close();
        }
    }
    // wait until jobs kicked off by adding the contribution are complete
    DynamicExtensionUtils.waitForJobs();
}
项目:Environment    文件:Example.java   
private static URL convertAttributeResource(String attr, IConfigurationElement el) 
{
    IContributor contributor = el.getDeclaringExtension().getContributor();
    Bundle bundle = Platform.getBundle(contributor.getName());
    URL u = bundle.getEntry(el.getAttribute(attr));
    try
    {
        return FileLocator.toFileURL(u);
    } catch (Exception e)
    {
        Logger.getGlobal().warning(String.format("Unable to find resource <%s> for example <%s>.", 
                el.getAttribute("name"),attr));
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return null;

}
项目:neoscada    文件:ValidationRunner.java   
private boolean isTargetClass ( final String className, final IContributor contributor, final Class<? extends EObject> clazz )
{
    if ( className == null )
    {
        return false;
    }

    final Bundle bundle = findBundle ( contributor );
    if ( bundle == null )
    {
        throw new IllegalStateException ( String.format ( "Unable to find bundle '%s'", contributor.getName () ) );
    }

    try
    {
        final Class<?> targetClazz = bundle.loadClass ( className );
        if ( targetClazz.isAssignableFrom ( clazz ) )
        {
            return true;
        }
    }
    catch ( final ClassNotFoundException e )
    {
        throw new IllegalStateException ( String.format ( "Unable to find target class '%s'", className ), e );
    }

    return false;
}
项目:neoscada    文件:ValidationRunner.java   
private Bundle findBundle ( final IContributor contributor )
{
    final String cid = contributor.getName ();

    for ( final Bundle bundle : this.context.getBundles () )
    {
        if ( bundle.getSymbolicName ().equals ( cid ) )
        {
            return bundle;
        }
    }
    return null;
}
项目:depan    文件:ContributionRegistry.java   
/**
 * 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);
      }
    }
  }
}
项目:Eclipse-Postfix-Code-Completion    文件:CompletionProposalComputerRegistry.java   
/**
 * Log the status and inform the user about a misbehaving extension.
 *
 * @param descriptor the descriptor of the misbehaving extension
 * @param status a status object that will be logged
 */
void informUser(CompletionProposalComputerDescriptor descriptor, IStatus status) {
    JavaPlugin.log(status);
       String title= JavaTextMessages.CompletionProposalComputerRegistry_error_dialog_title;
       CompletionProposalCategory category= descriptor.getCategory();
       IContributor culprit= descriptor.getContributor();
       Set<String> affectedPlugins= getAffectedContributors(category, culprit);

    final String avoidHint;
    final String culpritName= culprit == null ? null : culprit.getName();
    if (affectedPlugins.isEmpty())
        avoidHint= Messages.format(JavaTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHint, new Object[] {culpritName, category.getDisplayName()});
    else
        avoidHint= Messages.format(JavaTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning, new Object[] {culpritName, category.getDisplayName(), toString(affectedPlugins)});

    String message= status.getMessage();
       // inlined from MessageDialog.openError
       MessageDialog dialog = new MessageDialog(JavaPlugin.getActiveWorkbenchShell(), title, null /* default image */, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) {
        @Override
        protected Control createCustomArea(Composite parent) {
            Link link= new Link(parent, SWT.NONE);
            link.setText(avoidHint);
            link.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.jdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null).open(); //$NON-NLS-1$
                }
            });
            GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
            gridData.widthHint= this.getMinimumMessageWidth();
            link.setLayoutData(gridData);
            return link;
        }
       };
       dialog.open();
}
项目:Eclipse-Postfix-Code-Completion    文件:CompletionProposalComputerRegistry.java   
/**
 * Returns the names of contributors affected by disabling a category.
 *
 * @param category the category that would be disabled
 * @param culprit the culprit plug-in, which is not included in the returned list
 * @return the names of the contributors other than <code>culprit</code> that contribute to <code>category</code> (element type: {@link String})
 */
private Set<String> getAffectedContributors(CompletionProposalCategory category, IContributor culprit) {
    Set<String> affectedPlugins= new HashSet<String>();
       for (Iterator<CompletionProposalComputerDescriptor> it= getProposalComputerDescriptors().iterator(); it.hasNext();) {
        CompletionProposalComputerDescriptor desc= it.next();
        CompletionProposalCategory cat= desc.getCategory();
        if (cat.equals(category)) {
            IContributor contributor= desc.getContributor();
            if (contributor != null && !culprit.equals(contributor))
                affectedPlugins.add(contributor.getName());
        }
       }
    return affectedPlugins;
   }
项目:Eclipse-Postfix-Code-Completion    文件:CompletionProposalComputerDescriptor.java   
/**
* Returns the contributor of the described extension.
*
* @return the contributor of the described extension
*/
  IContributor getContributor()  {
      try {
       return fElement.getContributor();
      } catch (InvalidRegistryObjectException e) {
        return null;
      }
  }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CompletionProposalComputerRegistry.java   
/**
 * Log the status and inform the user about a misbehaving extension.
 *
 * @param descriptor the descriptor of the misbehaving extension
 * @param status a status object that will be logged
 */
void informUser(CompletionProposalComputerDescriptor descriptor, IStatus status) {
    JavaPlugin.log(status);
       String title= JavaTextMessages.CompletionProposalComputerRegistry_error_dialog_title;
       CompletionProposalCategory category= descriptor.getCategory();
       IContributor culprit= descriptor.getContributor();
       Set<String> affectedPlugins= getAffectedContributors(category, culprit);

    final String avoidHint;
    final String culpritName= culprit == null ? null : culprit.getName();
    if (affectedPlugins.isEmpty())
        avoidHint= Messages.format(JavaTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHint, new Object[] {culpritName, category.getDisplayName()});
    else
        avoidHint= Messages.format(JavaTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning, new Object[] {culpritName, category.getDisplayName(), toString(affectedPlugins)});

    String message= status.getMessage();
       // inlined from MessageDialog.openError
       MessageDialog dialog = new MessageDialog(JavaPlugin.getActiveWorkbenchShell(), title, null /* default image */, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) {
        @Override
        protected Control createCustomArea(Composite parent) {
            Link link= new Link(parent, SWT.NONE);
            link.setText(avoidHint);
            link.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.jdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null).open(); //$NON-NLS-1$
                }
            });
            GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
            gridData.widthHint= this.getMinimumMessageWidth();
            link.setLayoutData(gridData);
            return link;
        }
       };
       dialog.open();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CompletionProposalComputerRegistry.java   
/**
 * Returns the names of contributors affected by disabling a category.
 *
 * @param category the category that would be disabled
 * @param culprit the culprit plug-in, which is not included in the returned list
 * @return the names of the contributors other than <code>culprit</code> that contribute to <code>category</code> (element type: {@link String})
 */
private Set<String> getAffectedContributors(CompletionProposalCategory category, IContributor culprit) {
    Set<String> affectedPlugins= new HashSet<String>();
       for (Iterator<CompletionProposalComputerDescriptor> it= getProposalComputerDescriptors().iterator(); it.hasNext();) {
        CompletionProposalComputerDescriptor desc= it.next();
        CompletionProposalCategory cat= desc.getCategory();
        if (cat.equals(category)) {
            IContributor contributor= desc.getContributor();
            if (contributor != null && !culprit.equals(contributor))
                affectedPlugins.add(contributor.getName());
        }
       }
    return affectedPlugins;
   }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CompletionProposalComputerDescriptor.java   
/**
* Returns the contributor of the described extension.
*
* @return the contributor of the described extension
*/
  IContributor getContributor()  {
      try {
       return fElement.getContributor();
      } catch (InvalidRegistryObjectException e) {
        return null;
      }
  }
项目:Environment    文件:SpecificationProviderService.java   
private static void init() {
    IConfigurationElement[] elements = Platform.getExtensionRegistry()
            .getConfigurationElementsFor(
                    "org.scaledl.overview.Specification");

    for (IConfigurationElement el : elements) {
        try {
            IExtension declaringExtension = el.getDeclaringExtension();
            IContributor contributor = declaringExtension.getContributor();
            Bundle bundle = Platform.getBundle(contributor.getName());

            // Specification model URL -- this is correct way to get URI in product
            URL fileURL = bundle.getEntry(el.getAttribute("model"));
            URL resolvedFileURL = FileLocator.toFileURL(fileURL);
            URI resolvedURI = new URI (resolvedFileURL.getProtocol(), resolvedFileURL.getPath(), null);
            File file = new File(resolvedURI);

            // Load specification resource and add specification to registry
            XMIResourceImpl resource = new XMIResourceImpl();
            //File file = new File(FileLocator.resolve(fileURL).toURI());
            resource.load(new FileInputStream(file), new HashMap<Object,Object>());
            Specification specification = (Specification)resource.getContents().get(0);  
            instance.addSpecification(specification);

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
项目:FindBug-for-Domino-Designer    文件:DetectorsExtensionHelper.java   
private static void addContribution(TreeMap<String, String> set, IConfigurationElement configElt) {
    String libPathAsString;
    String pluginId;
    IContributor contributor = null;
    try {
        contributor = configElt.getContributor();
        if (contributor == null) {
            throw new IllegalArgumentException("Null contributor");
        }
        pluginId = configElt.getAttribute(PLUGIN_ID);
        if (pluginId == null) {
            throw new IllegalArgumentException("Missing '" + PLUGIN_ID + "'");
        }
        libPathAsString = configElt.getAttribute(LIBRARY_PATH);
        if (libPathAsString == null) {
            throw new IllegalArgumentException("Missing '" + LIBRARY_PATH + "'");
        }
        libPathAsString = resolveRelativePath(contributor, libPathAsString);
        if (libPathAsString == null) {
            throw new IllegalArgumentException("Failed to resolve library path for: " + pluginId);
        }
        if(set.containsKey(pluginId)) {
            throw new IllegalArgumentException("Duplicated '" + pluginId + "' contribution.");
        }
        set.put(pluginId, libPathAsString);
    } catch (Throwable e) {
        String cName = contributor != null ? contributor.getName() : "unknown contributor";
        String message = "Failed to read contribution for '" + EXTENSION_POINT_ID
                + "' extension point from " + cName;
        FindbugsPlugin.getDefault().logException(e, message);
    }
}
项目:birt    文件:ConfigurationElement.java   
public IContributor getContributor( ) throws InvalidRegistryObjectException
{
       if( bundle == null )
       {
           IExtension declaringExtn = getDeclaringExtension();
           if( declaringExtn != null )
               return declaringExtn.getContributor();
           return null;
       }

    return bundle.getContributor( );
}
项目:birt    文件:ExtensionRegistry.java   
public boolean addContribution( InputStream is, IContributor contributor,
        boolean persist, String name, ResourceBundle translationBundle,
        Object token ) throws IllegalArgumentException

{
    throw new UnsupportedOperationException(
            "addContribution is not implemented yet" );
}
项目:birt    文件:ExtensionRegistry.java   
public IExtensionPoint[] getExtensionPoints( IContributor contributor )
{
    for ( Bundle bundle : bundles.values() )
    {
        if ( bundle.getContributor( ) == contributor )
        {
            return bundle.getExtensionPoints( );
        }
    }
    return new IExtensionPoint[]{};
}
项目:birt    文件:ExtensionRegistry.java   
public IExtension[] getExtensions( IContributor contributor )
{
    for ( Bundle bundle : bundles.values() )
    {
        if ( bundle.getContributor( ) == contributor )
        {
            return bundle.getExtensions( );
        }
    }
    return new IExtension[]{};
}
项目:mesfavoris    文件:RemoteBookmarksStoreLoader.java   
private void loadRemoteBookmarksStore() {
    remoteBookmarksStores = new ArrayList<>();
    IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT);

    if (extPoint == null) {
        StatusHelper.logError(MessageFormat.format("no {0} extension point", EXTENSION_POINT), null);
        return;
    }

    IExtension[] extensions = extPoint.getExtensions();
    for (int i = 0; i < extensions.length; i++) {
        IExtension extension = extensions[i];
        IContributor contributor = extension.getContributor();
        String contributorName;
        if (contributor instanceof RegistryContributor) {
            // contributor is a fragment
            contributorName = ((RegistryContributor) contributor).getActualName();
        } else {
            contributorName = contributor.getName();
        }

        IConfigurationElement[] elements = extension.getConfigurationElements();

        for (IConfigurationElement configurationElement : elements) {
            try {
                String id = configurationElement.getAttribute("id");
                String shortId = id.substring(id.lastIndexOf('.') + 1);
                String label = configurationElement.getAttribute("label");
                String iconResource = configurationElement.getAttribute("icon");
                String iconOverlayResource = configurationElement.getAttribute("overlayIcon");
                AbstractRemoteBookmarksStore store = (AbstractRemoteBookmarksStore) configurationElement
                        .createExecutableExtension("class");
                RemoteBookmarkStoreDescriptor remoteStoreDescriptor = new RemoteBookmarkStoreDescriptor(shortId,
                        label, iconResource, iconOverlayResource, contributorName);
                store.init(remoteStoreDescriptor);
                remoteBookmarksStores.add(store);
            } catch (CoreException e) {
                StatusHelper.logWarn(
                        "Could not create remote bookmarks store " + configurationElement.getAttribute("class"), e);
            }
        }
    }
}
项目:triquetrum    文件:PaletteConfigurationElement.java   
@Override
public IContributor getContributor() throws InvalidRegistryObjectException {
  return contributor;
}
项目:gwt-eclipse-plugin    文件:GWTJavaSpellingReconcileStrategy.java   
public IContributor getContributor() throws InvalidRegistryObjectException {
  return null;
}
项目:thym    文件:ExtensionPointProxy.java   
protected void setContributor(IContributor contributor) {
    this.contributor = contributor;
}
项目:birt    文件:ExtensionPoint.java   
public IContributor getContributor( ) throws InvalidRegistryObjectException
{
    return bundle.getContributor( );
}
项目:birt    文件:Bundle.java   
public IContributor getContributor( )
{
    return contributor;
}
项目:birt    文件:Extension.java   
public IContributor getContributor( ) throws InvalidRegistryObjectException
{
    return bundle.getContributor( );
}