PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-0-pre3/jars/Firewall/FirewallOptionPane.java

#
Java | 96 lines | 57 code | 10 blank | 29 comment | 0 complexity | dcd399d3c77aba7e1d63708b7981c283 MD5 | raw file
 1/*
 2 * FirewallOptionPane.java - Firewall plugin options panel
 3 * Copyright (C) 1999 Dirk Moebius
 4 *
 5 * This program is free software; you can redistribute it and/or
 6 * modify it under the terms of the GNU General Public License
 7 * as published by the Free Software Foundation; either version 2
 8 * of the License, or any later version.
 9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 */
19
20import java.awt.*;
21import java.awt.event.*;
22import javax.swing.*;
23import javax.swing.border.*;
24import org.gjt.sp.jedit.*;
25
26
27public class FirewallOptionPane extends AbstractOptionPane {
28
29    // private members
30    private JCheckBox      cEnabled;
31    private JTextField     tHost;
32    private JTextField     tPort;
33    private JTextField     tUser;
34    private JPasswordField tPass;
35    private JTextField     tNonProxy;
36
37    public FirewallOptionPane() {
38        super("firewall");
39    }
40
41    public void _init()
42    {
43        // checkbox "Enable firewall authentication"
44        addComponent(cEnabled = new JCheckBox(jEdit.getProperty(
45            "options.firewall.enabled")));
46        // proxy host
47        addComponent(jEdit.getProperty("options.firewall.host"), 
48            tHost = new JTextField(jEdit.getProperty("firewall.host"), 15));
49        // proxy port
50        addComponent(jEdit.getProperty("options.firewall.port"), 
51            tPort = new JTextField(jEdit.getProperty("firewall.port"), 15));
52        // proxy username
53        addComponent(jEdit.getProperty("options.firewall.user"),
54            tUser = new JTextField(jEdit.getProperty("firewall.user"), 15));
55        // proxy password
56        addComponent(jEdit.getProperty("options.firewall.password"),
57            tPass = new JPasswordField(jEdit.getProperty("firewall.password"), 15));
58        // no proxy for
59        addComponent(jEdit.getProperty("options.firewall.nonProxy"),
60            tNonProxy = new JTextField(jEdit.getProperty("firewall.nonProxyHosts"), 15));
61
62        boolean enabled = jEdit.getBooleanProperty("firewall.enabled");
63        cEnabled.setSelected(enabled);
64        tHost.setEnabled(enabled);
65        tPort.setEnabled(enabled);
66        tUser.setEnabled(enabled);
67        tPass.setEnabled(enabled);
68        tNonProxy.setEnabled(enabled);
69        
70        cEnabled.addActionListener(new ActionListener() {
71            public void actionPerformed(ActionEvent e) {
72                boolean enbld = cEnabled.isSelected();
73                cEnabled.setSelected(enbld);
74                tHost.setEnabled(enbld);
75                tPort.setEnabled(enbld);
76                tUser.setEnabled(enbld);
77                tPass.setEnabled(enbld);
78                tNonProxy.setEnabled(enbld);
79            }
80        });
81    }
82
83
84    /**
85     * Called when the options dialog's `OK' button is pressed.
86     * This should save any properties saved in this option pane.
87     */
88    public void _save() {
89        jEdit.setBooleanProperty("firewall.enabled", cEnabled.isSelected());
90        jEdit.setProperty("firewall.host", tHost.getText());            
91        jEdit.setProperty("firewall.port", tPort.getText());
92        jEdit.setProperty("firewall.user", tUser.getText());
93        jEdit.setProperty("firewall.password", new String(tPass.getPassword()));
94        jEdit.setProperty("firewall.nonProxyHosts", tNonProxy.getText());
95    }
96}