Search in sources :

Example 66 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.

the class AddFilesToRepositoryWizard method addPages.

@Override
public void addPages() {
    if (repository == null) {
        addPage(repoSelectionPage);
        repoSelectionPage.addPropertyChangeListener(LocalRepositorySelectionPage.PROP_SELECTED_REPO, new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                repository = (RepositoryPlugin) evt.getNewValue();
            }
        });
    }
    addPage(fileSelectionPage);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin)

Example 67 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.

the class ImportPackageQuickFixProcessor method getSuggestions.

IJavaCompletionProposal[] getSuggestions(Set<String> pkgs, IInvocationContext context) throws CoreException {
    List<RepositoryPlugin> ps = listRepositories();
    final BndBuildPathHandler handler = getBuildPathHandler(context);
    MultiMap<String, String> bundles = new MultiMap<>();
    String wsName = null;
    boolean loggedWorkspaceError = false;
    for (String pkg : pkgs) {
        for (RepositoryPlugin p : ps) {
            Collection<Capability> caps = null;
            if (p instanceof Repository) {
                caps = searchRepository((Repository) p, pkg);
            } else if (p instanceof WorkspaceRepository) {
                try {
                    caps = searchRepository(getWorkspaceRepo(), pkg);
                    wsName = p.getName();
                } catch (Exception e) {
                    if (!loggedWorkspaceError) {
                        logger.logError("Error trying to fetch the repository for the current workspace", e);
                        loggedWorkspaceError = true;
                    }
                }
            }
            if (caps == null) {
                continue;
            }
            for (Capability cap : caps) {
                final String bsn = capabilityToBSN(cap);
                if (bsn != null && !handler.containsBundle(bsn)) {
                    bundles.add(bsn, p.getName());
                }
            }
        }
    }
    if (bundles.isEmpty()) {
        return null;
    }
    IJavaCompletionProposal[] retval = new IJavaCompletionProposal[bundles.size()];
    int i = 0;
    for (Map.Entry<String, List<String>> bundle : bundles.entrySet()) {
        // NOTE: The call to contains() here, based on the current MultiMap implementation, will
        // do a linear search. Because a single bundle is unlikely to be found in more than a few
        // repos in any given workspace this probably won't make a difference, but if any performance issues show up
        // in the future this would be a place to look.
        final int relevance = bundle.getValue().contains(wsName) ? ADD_BUNDLE_WORKSPACE : ADD_BUNDLE;
        retval[i++] = new AddBundleCompletionProposal(bundle.getKey(), bundle.getValue(), relevance, context);
    }
    return retval;
}
Also used : Capability(org.osgi.resource.Capability) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) IJavaCompletionProposal(org.eclipse.jdt.ui.text.java.IJavaCompletionProposal) CoreException(org.eclipse.core.runtime.CoreException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) Point(org.eclipse.swt.graphics.Point) MultiMap(aQute.lib.collections.MultiMap) WorkspaceRepository(aQute.bnd.build.WorkspaceRepository) Repository(org.osgi.service.repository.Repository) WorkspaceRepository(aQute.bnd.build.WorkspaceRepository) List(java.util.List) ArrayList(java.util.ArrayList) MultiMap(aQute.lib.collections.MultiMap) Map(java.util.Map)

Aggregations

RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)67 Version (aQute.bnd.version.Version)26 File (java.io.File)26 Workspace (aQute.bnd.build.Workspace)12 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)11 Project (aQute.bnd.build.Project)9 HashMap (java.util.HashMap)9 Jar (aQute.bnd.osgi.Jar)7 CoreException (org.eclipse.core.runtime.CoreException)7 RemoteRepositoryPlugin (aQute.bnd.service.RemoteRepositoryPlugin)5 VersionRange (aQute.bnd.version.VersionRange)5 Description (aQute.lib.getopt.Description)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 IStatus (org.eclipse.core.runtime.IStatus)5 Parameters (aQute.bnd.header.Parameters)4 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 Status (org.eclipse.core.runtime.Status)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4