use of org.eclipse.epp.mpc.core.model.ISearchResult in project epp.mpc by eclipse.
the class DiscoverFileSupportJob method run.
private IStatus run(IMarketplaceService marketplaceService, IProgressMonitor monitor) {
final List<String> fileExtensions = getFileExtensions(fileName);
final List<String> fileExtensionTags = new ArrayList<String>();
for (String string : fileExtensions) {
fileExtensionTags.add(getFileExtensionTag(string));
}
final List<? extends INode> nodes;
try {
ISearchResult searchResult = marketplaceService.tagged(fileExtensionTags, monitor);
nodes = orderNodesByTagSubExtensionCount(searchResult.getNodes(), fileExtensionTags);
} catch (CoreException ex) {
IStatus status = new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, NLS.bind(Messages.DiscoverFileSupportJob_discoveryFailed, getFileExtensionLabel(fileName)), ex);
// Do not return this status as it would show an error, e.g. when the user is currently offline
MarketplaceClientUi.getLog().log(status);
return Status.CANCEL_STATUS;
}
if (nodes.isEmpty()) {
return Status.OK_STATUS;
}
UIJob openDialog = new ShowFileSupportProposalsJob(fileName, nodes, editorRegistry, defaultDescriptor, display);
openDialog.setPriority(Job.INTERACTIVE);
openDialog.setSystem(true);
openDialog.schedule();
return Status.OK_STATUS;
}
use of org.eclipse.epp.mpc.core.model.ISearchResult in project epp.mpc by eclipse.
the class DefaultMarketplaceService method resolveFavoriteNodes.
private ISearchResult resolveFavoriteNodes(final List<INode> nodes, IProgressMonitor monitor, boolean filterIncompatible) throws CoreException {
IMarketplaceService resolveService = this;
IMarketplaceService registeredService = ServiceHelper.getMarketplaceServiceLocator().getMarketplaceService(this.getBaseUrl().toString());
if (registeredService instanceof CachingMarketplaceService) {
CachingMarketplaceService cachingService = (CachingMarketplaceService) registeredService;
if (cachingService.getDelegate() == this) {
resolveService = cachingService;
}
}
final List<INode> resolvedNodes = resolveService.getNodes(nodes, monitor);
for (ListIterator<INode> i = resolvedNodes.listIterator(); i.hasNext(); ) {
INode resolved = i.next();
((Node) resolved).setUserFavorite(true);
if (filterIncompatible && !isInstallable(resolved)) {
i.remove();
}
}
if (!filterIncompatible) {
// sort the node list so uninstallable nodes come last
Collections.sort(resolvedNodes, new Comparator<INode>() {
public int compare(INode n1, INode n2) {
if (n1 == n2) {
return 0;
}
boolean n1Installable = isInstallable(n1);
boolean n2Installable = isInstallable(n2);
if (n1Installable == n2Installable) {
return 0;
}
if (n1Installable) {
// && !n2Installable
return -1;
}
// !n1Installable && n2Installable
return 1;
}
});
}
return new ISearchResult() {
public List<? extends INode> getNodes() {
return resolvedNodes;
}
public Integer getMatchCount() {
return resolvedNodes.size();
}
};
}
use of org.eclipse.epp.mpc.core.model.ISearchResult in project epp.mpc by eclipse.
the class CachingMarketplaceService method related.
public ISearchResult related(final List<? extends INode> basedOn, IProgressMonitor monitor) throws CoreException {
String searchKey = null;
if (basedOn != null && !basedOn.isEmpty()) {
StringBuilder searchKeyBldr = new StringBuilder();
for (INode node : basedOn) {
searchKeyBldr.append(node.getId()).append('+');
}
searchKey = searchKeyBldr.substring(0, searchKeyBldr.length() - 1);
}
// $NON-NLS-1$
String key = computeSearchKey("related", null, null, searchKey);
return performSearch(monitor, key, new SearchOperation() {
public ISearchResult doSearch(IProgressMonitor monitor) throws CoreException {
return delegate.related(basedOn, monitor);
}
});
}
use of org.eclipse.epp.mpc.core.model.ISearchResult in project epp.mpc by eclipse.
the class DefaultMarketplaceServiceTest method favorites.
@Test
@org.junit.experimental.categories.Category(RemoteTests.class)
// top favorites are not exposed in MPC anymore - this fails with a 503 due to the varnish cache failing
@Ignore
public void favorites() throws CoreException {
ISearchResult result = marketplaceService.topFavorites(new NullProgressMonitor());
assertSearchResultSanity(result);
}
use of org.eclipse.epp.mpc.core.model.ISearchResult in project epp.mpc by eclipse.
the class DefaultMarketplaceServiceTest method search_bug448453.
@Test
@org.junit.experimental.categories.Category(RemoteTests.class)
public void search_bug448453() throws CoreException {
ISearchResult result = search(null, null, "play!");
assertNotNull(result);
assertNotNull(result.getNodes());
}
Aggregations