KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > sp > jedit > options > FirewallOptionPane


1 /*
2  * FirewallOptionPane.java - Firewall options panel
3  * :tabSize=8:indentSize=8:noTabs=false:
4  * :folding=explicit:collapseFolds=1:
5  *
6  * Copyright (C) 1999 Dirk Moebius
7  * Portions copyright (C) 2002 Slava Pestov
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  */

23
24 package org.gjt.sp.jedit.options;
25
26  //{{{ Imports
27
import java.awt.event.*;
28 import javax.swing.*;
29 import org.gjt.sp.jedit.*;
30 //}}}
31

32 public class FirewallOptionPane extends AbstractOptionPane {
33
34     //{{{ FirewallOptionPane constructor
35
public FirewallOptionPane()
36     {
37         super("firewall");
38     } //}}}
39

40     //{{{ _init() method
41
public void _init()
42     {
43         // checkbox
44
addComponent(httpEnabled = new JCheckBox(jEdit.getProperty(
45             "options.firewall.http.enabled")));
46         // proxy host
47
addComponent(jEdit.getProperty("options.firewall.http.host"),
48             httpHost = new JTextField(jEdit.getProperty("firewall.host"), 15));
49         // proxy port
50
addComponent(jEdit.getProperty("options.firewall.http.port"),
51             httpPort = new JTextField(jEdit.getProperty("firewall.port"), 15));
52         // proxy username
53
addComponent(jEdit.getProperty("options.firewall.http.user"),
54             httpUser = new JTextField(jEdit.getProperty("firewall.user"), 15));
55         // proxy password
56
addComponent(jEdit.getProperty("options.firewall.http.password"),
57             httpPass = new JPasswordField(jEdit.getProperty("firewall.password"), 15));
58         // no proxy for
59
addComponent(jEdit.getProperty("options.firewall.http.nonProxy"),
60             httpNonProxy = new JTextField(jEdit.getProperty("firewall.nonProxyHosts"), 15));
61
62         boolean enabled = jEdit.getBooleanProperty("firewall.enabled");
63         httpEnabled.setSelected(enabled);
64         httpHost.setEnabled(enabled);
65         httpPort.setEnabled(enabled);
66         httpUser.setEnabled(enabled);
67         httpPass.setEnabled(enabled);
68         httpNonProxy.setEnabled(enabled);
69
70         httpEnabled.addActionListener(new ActionHandler());
71
72         // checkbox
73
addComponent(socksEnabled = new JCheckBox(jEdit.getProperty(
74             "options.firewall.socks.enabled")));
75         // proxy host
76
addComponent(jEdit.getProperty("options.firewall.socks.host"),
77             socksHost = new JTextField(jEdit.getProperty("firewall.socks.host"), 15));
78         // proxy port
79
addComponent(jEdit.getProperty("options.firewall.socks.port"),
80             socksPort = new JTextField(jEdit.getProperty("firewall.socks.port"), 15));
81
82         enabled = jEdit.getBooleanProperty("firewall.socks.enabled");
83         socksEnabled.setSelected(enabled);
84         socksHost.setEnabled(enabled);
85         socksPort.setEnabled(enabled);
86
87         socksEnabled.addActionListener(new ActionHandler());
88     } //}}}
89

90     //{{{ _save() method
91
public void _save() {
92         jEdit.setBooleanProperty("firewall.enabled", httpEnabled.isSelected());
93         jEdit.setProperty("firewall.host", httpHost.getText());
94         jEdit.setProperty("firewall.port", httpPort.getText());
95         jEdit.setProperty("firewall.user", httpUser.getText());
96         jEdit.setProperty("firewall.password", new String JavaDoc(httpPass.getPassword()));
97         jEdit.setProperty("firewall.nonProxyHosts", httpNonProxy.getText());
98
99         jEdit.setBooleanProperty("firewall.socks.enabled", socksEnabled.isSelected());
100         jEdit.setProperty("firewall.socks.host", socksHost.getText());
101         jEdit.setProperty("firewall.socks.port", socksPort.getText());
102     } //}}}
103

104     //{{{ Private members
105
private JCheckBox httpEnabled;
106     private JTextField httpHost;
107     private JTextField httpPort;
108     private JTextField httpUser;
109     private JPasswordField httpPass;
110     private JTextField httpNonProxy;
111     private JCheckBox socksEnabled;
112     private JTextField socksHost;
113     private JTextField socksPort;
114     //}}}
115

116     //{{{ ActionHandler class
117
class ActionHandler implements ActionListener
118     {
119         public void actionPerformed(ActionEvent evt)
120         {
121             httpHost.setEnabled(httpEnabled.isSelected());
122             httpPort.setEnabled(httpEnabled.isSelected());
123             httpUser.setEnabled(httpEnabled.isSelected());
124             httpPass.setEnabled(httpEnabled.isSelected());
125             httpNonProxy.setEnabled(httpEnabled.isSelected());
126             socksHost.setEnabled(socksEnabled.isSelected());
127             socksPort.setEnabled(socksEnabled.isSelected());
128         }
129     }
130 }
131
Popular Tags