Skip to content

Commit

Permalink
493913: Add drag&drop support for favorites list URL
Browse files Browse the repository at this point in the history
Show Import Favorites wizard for a specific URL, using command parameter

Bug: 493913
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=493913
  • Loading branch information
creckord committed Mar 16, 2017
1 parent 4b1af25 commit cf0f0f0
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 23 deletions.
10 changes: 6 additions & 4 deletions org.eclipse.epp.mpc.ui/OSGI-INF/l10n/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
###############################################################################
Bundle-Vendor = Eclipse Marketplace Client
Bundle-Name = Marketplace Client
command.description = Show the Eclipse Marketplace wizard
command.name = Eclipse Marketplace
command.label = Eclipse &Marketplace...
command.tooltip = Open the Eclipse Marketplace wizard
command.open.description = Show the Eclipse Marketplace wizard
command.open.name = Eclipse Marketplace
command.open.label = Eclipse &Marketplace...
command.open.tooltip = Open the Eclipse Marketplace wizard
command.importFavorites.description = Import another user's Marketplace Favorites List
command.importFavorites.name = Import Marketplace Favorites
catalog.description = Eclipse Marketplace (MP) is a place to find and keep track of Eclipse-based solutions.
catalog.label = Eclipse Marketplace
extension-point.name = Marketplace Catalog
Expand Down
22 changes: 18 additions & 4 deletions org.eclipse.epp.mpc.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,27 @@
class="org.eclipse.epp.internal.mpc.ui.commands.MarketplaceWizardCommand"
commandId="org.eclipse.epp.mpc.ui.command.showMarketplaceWizard">
</handler>
<handler
class="org.eclipse.epp.internal.mpc.ui.commands.ImportFavoritesWizardCommand"
commandId="org.eclipse.epp.mpc.ui.command.importFavoritesWizard">
</handler>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
description="%command.description"
description="%command.open.description"
id="org.eclipse.epp.mpc.ui.command.showMarketplaceWizard"
name="%command.name">
name="%command.open.name">
</command>
<command
description="%command.importFavorites.description"
id="org.eclipse.epp.mpc.ui.command.importFavoritesWizard"
name="%command.importFavorites.name">
<commandParameter
id="favoritesUrl"
name="favoritesUrl"
optional="true">
</commandParameter>
</command>
</extension>
<extension
Expand All @@ -36,9 +50,9 @@
<command
commandId="org.eclipse.epp.mpc.ui.command.showMarketplaceWizard"
icon="icons/marketplace16.png"
label="%command.label"
label="%command.open.label"
style="push"
tooltip="%command.tooltip">
tooltip="%command.open.tooltip">
</command>
</menuContribution>
</extension>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public abstract class AbstractMarketplaceWizardCommand extends AbstractHandler i

public Object execute(ExecutionEvent event) throws ExecutionException {
final MarketplaceCatalog catalog = createCatalog();
MarketplaceCatalogConfiguration configuration = createConfiguration(catalog);
DiscoveryWizard wizard = createWizard(catalog, configuration);
openWizardDialog(wizard);
MarketplaceCatalogConfiguration configuration = createConfiguration(catalog, event);
DiscoveryWizard wizard = createWizard(catalog, configuration, event);
openWizardDialog(wizard, event);

return null;
}
Expand All @@ -72,7 +72,8 @@ protected MarketplaceCatalog createCatalog() {
return catalog;
}

