use of org.eclipse.epp.mpc.core.model.INews in project epp.mpc by eclipse.
the class UnmarshallerTest method marketplaceCatalogs.
@Test
public void marketplaceCatalogs() throws IOException, UnmarshalException {
Object model = processResource("resources/catalogs.xml");
assertNotNull(model);
assertTrue(model instanceof ICatalogs);
ICatalogs catalogs = (ICatalogs) model;
assertEquals(3, catalogs.getCatalogs().size());
// <catalog id="35656" title="Marketplace Catalog" url="http://marketplace.eclipse.org" selfContained="1" dependencyRepository="http://download.eclipse.org/releases/helios">
// <description>Here is a description</description>
// <icon>http://marketplace.eclipse.org/sites/default/files/jacket.jpg</icon>
// <wizard title="Eclipse Marketplace Catalog">
// <icon>http://marketplace.eclipse.org/sites/default/files/giant-rabbit2.jpg</icon>
// <searchtab enabled='1'>Search</searchtab>
// <populartab enabled='1'>Popular</populartab>
// <recenttab enabled='1'>Recent</recenttab>
// </wizard>
// </catalog>
ICatalog catalog = catalogs.getCatalogs().get(0);
assertEquals("35656", catalog.getId());
assertEquals("Marketplace Catalog", catalog.getName());
assertEquals("http://marketplace.eclipse.org", catalog.getUrl());
assertEquals("Here is a description", catalog.getDescription());
assertTrue(catalog.isSelfContained());
assertEquals("http://marketplace.eclipse.org/sites/default/files/marketplace32.png", catalog.getImageUrl());
assertEquals("http://download.eclipse.org/releases/helios", catalog.getDependencyRepository());
ICatalogBranding branding = catalog.getBranding();
assertNotNull(branding);
assertEquals("Eclipse Marketplace Catalog", branding.getWizardTitle());
assertEquals("http://marketplace.eclipse.org/sites/default/files/giant-rabbit2.jpg", branding.getWizardIcon());
assertEquals("Search", branding.getSearchTabName());
assertEquals("Popular", branding.getPopularTabName());
assertEquals("Recent", branding.getRecentTabName());
assertTrue(branding.hasSearchTab());
assertFalse(branding.hasPopularTab());
assertTrue(branding.hasRecentTab());
INews news = catalog.getNews();
assertNotNull(news);
assertEquals("http://marketplace.eclipse.org/news", news.getUrl());
assertEquals("News", news.getShortTitle());
assertEquals(Long.valueOf(1363181064000l), news.getTimestamp());
assertNull(catalogs.getCatalogs().get(1).getNews());
assertNull(catalogs.getCatalogs().get(2).getNews());
}
use of org.eclipse.epp.mpc.core.model.INews in project epp.mpc by eclipse.
the class MarketplacePage method setActiveTab.
private void setActiveTab(TabItem tab) {
if (disableTabSelection) {
return;
}
if (tab == newsTabItem) {
final INews news = getNews();
if (news == null) {
setActiveTab(currentContentType != null ? currentContentType : previousContentType != null ? previousContentType : ContentType.SEARCH);
updateNewsTab();
return;
}
boolean wasUpdated = newsViewer.isUpdated(news);
newsViewer.showNews(news);
if (wasUpdated) {
updateBranding();
TabItem currentTabItem = getSelectedTabItem();
if (currentTabItem != newsTabItem) {
tabFolder.setSelection(newsTabItem);
// required for Mac to not switch back to first tab
getControl().getDisplay().asyncExec(new Runnable() {
public void run() {
tabFolder.setSelection(newsTabItem);
}
});
}
}
return;
}
ContentType currentContentType = getViewer().getContentType();
if (currentContentType != null) {
TabItem tabItem = getTabItem(currentContentType);
if (tabItem == tab) {
setActiveTab(currentContentType);
return;
}
}
for (ContentType contentType : ContentType.values()) {
if (getTabItem(contentType) == tab) {
setActiveTab(contentType);
return;
}
}
throw new IllegalArgumentException(tab.getText());
}
use of org.eclipse.epp.mpc.core.model.INews in project epp.mpc by eclipse.
the class MarketplacePage method updateNewsTab.
private void updateNewsTab() {
if (newsTabItem == null) {
createNewsTab();
}
INews news = getNews();
if (news == null) {
if (!newsTabItem.isDisposed()) {
newsTabItem.dispose();
}
return;
} else if (newsTabItem.isDisposed()) {
createNewsTab();
}
if (news.getShortTitle() != null && news.getShortTitle().length() > 0) {
// $NON-NLS-1$//$NON-NLS-2$
String title = news.getShortTitle().replace("&", "&&");
String tooltip = title;
if (title.length() > 40) {
tooltip = title;
title = title.substring(0, 39) + '\u2026';
}
newsTabItem.setText(title);
newsTabItem.setToolTipText(tooltip);
}
updateNewsStatus();
}
use of org.eclipse.epp.mpc.core.model.INews in project epp.mpc by eclipse.
the class MarketplaceCatalog method performNewsDiscovery.
public IStatus performNewsDiscovery(IProgressMonitor monitor) {
if (getDiscoveryStrategies().isEmpty()) {
throw new IllegalStateException();
}
INews news = null;
MultiStatus status = new MultiStatus(MarketplaceClientUi.BUNDLE_ID, 0, Messages.MarketplaceCatalog_queryFailed, null);
final int totalTicks = 100000;
final SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceCatalog_Checking_News, totalTicks);
try {
int strategyTicks = totalTicks / getDiscoveryStrategies().size();
for (AbstractDiscoveryStrategy discoveryStrategy : getDiscoveryStrategies()) {
if (monitor.isCanceled()) {
status.add(Status.CANCEL_STATUS);
break;
}
if (discoveryStrategy instanceof MarketplaceDiscoveryStrategy) {
try {
MarketplaceDiscoveryStrategy marketplaceStrategy = (MarketplaceDiscoveryStrategy) discoveryStrategy;
news = marketplaceStrategy.performNewsDiscovery(progress.newChild(strategyTicks));
if (news != null) {
break;
}
} catch (CoreException e) {
status.add(new Status(e.getStatus().getSeverity(), DiscoveryCore.ID_PLUGIN, NLS.bind(Messages.MarketplaceCatalog_failedWithError, discoveryStrategy.getClass().getSimpleName()), e));
}
}
}
} finally {
monitor.done();
}
if (status.isOK()) {
setNews(news);
}
return status;
}
use of org.eclipse.epp.mpc.core.model.INews in project epp.mpc by eclipse.
the class CachingMarketplaceService method news.
public INews news(IProgressMonitor monitor) throws CoreException {
// $NON-NLS-1$
String newsKey = "News:News";
INews newsResult = getCached(newsKey, INews.class);
if (newsResult == null) {
newsResult = delegate.news(monitor);
synchronized (cache) {
cache(newsKey, newsResult);
}
}
return newsResult;
}
Aggregations