use of org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceViewer.ContentType in project epp.mpc by eclipse.
the class MarketplacePage method setActiveTab.
private void setActiveTab(TabItem tab) {
if (disableTabSelection) {
return;
}
if (tab == newsTabItem) {
final INews news = getNews();
if (news == null) {
setActiveTab(currentContentType != null ? currentContentType : previousContentType != null ? previousContentType : ContentType.SEARCH);
updateNewsTab();
return;
}
boolean wasUpdated = newsViewer.isUpdated(news);
newsViewer.showNews(news);
if (wasUpdated) {
updateBranding();
TabItem currentTabItem = getSelectedTabItem();
if (currentTabItem != newsTabItem) {
tabFolder.setSelection(newsTabItem);
// required for Mac to not switch back to first tab
getControl().getDisplay().asyncExec(new Runnable() {
public void run() {
tabFolder.setSelection(newsTabItem);
}
});
}
}
return;
}
ContentType currentContentType = getViewer().getContentType();
if (currentContentType != null) {
TabItem tabItem = getTabItem(currentContentType);
if (tabItem == tab) {
setActiveTab(currentContentType);
return;
}
}
for (ContentType contentType : ContentType.values()) {
if (getTabItem(contentType) == tab) {
setActiveTab(contentType);
return;
}
}
throw new IllegalArgumentException(tab.getText());
}
use of org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceViewer.ContentType in project epp.mpc by eclipse.
the class MarketplacePage method createControl.
@Override
public void createControl(final Composite parent) {
currentBranding = getDefaultBranding();
boolean needSwitchMarketplaceControl = configuration.getCatalogDescriptors().size() > 1;
Composite pageContent = new Composite(parent, SWT.NULL);
GridLayoutFactory.fillDefaults().numColumns(1).spacing(0, 5).applyTo(pageContent);
tabFolder = new TabFolder(pageContent, SWT.TOP);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tabFolder);
super.createControl(tabFolder);
tabContent = getControl();
searchTabItem = createCatalogTab(-1, ContentType.SEARCH, WIDGET_ID_TAB_SEARCH, currentBranding.getSearchTabName());
recentTabItem = createCatalogTab(-1, ContentType.RECENT, WIDGET_ID_TAB_RECENT, currentBranding.getRecentTabName());
popularTabItem = createCatalogTab(-1, ContentType.POPULAR, WIDGET_ID_TAB_POPULAR, currentBranding.getPopularTabName());
favoritedTabItem = createCatalogTab(-1, ContentType.FAVORITES, WIDGET_ID_TAB_FAVORITES, getFavoritedTabName(currentBranding));
installedTabItem = createCatalogTab(-1, ContentType.INSTALLED, WIDGET_ID_TAB_INSTALLED, Messages.MarketplacePage_installed);
updateNewsTab();
searchTabItem.setControl(tabContent);
tabFolder.setSelection(searchTabItem);
tabFolder.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
if (e.item.isDisposed()) {
return;
}
setActiveTab((TabItem) e.item);
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
{
// TODO id
contentListLinks = new Link(pageContent, SWT.NULL);
contentListLinks.setToolTipText(Messages.MarketplacePage_showSelection);
contentListLinks.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
String actionId = e.text;
ActionLink actionLink = actions.get(actionId);
if (actionLink != null) {
actionLink.selected();
}
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(contentListLinks);
updateSelectionLink();
}
if (needSwitchMarketplaceControl) {
createMarketplaceSwitcher(pageContent);
}
updateBranding();
// bug 312411: a selection listener so that we can streamline install of single product
getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
private int previousSelectionSize = 0;
public void selectionChanged(SelectionChangedEvent event) {
if (!isCurrentPage()) {
return;
}
SelectionModel selectionModel = getWizard().getSelectionModel();
int newSelectionSize = selectionModel.getItemToSelectedOperation().size();
// sets the empty selection whenever the catalog is updated.
if (!event.getSelection().isEmpty()) {
if (previousSelectionSize == 0 && newSelectionSize > 0 && selectionModel.computeProvisioningOperationViableForFeatureSelection()) {
showNextPage();
}
}
previousSelectionSize = newSelectionSize;
}
});
getViewer().addPropertyChangeListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(MarketplaceViewer.CONTENT_TYPE_PROPERTY) && event.getNewValue() != null) {
setActiveTab((ContentType) event.getNewValue());
}
}
});
setControl(pageContent);
if (!tabContent.isDisposed()) {
// bug 473031 - no clue how this can happen during createControl...
MarketplaceClientUi.setDefaultHelp(tabContent);
}
}
use of org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceViewer.ContentType in project epp.mpc by eclipse.
the class MarketplaceClientService method setInitialContentType.
private void setInitialContentType(IMarketplaceClientConfiguration configuration, WizardState wizardState) {
if (configuration instanceof MarketplaceCatalogConfiguration) {
MarketplaceCatalogConfiguration catalogConfiguration = (MarketplaceCatalogConfiguration) configuration;
ContentType initialContentType = catalogConfiguration.getInitialContentType();
if (initialContentType != null) {
wizardState.setContentType(initialContentType);
}
}
}
use of org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceViewer.ContentType in project epp.mpc by eclipse.
the class BrowseCatalogItem method getMarketplaceUrl.
private static String getMarketplaceUrl(CatalogDescriptor catalogDescriptor, MarketplaceViewer viewer) throws URISyntaxException {
URL url = catalogDescriptor.getUrl();
try {
ContentType contentType = viewer.getQueryContentType();
if (contentType == ContentType.SEARCH) {
String queryText = viewer.getQueryText();
ICategory queryCategory = viewer.getQueryCategory();
IMarket queryMarket = viewer.getQueryMarket();
String path = new DefaultMarketplaceService(url).computeRelativeSearchUrl(queryMarket, queryCategory, queryText, false);
if (path != null) {
url = new URL(url, path);
}
}
} catch (IllegalArgumentException e) {
// should never happen
MarketplaceClientUi.error(e);
} catch (MalformedURLException e) {
// should never happen
MarketplaceClientUi.error(e);
}
URI uri = url.toURI();
return uri.toString();
}
Aggregations