KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > welcome > content > HttpProxySettings


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.welcome.content;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.beans.PropertyChangeSupport JavaDoc;
24 import java.util.prefs.PreferenceChangeEvent JavaDoc;
25 import java.util.prefs.PreferenceChangeListener JavaDoc;
26 import java.util.prefs.Preferences JavaDoc;
27 import org.netbeans.api.options.OptionsDisplayer;
28 import org.openide.util.NbPreferences;
29
30 /**
31  *
32  * @author S. Aubrecht
33  */

34 class HttpProxySettings {
35
36     private static HttpProxySettings theInstance;
37     private static Preferences JavaDoc proxySettingsNode;
38
39     private PropertyChangeSupport JavaDoc propertySupport = new PropertyChangeSupport JavaDoc( this );
40
41     public static final String JavaDoc PROXY_SETTINGS = "ProxySettings"; // NOI18N
42

43     /** Creates a new instance of HttpProxySettings */
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 JavaDoc l ) {
56         propertySupport.addPropertyChangeListener( l );
57     }
58
59     public void removePropertyChangeListener( PropertyChangeListener JavaDoc l ) {
60         propertySupport.removePropertyChangeListener( l );
61     }
62
63     public void showConfigurationDialog() {
64         OptionsDisplayer.getDefault().open( "General" );//NOI18N
65
}
66
67     private static synchronized void initProxyMethodsMaybe() {
68         proxySettingsNode = NbPreferences.root ().node ("/org/netbeans/core");
69         assert proxySettingsNode != null;
70         proxySettingsNode.addPreferenceChangeListener (new PreferenceChangeListener JavaDoc (){
71             public void preferenceChange (PreferenceChangeEvent JavaDoc 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