1 23 24 package org.gjt.sp.jedit.options; 25 26 import java.awt.event.*; 28 import javax.swing.*; 29 import org.gjt.sp.jedit.*; 30 32 public class FirewallOptionPane extends AbstractOptionPane { 33 34 public FirewallOptionPane() 36 { 37 super("firewall"); 38 } 40 public void _init() 42 { 43 addComponent(httpEnabled = new JCheckBox(jEdit.getProperty( 45 "options.firewall.http.enabled"))); 46 addComponent(jEdit.getProperty("options.firewall.http.host"), 48 httpHost = new JTextField(jEdit.getProperty("firewall.host"), 15)); 49 addComponent(jEdit.getProperty("options.firewall.http.port"), 51 httpPort = new JTextField(jEdit.getProperty("firewall.port"), 15)); 52 addComponent(jEdit.getProperty("options.firewall.http.user"), 54 httpUser = new JTextField(jEdit.getProperty("firewall.user"), 15)); 55 addComponent(jEdit.getProperty("options.firewall.http.password"), 57 httpPass = new JPasswordField(jEdit.getProperty("firewall.password"), 15)); 58 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 addComponent(socksEnabled = new JCheckBox(jEdit.getProperty( 74 "options.firewall.socks.enabled"))); 75 addComponent(jEdit.getProperty("options.firewall.socks.host"), 77 socksHost = new JTextField(jEdit.getProperty("firewall.socks.host"), 15)); 78 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 } 90 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 (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 } 104 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 116 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 |