use of org.eclipse.epp.mpc.ui.CatalogDescriptor 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.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class MarketplaceWizard method resumeWizard.
public static void resumeWizard(Display display, Object state, boolean proceedWithInstall) {
String catalogUrl = (String) state;
if (proceedWithInstall) {
org.eclipse.epp.mpc.ui.MarketplaceUrlHandler.SolutionInstallationInfo installInfo = MarketplaceUrlHandler.createSolutionInstallInfo(catalogUrl);
if (installInfo != null) {
MarketplaceUrlHandler.triggerInstall(installInfo);
return;
}
}
CatalogDescriptor descriptor = catalogUrl == null ? null : CatalogRegistry.getInstance().findCatalogDescriptor(catalogUrl);
final MarketplaceWizardCommand command = new MarketplaceWizardCommand();
if (descriptor != null) {
descriptor = new CatalogDescriptor(descriptor);
descriptor.setLabel(MarketplaceUrlHandler.DESCRIPTOR_HINT);
command.setSelectedCatalogDescriptor(descriptor);
}
String mpcState = MarketplaceUrlHandler.getMPCState(catalogUrl);
if (mpcState != null && mpcState.length() > 0) {
try {
// $NON-NLS-1$
command.setWizardState(URLDecoder.decode(mpcState, "UTF-8"));
} catch (UnsupportedEncodingException e) {
// should never happen
throw new IllegalStateException(e);
}
if (!proceedWithInstall) {
WizardState wizardState = new WizardState();
wizardState.setProceedWithInstallation(false);
command.setWizardDialogState(wizardState);
}
}
display.asyncExec(new Runnable() {
public void run() {
try {
command.execute(new ExecutionEvent());
} catch (ExecutionException e) {
IStatus status = MarketplaceClientCore.computeStatus(e, Messages.MarketplaceBrowserIntegration_cannotOpenMarketplaceWizard);
MarketplaceClientUi.handle(status, StatusManager.SHOW | StatusManager.BLOCK | StatusManager.LOG);
}
}
});
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class MarketplaceWizard method updateNews.
protected void updateNews() {
CatalogDescriptor catalogDescriptor = getConfiguration().getCatalogDescriptor();
INews news = null;
if (Boolean.parseBoolean(Platform.getDebugOption(DEBUG_NEWS_FLAG))) {
// use debug override values
String debugNewsUrl = Platform.getDebugOption(DEBUG_NEWS_URL);
if (debugNewsUrl != null && debugNewsUrl.length() > 0) {
News debugNews = new News();
news = debugNews;
debugNews.setUrl(debugNewsUrl);
String debugNewsTitle = Platform.getDebugOption(DEBUG_NEWS_TITLE);
if (debugNewsTitle == null || debugNewsTitle.length() == 0) {
// $NON-NLS-1$
debugNews.setShortTitle("Debug News");
} else {
debugNews.setShortTitle(debugNewsTitle);
}
debugNews.setTimestamp(System.currentTimeMillis());
}
}
if (news == null) {
// try requesting news from marketplace
try {
final INews[] result = new INews[1];
getContainer().run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IStatus status = getCatalog().performNewsDiscovery(monitor);
if (!status.isOK() && status.getSeverity() != IStatus.CANCEL) {
// don't bother user with missing news
MarketplaceClientUi.handle(status, StatusManager.LOG);
}
result[0] = getCatalog().getNews();
}
});
if (result[0] != null) {
news = result[0];
}
} catch (InvocationTargetException e) {
final IStatus status = MarketplaceClientCore.computeStatus(e, Messages.MarketplaceViewer_unexpectedException);
MarketplaceClientUi.handle(status, StatusManager.LOG);
} catch (InterruptedException e) {
// cancelled by user
}
}
if (news == null) {
// use news from catalog
news = CatalogRegistry.getInstance().getCatalogNews(catalogDescriptor);
}
CatalogRegistry.getInstance().addCatalogNews(catalogDescriptor, news);
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class MarketplaceWizard method getCatalogUrl.
protected String getCatalogUrl() {
CatalogDescriptor catalogDescriptor = getConfiguration().getCatalogDescriptor();
URL catalogUrl = catalogDescriptor.getUrl();
URI catalogUri;
try {
catalogUri = catalogUrl.toURI();
} catch (URISyntaxException e) {
// should never happen
throw new IllegalStateException(e);
}
return catalogUri.toString();
}
use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.
the class MarketplaceWizard method openUrl.
public void openUrl(String url) {
String catalogUrl = getCatalogUrl();
if (WorkbenchBrowserSupport.getInstance().isInternalWebBrowserAvailable() && url.toLowerCase().startsWith(catalogUrl.toLowerCase())) {
int style = IWorkbenchBrowserSupport.AS_EDITOR | IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR;
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String browserId = "MPC-" + catalogUrl.replaceAll("[^a-zA-Z0-9_-]", "_");
try {
CatalogDescriptor catalogDescriptor = getConfiguration().getCatalogDescriptor();
IWebBrowser browser = WorkbenchBrowserSupport.getInstance().createBrowser(style, browserId, catalogDescriptor.getLabel(), catalogDescriptor.getDescription());
final String originalUrl = url;
url = appendWizardState(url);
// ORDER DEPENDENCY //don't encode/validate URL - browser can be quite lenient
browser.openURL(new URL(url));
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setActive();
if (!hookLocationListener(browser)) {
// ORDER DEPENDENCY
browser.openURL(new URL(originalUrl));
}
} catch (PartInitException e) {
MarketplaceClientUi.handle(e.getStatus(), StatusManager.SHOW | StatusManager.BLOCK | StatusManager.LOG);
} catch (MalformedURLException e) {
IStatus status = new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, NLS.bind(Messages.MarketplaceWizard_cannotOpenUrl, new Object[] { url, e.getMessage() }), e);
MarketplaceClientUi.handle(status, StatusManager.SHOW | StatusManager.BLOCK | StatusManager.LOG);
}
} else {
WorkbenchUtil.openUrl(url, IWorkbenchBrowserSupport.AS_EXTERNAL);
}
}
Aggregations