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);
}
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;
}
Aggregations