use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class AbstractMarketplaceWizardCommand method installRemoteCatalogs.
public IStatus installRemoteCatalogs() {
try {
final AtomicReference<List<? extends ICatalog>> result = new AtomicReference<List<? extends ICatalog>>();
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
ICatalogService catalogService = ServiceHelper.getMarketplaceServiceLocator().getCatalogService();
final List<? extends ICatalog> catalogs = catalogService.listCatalogs(monitor);
result.set(catalogs);
} catch (CoreException e) {
if (e.getStatus().getSeverity() == IStatus.CANCEL) {
throw new InterruptedException();
}
throw new InvocationTargetException(e);
}
}
});
List<? extends ICatalog> catalogs = result.get();
for (ICatalog catalog : catalogs) {
ResourceProvider resourceProvider = MarketplaceClientUiPlugin.getInstance().getResourceProvider();
String catalogName = catalog.getName();
String requestSource = NLS.bind(Messages.MarketplaceWizardCommand_requestCatalog, catalogName, catalog.getId());
String catalogImageUrl = catalog.getImageUrl();
if (catalogImageUrl != null) {
try {
resourceProvider.retrieveResource(requestSource, catalogImageUrl);
} catch (Exception e) {
MarketplaceClientUi.log(IStatus.WARNING, Messages.MarketplaceWizardCommand_FailedRetrievingCatalogImage, catalogName, catalogImageUrl, e);
}
}
if (catalog.getBranding() != null && catalog.getBranding().getWizardIcon() != null) {
String wizardIconUrl = catalog.getBranding().getWizardIcon();
try {
resourceProvider.retrieveResource(requestSource, wizardIconUrl);
} catch (Exception e) {
MarketplaceClientUi.log(IStatus.WARNING, Messages.MarketplaceWizardCommand_FailedRetrievingCatalogWizardIcon, catalogName, wizardIconUrl, e);
}
}
CatalogDescriptor descriptor = new CatalogDescriptor(catalog);
registerOrOverrideCatalog(descriptor);
}
} catch (InterruptedException ie) {
if (ie.getMessage() == null || "".equals(ie.getMessage())) {
InterruptedException ie1 = new InterruptedException("Operation cancelled");
ie1.setStackTrace(ie.getStackTrace());
if (ie.getCause() != null) {
ie1.initCause(ie.getCause());
}
ie = ie1;
}
IStatus errorStatus = MarketplaceClientCore.computeStatus(ie, Messages.MarketplaceWizardCommand_CannotInstallRemoteLocations);
return new Status(IStatus.CANCEL, MarketplaceClientCore.BUNDLE_ID, errorStatus.getMessage(), ie);
} catch (Exception e) {
IStatus status = MarketplaceClientCore.computeStatus(e, Messages.MarketplaceWizardCommand_CannotInstallRemoteLocations);
return status;
}
return Status.OK_STATUS;
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class NewsViewer method computeNewsPreferenceKey.
private String computeNewsPreferenceKey() {
CatalogDescriptor catalogDescriptor = wizard.getConfiguration().getCatalogDescriptor();
URL catalogUrl = catalogDescriptor.getUrl();
URI catalogUri;
try {
catalogUri = catalogUrl.toURI();
} catch (URISyntaxException e) {
// should never happen
throw new IllegalStateException(e);
}
// $NON-NLS-1$ //$NON-NLS-2$
String marketplaceId = catalogUri.toString().replaceAll("[^a-zA-Z0-9_-]", "_");
// $NON-NLS-1$
return News.class.getSimpleName() + "/" + marketplaceId;
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategyTest method setUp.
@Before
public void setUp() throws Exception {
catalogUrl = new URL("http://marketplace.eclipse.org");
catalogDescriptor = new CatalogDescriptor(catalogUrl, "Eclipse.org Marketplace");
CatalogRegistry.getInstance().register(catalogDescriptor);
catalog = new MarketplaceCatalog();
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class CatalogDescriptorTest method testFindCatalogDescriptorWithCommonPrefixDifferentProtocol2.
/**
* @throws Exception
* @see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=488436">bug 488436</a>
*/
@Test
public void testFindCatalogDescriptorWithCommonPrefixDifferentProtocol2() throws Exception {
CatalogRegistry registry = CatalogRegistry.getInstance();
String marketplace = "https://marketplace.eclipse.org";
String marketplaceHttp = URLUtil.toggleHttps(marketplace);
String hostedMarketplace = "http://marketplace.eclipse.org/hosted_catalog/test";
String hostedMarketplaceHttps = 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(marketplaceHttp);
assertThat(found, is(marketplaceDescriptor));
found = registry.findCatalogDescriptor(hostedMarketplaceHttps);
assertThat(found, is(hostedMarketplaceDescriptor));
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class CatalogDescriptorTest method testCatalogDescriptorURLString.
@Test
public void testCatalogDescriptorURLString() throws Exception {
String label = "some label";
URL url = new URL("http://marketplace.eclipse.org");
CatalogDescriptor descriptor = new CatalogDescriptor(url, label);
assertEquals(label, descriptor.getLabel());
assertEquals(url.toString(), descriptor.getUrl().toString());
}
Aggregations