use of org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter 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();
}
});
}
use of org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter in project epp.mpc by eclipse.
the class MarketplaceViewer method setFilters.
private void setFilters(QueryData queryData) {
// $NON-NLS-1$
setFindText(queryData.queryText == null ? "" : queryData.queryText);
for (CatalogFilter filter : getConfiguration().getFilters()) {
if (filter instanceof AbstractTagFilter) {
AbstractTagFilter tagFilter = (AbstractTagFilter) filter;
if (tagFilter.getTagClassification() == ICategory.class) {
List<Tag> choices = tagFilter.getChoices();
Tag tag = choices.isEmpty() ? null : choices.get(0);
if (tag != null) {
IIdentifiable data = null;
if (tag.getTagClassifier() == IMarket.class) {
data = queryData.queryMarket;
} else if (tag.getTagClassifier() == ICategory.class) {
data = queryData.queryCategory;
} else {
continue;
}
tag = null;
if (data != null) {
for (Tag choice : choices) {
final Object choiceData = choice.getData();
if (choiceData == data || matches(data, choiceData)) {
tag = choice;
break;
}
}
}
tagFilter.setSelected(tag == null ? Collections.<Tag>emptySet() : Collections.singleton(tag));
// we expect a query to happen next, so don't fire a property change resulting in an additional query
tagFilter.updateUi();
}
}
}
}
initQueryFromFilters();
}
Aggregations