PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms 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
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  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. import java.awt.*;
  20. import java.awt.event.*;
  21. import javax.swing.*;
  22. import javax.swing.border.*;
  23. import org.gjt.sp.jedit.*;
  24. public class FirewallOptionPane extends AbstractOptionPane {
  25. // private members
  26. private JCheckBox cEnabled;
  27. private JTextField tHost;
  28. private JTextField tPort;
  29. private JTextField tUser;
  30. private JPasswordField tPass;
  31. private JTextField tNonProxy;
  32. public FirewallOptionPane() {
  33. super("firewall");
  34. }
  35. public void _init()
  36. {
  37. // checkbox "Enable firewall authentication"
  38. addComponent(cEnabled = new JCheckBox(jEdit.getProperty(
  39. "options.firewall.enabled")));
  40. // proxy host
  41. addComponent(jEdit.getProperty("options.firewall.host"),
  42. tHost = new JTextField(jEdit.getProperty("firewall.host"), 15));
  43. // proxy port
  44. addComponent(jEdit.getProperty("options.firewall.port"),
  45. tPort = new JTextField(jEdit.getProperty("firewall.port"), 15));
  46. // proxy username
  47. addComponent(jEdit.getProperty("options.firewall.user"),
  48. tUser = new JTextField(jEdit.getProperty("firewall.user"), 15));
  49. // proxy password
  50. addComponent(jEdit.getProperty("options.firewall.password"),
  51. tPass = new JPasswordField(jEdit.getProperty("firewall.password"), 15));
  52. // no proxy for
  53. addComponent(jEdit.getProperty("options.firewall.nonProxy"),
  54. tNonProxy = new JTextField(jEdit.getProperty("firewall.nonProxyHosts"), 15));
  55. boolean enabled = jEdit.getBooleanProperty("firewall.enabled");
  56. cEnabled.setSelected(enabled);
  57. tHost.setEnabled(enabled);
  58. tPort.setEnabled(enabled);
  59. tUser.setEnabled(enabled);
  60. tPass.setEnabled(enabled);
  61. tNonProxy.setEnabled(enabled);
  62. cEnabled.addActionListener(new ActionListener() {
  63. public void actionPerformed(ActionEvent e) {
  64. boolean enbld = cEnabled.isSelected();
  65. cEnabled.setSelected(enbld);
  66. tHost.setEnabled(enbld);
  67. tPort.setEnabled(enbld);
  68. tUser.setEnabled(enbld);
  69. tPass.setEnabled(enbld);
  70. tNonProxy.setEnabled(enbld);
  71. }
  72. });
  73. }
  74. /**
  75. * Called when the options dialog's `OK' button is pressed.
  76. * This should save any properties saved in this option pane.
  77. */
  78. public void _save() {
  79. jEdit.setBooleanProperty("firewall.enabled", cEnabled.isSelected());
  80. jEdit.setProperty("firewall.host", tHost.getText());
  81. jEdit.setProperty("firewall.port", tPort.getText());
  82. jEdit.setProperty("firewall.user", tUser.getText());
  83. jEdit.setProperty("firewall.password", new String(tPass.getPassword()));
  84. jEdit.setProperty("firewall.nonProxyHosts", tNonProxy.getText());
  85. }
  86. }