Search in sources :

Example 1 with MarketplaceClientUiPlugin

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

the class MarketplaceDiscoveryStrategy method dispose.

@Override
public void dispose() {
    List<LoginListener> loginListeners = this.loginListeners;
    this.loginListeners = null;
    if (loginListeners != null) {
        IUserFavoritesService favoritesService = marketplaceService.getUserFavoritesService();
        if (favoritesService != null) {
            IMarketplaceStorageService storageService = favoritesService.getStorageService();
            for (LoginListener loginListener : loginListeners) {
                storageService.removeLoginListener(loginListener);
            }
        }
    }
    if (source != null) {
        source.dispose();
        source = null;
    }
    if (marketplaceInfo != null) {
        final MarketplaceInfo fMarketplaceInfo = marketplaceInfo;
        new Job(Messages.MarketplaceDiscoveryStrategy_saveMarketplaceInfoJobName) {

            {
                setSystem(true);
                setPriority(SHORT);
                setUser(false);
            }

            @Override
            public boolean belongsTo(Object family) {
                BundleContext bundleContext = MarketplaceClientUiPlugin.getBundleContext();
                MarketplaceClientUiPlugin plugin = MarketplaceClientUiPlugin.getInstance();
                return (bundleContext != null && (family == bundleContext || family == bundleContext.getBundle())) || (plugin != null && family == plugin);
            }

            @Override
            protected IStatus run(IProgressMonitor monitor) {
                try {
                    fMarketplaceInfo.save();
                } catch (Exception e) {
                    return MarketplaceClientCore.computeStatus(e, Messages.MarketplaceDiscoveryStrategy_failedToSaveMarketplaceInfo);
                }
                return Status.OK_STATUS;
            }
        }.schedule();
        marketplaceInfo = null;
    }
    super.dispose();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IUserFavoritesService(org.eclipse.epp.mpc.core.service.IUserFavoritesService) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) NotAuthorizedException(org.eclipse.epp.internal.mpc.core.service.AbstractDataStorageService.NotAuthorizedException) NoSuchElementException(java.util.NoSuchElementException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) MarketplaceClientUiPlugin(org.eclipse.epp.internal.mpc.ui.MarketplaceClientUiPlugin) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) LoginListener(org.eclipse.epp.mpc.core.service.IMarketplaceStorageService.LoginListener) Job(org.eclipse.core.runtime.jobs.Job) IMarketplaceStorageService(org.eclipse.epp.mpc.core.service.IMarketplaceStorageService) BundleContext(org.osgi.framework.BundleContext)

Aggregations

IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 NoSuchElementException (java.util.NoSuchElementException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Job (org.eclipse.core.runtime.jobs.Job)1 NotAuthorizedException (org.eclipse.epp.internal.mpc.core.service.AbstractDataStorageService.NotAuthorizedException)1 MarketplaceClientUiPlugin (org.eclipse.epp.internal.mpc.ui.MarketplaceClientUiPlugin)1 IMarketplaceStorageService (org.eclipse.epp.mpc.core.service.IMarketplaceStorageService)1 LoginListener (org.eclipse.epp.mpc.core.service.IMarketplaceStorageService.LoginListener)1 IUserFavoritesService (org.eclipse.epp.mpc.core.service.IUserFavoritesService)1 BundleContext (org.osgi.framework.BundleContext)1