Search in sources :

Example 1 with ICatalogBranding

use of org.eclipse.epp.mpc.core.model.ICatalogBranding 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 ICatalogBranding

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

the class MarketplacePage method updateBranding.

private void updateBranding() {
    disableTabSelection = true;
    updateTitle();
    CatalogDescriptor descriptor = configuration.getCatalogDescriptor();
    ICatalogBranding oldBranding = currentBranding;
    ICatalogBranding branding = descriptor == null ? null : descriptor.getCatalogBranding();
    if (branding == null) {
        branding = getDefaultBranding();
    }
    currentBranding = branding;
    TabItem selectedTabItem = getSelectedTabItem();
    int tabIndex = 0;
    boolean hasTab = branding.hasSearchTab();
    searchTabItem = updateTab(searchTabItem, ContentType.SEARCH, WIDGET_ID_TAB_SEARCH, branding.getSearchTabName(), hasTab, oldBranding.hasSearchTab(), tabIndex);
    if (hasTab) {
        tabIndex++;
    }
    hasTab = hasFeaturedMarketTab(branding);
    featuredMarketTabItem = updateTab(featuredMarketTabItem, ContentType.SEARCH, WIDGET_ID_TAB_FEATURED_MARKET, branding.getFeaturedMarketTabName(), hasTab, hasFeaturedMarketTab(oldBranding), tabIndex);
    if (hasTab) {
        tabIndex++;
    }
    hasTab = branding.hasRecentTab();
    recentTabItem = updateTab(recentTabItem, ContentType.SEARCH, WIDGET_ID_TAB_RECENT, branding.getRecentTabName(), hasTab, oldBranding.hasRecentTab(), tabIndex);
    if (hasTab) {
        tabIndex++;
    }
    hasTab = branding.hasPopularTab();
    popularTabItem = updateTab(popularTabItem, ContentType.SEARCH, WIDGET_ID_TAB_POPULAR, branding.getPopularTabName(), hasTab, oldBranding.hasPopularTab(), tabIndex);
    if (hasTab) {
        tabIndex++;
    }
    hasTab = branding.hasRelatedTab();
    relatedTabItem = updateTab(relatedTabItem, ContentType.SEARCH, WIDGET_ID_TAB_RELATED, branding.getRelatedTabName(), hasTab, oldBranding.hasRelatedTab(), tabIndex);
    if (hasTab) {
        tabIndex++;
    }
    hasTab = hasFavoritedTab(branding);
    favoritedTabItem = updateTab(favoritedTabItem, ContentType.SEARCH, WIDGET_ID_TAB_FAVORITES, getFavoritedTabName(branding), hasTab, hasFavoritedTab(oldBranding), tabIndex);
    if (hasTab) {
        tabIndex++;
    }
    updateNewsTab();
    if (selectedTabItem == null || selectedTabItem.isDisposed()) {
        tabFolder.setSelection(0);
    }
    final ImageDescriptor defaultWizardIconDescriptor = DiscoveryImages.BANNER_DISOVERY;
    if (branding.getWizardIcon() == null) {
        setImageDescriptor(defaultWizardIconDescriptor);
    } else {
        final Display display = Display.getCurrent();
        MarketplaceClientUiPlugin.getInstance().getResourceProvider().provideResource(new ResourceReceiver<ImageDescriptor>() {

            public ImageDescriptor processResource(URL resource) {
                return ImageDescriptor.createFromURL(resource);
            }

            public void setResource(final ImageDescriptor resource) {
                display.asyncExec(new Runnable() {

                    public void run() {
                        try {
                            setImageDescriptor(resource);
                        } catch (SWTException ex) {
                            // broken image
                            setImageDescriptor(defaultWizardIconDescriptor);
                        }
                    }
                });
            }
        }, branding.getWizardIcon(), defaultWizardIconDescriptor);
    }
    disableTabSelection = false;
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) SWTException(org.eclipse.swt.SWTException) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) ICatalogBranding(org.eclipse.epp.mpc.core.model.ICatalogBranding) URL(java.net.URL) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Display(org.eclipse.swt.widgets.Display)

Example 3 with ICatalogBranding

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

the class MarketplacePage method getDefaultBranding.

