Search in sources :

Example 6 with INews

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

Example 7 with INews

use of org.eclipse.epp.mpc.core.model.INews in project epp.mpc by eclipse.

the class MarketplacePage method updateNewsStatus.

private void updateNewsStatus() {
    INews news = getNews();
    Image tabImage = null;
    if (news != null && newsViewer.isUpdated(news)) {
        tabImage = MarketplaceClientUiPlugin.getInstance().getImageRegistry().get(MarketplaceClientUiPlugin.NEWS_ICON_UPDATE);
    }
    newsTabItem.setImage(tabImage);
    newsTabItem.getParent().layout();
}
Also used : INews(org.eclipse.epp.mpc.core.model.INews) Image(org.eclipse.swt.graphics.Image)

Example 8 with INews

use of org.eclipse.epp.mpc.core.model.INews in project epp.mpc by eclipse.

the class MarketplaceWizard method updateNews.

protected void updateNews() {
    CatalogDescriptor catalogDescriptor = getConfiguration().getCatalogDescriptor();
    INews news = null;
    if (Boolean.parseBoolean(Platform.getDebugOption(DEBUG_NEWS_FLAG))) {
        // use debug override values
        String debugNewsUrl = Platform.getDebugOption(DEBUG_NEWS_URL);
        if (debugNewsUrl != null && debugNewsUrl.length() > 0) {
            News debugNews = new News();
            news = debugNews;
            debugNews.setUrl(debugNewsUrl);
            String debugNewsTitle = Platform.getDebugOption(DEBUG_NEWS_TITLE);
            if (debugNewsTitle == null || debugNewsTitle.length() == 0) {
                // $NON-NLS-1$
                debugNews.setShortTitle("Debug News");
            } else {
                debugNews.setShortTitle(debugNewsTitle);
            }
            debugNews.setTimestamp(System.currentTimeMillis());
        }
    }
    if (news == null) {
        // try requesting news from marketplace
        try {
            final INews[] result = new INews[1];
            getContainer().run(true, true, new IRunnableWithProgress() {

                public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    IStatus status = getCatalog().performNewsDiscovery(monitor);
                    if (!status.isOK() && status.getSeverity() != IStatus.CANCEL) {
                        // don't bother user with missing news
                        MarketplaceClientUi.handle(status, StatusManager.LOG);
                    }
                    result[0] = getCatalog().getNews();
                }
            });
            if (result[0] != null) {
                news = result[0];
            }
        } catch (InvocationTargetException e) {
            final IStatus status = MarketplaceClientCore.computeStatus(e, Messages.MarketplaceViewer_unexpectedException);
            MarketplaceClientUi.handle(status, StatusManager.LOG);
        } catch (InterruptedException e) {
        // cancelled by user
        }
    }
    if (news == null) {
        // use news from catalog
        news = CatalogRegistry.getInstance().getCatalogNews(catalogDescriptor);
    }
    CatalogRegistry.getInstance().addCatalogNews(catalogDescriptor, news);
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) INews(org.eclipse.epp.mpc.core.model.INews) News(org.eclipse.epp.internal.mpc.core.model.News) INews(org.eclipse.epp.mpc.core.model.INews) InvocationTargetException(java.lang.reflect.InvocationTargetException) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

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