PageRenderTime 35ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre4/org/gjt/sp/jedit/options/FirewallOptionPane.java

#
Java | 130 lines | 77 code | 14 blank | 39 comment | 0 complexity | 1ca6cd9dcb3524e268d6cc95ff6ae38f 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 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. package org.gjt.sp.jedit.options;
  24. //{{{ Imports
  25. import java.awt.event.*;
  26. import javax.swing.*;
  27. import org.gjt.sp.jedit.*;
  28. //}}}
  29. public class FirewallOptionPane extends AbstractOptionPane {
  30. //{{{ FirewallOptionPane constructor
  31. public FirewallOptionPane()
  32. {
  33. super("firewall");
  34. } //}}}
  35. //{{{ _init() method
  36. public void _init()
  37. {
  38. // checkbox
  39. addComponent(httpEnabled = new JCheckBox(jEdit.getProperty(
  40. "options.firewall.http.enabled")));
  41. // proxy host
  42. addComponent(jEdit.getProperty("options.firewall.http.host"),
  43. httpHost = new JTextField(jEdit.getProperty("firewall.host"), 15));
  44. // proxy port
  45. addComponent(jEdit.getProperty("options.firewall.http.port"),
  46. httpPort = new JTextField(jEdit.getProperty("firewall.port"), 15));
  47. // proxy username
  48. addComponent(jEdit.getProperty("options.firewall.http.user"),
  49. httpUser = new JTextField(jEdit.getProperty("firewall.user"), 15));
  50. // proxy password
  51. addComponent(jEdit.getProperty("options.firewall.http.password"),
  52. httpPass = new JPasswordField(jEdit.getProperty("firewall.password"), 15));
  53. // no proxy for
  54. addComponent(jEdit.getProperty("options.firewall.http.nonProxy"),
  55. httpNonProxy = new JTextField(jEdit.getProperty("firewall.nonProxyHosts"), 15));
  56. boolean enabled = jEdit.getBooleanProperty("firewall.enabled");
  57. httpEnabled.setSelected(enabled);
  58. httpHost.setEnabled(enabled);
  59. httpPort.setEnabled(enabled);
  60. httpUser.setEnabled(enabled);
  61. httpPass.setEnabled(enabled);
  62. httpNonProxy.setEnabled(enabled);
  63. httpEnabled.addActionListener(new ActionHandler());
  64. // checkbox
  65. addComponent(socksEnabled = new JCheckBox(jEdit.getProperty(
  66. "options.firewall.socks.enabled")));
  67. // proxy host
  68. addComponent(jEdit.getProperty("options.firewall.socks.host"),
  69. socksHost = new JTextField(jEdit.getProperty("firewall.socks.host"), 15));
  70. // proxy port
  71. addComponent(jEdit.getProperty("options.firewall.socks.port"),
  72. socksPort = new JTextField(jEdit.getProperty("firewall.socks.port"), 15));
  73. enabled = jEdit.getBooleanProperty("firewall.socks.enabled");
  74. socksEnabled.setSelected(enabled);
  75. socksHost.setEnabled(enabled);
  76. socksPort.setEnabled(enabled);
  77. socksEnabled.addActionListener(new ActionHandler());
  78. } //}}}
  79. //{{{ _save() method
  80. public void _save() {
  81. jEdit.setBooleanProperty("firewall.enabled", httpEnabled.isSelected());
  82. jEdit.setProperty("firewall.host", httpHost.getText());
  83. jEdit.setProperty("firewall.port", httpPort.getText());
  84. jEdit.setProperty("firewall.user", httpUser.getText());
  85. jEdit.setProperty("firewall.password", new String(httpPass.getPassword()));
  86. jEdit.setProperty("firewall.nonProxyHosts", httpNonProxy.getText());
  87. jEdit.setBooleanProperty("firewall.socks.enabled", socksEnabled.isSelected());
  88. jEdit.setProperty("firewall.socks.host", socksHost.getText());
  89. jEdit.setProperty("firewall.socks.port", socksPort.getText());
  90. } //}}}
  91. //{{{ Private members
  92. private JCheckBox httpEnabled;
  93. private JTextField httpHost;
  94. private JTextField httpPort;
  95. private JTextField httpUser;
  96. private JPasswordField httpPass;
  97. private JTextField httpNonProxy;
  98. private JCheckBox socksEnabled;
  99. private JTextField socksHost;
  100. private JTextField socksPort;
  101. //}}}
  102. //{{{ ActionHandler class
  103. class ActionHandler implements ActionListener
  104. {
  105. public void actionPerformed(ActionEvent evt)
  106. {
  107. httpHost.setEnabled(httpEnabled.isSelected());
  108. httpPort.setEnabled(httpEnabled.isSelected());
  109. httpUser.setEnabled(httpEnabled.isSelected());
  110. httpPass.setEnabled(httpEnabled.isSelected());
  111. httpNonProxy.setEnabled(httpEnabled.isSelected());
  112. socksHost.setEnabled(socksEnabled.isSelected());
  113. socksPort.setEnabled(socksEnabled.isSelected());
  114. }
  115. }
  116. }