Skip to content

Commit

Permalink
Bug 536589: Add support of new uriScheme extension point
Browse files Browse the repository at this point in the history
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
BeckerWdf committed Jun 27, 2019
1 parent 25d72e2 commit d3f7612
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.epp.mpc-target/staging.target
Expand Up @@ -7,7 +7,7 @@
<unit id="org.eclipse.equinox.p2.sdk.feature.group" version="0.0.0"/>
<unit id="org.eclipse.equinox.ds" version="0.0.0"/>
<unit id="org.eclipse.sdk.feature.group" version="0.0.0"/>
<repository location="http://download.eclipse.org/eclipse/updates/4.12-I-builds"/>
<repository location="http://download.eclipse.org/eclipse/updates/4.13-I-builds"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.hamcrest" version="0.0.0"/>
Expand Down
3 changes: 2 additions & 1 deletion org.eclipse.epp.mpc.ui/META-INF/MANIFEST.MF
Expand Up @@ -28,7 +28,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.6.0",
org.eclipse.ui.ide;bundle-version="[3.13.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.12.0,4.0.0)",
org.eclipse.e4.ui.css.core;bundle-version="[0.12.200,1.0.0)",
org.eclipse.e4.ui.css.swt;bundle-version="[0.13.100,1.0.0)"
org.eclipse.e4.ui.css.swt;bundle-version="[0.13.100,1.0.0)",
org.eclipse.urischeme;bundle-version="[1.0.300,2.0.0)"
Export-Package: org.eclipse.epp.internal.mpc.ui;x-internal:=true,
org.eclipse.epp.internal.mpc.ui.actions;x-internal:=true,
org.eclipse.epp.internal.mpc.ui.catalog;x-internal:=true,
Expand Down
8 changes: 8 additions & 0 deletions org.eclipse.epp.mpc.ui/plugin.xml
Expand Up @@ -188,4 +188,12 @@
</widget>
</provider>
</extension>
<extension
point="org.eclipse.urischeme.uriSchemeHandlers">
<uriSchemeHandler
class="org.eclipse.epp.mpc.ui.MarketPlaceUirSchemeHandler"
uriScheme="eclipse-mpc"
uriSchemeDescription="Eclipse Marketplace">
</uriSchemeHandler>
</extension>
</plugin>
@@ -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$
}
}

}

0 comments on commit d3f7612

Please sign in to comment.