summaryrefslogtreecommitdiff
path: root/NET/worlds/console/ProxyServerDialog.java
blob: 310a9a8eda6d60d0e98fe6c5414c89919d5f97c4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package NET.worlds.console;

import NET.worlds.core.IniFile;
import java.awt.GridBagConstraints;
import java.awt.Label;
import java.awt.TextField;
import java.util.Properties;

class ProxyServerDialog extends OkCancelDialog {
   private static final long serialVersionUID = 8421990344972629940L;
   private Label ipLabel = new Label("Proxy IP");
   private TextField ipText = new TextField("", 15);
   private Label portLabel = new Label("Proxy Port");
   private TextField portText = new TextField("", 3);

   public ProxyServerDialog() {
      super(Console.getFrame(), null, Console.message("Proxy-Server"), "Cancel", "Ok", "", false);
      this.ipText.setText(IniFile.gamma().getIniString("Proxy Server IP", ""));
      this.portText.setText(IniFile.gamma().getIniString("Proxy Server Port", ""));
   }

   @Override
   protected synchronized boolean done(boolean confirmed) {
      if (confirmed) {
         Properties p = System.getProperties();
         IniFile.gamma().setIniString("Proxy Server IP", this.ipText.getText());
         IniFile.gamma().setIniString("Proxy Server Port", this.portText.getText());
         p.remove("socksProxyHost");
         p.remove("socksProxyPort");
         p.put("socksProxyHost", this.ipText.getText());
         p.put("socksProxyPort", this.portText.getText());
         System.setProperties(p);
      }

      return super.done(confirmed);
   }

   @Override
   public void build() {
      GridBagConstraints c = new GridBagConstraints();
      c.gridx = 1;
      c.gridy = 1;
      c.weightx = 1.0;
      c.weighty = 1.0;
      this.add(this.gbag, this.ipLabel, c);
      c.gridy = 2;
      this.add(this.gbag, this.portLabel, c);
      c.gridx = 2;
      c.gridy = 1;
      c.weightx = 3.0;
      this.add(this.gbag, this.ipText, c);
      c.gridy = 2;
      this.add(this.gbag, this.portText, c);
      this.okButton.setFont(bfont);
      this.cancelButton.setFont(bfont);
      c.gridx = 1;
      c.gridy = 3;
      c.weightx = 1.0;
      this.add(this.gbag, this.okButton, c);
      c.gridx = 4;
      this.add(this.gbag, this.cancelButton, c);
   }
}