org.eclipse.core.runtime.IContributor Java Examples
The following examples show how to use
org.eclipse.core.runtime.IContributor.
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: BundleUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * 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; }
Example #2
Source File: CompletionProposalComputerDescriptor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * 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; } }
Example #3
Source File: ExtensionRegistry.java From birt with Eclipse Public License 1.0 | 5 votes |
public IExtension[] getExtensions( IContributor contributor ) { for ( Bundle bundle : bundles.values() ) { if ( bundle.getContributor( ) == contributor ) { return bundle.getExtensions( ); } } return new IExtension[]{}; }
Example #4
Source File: ExtensionRegistry.java From birt with Eclipse Public License 1.0 | 5 votes |
public IExtensionPoint[] getExtensionPoints( IContributor contributor ) { for ( Bundle bundle : bundles.values() ) { if ( bundle.getContributor( ) == contributor ) { return bundle.getExtensionPoints( ); } } return new IExtensionPoint[]{}; }
Example #5
Source File: ExtensionRegistry.java From birt with Eclipse Public License 1.0 | 5 votes |
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" ); }
Example #6
Source File: ConfigurationElement.java From birt with Eclipse Public License 1.0 | 5 votes |
public IContributor getContributor( ) throws InvalidRegistryObjectException { if( bundle == null ) { IExtension declaringExtn = getDeclaringExtension(); if( declaringExtn != null ) return declaringExtn.getContributor(); return null; } return bundle.getContributor( ); }
Example #7
Source File: ValidationRunner.java From neoscada with Eclipse Public License 1.0 | 5 votes |
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; }
Example #8
Source File: CompletionProposalComputerRegistry.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * 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; }
Example #9
Source File: CompletionProposalComputerRegistry.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * 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(); }
Example #10
Source File: ContributionRegistry.java From depan with Apache License 2.0 | 5 votes |
/** * 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 #11
Source File: DetectorsExtensionHelper.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
private static void addContribution(TreeMap<String, String> set, IConfigurationElement configElt) { IContributor contributor = configElt.getContributor(); try { if (contributor == null) { throw new IllegalArgumentException("Null contributor"); } String pluginId = configElt.getAttribute(PLUGIN_ID); if (pluginId == null) { throw new IllegalArgumentException("Missing '" + PLUGIN_ID + "'"); } String 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); } }
Example #12
Source File: ValidationRunner.java From neoscada with Eclipse Public License 1.0 | 5 votes |
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; }
Example #13
Source File: GWTJavaSpellingReconcileStrategy.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
public IContributor getContributor() throws InvalidRegistryObjectException { return null; }
Example #14
Source File: ExtensionPointProxy.java From thym with Eclipse Public License 1.0 | 4 votes |
protected void setContributor(IContributor contributor) { this.contributor = contributor; }
Example #15
Source File: ExtensionPoint.java From birt with Eclipse Public License 1.0 | 4 votes |
public IContributor getContributor( ) throws InvalidRegistryObjectException { return bundle.getContributor( ); }
Example #16
Source File: Bundle.java From birt with Eclipse Public License 1.0 | 4 votes |
public IContributor getContributor( ) { return contributor; }
Example #17
Source File: Extension.java From birt with Eclipse Public License 1.0 | 4 votes |
public IContributor getContributor( ) throws InvalidRegistryObjectException { return bundle.getContributor( ); }
Example #18
Source File: QuickFixesExtensionHelper.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
private static void addContribution(Map<String, List<QuickFixContribution>> set, final IConfigurationElement configElt) { IContributor contributor = null; try { contributor = configElt.getContributor(); if (contributor == null) { throw new IllegalArgumentException("Null contributor"); } String clazzFqn = configElt.getAttribute(CLASS_FQN); if (isEmpty(clazzFqn)) { throw new IllegalArgumentException("Missing '" + CLASS_FQN + "' attribute"); } String label = configElt.getAttribute(LABEL); if (isEmpty(label)) { throw new IllegalArgumentException("Missing '" + LABEL + "' attribute"); } String pattern = configElt.getAttribute(PATTERN); if (isEmpty(pattern)) { throw new IllegalArgumentException("Missing '" + PATTERN + "' attribute"); } String arg = configElt.getAttribute(ARGUMENTS); Set<String> args; if (arg == null) { args = Collections.emptySet(); } else { args = new HashSet<>(); for (String string : arg.split(",\\s*")) { args.add(string); } } QuickFixContribution qf = createQuickFix(configElt, clazzFqn, label, pattern, args); List<QuickFixContribution> list = set.get(pattern); if (list == null) { list = new ArrayList<>(); set.put(pattern, list); } if (list.contains(qf)) { throw new IllegalArgumentException("Duplicated quick fix contribution for pattern '" + pattern + "': " + qf + "."); } list.add(qf); } 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); } }