use of org.eclipse.equinox.internal.p2.discovery.model.Tag in project epp.mpc by eclipse.
the class ComboTagFilter method rebuildChoicesUi.
protected void rebuildChoicesUi() {
if (combo != null) {
combo.removeSelectionListener(listener);
combo.removeAll();
// $NON-NLS-1$
combo.add(noSelectionLabel == null ? "" : noSelectionLabel);
if (getChoices() != null) {
for (Tag tag : getChoices()) {
combo.add(tag.getLabel());
}
}
combo.select(0);
combo.addSelectionListener(listener);
}
}
use of org.eclipse.equinox.internal.p2.discovery.model.Tag in project epp.mpc by eclipse.
the class ComboTagFilter method updateUi.
@Override
protected void updateUi() {
if (combo.isDisposed()) {
return;
}
int index = -1;
if (!getSelected().isEmpty()) {
Tag selected = getSelected().iterator().next();
index = getChoices().indexOf(selected);
}
// offset+1 for "All Markets" entry
combo.select(index + 1);
super.updateUi();
}
use of org.eclipse.equinox.internal.p2.discovery.model.Tag in project epp.mpc by eclipse.
the class AbstractMarketplaceWizardBotTest method checkSelected.
private void checkSelected(AbstractTagFilter filter, String selection) {
Set<Tag> selected = filter.getSelected();
if (selection == null) {
assertTrue(selected.isEmpty());
return;
}
for (Tag tag : selected) {
if (tag.getLabel().equals(selection)) {
return;
}
if (tag.getValue().equals(selection)) {
return;
}
}
fail(NLS.bind("Expected value {0} not selected in filter", selection));
}
use of org.eclipse.equinox.internal.p2.discovery.model.Tag 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.discovery.model.Tag 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