Search in sources :

Example 1 with FavoritesDiscoveryStrategy

use of org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy in project epp.mpc by eclipse.

the class MarketplaceWizard method importFavorites.

protected void importFavorites(MarketplaceDiscoveryStrategy marketplaceStrategy, String url) {
    FavoritesCatalog favoritesCatalog = new FavoritesCatalog();
    ImportFavoritesWizard importFavoritesWizard = new ImportFavoritesWizard(favoritesCatalog, getConfiguration(), this);
    importFavoritesWizard.setInitialFavoritesUrl(url);
    final ImportFavoritesPage importFavoritesPage = importFavoritesWizard.getImportFavoritesPage();
    favoritesCatalog.getDiscoveryStrategies().add(new FavoritesDiscoveryStrategy(marketplaceStrategy) {

        private String discoveryError = null;

        @Override
        protected void preDiscovery() {
            discoveryError = null;
        }

        @Override
        protected void handleDiscoveryError(CoreException ex) throws CoreException {
            discoveryError = ImportFavoritesPage.handleDiscoveryError(getFavoritesReference(), ex);
        }

        @Override
        protected void postDiscovery() {
            final String errorMessage = this.discoveryError;
            this.discoveryError = null;
            importFavoritesPage.setDiscoveryError(errorMessage);
        }
    });
    ImportFavoritesWizardDialog importWizard = new ImportFavoritesWizardDialog(getShell(), importFavoritesWizard);
    Map<String, Operation> oldOperations = getSelectionModel().getItemIdToSelectedOperation();
    int result = importWizard.open();
    if (result == Window.OK) {
        MarketplacePage catalogPage = getCatalogPage();
        catalogPage.setActiveTab(ContentType.FAVORITES);
        catalogPage.reloadCatalog();
        Map<String, Operation> newOperations = getSelectionModel().getItemIdToSelectedOperation();
        if (!newOperations.equals(oldOperations)) {
            updateSelection();
        }
    }
}
Also used : FavoritesDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy) CoreException(org.eclipse.core.runtime.CoreException) AbstractProvisioningOperation(org.eclipse.epp.internal.mpc.ui.operations.AbstractProvisioningOperation) RemediationOperation(org.eclipse.equinox.p2.operations.RemediationOperation) ProfileChangeOperation(org.eclipse.equinox.p2.operations.ProfileChangeOperation) UninstallOperation(org.eclipse.equinox.p2.operations.UninstallOperation) Operation(org.eclipse.epp.mpc.ui.Operation) FavoritesCatalog(org.eclipse.epp.internal.mpc.ui.catalog.FavoritesCatalog)

Example 2 with FavoritesDiscoveryStrategy

use of org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy in project epp.mpc by eclipse.

the class ImportFavoritesWizardCommand method createWizard.

@Override
protected ImportFavoritesWizard createWizard(MarketplaceCatalog catalog, 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);
    wizard.setInitialFavoritesUrl(favoritesUrl);
    final ImportFavoritesPage importFavoritesPage = wizard.getImportFavoritesPage();
    favoritesCatalog.getDiscoveryStrategies().add(new FavoritesDiscoveryStrategy(configuration.getCatalogDescriptor()) {

        private String discoveryError = null;

        @Override
        protected void preDiscovery() {
            discoveryError = null;
        }

        @Override
        protected void handleDiscoveryError(CoreException ex) throws CoreException {
            discoveryError = ImportFavoritesPage.handleDiscoveryError(getFavoritesReference(), ex);
        }

        @Override
        protected void postDiscovery() {
            final String errorMessage = this.discoveryError;
            this.discoveryError = null;
            importFavoritesPage.setDiscoveryError(errorMessage);
        }
    });
    return wizard;
}
Also used : FavoritesDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy) CoreException(org.eclipse.core.runtime.CoreException) ImportFavoritesPage(org.eclipse.epp.internal.mpc.ui.wizards.ImportFavoritesPage) ImportFavoritesWizard(org.eclipse.epp.internal.mpc.ui.wizards.ImportFavoritesWizard) FavoritesCatalog(org.eclipse.epp.internal.mpc.ui.catalog.FavoritesCatalog)

Example 3 with FavoritesDiscoveryStrategy

use of org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy in project epp.mpc by eclipse.

the class FavoritesViewer method findFavoritesStrategy.

private FavoritesDiscoveryStrategy findFavoritesStrategy() {
    FavoritesDiscoveryStrategy favoritesStrategy = null;
    List<AbstractDiscoveryStrategy> discoveryStrategies = getCatalog().getDiscoveryStrategies();
    for (AbstractDiscoveryStrategy strategy : discoveryStrategies) {
        if (strategy instanceof FavoritesDiscoveryStrategy) {
            favoritesStrategy = (FavoritesDiscoveryStrategy) strategy;
            break;
        }
    }
    return favoritesStrategy;
}
Also used : FavoritesDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy) AbstractDiscoveryStrategy(org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy)

Example 4 with FavoritesDiscoveryStrategy

use of org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy in project epp.mpc by eclipse.

the class FavoritesViewer method doFind.

@Override
protected void doFind(final String text) {
    FavoritesDiscoveryStrategy favoritesStrategy = findFavoritesStrategy();
    if (favoritesStrategy != null) {
        favoritesStrategy.setFavoritesReference(text);
    }
    updateCatalog();
}
Also used : FavoritesDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy)

Example 5 with FavoritesDiscoveryStrategy

use of org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy in project epp.mpc by eclipse.

the class ImportFavoritesPage method findUserFavoritesService.

private IUserFavoritesService findUserFavoritesService() {
    IUserFavoritesService userFavoritesService = null;
    for (AbstractDiscoveryStrategy strategy : getCatalog().getDiscoveryStrategies()) {
        if (strategy instanceof FavoritesDiscoveryStrategy) {
            FavoritesDiscoveryStrategy favoritesStrategy = (FavoritesDiscoveryStrategy) strategy;
            userFavoritesService = favoritesStrategy.getMarketplaceService().getUserFavoritesService();
        }
    }
    return userFavoritesService;
}
Also used : FavoritesDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy) AbstractDiscoveryStrategy(org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy) IUserFavoritesService(org.eclipse.epp.mpc.core.service.IUserFavoritesService)

Aggregations

FavoritesDiscoveryStrategy (org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy)5 CoreException (org.eclipse.core.runtime.CoreException)2 FavoritesCatalog (org.eclipse.epp.internal.mpc.ui.catalog.FavoritesCatalog)2 AbstractDiscoveryStrategy (org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy)2 AbstractProvisioningOperation (org.eclipse.epp.internal.mpc.ui.operations.AbstractProvisioningOperation)1 ImportFavoritesPage (org.eclipse.epp.internal.mpc.ui.wizards.ImportFavoritesPage)1 ImportFavoritesWizard (org.eclipse.epp.internal.mpc.ui.wizards.ImportFavoritesWizard)1 IUserFavoritesService (org.eclipse.epp.mpc.core.service.IUserFavoritesService)1 Operation (org.eclipse.epp.mpc.ui.Operation)1 ProfileChangeOperation (org.eclipse.equinox.p2.operations.ProfileChangeOperation)1 RemediationOperation (org.eclipse.equinox.p2.operations.RemediationOperation)1 UninstallOperation (org.eclipse.equinox.p2.operations.UninstallOperation)1