Search in sources :

Example 1 with IMarket

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

the class DefaultMarketplaceServiceTest method findMarket.

private IMarket findMarket(String marketName) throws CoreException {
    List<? extends IMarket> markets = marketplaceService.listMarkets(new NullProgressMonitor());
    assertTrue(!markets.isEmpty());
    IMarket toolsMarket = null;
    for (IMarket market : markets) {
        if (marketName.equals(market.getName())) {
            toolsMarket = market;
            break;
        }
    }
    assertNotNull(toolsMarket);
    return toolsMarket;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IMarket(org.eclipse.epp.mpc.core.model.IMarket)

Example 2 with IMarket

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

the class DefaultMarketplaceServiceTest method listMarkets.

@Test
@org.junit.experimental.categories.Category(RemoteTests.class)
public void listMarkets() throws CoreException {
    List<? extends IMarket> markets = marketplaceService.listMarkets(new NullProgressMonitor());
    assertNotNull(markets);
    assertFalse(markets.isEmpty());
    for (IMarket market : markets) {
        assertNotNull(market.getId());
        assertNotNull(market.getUrl());
        assertNotNull(market.getName());
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IMarket(org.eclipse.epp.mpc.core.model.IMarket) Test(org.junit.Test)

Example 3 with IMarket

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

the class DefaultMarketplaceServiceTest method search.

private ISearchResult search(String marketName, String categoryName, String queryText) throws CoreException {
    IMarket toolsMarket = marketName == null ? null : findMarket(marketName);
    ICategory mylynCategory = categoryName == null ? null : findCategory(toolsMarket, categoryName);
    ISearchResult result = marketplaceService.search(toolsMarket, mylynCategory, queryText, new NullProgressMonitor());
    return result;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ISearchResult(org.eclipse.epp.mpc.core.model.ISearchResult) ICategory(org.eclipse.epp.mpc.core.model.ICategory) IMarket(org.eclipse.epp.mpc.core.model.IMarket)

Example 4 with IMarket

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

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

the class MarketplaceWizardCommand method createConfiguration.

@Override
protected MarketplaceCatalogConfiguration createConfiguration(final MarketplaceCatalog catalog, ExecutionEvent event) {
    MarketplaceCatalogConfiguration configuration = super.createConfiguration(catalog, event);
    if (configuration == null) {
        // errors have already been logged, just return
        return null;
    }
    configuration.getFilters().clear();
    final ComboTagFilter marketFilter = new ComboTagFilter() {

        @Override
        public void catalogUpdated(boolean wasCancelled) {
            List<Tag> choices = new ArrayList<Tag>();
            List<IMarket> markets = catalog.getMarkets();
            for (IMarket market : markets) {
                Tag marketTag = new Tag(IMarket.class, market.getId(), market.getName());
                marketTag.setData(market);
                choices.add(marketTag);
            }
            setChoices(choices);
        }
    };
    marketFilter.setSelectAllOnNoSelection(true);
    marketFilter.setNoSelectionLabel(Messages.MarketplaceWizardCommand_allMarkets);
    marketFilter.setTagClassification(ICategory.class);
    marketFilter.setChoices(new ArrayList<Tag>());
    final ComboTagFilter marketCategoryTagFilter = new ComboTagFilter() {

        @Override
        public void catalogUpdated(boolean wasCancelled) {
            updateCategoryChoices(this, marketFilter);
        }
    };
    marketCategoryTagFilter.setSelectAllOnNoSelection(true);
    marketCategoryTagFilter.setNoSelectionLabel(Messages.MarketplaceWizardCommand_allCategories);
    marketCategoryTagFilter.setTagClassification(ICategory.class);
    marketCategoryTagFilter.setChoices(new ArrayList<Tag>());
    final IPropertyChangeListener marketListener = new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            final String property = event.getProperty();
            if (AbstractTagFilter.PROP_SELECTED.equals(property)) {
                updateCategoryChoices(marketCategoryTagFilter, marketFilter);
            }
        }
    };
    marketFilter.addPropertyChangeListener(marketListener);
    configuration.getFilters().add(marketFilter);
    configuration.getFilters().add(marketCategoryTagFilter);
    configuration.setInitialState(wizardState);
    if (operations != null && !operations.isEmpty()) {
        configuration.setInitialOperations(operations);
    }
    for (CatalogFilter filter : configuration.getFilters()) {
        ((MarketplaceFilter) filter).setCatalog(catalog);
    }
    return configuration;
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) MarketplaceFilter(org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceFilter) ArrayList(java.util.ArrayList) CatalogFilter(org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter) MarketplaceCatalogConfiguration(org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceCatalogConfiguration) Tag(org.eclipse.equinox.internal.p2.discovery.model.Tag) ComboTagFilter(org.eclipse.epp.internal.mpc.ui.wizards.ComboTagFilter) IMarket(org.eclipse.epp.mpc.core.model.IMarket)

Aggregations

IMarket (org.eclipse.epp.mpc.core.model.IMarket)16 ICategory (org.eclipse.epp.mpc.core.model.ICategory)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 Test (org.junit.Test)5 Tag (org.eclipse.equinox.internal.p2.discovery.model.Tag)3 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 NoSuchElementException (java.util.NoSuchElementException)2 DefaultMarketplaceService (org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService)2 ISearchResult (org.eclipse.epp.mpc.core.model.ISearchResult)2 CatalogFilter (org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter)2 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 HashSet (java.util.HashSet)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 Marketplace (org.eclipse.epp.internal.mpc.core.model.Marketplace)1 Node (org.eclipse.epp.internal.mpc.core.model.Node)1 MarketplaceCatalog (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog)1