Showing posts with label listener. Show all posts
Showing posts with label listener. Show all posts

Tuesday, March 24, 2015

Registering a listener for changes in network connections and proxy from eclipse preferences

import org.eclipse.core.net.proxy.IProxyChangeEvent;
import org.eclipse.core.net.proxy.IProxyChangeListener;
import org.eclipse.core.net.proxy.IProxyService;
import org.osgi.util.tracker.ServiceTracker;

public class ProxyHelper
{

public void registerListener()
{
ServiceTracker tracker = new ServiceTracker(MyPlugin.getDefault().getBundle().getBundleContext(),
IProxyService.class.getName(), null);
tracker.open();
IProxyService proxyService = (IProxyService) tracker.getService();
proxyService.addProxyChangeListener(new IProxyChangeListener()
{

@Override
public void proxyInfoChanged(IProxyChangeEvent event)
{
// TODO: your action for proxy changed
}
});
}

}