1 16 package net.sf.jftp.gui.tasks; 17 18 import java.awt.FlowLayout ; 19 import java.awt.event.ActionEvent ; 20 import java.awt.event.ActionListener ; 21 22 import javax.swing.JLabel ; 23 24 import net.sf.jftp.config.Settings; 25 import net.sf.jftp.gui.framework.HButton; 26 import net.sf.jftp.gui.framework.HPanel; 27 import net.sf.jftp.gui.framework.HTextField; 28 import net.sf.jftp.system.logging.Log; 29 30 31 public class ProxyChooser extends HPanel implements ActionListener 32 { 33 private HTextField proxy; 34 private HTextField port; 35 private HButton ok = new HButton("Ok"); 36 37 public ProxyChooser() 38 { 39 setLayout(new FlowLayout (FlowLayout.LEFT)); 44 45 proxy = new HTextField("Socks proxy:", ""); 46 port = new HTextField("Port:", ""); 47 48 proxy.setText(Settings.getSocksProxyHost()); 49 port.setText(Settings.getSocksProxyPort()); 50 51 add(proxy); 53 54 add(port); 56 57 add(ok); 59 60 add(new JLabel ("Please note that you have to restart JFtp to apply the changes!")); 62 ok.addActionListener(this); 63 64 } 66 67 public void actionPerformed(ActionEvent e) 68 { 69 if(e.getSource() == ok) 70 { 71 String h = proxy.getText().trim(); 73 String p = port.getText().trim(); 74 75 java.util.Properties sysprops = System.getProperties(); 76 77 sysprops.remove("socksProxyHost"); 79 sysprops.remove("socksProxyPort"); 80 81 Settings.setProperty("jftp.socksProxyHost", h); 82 Settings.setProperty("jftp.socksProxyPort", p); 83 Settings.save(); 84 85 Log.out("proxy vars: " + h + ":" + p); 86 87 if(h.equals("") || p.equals("")) 88 { 89 return; 90 } 91 92 sysprops.put("socksProxyHost", h); 94 sysprops.put("socksProxyPort", p); 95 96 Log.out("new proxy vars set."); 97 98 remove(3); 99 add(new JLabel ("Options set. Please restart JFtp.")); 100 validate(); 101 setVisible(true); 102 } 103 } 104 } 105 | Popular Tags |