private ICatalogBranding getDefaultBranding() {
    CatalogBranding branding = new CatalogBranding();
    branding.setHasSearchTab(true);
    branding.setHasPopularTab(true);
    branding.setHasRecentTab(true);
    branding.setHasRelatedTab(false);
    branding.setHasFavoritesTab(false);
    branding.setHasFeaturedMarketTab(false);
    branding.setSearchTabName(Messages.MarketplacePage_search);
    branding.setPopularTabName(Messages.MarketplacePage_popular);
    branding.setRecentTabName(Messages.MarketplacePage_recent);
    branding.setRelatedTabName(Messages.MarketplacePage_related);
    branding.setFeaturedMarketTabName(Messages.MarketplacePage_featuredMarket);
    branding.setFavoritesTabName(Messages.MarketplacePage_favorites);
    branding.setWizardTitle(Messages.MarketplacePage_eclipseMarketplaceSolutions);
    branding.setWizardIcon(null);
    return branding;
}
Also used : ICatalogBranding(org.eclipse.epp.mpc.core.model.ICatalogBranding) CatalogBranding(org.eclipse.epp.internal.mpc.core.model.CatalogBranding)

Example 4 with ICatalogBranding

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

the class MarketplaceViewer method updateContent.

private void updateContent(final ContentType contentType, final Runnable queryCall) {
    final ContentType oldContentType = this.contentType;
    this.contentType = contentType;
    final boolean hadQuery = showQueryHeader(oldContentType);
    final boolean hasQuery = showQueryHeader(contentType);
    ContentType oldQueryType = oldContentType;
    if (oldQueryType == ContentType.SELECTION) {
        oldQueryType = ContentType.SEARCH;
    }
    ContentType queryType = contentType;
    if (queryType == ContentType.SELECTION) {
        queryType = ContentType.SEARCH;
    }
    if (oldQueryType != queryType || hasQuery != hadQuery) {
        if (hadQuery) {
            initQueryFromFilters();
            tabQueries.put(oldQueryType, queryData);
        }
        if (hasQuery) {
            QueryData newQueryData = tabQueries.get(queryType);
            if (newQueryData == null) {
                newQueryData = new QueryData();
                if (queryType == ContentType.FEATURED_MARKET) {
                    CatalogDescriptor catalogDescriptor = this.getWizard().getConfiguration().getCatalogDescriptor();
                    ICatalogBranding catalogBranding = catalogDescriptor.getCatalogBranding();
                    if (catalogBranding != null) {
                        boolean hasFeaturedMarketTab = catalogBranding.hasFeaturedMarketTab();
                        if (hasFeaturedMarketTab) {
                            String marketName = catalogBranding.getFeaturedMarketTabName();
                            if (marketName != null) {
                                for (CatalogFilter filter : getConfiguration().getFilters()) {
                                    if (filter instanceof AbstractTagFilter) {
                                        AbstractTagFilter tagFilter = (AbstractTagFilter) filter;
                                        if (tagFilter.getTagClassification() == ICategory.class) {
                                            for (Tag tag : tagFilter.getChoices()) {
                                                if (tag.getTagClassifier() != IMarket.class) {
                                                    break;
                                                }
                                                IMarket market = (IMarket) tag.getData();
                                                if (marketName.equals(market.getName())) {
                                                    // tagFilter.setSelected(Collections.singleton(tag));
                                                    newQueryData.queryMarket = market;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                                if (newQueryData.queryMarket == null) {
                                    // TODO remove/disable tab?
                                    setContentType(oldContentType);
                                    return;
                                }
                            }
                        }
                    }
                }
                tabQueries.put(queryType, newQueryData);
            }
            setFilters(newQueryData);
        }
    }
    runUpdate(new Runnable() {

        public void run() {
            fireContentTypeChange(oldContentType, contentType);
            setHeaderVisible(hasQuery);
            queryCall.run();
        }
    });
}
Also used : CatalogFilter(org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter) ICatalogBranding(org.eclipse.epp.mpc.core.model.ICatalogBranding) Tag(org.eclipse.equinox.internal.p2.discovery.model.Tag) IMarket(org.eclipse.epp.mpc.core.model.IMarket) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor)

Aggregations

ICatalogBranding (org.eclipse.epp.mpc.core.model.ICatalogBranding)4 CatalogDescriptor (org.eclipse.epp.mpc.ui.CatalogDescriptor)2 URL (java.net.URL)1 CatalogBranding (org.eclipse.epp.internal.mpc.core.model.CatalogBranding)1 ICatalog (org.eclipse.epp.mpc.core.model.ICatalog)1 ICatalogs (org.eclipse.epp.mpc.core.model.ICatalogs)1 IMarket (org.eclipse.epp.mpc.core.model.IMarket)1 INews (org.eclipse.epp.mpc.core.model.INews)1 Tag (org.eclipse.equinox.internal.p2.discovery.model.Tag)1 CatalogFilter (org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 SWTException (org.eclipse.swt.SWTException)1 Display (org.eclipse.swt.widgets.Display)1 TabItem (org.eclipse.swt.widgets.TabItem)1 Test (org.junit.Test)1