1 19 20 package org.netbeans.modules.welcome.content; 21 22 import java.beans.PropertyChangeListener ; 23 import java.beans.PropertyChangeSupport ; 24 import java.util.prefs.PreferenceChangeEvent ; 25 import java.util.prefs.PreferenceChangeListener ; 26 import java.util.prefs.Preferences ; 27 import org.netbeans.api.options.OptionsDisplayer; 28 import org.openide.util.NbPreferences; 29 30 34 class HttpProxySettings { 35 36 private static HttpProxySettings theInstance; 37 private static Preferences proxySettingsNode; 38 39 private PropertyChangeSupport propertySupport = new PropertyChangeSupport ( this ); 40 41 public static final String PROXY_SETTINGS = "ProxySettings"; 43 44 private HttpProxySettings() { 45 initProxyMethodsMaybe(); 46 } 47 48 public static HttpProxySettings getDefault() { 49 if( null == theInstance ) { 50 theInstance = new HttpProxySettings(); 51 } 52 return theInstance; 53 } 54 55 public void addPropertyChangeListener( PropertyChangeListener l ) { 56 propertySupport.addPropertyChangeListener( l ); 57 } 58 59 public void removePropertyChangeListener( PropertyChangeListener l ) { 60 propertySupport.removePropertyChangeListener( l ); 61 } 62 63 public void showConfigurationDialog() { 64 OptionsDisplayer.getDefault().open( "General" ); } 66 67 private static synchronized void initProxyMethodsMaybe() { 68 proxySettingsNode = NbPreferences.root ().node ("/org/netbeans/core"); 69 assert proxySettingsNode != null; 70 proxySettingsNode.addPreferenceChangeListener (new PreferenceChangeListener (){ 71 public void preferenceChange (PreferenceChangeEvent evt) { 72 if (evt.getKey ().startsWith ("proxy") || evt.getKey ().startsWith ("useProxy")) { 73 getDefault ().propertySupport.firePropertyChange (PROXY_SETTINGS, null, getDefault()); 74 } 75 } 76 }); 77 } 78 } 79 | Popular Tags |