use of org.eclipse.equinox.internal.p2.discovery.model.Tag in project epp.mpc by eclipse.
the class AbstractMarketplaceWizardBotTest method findFilter.
private AbstractTagFilter findFilter(Class<?> classifier) {
List<CatalogFilter> filters = getWizard().getConfiguration().getFilters();
for (CatalogFilter filter : filters) {
if (filter instanceof AbstractTagFilter) {
AbstractTagFilter tagFilter = (AbstractTagFilter) filter;
List<Tag> choices = tagFilter.getChoices();
Object classification = choices.isEmpty() ? null : choices.get(0).getTagClassifier();
if (classification == classifier) {
return tagFilter;
}
}
}
fail("No filter found for " + classifier.getName());
// unreachable
return null;
}
use of org.eclipse.equinox.internal.p2.discovery.model.Tag 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.equinox.internal.p2.discovery.model.Tag in project epp.mpc by eclipse.
the class CheckboxTagFilter method rebuildChoicesUi.
protected void rebuildChoicesUi() {
if (buttonContainer != null) {
for (Control control : buttonContainer.getChildren()) {
control.dispose();
}
for (final Tag choice : getChoices()) {
final Button checkbox = new Button(buttonContainer, SWT.CHECK);
checkbox.setData(choice);
checkbox.setSelection(getSelected().contains(choice));
checkbox.setText(choice.getLabel());
checkbox.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
boolean selection = checkbox.getSelection();
if (selection) {
getSelected().add(choice);
} else {
getSelected().remove(choice);
}
selectionUpdated();
}
});
}
GridLayoutFactory.fillDefaults().numColumns(buttonContainer.getChildren().length).applyTo(buttonContainer);
}
}
use of org.eclipse.equinox.internal.p2.discovery.model.Tag 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;
}
use of org.eclipse.equinox.internal.p2.discovery.model.Tag 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);
}
Aggregations