001: package com.sun.portal.proxylet.client.applet;
002:
003: /**
004: * Created by IntelliJ IDEA.
005: * User: Venugopala Rao M.
006: * Date: Mar 24, 2004
007: * Time: 4:18:56 PM
008: * To change this template use File | Settings | File Templates.
009: */
010:
011: import com.sun.portal.proxylet.client.common.Param;
012: import com.sun.portal.proxylet.client.common.browser.BrowserHelper;
013: import com.sun.portal.proxylet.client.applet.ProxyInfoHelpDialog;
014: import com.sun.portal.proxylet.client.applet.ProxyInfoDialog;
015:
016: import javax.swing.JFrame;
017: import java.awt.event.ActionEvent;
018: import java.awt.event.ActionListener;
019: import java.awt.event.ItemEvent;
020: import java.awt.event.ItemListener;
021:
022: public class PluginProxyInfo implements ActionListener, ItemListener {
023:
024: // Proxy types
025: public static final int DIRECT = 0; // Direct connection to the Internet
026: public static final int MANUAL = 1; // Manual proxy configuration
027: public static final int AUTO = 2; // Automatic proxy configuration
028:
029: private static ProxyInfoDialog pid = null;
030: private static ProxyInfoHelpDialog pihd = null;
031:
032: private boolean actionOk = true;
033:
034: /*
035: * Default constructor - reads the proxy information ( Proxy mode,
036: * SSL proxy host, SSL proxy port, Proxy Bypass list).
037: */
038: public PluginProxyInfo() {
039: // Ask the user for the proxy settings
040: pid = new ProxyInfoDialog(new JFrame(), this , this );
041: pid.showWarning();
042: pid.waitForAction();
043: }
044:
045: /*
046: * Process the proxy information entered by user.
047: */
048: public void actionPerformed(ActionEvent evt) {
049: Object obj = evt.getSource();
050: if ("OK".equals(evt.getActionCommand())) {
051: if (obj == pid.ok) {
052: pid.setVisible(false);
053:
054: if (pid.manual.isSelected()) {
055: String proxySSL = pid.proxyHost.getText();
056: try {
057: Integer.parseInt(pid.proxyPort.getText());
058: } catch (NumberFormatException nfe) {
059: System.out.println("Invalid SSL proxy port: "
060: + nfe);
061: }
062: Param.setClientProxy(proxySSL, pid.proxyPort
063: .getText());
064: Param.setByPassList(pid.noProxy.getText());
065: } else if (pid.auto.isSelected()) {
066: BrowserHelper.checkPACFileSetting(pid.autoURL
067: .getText());
068: }
069: if (pihd != null) {
070: pihd.setVisible(false);
071: pihd = null;
072: }
073: pid.notifyAction();
074: }
075: } else if ("Cancel".equals(evt.getActionCommand())) {
076: if (obj == pid.cancel) {
077: pid.setVisible(false);
078: if (pihd != null) {
079: pihd.setVisible(false);
080: pihd = null;
081: }
082: actionOk = false;
083: pid.notifyAction();
084: }
085: } else if ("Help".equals(evt.getActionCommand())) {
086: if (obj == pid.help) {
087: if (pihd == null) {
088: pihd = new ProxyInfoHelpDialog(new JFrame());
089: }
090: pihd.show();
091: }
092: }
093: }
094:
095: /*
096: * Process the change in selection, esp change the colors.
097: */
098: public void itemStateChanged(ItemEvent evt) {
099: if (pid.direct.isSelected()) {
100: pid.setState(DIRECT);
101: } else if (pid.manual.isSelected()) {
102: pid.setState(MANUAL);
103: } else if (pid.auto.isSelected()) {
104: pid.setState(AUTO);
105: }
106: }
107:
108: /**
109: * it returns true if the user clicks OK and false if user clicks Cancel
110: * @return
111: */
112: public boolean isActionOk() {
113: return actionOk;
114: }
115:
116: }
|