Java Code Examples for org.eclipse.core.runtime.IContributor#getName()

The following examples show how to use org.eclipse.core.runtime.IContributor#getName() . 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: ValidationRunner.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
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 2
Source File: DetectorsExtensionHelper.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 3
Source File: ContributionRegistry.java    From depan with Apache License 2.0 5 votes vote down vote up
/**
 * 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 4
Source File: CompletionProposalComputerRegistry.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 5
Source File: QuickFixesExtensionHelper.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
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);
    }
}