001: /*
002: * FirewallOptionPane.java - Firewall options panel
003: * :tabSize=8:indentSize=8:noTabs=false:
004: * :folding=explicit:collapseFolds=1:
005: *
006: * Copyright (C) 1999 Dirk Moebius
007: * Portions copyright (C) 2002 Slava Pestov
008: *
009: * This program is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; either version 2
012: * of the License, or any later version.
013: *
014: * This program is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
017: * GNU General Public License for more details.
018: *
019: * You should have received a copy of the GNU General Public License
020: * along with this program; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
022: */
023:
024: package org.gjt.sp.jedit.options;
025:
026: //{{{ Imports
027: import java.awt.event.*;
028: import javax.swing.*;
029: import org.gjt.sp.jedit.*;
030:
031: //}}}
032:
033: public class FirewallOptionPane extends AbstractOptionPane {
034:
035: //{{{ FirewallOptionPane constructor
036: public FirewallOptionPane() {
037: super ("firewall");
038: } //}}}
039:
040: //{{{ _init() method
041: public void _init() {
042: // checkbox
043: addComponent(httpEnabled = new JCheckBox(jEdit
044: .getProperty("options.firewall.http.enabled")));
045: // proxy host
046: addComponent(jEdit.getProperty("options.firewall.http.host"),
047: httpHost = new JTextField(jEdit
048: .getProperty("firewall.host"), 15));
049: // proxy port
050: addComponent(jEdit.getProperty("options.firewall.http.port"),
051: httpPort = new JTextField(jEdit
052: .getProperty("firewall.port"), 15));
053: // proxy username
054: addComponent(jEdit.getProperty("options.firewall.http.user"),
055: httpUser = new JTextField(jEdit
056: .getProperty("firewall.user"), 15));
057: // proxy password
058: addComponent(jEdit
059: .getProperty("options.firewall.http.password"),
060: httpPass = new JPasswordField(jEdit
061: .getProperty("firewall.password"), 15));
062: // no proxy for
063: addComponent(jEdit
064: .getProperty("options.firewall.http.nonProxy"),
065: httpNonProxy = new JTextField(jEdit
066: .getProperty("firewall.nonProxyHosts"), 15));
067:
068: boolean enabled = jEdit.getBooleanProperty("firewall.enabled");
069: httpEnabled.setSelected(enabled);
070: httpHost.setEnabled(enabled);
071: httpPort.setEnabled(enabled);
072: httpUser.setEnabled(enabled);
073: httpPass.setEnabled(enabled);
074: httpNonProxy.setEnabled(enabled);
075:
076: httpEnabled.addActionListener(new ActionHandler());
077:
078: // checkbox
079: addComponent(socksEnabled = new JCheckBox(jEdit
080: .getProperty("options.firewall.socks.enabled")));
081: // proxy host
082: addComponent(jEdit.getProperty("options.firewall.socks.host"),
083: socksHost = new JTextField(jEdit
084: .getProperty("firewall.socks.host"), 15));
085: // proxy port
086: addComponent(jEdit.getProperty("options.firewall.socks.port"),
087: socksPort = new JTextField(jEdit
088: .getProperty("firewall.socks.port"), 15));
089:
090: enabled = jEdit.getBooleanProperty("firewall.socks.enabled");
091: socksEnabled.setSelected(enabled);
092: socksHost.setEnabled(enabled);
093: socksPort.setEnabled(enabled);
094:
095: socksEnabled.addActionListener(new ActionHandler());
096: } //}}}
097:
098: //{{{ _save() method
099: public void _save() {
100: jEdit.setBooleanProperty("firewall.enabled", httpEnabled
101: .isSelected());
102: jEdit.setProperty("firewall.host", httpHost.getText());
103: jEdit.setProperty("firewall.port", httpPort.getText());
104: jEdit.setProperty("firewall.user", httpUser.getText());
105: jEdit.setProperty("firewall.password", new String(httpPass
106: .getPassword()));
107: jEdit.setProperty("firewall.nonProxyHosts", httpNonProxy
108: .getText());
109:
110: jEdit.setBooleanProperty("firewall.socks.enabled", socksEnabled
111: .isSelected());
112: jEdit.setProperty("firewall.socks.host", socksHost.getText());
113: jEdit.setProperty("firewall.socks.port", socksPort.getText());
114: } //}}}
115:
116: //{{{ Private members
117: private JCheckBox httpEnabled;
118: private JTextField httpHost;
119: private JTextField httpPort;
120: private JTextField httpUser;
121: private JPasswordField httpPass;
122: private JTextField httpNonProxy;
123: private JCheckBox socksEnabled;
124: private JTextField socksHost;
125: private JTextField socksPort;
126:
127: //}}}
128:
129: //{{{ ActionHandler class
130: class ActionHandler implements ActionListener {
131: public void actionPerformed(ActionEvent evt) {
132: httpHost.setEnabled(httpEnabled.isSelected());
133: httpPort.setEnabled(httpEnabled.isSelected());
134: httpUser.setEnabled(httpEnabled.isSelected());
135: httpPass.setEnabled(httpEnabled.isSelected());
136: httpNonProxy.setEnabled(httpEnabled.isSelected());
137: socksHost.setEnabled(socksEnabled.isSelected());
138: socksPort.setEnabled(socksEnabled.isSelected());
139: }
140: } //}}}
141: }
|