use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class MarketplaceCatalogTest method setupCatalog.
protected void setupCatalog() throws MalformedURLException {
final SearchResult discoveryResult = new SearchResult();
discoveryResult.setNodes(discoveryNodes);
CatalogDescriptor catalogDescriptor = new CatalogDescriptor();
catalogDescriptor.setUrl(new URL("http://marketplace.eclipse.org"));
MarketplaceDiscoveryStrategy discoveryStrategy = new MarketplaceDiscoveryStrategy(catalogDescriptor) {
final MarketplaceCategory category = new MarketplaceCategory();
{
category.setId("<root>");
}
@Override
public void performDiscovery(IProgressMonitor monitor) throws CoreException {
if (!categories.contains(category)) {
categories.add(category);
}
handleSearchResult(category, discoveryResult, new NullProgressMonitor());
}
@Override
protected synchronized Map<String, IInstallableUnit> computeInstalledIUs(IProgressMonitor monitor) {
Map<String, IInstallableUnit> installedIus = new HashMap<String, IInstallableUnit>();
for (INode node : installedNodes) {
IIus ius = node.getIus();
if (ius != null) {
for (IIu iu : ius.getIuElements()) {
String featureId = iu.getId() + ".feature.group";
InstallableUnit installableUnit = new InstallableUnit();
installableUnit.setId(featureId);
installedIus.put(featureId, installableUnit);
}
}
}
return installedIus;
}
@Override
protected MarketplaceCategory findMarketplaceCategory(IProgressMonitor monitor) throws CoreException {
return category;
}
};
catalog = new MarketplaceCatalog() {
@Override
protected IStatus checkForUpdates(List<MarketplaceNodeCatalogItem> updateCheckNeeded, final Map<String, IInstallableUnit> installedIUs, final IProgressMonitor monitor) {
for (MarketplaceNodeCatalogItem item : updateCheckNeeded) {
checkedForUpdate.add(item.getData());
List<MarketplaceNodeInstallableUnitItem> installableUnitItems = item.getInstallableUnitItems();
boolean hasUpdate = updateAvailable.contains(item.getData());
for (MarketplaceNodeInstallableUnitItem iuItem : installableUnitItems) {
iuItem.setUpdateAvailable(hasUpdate);
}
}
return Status.OK_STATUS;
}
};
catalog.getDiscoveryStrategies().add(discoveryStrategy);
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class MarketplaceUrlHandlerTest method installMockMarketplace.
@Before
public void installMockMarketplace() throws Exception {
URL url = new URL("http://marketplace.eclipse.org");
eclipseMarketplace = new CatalogDescriptor(url, "Eclipse Marketplace");
CatalogRegistry.getInstance().register(eclipseMarketplace);
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class SelectionModelStateSerializerTest method setUp.
@Before
public void setUp() throws Exception {
CatalogDescriptor catalogDescriptor = new CatalogDescriptor(new URL("http://marketplace.eclipse.org"), "Eclipse.org Marketplace");
discoveryStrategy = new MarketplaceDiscoveryStrategy(catalogDescriptor) {
@Override
public IMarketplaceService createMarketplaceService() {
DefaultMarketplaceService marketplaceService = new DefaultMarketplaceService(catalogDescriptor.getUrl());
Map<String, String> requestMetaParameters = ServiceLocator.computeDefaultRequestMetaParameters();
marketplaceService.setRequestMetaParameters(requestMetaParameters);
return marketplaceService;
}
};
catalog = new MarketplaceCatalog();
catalog.getDiscoveryStrategies().add(discoveryStrategy);
selectionModel = new SelectionModel(new InstallProfile() {
public Set<String> getInstalledFeatures() {
return Collections.emptySet();
}
});
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class CatalogRegistry method doFindCatalogDescriptor.
private CatalogDescriptor doFindCatalogDescriptor(String url) {
CatalogDescriptor matchingDescriptor = null;
String matchingUrl = null;
for (CatalogDescriptor catalogDescriptor : catalogDescriptors) {
String descriptorUrl = catalogDescriptor.getUrl().toExternalForm();
if (url.startsWith(descriptorUrl) && (matchingUrl == null || matchingUrl.length() < descriptorUrl.length())) {
String suffix = url.substring(descriptorUrl.length());
if (suffix.length() > 0 && suffix.charAt(0) == '/') {
suffix = suffix.substring(1);
}
if (suffix.startsWith(ICatalogService.DEDICATED_CATALOG_HOSTING_SEGMENT)) {
continue;
}
matchingDescriptor = catalogDescriptor;
matchingUrl = descriptorUrl;
}
}
return matchingDescriptor;
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class MarketplacePage method createMarketplaceSwitcher.
private void createMarketplaceSwitcher(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout());
final CatalogSwitcher switcher = new CatalogSwitcher(composite, SWT.BORDER, configuration);
switcher.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
CatalogDescriptor descriptor = (CatalogDescriptor) ((IStructuredSelection) event.getSelection()).getFirstElement();
showMarketplace(descriptor);
}
});
CatalogDescriptor selectedDescriptor = configuration.getCatalogDescriptor();
if (selectedDescriptor != null) {
switcher.setSelection(new StructuredSelection(selectedDescriptor));
lastSelection = selectedDescriptor;
}
marketplaceSwitcher = switcher;
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).minSize(1, SWT.DEFAULT).hint(500, SWT.DEFAULT).applyTo(composite);
}
Aggregations