Search in sources :

Example 1 with LoginListener

use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService.LoginListener in project epp.mpc by eclipse.

the class MarketplaceDiscoveryStrategy method addLoginListener.

public synchronized void addLoginListener(LoginListener loginListener) {
    IUserFavoritesService favoritesService = marketplaceService.getUserFavoritesService();
    if (favoritesService != null) {
        if (loginListeners == null) {
            loginListeners = new CopyOnWriteArrayList<LoginListener>();
        }
        if (!loginListeners.contains(loginListener)) {
            loginListeners.add(loginListener);
            IMarketplaceStorageService storageService = favoritesService.getStorageService();
            storageService.addLoginListener(loginListener);
        }
    }
}
Also used : LoginListener(org.eclipse.epp.mpc.core.service.IMarketplaceStorageService.LoginListener) IUserFavoritesService(org.eclipse.epp.mpc.core.service.IUserFavoritesService) IMarketplaceStorageService(org.eclipse.epp.mpc.core.service.IMarketplaceStorageService)

Example 2 with LoginListener

use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService.LoginListener 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

IMarketplaceStorageService (org.eclipse.epp.mpc.core.service.IMarketplaceStorageService)2 LoginListener (org.eclipse.epp.mpc.core.service.IMarketplaceStorageService.LoginListener)2 IUserFavoritesService (org.eclipse.epp.mpc.core.service.IUserFavoritesService)2 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 BundleContext (org.osgi.framework.BundleContext)1