Search in sources :

Example 1 with INews

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());
}
Also used : INews(org.eclipse.epp.mpc.core.model.INews) ICatalogs(org.eclipse.epp.mpc.core.model.ICatalogs) ICatalogBranding(org.eclipse.epp.mpc.core.model.ICatalogBranding) ICatalog(org.eclipse.epp.mpc.core.model.ICatalog) Test(org.junit.Test)

Example 2 with INews

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());
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) ContentType(org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceViewer.ContentType) INews(org.eclipse.epp.mpc.core.model.INews)

Example 3 with INews

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();
}
Also used : INews(org.eclipse.epp.mpc.core.model.INews)

Example 4 with INews

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;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CoreException(org.eclipse.core.runtime.CoreException) INews(org.eclipse.epp.mpc.core.model.INews) AbstractDiscoveryStrategy(org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy) SubMonitor(org.eclipse.core.runtime.SubMonitor) MultiStatus(org.eclipse.core.runtime.MultiStatus)

Example 5 with INews

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;
}
Also used : INews(org.eclipse.epp.mpc.core.model.INews)

Aggregations

INews (org.eclipse.epp.mpc.core.model.INews)8 IStatus (org.eclipse.core.runtime.IStatus)2 CatalogDescriptor (org.eclipse.epp.mpc.ui.CatalogDescriptor)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 Status (org.eclipse.core.runtime.Status)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 News (org.eclipse.epp.internal.mpc.core.model.News)1 ContentType (org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceViewer.ContentType)1 ICatalog (org.eclipse.epp.mpc.core.model.ICatalog)1 ICatalogBranding (org.eclipse.epp.mpc.core.model.ICatalogBranding)1 ICatalogs (org.eclipse.epp.mpc.core.model.ICatalogs)1 AbstractDiscoveryStrategy (org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 Image (org.eclipse.swt.graphics.Image)1 TabItem (org.eclipse.swt.widgets.TabItem)1 Test (org.junit.Test)1