protected MarketplaceCatalogConfiguration createConfiguration(final MarketplaceCatalog catalog) {
protected MarketplaceCatalogConfiguration createConfiguration(final MarketplaceCatalog catalog,
ExecutionEvent event) {
MarketplaceCatalogConfiguration configuration = new MarketplaceCatalogConfiguration();
configuration.setVerifyUpdateSiteAvailability(false);

Expand Down Expand Up @@ -129,15 +130,15 @@ Messages.MarketplaceWizardCommand_CouldNotFindMarketplaceForSolution, new Execut
return configuration;
}

protected void openWizardDialog(DiscoveryWizard wizard) {
WizardDialog dialog = createWizardDialog(wizard);
protected void openWizardDialog(DiscoveryWizard wizard, ExecutionEvent event) {
WizardDialog dialog = createWizardDialog(wizard, event);
dialog.open();
}

protected abstract AbstractMarketplaceWizardDialog createWizardDialog(DiscoveryWizard wizard);
protected abstract AbstractMarketplaceWizardDialog createWizardDialog(DiscoveryWizard wizard, ExecutionEvent event);

protected abstract DiscoveryWizard createWizard(final MarketplaceCatalog catalog,
MarketplaceCatalogConfiguration configuration);
MarketplaceCatalogConfiguration configuration, ExecutionEvent event);

public void setCatalogDescriptors(List<CatalogDescriptor> catalogDescriptors) {
this.catalogDescriptors = catalogDescriptors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.epp.internal.mpc.ui.commands;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.epp.internal.mpc.ui.catalog.FavoritesCatalog;
import org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy;
Expand All @@ -23,16 +24,23 @@

public class ImportFavoritesWizardCommand extends AbstractMarketplaceWizardCommand {

private static final String FAVORITES_URL_PARAMETER = "favoritesUrl"; //$NON-NLS-1$

private String favoritesUrl;

@Override
protected ImportFavoritesWizardDialog createWizardDialog(DiscoveryWizard wizard) {
protected ImportFavoritesWizardDialog createWizardDialog(DiscoveryWizard wizard, ExecutionEvent event) {
return new ImportFavoritesWizardDialog(WorkbenchUtil.getShell(), wizard);
}

@Override
protected ImportFavoritesWizard createWizard(MarketplaceCatalog catalog,
MarketplaceCatalogConfiguration configuration) {
MarketplaceCatalogConfiguration configuration, ExecutionEvent event) {
String favoritesUrl = event.getParameter(FAVORITES_URL_PARAMETER);
if (favoritesUrl == null) {
favoritesUrl = this.favoritesUrl;
}

FavoritesCatalog favoritesCatalog = new FavoritesCatalog();

ImportFavoritesWizard wizard = new ImportFavoritesWizard(favoritesCatalog, configuration, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Map;
import java.util.Set;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.IHandler;
import org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog;
import org.eclipse.epp.internal.mpc.ui.wizards.AbstractTagFilter;
Expand All @@ -40,6 +41,8 @@
import org.eclipse.equinox.internal.p2.ui.discovery.wizards.DiscoveryWizard;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.handlers.HandlerUtil;

/**
* @author David Green
Expand All @@ -54,8 +57,9 @@ public class MarketplaceWizardCommand extends AbstractMarketplaceWizardCommand i
private WizardState wizardDialogState;

@Override
protected MarketplaceCatalogConfiguration createConfiguration(final MarketplaceCatalog catalog) {
MarketplaceCatalogConfiguration configuration = super.createConfiguration(catalog);
protected MarketplaceCatalogConfiguration createConfiguration(final MarketplaceCatalog catalog,
ExecutionEvent event) {
MarketplaceCatalogConfiguration configuration = super.createConfiguration(catalog, event);
configuration.getFilters().clear();

final ComboTagFilter marketFilter = new ComboTagFilter() {
Expand Down Expand Up @@ -111,13 +115,17 @@ public void propertyChange(PropertyChangeEvent event) {
}

@Override
protected MarketplaceWizardDialog createWizardDialog(DiscoveryWizard wizard) {
return new MarketplaceWizardDialog(WorkbenchUtil.getShell(), (MarketplaceWizard) wizard);
protected MarketplaceWizardDialog createWizardDialog(DiscoveryWizard wizard, ExecutionEvent event) {
Shell activeShell = HandlerUtil.getActiveShell(event);
if (activeShell == null) {
activeShell = WorkbenchUtil.getShell();
}
return new MarketplaceWizardDialog(activeShell, (MarketplaceWizard) wizard);
}

@Override
protected MarketplaceWizard createWizard(final MarketplaceCatalog catalog,
MarketplaceCatalogConfiguration configuration) {
MarketplaceCatalogConfiguration configuration, ExecutionEvent event) {
MarketplaceWizard wizard = new MarketplaceWizard(catalog, configuration);
wizard.setInitialState(wizardDialogState);
wizard.setWindowTitle(Messages.MarketplaceWizardCommand_eclipseMarketplace);
Expand Down

0 comments on commit cf0f0f0

Please sign in to comment.