📄 networkconfigdialog.java
字号:
} aglets_res.save("Tahiti"); atp_res.save("Tahiti"); // REMIND: needs update // com.ibm.atp.protocol.http.HttpProxy.update(); return changed; } private String setSubscribeStatus(int i) { switch (i) { case YES: return "yes"; case NO: return "no"; case UNDEFINED: return "undefined"; default: return "undefined"; } } /* * Make the authentication panel */ void setupAuthenticationPanel(BorderPanel authPanel) { GridBagConstraints cns = new GridBagConstraints(); cns.anchor = GridBagConstraints.WEST; cns.fill = GridBagConstraints.NONE; cns.weighty = 1.0; cns.insets = authPanel.topInsets(); cns.insets.bottom = authPanel.bottomInsets().bottom; authPanel.setConstraints(cns); cns.fill = GridBagConstraints.HORIZONTAL; authPanel.add(_authenticationMode, GridBagConstraints.REMAINDER, 1.0); authPanel.add(_secureRandomSeed, GridBagConstraints.REMAINDER, 1.0); cns.fill = GridBagConstraints.HORIZONTAL; cns.gridwidth = GridBagConstraints.RELATIVE; authPanel.add(_createSharedSecret); _createSharedSecret.setActionCommand(CREATE_SHARED_SECRET); _createSharedSecret.addActionListener(this); cns.gridwidth = GridBagConstraints.REMAINDER; authPanel.add(_removeSharedSecret); _removeSharedSecret.setActionCommand(REMOVE_SHARED_SECRET); _removeSharedSecret.addActionListener(this); cns.gridwidth = GridBagConstraints.RELATIVE; authPanel.add(_importSharedSecret); _importSharedSecret.setActionCommand(IMPORT_SHARED_SECRET); _importSharedSecret.addActionListener(this); cns.gridwidth = GridBagConstraints.REMAINDER; authPanel.add(_exportSharedSecret); _exportSharedSecret.setActionCommand(EXPORT_SHARED_SECRET); _exportSharedSecret.addActionListener(this); } /* * Make the GUI for setting http proxy */ void setupHttpTunnelingPanel(BorderPanel proxyPanel) { GridBagConstraints cns = new GridBagConstraints(); cns.anchor = GridBagConstraints.WEST; cns.fill = GridBagConstraints.NONE; cns.weighty = 1.0; cns.insets = proxyPanel.topInsets(); cns.insets.bottom = proxyPanel.bottomInsets().bottom; proxyPanel.setConstraints(cns); proxyPanel.add(_httpTunneling, GridBagConstraints.REMAINDER, 1.0); proxyPanel.add(_useProxy, GridBagConstraints.REMAINDER, 1.0); cns.fill = GridBagConstraints.HORIZONTAL; cns.insets = proxyPanel.bottomInsets(); proxyPanel.add(new Label("ProxyHost:"), 1, 0.1); proxyPanel.add(_proxyHost, 1, 1.0); proxyPanel.add(new Label("Port:"), 1, 0.1); proxyPanel.add(_proxyPort, GridBagConstraints.REMAINDER, 0.4); proxyPanel.add(new Label("Do not use the proxy server for domains:"), GridBagConstraints.REMAINDER, 1.0); proxyPanel.add(_noProxy, GridBagConstraints.REMAINDER, 1.0); _useProxy.addItemListener(this); } /* * */ void setupOthersPanel(BorderPanel othersPanel) { GridBagConstraints cns = new GridBagConstraints(); cns.anchor = GridBagConstraints.WEST; cns.fill = GridBagConstraints.NONE; cns.weighty = 1.0; othersPanel.setConstraints(cns); cns.insets = othersPanel.topInsets(); cns.insets.bottom = othersPanel.bottomInsets().bottom; othersPanel.add(_httpMessaging, GridBagConstraints.REMAINDER, 1.0); } /* * Make the subscription panel */ void setupSubscriptionPanel(BorderPanel subPanel) { GridBagConstraints cns = new GridBagConstraints(); cns.anchor = GridBagConstraints.WEST; cns.fill = GridBagConstraints.NONE; cns.weighty = 1.0; cns.insets = subPanel.topInsets(); cns.insets.bottom = subPanel.bottomInsets().bottom; subPanel.setConstraints(cns); /* * Util.addCmp(subPanel,grid, cns, _useBox, * GridBagConstraints.REMAINDER, 1.0); */ cns.fill = GridBagConstraints.HORIZONTAL; subPanel.add(new Label("Server(URL):"), 1, 0.1); subPanel.add(_boxHost, GridBagConstraints.REMAINDER, 1.0); /* * Util.addCmp(subPanel, grid, cns,makeSubscribeButtonPanel(), * GridBagConstraints.REMAINDER, 1.0); */ cns.insets = subPanel.bottomInsets(); _boxPasswd.setEchoChar('x'); subPanel.add(new Label("Password:"), 1, 0.1); subPanel.add(_boxPasswd, GridBagConstraints.REMAINDER, 1.0); subPanel.add(new Label("UserId:"), 1, 0.1); subPanel.add(_boxUserid, GridBagConstraints.REMAINDER, 1.0); cns.fill = GridBagConstraints.NONE; subPanel.add(new Label("Frequency:"), 1, 0.1); subPanel.add(_updateChoice, 1, 0.1); cns.anchor = GridBagConstraints.EAST; subPanel.add(_subscribe, GridBagConstraints.REMAINDER, 1.0); subPanel.add(_unsubscribe, GridBagConstraints.REMAINDER, 1.0); } void subscribe() { /* * Resource res = Resource.getResourceFor("aglets"); * try { * res.setResource("aglets.box.host", _boxHost.getText().trim()); * res.setResource("aglets.box.passwd", _boxPasswd.getText().trim()); * res.setResource("aglets.box.userid", _boxUserid.getText().trim()); * String name = res.getString("aglets.box.userid",""); * URL url = new URL("aglet", name, ""); * AgletConnection connection = new AgletConnection(url,"subscribe"); * connection.sendRequest(); * InputStream is = connection.getInputStream(); * DataInputStream ds = new DataInputStream(is); * Hashtable headers = new Hashtable(); * AtpConnectionImpl.parseHeaders(ds,headers); * if (getStatusCode(headers) != AtciConstants.OKAY) { * String line =ds.readLine(); * throw new IOException(line.trim()); * } * updateSubscribeGUIState(YES); * res.setResource("aglets.box.subscribe", setSubscribeStatus(YES)); * res.save("Tahiti"); * } catch (IOException ex) { * TahitiDialog.alert(getMainWindow(), * "ERROR during SUBSCRIBE!!\n" + * ex.getClass().getName() + ":" + ex.getMessage()).popupAtCenterOfParent(); * } */ } void unsubscribe() { /* * Resource res = Resource.getResourceFor("aglets"); * try { * String name = res.getString("aglets.box.userid",""); * URL url = new URL("aglet", name, ""); * AgletConnection connection = new AgletConnection(url,"unsubscribe"); * connection.sendRequest(); * InputStream is = connection.getInputStream(); * DataInputStream ds = new DataInputStream(is); * Hashtable headers = new Hashtable(); * AtpConnectionImpl.parseHeaders(ds,headers); * if (getStatusCode(headers) != AtciConstants.OKAY) { * String line =ds.readLine(); * throw new IOException(line.trim()); * } * updateSubscribeGUIState(NO); * res.setResource("aglets.box.subscribe", setSubscribeStatus(NO)); * res.save("Tahiti"); * } catch (IOException ex) { * TahitiDialog.alert(getMainWindow(), * "ERROR during UNSUBSCRIBE!!\n" + * ex.getClass().getName() + ":" + ex.getMessage() * ).popupAtCenterOfParent(); * } */ } void updateGUIState() { _boxUserid.setEnabled(false); boolean b = _useProxy.getState(); _proxyHost.setEnabled(b); _proxyPort.setEnabled(b); _noProxy.setEnabled(b); _boxUserid.setEnabled(false); /* * // Temporarely * _useUpdate.setLabel("Update Off:"); * _boxUpdate.setEnabled(false); * _useUpdate.setEnabled(false); */ updateSubscribeGUIState(_boxSubscribe); /* * if (_useBox.getState()==false) { * _useBox.setLabel("Box: Disabled"); * // _boxUserid.setEnabled(false); * _boxPasswd.setEnabled(false); * _useUpdate.setEnabled(false); * _subscribe.setEnabled(false); * _unsubscribe.setEnabled(false); * _boxUpdate.setEnabled(false); * _boxHost.setEnabled(false); * } else { * _useBox.setLabel("Box: Enabled"); * // _boxUserid.setEnabled(true); * // _boxPasswd.setEnabled(true); * _useUpdate.setEnabled(true); * updateSubscribeGUIState(_boxSubscribe); * // _boxHost.setEnabled(true); * if (_useUpdate.getState() == false) { * _useUpdate.setLabel("Update Off:"); * _boxUpdate.setEnabled(false); * } else { * _useUpdate.setLabel("Update On:"); * _boxUpdate.setEnabled(true); * } * } */ } private int updateIndex(int value) { int i = -1; for (int j = 0; j < boxUpdateValues.length; j++) { if (value == boxUpdateValues[j]) { i = j; break; } } return i; } private void updateSubscribeGUIState(int cond) { if (Tahiti.enableBox == false) { _subscribe.setEnabled(false); _unsubscribe.setEnabled(false); _boxHost.setText("Disabled"); _boxUserid.setText("Disabled"); _boxHost.setEnabled(false); _boxPasswd.setEnabled(false); _updateChoice.select(0); _updateChoice.setEnabled(false); // Temporary Resource res = Resource.getResourceFor("aglets"); res.setResource("aglets.box.subscribe", setSubscribeStatus(NO)); return; } switch (cond) { case YES: _subscribe.setEnabled(false); _unsubscribe.setEnabled(true); _boxHost.setEnabled(false); _boxPasswd.setEnabled(false); // _boxUserid.setEnabled(false); break; case NO: _subscribe.setEnabled(true); _unsubscribe.setEnabled(false); _boxHost.setEnabled(true); _boxPasswd.setEnabled(true); // _boxUserid.setEnabled(true); break; case UNDEFINED: _subscribe.setEnabled(true); _unsubscribe.setEnabled(true); _boxHost.setEnabled(true); _boxPasswd.setEnabled(true); // _boxUserid.setEnabled(true); break; default: } _boxSubscribe = cond; } private int updateValue(int index) { return (index < boxUpdateValues.length) ? boxUpdateValues[index] : 0; } /* * Setting values */ private void updateValues() { Resource atp_res = Resource.getResourceFor("atp"); _proxyHost.setText(atp_res.getString("atp.http.proxyHost", "")); _proxyPort.setText(atp_res.getString("atp.http.proxyPort", "")); _noProxy.setText(atp_res.getString("atp.noProxy", "")); _useProxy.setState(atp_res.getBoolean("atp.useHttpProxy", false)); Resource res = Resource.getResourceFor("aglets"); /* * allow/disallow http tunneling/messaging */ _httpTunneling.setState(atp_res.getBoolean("atp.http.tunneling", false)); _httpMessaging.setState(atp_res.getBoolean("atp.http.messaging", false)); /* * Authentication */ _authenticationMode.setState(atp_res.getBoolean("atp.authentication", false)); _secureRandomSeed.setState(atp_res.getBoolean("atp.secureseed", false)); /* * BOX */ String email = res.getString("aglets.box.userid", ""); // _useBox.setState( res.getBoolean("aglets.box.enabled", false) ); _boxUserid.setText(res.getString("aglets.box.userid", email)); _boxPasswd.setText(res.getString("aglets.box.passwd")); // _useUpdate.setState( res.getBoolean("aglets.box.update.enabled", false)); _updateChoice .select(updateIndex(res.getInteger("aglets.box.update.sec", 0))); _updateChoice.select(res.getInteger("aglets.box.update", 0)); _boxHost.setText(res.getString("aglets.box.host")); String tmp = res.getString("aglets.box.subscribe", "undefined"); _boxSubscribe = (_boxSubscribe == UNDEFINED) ? getSubscribeStatus(tmp) : _boxSubscribe; updateGUIState(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -