Search in sources :

Example 6 with ICategory

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

the class MarketplaceClientServiceTest method testOpenSearch.

@Test
public void testOpenSearch() throws Exception {
    final IMarket toolsMarket = QueryHelper.marketByName("Tools");
    final ICategory mylynCategory = QueryHelper.categoryByName("Editor");
    display.asyncExec(new Runnable() {

        public void run() {
            service.openSearch(config, toolsMarket, mylynCategory, "snipmatch");
        }
    });
    initWizardBot();
    checkSelectedTab("Search");
    SWTBotCombo marketCombo = bot.comboBox(0);
    SWTBotCombo categoryCombo = bot.comboBox(1);
    assertEquals("Tools", marketCombo.getText());
    assertEquals("Editor", categoryCombo.getText());
    SWTBotText searchText = bot.text(0);
    assertEquals("snipmatch", searchText.getText());
    itemBot(NodeMatcher.withNameRegex(".*Snipmatch.*"));
}
Also used : SWTBotCombo(org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo) ICategory(org.eclipse.epp.mpc.core.model.ICategory) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) IMarket(org.eclipse.epp.mpc.core.model.IMarket) Test(org.junit.Test)

Example 7 with ICategory

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

the class MarketplaceViewer method initQueryFromFilters.

private void initQueryFromFilters() {
    queryData = new QueryData();
    findText = getFilterText();
    AbstractTagFilter marketFilter = null;
    for (CatalogFilter filter : getConfiguration().getFilters()) {
        if (filter instanceof AbstractTagFilter) {
            AbstractTagFilter tagFilter = (AbstractTagFilter) filter;
            if (tagFilter.getTagClassification() == ICategory.class) {
                Tag tag = tagFilter.getSelected().isEmpty() ? null : tagFilter.getSelected().iterator().next();
                if (tag != null) {
                    if (tag.getTagClassifier() == IMarket.class) {
                        marketFilter = tagFilter;
                        queryData.queryMarket = (IMarket) tag.getData();
                    } else if (tag.getTagClassifier() == ICategory.class) {
                        queryData.queryCategory = (ICategory) tag.getData();
                    }
                }
            }
        }
    }
    if (marketFilter != null) {
        setFilterEnabled(marketFilter, contentType != ContentType.FEATURED_MARKET);
    }
    queryData.queryText = findText;
}
Also used : CatalogFilter(org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter) ICategory(org.eclipse.epp.mpc.core.model.ICategory) Tag(org.eclipse.equinox.internal.p2.discovery.model.Tag)

Example 8 with ICategory

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

the class MarketplaceWizardCommand method updateCategoryChoices.

private void updateCategoryChoices(final ComboTagFilter marketCategoryTagFilter, final ComboTagFilter marketFilter) {
    Set<Tag> newChoices = new HashSet<Tag>();
    List<Tag> choices = new ArrayList<Tag>();
    Set<IMarket> selectedMarkets = new HashSet<IMarket>();
    for (Tag marketTag : marketFilter.getSelected()) {
        selectedMarkets.add((IMarket) marketTag.getData());
    }
    final MarketplaceCatalog catalog = (MarketplaceCatalog) marketCategoryTagFilter.getCatalog();
    List<IMarket> markets = catalog.getMarkets();
    for (IMarket market : markets) {
        if (selectedMarkets.isEmpty() || selectedMarkets.contains(market)) {
            for (ICategory marketCategory : market.getCategory()) {
                Tag categoryTag = new Tag(ICategory.class, marketCategory.getId(), marketCategory.getName());
                categoryTag.setData(marketCategory);
                if (newChoices.add(categoryTag)) {
                    choices.add(categoryTag);
                }
            }
        }
    }
    Collections.sort(choices, new Comparator<Tag>() {

        public int compare(Tag o1, Tag o2) {
            return o1.getLabel().compareTo(o2.getLabel());
        }
    });
    marketCategoryTagFilter.setChoices(choices);
}
Also used : ICategory(org.eclipse.epp.mpc.core.model.ICategory) ArrayList(java.util.ArrayList) Tag(org.eclipse.equinox.internal.p2.discovery.model.Tag) MarketplaceCatalog(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog) IMarket(org.eclipse.epp.mpc.core.model.IMarket) HashSet(java.util.HashSet)

Example 9 with ICategory

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

the class CachingMarketplaceService method cacheMarket.

private void cacheMarket(IMarket market) {
    String marketKey = computeMarketKey(market);
    cache(marketKey, market);
    List<? extends ICategory> categories = market.getCategory();
    for (ICategory category : categories) {
        cacheCategory(category);
    }
}
Also used : ICategory(org.eclipse.epp.mpc.core.model.ICategory)

Example 10 with ICategory

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

the class CachingMarketplaceService method getCategory.

public ICategory getCategory(ICategory category, IProgressMonitor monitor) throws CoreException {
    String categoryKey = computeCategoryKey(category);
    ICategory categoryResult = null;
    if (categoryKey != null) {
        categoryResult = getCached(categoryKey, ICategory.class);
    }
    if (categoryResult == null) {
        categoryResult = delegate.getCategory(category, monitor);
        if (categoryResult != null) {
            synchronized (cache) {
                cacheCategory(categoryResult);
            }
        }
    }
    return categoryResult;
}
Also used : ICategory(org.eclipse.epp.mpc.core.model.ICategory)

Aggregations

ICategory (org.eclipse.epp.mpc.core.model.ICategory)22 IMarket (org.eclipse.epp.mpc.core.model.IMarket)11 Test (org.junit.Test)10 Marketplace (org.eclipse.epp.internal.mpc.core.model.Marketplace)8 INode (org.eclipse.epp.mpc.core.model.INode)8 ICategories (org.eclipse.epp.mpc.core.model.ICategories)5 ArrayList (java.util.ArrayList)3 NoSuchElementException (java.util.NoSuchElementException)3 CoreException (org.eclipse.core.runtime.CoreException)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 SubMonitor (org.eclipse.core.runtime.SubMonitor)3 Tag (org.eclipse.equinox.internal.p2.discovery.model.Tag)3 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 DefaultMarketplaceService (org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService)2 ISearchResult (org.eclipse.epp.mpc.core.model.ISearchResult)2 IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 HashSet (java.util.HashSet)1