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.*"));
}
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;
}
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);
}
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);
}
}
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;
}
Aggregations