Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 536589: Add support of new uriScheme extension point
This adds an uri scheme handler for the custom uri scheme "eclipse-mpc". Marketplace client currently get's URLs in the form http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=311881 "eclipse-mpc"-URLs are exactly the same only the "http" is exchanged with "eclipse.-mpc". The idea is that the marketplace website renders links with the "eclipse-mpc" URI scheme. The implementation is quite easy. It just replaces the "eclipse-mpc" back to "https" and just calls the existing facilities in the MarketplaceUrlHandler class. Change-Id: I6934c35e0188288ffa6962bf0d6f62e369e9a05c Signed-off-by: Matthias Becker <ma.becker@sap.com>
- Loading branch information
Showing
4 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
org.eclipse.epp.mpc.ui/src/org/eclipse/epp/mpc/ui/MarketPlaceUirSchemeHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018 The Eclipse Foundation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* The Eclipse Foundation - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.epp.mpc.ui; | ||
|
||
import org.eclipse.epp.internal.mpc.ui.MarketplaceClientUiPlugin; | ||
import org.eclipse.epp.mpc.ui.MarketplaceUrlHandler.SolutionInstallationInfo; | ||
import org.eclipse.swt.widgets.Display; | ||
import org.eclipse.urischeme.IUriSchemeHandler; | ||
|
||
public class MarketPlaceUirSchemeHandler implements IUriSchemeHandler { | ||
|
||
public MarketPlaceUirSchemeHandler() { | ||
// ignore | ||
} | ||
|
||
@Override | ||
public void handle(String mpcUri) { | ||
String uri = mpcUri.replaceFirst("eclipse-mpc://", "https://"); //$NON-NLS-1$ //$NON-NLS-2$ | ||
|
||
Display display = Display.getDefault(); | ||
if (MarketplaceUrlHandler.isPotentialSolution(uri)) { | ||
//https://marketplace.eclipse.org/marketplace-client-intro?mpc_install=1640500 | ||
display.asyncExec(() -> proceedInstallation(uri)); | ||
} else if (MarketplaceUrlHandler.isPotentialFavoritesList(uri)) { | ||
//https://marketplace.eclipse.org/user/xxx/favorites | ||
display.asyncExec(() -> proceedFavorites(uri)); | ||
} else { | ||
traceInvalidUrl(uri); | ||
} | ||
} | ||
|
||
private void proceedInstallation(String url) { | ||
SolutionInstallationInfo info = MarketplaceUrlHandler.createSolutionInstallInfo(url); | ||
if (info != null) { | ||
MarketplaceUrlHandler.triggerInstall(info); | ||
} | ||
} | ||
|
||
private void proceedFavorites(String url) { | ||
MarketplaceUrlHandler.triggerFavorites(url); | ||
} | ||
|
||
private void traceInvalidUrl(String url) { | ||
if (MarketplaceClientUiPlugin.DEBUG) { | ||
MarketplaceClientUiPlugin.trace(MarketplaceClientUiPlugin.DROP_ADAPTER_DEBUG_OPTION, | ||
"Drop event: Data is not a solution url: {0}", url, new Throwable()); //$NON-NLS-1$ | ||
} | ||
} | ||
|
||
} |