use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class CatalogDescriptorTest method testFindCatalogDescriptorWithCommonPrefixDifferentProtocol1.
/**
* @throws Exception
* @see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=488436">bug 488436</a>
*/
@Test
public void testFindCatalogDescriptorWithCommonPrefixDifferentProtocol1() throws Exception {
CatalogRegistry registry = CatalogRegistry.getInstance();
String marketplace = "http://marketplace.eclipse.org";
String marketplaceHttps = URLUtil.toggleHttps(marketplace);
String hostedMarketplace = "https://marketplace.eclipse.org/hosted_catalog/test";
String hostedMarketplaceHttp = URLUtil.toggleHttps(hostedMarketplace);
CatalogDescriptor marketplaceDescriptor = new CatalogDescriptor(new URL(marketplace), null);
CatalogDescriptor hostedMarketplaceDescriptor = new CatalogDescriptor(new URL(hostedMarketplace), null);
registry.register(marketplaceDescriptor);
registry.register(hostedMarketplaceDescriptor);
CatalogDescriptor found = registry.findCatalogDescriptor(marketplaceHttps);
assertThat(found, is(marketplaceDescriptor));
found = registry.findCatalogDescriptor(hostedMarketplaceHttp);
assertThat(found, is(hostedMarketplaceDescriptor));
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class CatalogDescriptorTest method testFindCatalogDescriptorWithCommonPrefix.
/**
* @throws Exception
* @see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=488436">bug 488436</a>
*/
@Test
public void testFindCatalogDescriptorWithCommonPrefix() throws Exception {
CatalogRegistry registry = CatalogRegistry.getInstance();
String marketplace = "http://marketplace.eclipse.org";
String hostedMarketplace = "http://marketplace.eclipse.org/hosted_catalog/test";
CatalogDescriptor marketplaceDescriptor = new CatalogDescriptor(new URL(marketplace), null);
CatalogDescriptor hostedMarketplaceDescriptor = new CatalogDescriptor(new URL(hostedMarketplace), null);
registry.register(marketplaceDescriptor);
registry.register(hostedMarketplaceDescriptor);
CatalogDescriptor found = registry.findCatalogDescriptor(marketplace);
assertThat(found, is(marketplaceDescriptor));
found = registry.findCatalogDescriptor(hostedMarketplace);
assertThat(found, is(hostedMarketplaceDescriptor));
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class CatalogExtensionPointReader method getCatalogDescriptors.
public List<CatalogDescriptor> getCatalogDescriptors() {
IExtensionPoint extensionPoint = // $NON-NLS-1$
Platform.getExtensionRegistry().getExtensionPoint(// $NON-NLS-1$
"org.eclipse.epp.mpc.ui", // $NON-NLS-1$
"catalog");
if (extensionPoint == null) {
throw new IllegalStateException();
}
List<CatalogDescriptor> descriptors = new ArrayList<CatalogDescriptor>();
for (IConfigurationElement element : extensionPoint.getConfigurationElements()) {
if (element.getName().equals("catalog")) {
// $NON-NLS-1$
try {
// $NON-NLS-1$
String urlText = element.getAttribute("url");
if (urlText == null || urlText.trim().length() == 0) {
throw new Exception(Messages.CatalogExtensionPointReader_urlRequired);
}
URL url = URLUtil.toURL(urlText);
// $NON-NLS-1$
String label = element.getAttribute("label");
if (label == null || label.trim().length() == 0) {
throw new Exception(Messages.CatalogExtensionPointReader_labelRequired);
}
CatalogDescriptor descriptor = new CatalogDescriptor(url, label);
// $NON-NLS-1$
descriptor.setDescription(element.getAttribute("description"));
// $NON-NLS-1$
final String icon = element.getAttribute("icon");
if (icon != null) {
URL iconResource = Platform.getBundle(element.getContributor().getName()).getResource(icon);
if (iconResource == null) {
throw new Exception(NLS.bind(Messages.CatalogExtensionPointReader_cannotFindResource, icon));
}
descriptor.setIcon(ImageDescriptor.createFromURL(iconResource));
}
// $NON-NLS-1$
String selfContained = element.getAttribute("selfContained");
if (selfContained == null || selfContained.trim().length() == 0) {
// $NON-NLS-1$
selfContained = "true";
} else {
selfContained = selfContained.trim();
}
descriptor.setInstallFromAllRepositories(!Boolean.valueOf(selfContained));
// $NON-NLS-1$
String dependenciesRepository = element.getAttribute("dependenciesRepository");
if (dependenciesRepository != null && dependenciesRepository.trim().length() > 0) {
URL repository = new URL(dependenciesRepository);
// we do this later, so let's see the error now.
repository.toURI();
descriptor.setDependenciesRepository(repository);
}
if (!descriptors.contains(descriptor)) {
descriptors.add(descriptor);
}
} catch (Exception e) {
MarketplaceClientUi.error(NLS.bind(Messages.CatalogExtensionPointReader_cannotRegisterCatalog_bundle_reason, element.getContributor().getName(), e.getMessage()), e);
}
}
}
return descriptors;
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class MarketplacePage method getNews.
private INews getNews() {
CatalogDescriptor descriptor = configuration.getCatalogDescriptor();
INews news = CatalogRegistry.getInstance().getCatalogNews(descriptor);
return news;
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class MarketplacePage method setVisible.
@Override
public void setVisible(boolean visible) {
if (visible) {
CatalogDescriptor catalogDescriptor = configuration.getCatalogDescriptor();
if (catalogDescriptor != null) {
setTitle(catalogDescriptor.getLabel());
}
if (previousCatalogDescriptor == null || !previousCatalogDescriptor.equals(catalogDescriptor)) {
previousCatalogDescriptor = catalogDescriptor;
tabFolder.setSelection(searchTabItem);
getViewer().setContentType(ContentType.SEARCH);
getWizard().initializeCatalog();
updated = false;
}
}
super.setVisible(visible);
}
Aggregations