Search in sources :

Example 6 with Tag

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);
    }
}
Also used : Tag(org.eclipse.equinox.internal.p2.discovery.model.Tag)

Example 7 with Tag

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();
}
Also used : Tag(org.eclipse.equinox.internal.p2.discovery.model.Tag)

Example 8 with Tag

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));
}
Also used : Tag(org.eclipse.equinox.internal.p2.discovery.model.Tag)

Example 9 with Tag

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();
        }
    });
}
Also used : CatalogFilter(org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter) ICatalogBranding(org.eclipse.epp.mpc.core.model.ICatalogBranding) Tag(org.eclipse.equinox.internal.p2.discovery.model.Tag) IMarket(org.eclipse.epp.mpc.core.model.IMarket) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor)

Example 10 with Tag

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();
}
Also used : CatalogFilter(org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter) ICategory(org.eclipse.epp.mpc.core.model.ICategory) IIdentifiable(org.eclipse.epp.mpc.core.model.IIdentifiable) Tag(org.eclipse.equinox.internal.p2.discovery.model.Tag)

Aggregations

Tag (org.eclipse.equinox.internal.p2.discovery.model.Tag)14 CatalogFilter (org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter)5 ArrayList (java.util.ArrayList)4 ICategory (org.eclipse.epp.mpc.core.model.ICategory)4 CoreException (org.eclipse.core.runtime.CoreException)3 IMarket (org.eclipse.epp.mpc.core.model.IMarket)3 CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 HashSet (java.util.HashSet)2 IStatus (org.eclipse.core.runtime.IStatus)2 INode (org.eclipse.epp.mpc.core.model.INode)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 NoSuchElementException (java.util.NoSuchElementException)1 Set (java.util.Set)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1