loginsettingdialog.java.svn-base
来自「开源项目openfire的完整源程序」· SVN-BASE 代码 · 共 707 行 · 第 1/3 页
SVN-BASE
707 行
ssoMethodRadio.add(ssoMethodFileRadio);
ssoMethodDNSLabel.setText("Use DNS:");
ssoPanel.add(ssoMethodDNSLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
ssoPanel.add(ssoMethodDNSRadio, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
ssoMethodRadio.add(ssoMethodDNSRadio);
ssoMethodManualLabel.setText("Specify Below:");
ssoPanel.add(ssoMethodManualLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
ssoPanel.add(ssoMethodManualRadio, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
ssoMethodRadio.add(ssoMethodManualRadio);
ssoRealmLabel.setText(" Realm:");
ssoPanel.add(ssoRealmLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
ssoPanel.add(ssoRealmField, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
ssoKDCLabel.setText(" KDC:");
ssoPanel.add(ssoKDCLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
ssoPanel.add(ssoKDCField, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
}
if (isSSOEnabled) {
String method = localPreferences.getSSOMethod();
if (ModelUtil.hasLength(method)) {
if(method.equals("file")) {
ssoMethodFileRadio.setSelected(true);
} else if(method.equals("dns")) {
ssoMethodDNSRadio.setSelected(true);
} else if(method.equals("manual")) {
ssoMethodManualRadio.setSelected(true);
} //else: do what?
} else {
//Do some OS detection here...
if(System.getProperty("os.name").toLowerCase().startsWith("windows")) {
ssoMethodDNSRadio.setSelected(true);
} else {
ssoMethodFileRadio.setSelected(true);
}
}
String realm = localPreferences.getSSORealm();
if (ModelUtil.hasLength(realm)) {
ssoRealmField.setText(realm);
}
String kdc = localPreferences.getSSOKDC();
if (ModelUtil.hasLength(kdc)) {
ssoKDCField.setText(kdc);
}
}
useSSOBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (useSSOBox.isSelected()) {
ssoMethodFileRadio.setEnabled(useSSOBox.isSelected());
ssoMethodDNSRadio.setEnabled(useSSOBox.isSelected());
ssoMethodManualRadio.setEnabled(useSSOBox.isSelected());
ssoRealmField.setEnabled(useSSOBox.isSelected());
ssoKDCField.setEnabled(useSSOBox.isSelected());
String method = localPreferences.getSSOMethod();
if (ModelUtil.hasLength(method)) {
if(method.equals("file")) {
ssoMethodFileRadio.setSelected(true);
} else if(method.equals("dns")) {
ssoMethodDNSRadio.setSelected(true);
} else if(method.equals("manual")) {
ssoMethodManualRadio.setSelected(true);
} //else: do what?
} else {
//Do some OS detection here...
ssoMethodDNSRadio.setSelected(true);
}
String realm = localPreferences.getSSORealm();
if (ModelUtil.hasLength(realm)) {
ssoRealmField.setText(realm);
}
String kdc = localPreferences.getSSOKDC();
if (ModelUtil.hasLength(kdc)) {
ssoKDCField.setText(kdc);
}
localPreferences.setSSOEnabled(true);
localPreferences.setAutoLogin(true);
}
else {
ssoMethodFileRadio.setEnabled(false);
ssoMethodFileRadio.setSelected(false);
ssoMethodDNSRadio.setEnabled(false);
ssoMethodDNSRadio.setSelected(false);
ssoMethodManualRadio.setEnabled(false);
ssoMethodManualRadio.setSelected(false);
ssoRealmField.setEnabled(false);
ssoRealmField.setText("");
ssoKDCField.setEnabled(false);
ssoKDCField.setText("");
localPreferences.setSSOEnabled(false);
}
}
});
debuggerBox.setSelected(localPreferences.isDebuggerEnabled());
// Construct main panel w/ layout.
final JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(titlePanel, BorderLayout.NORTH);
// The user should only be able to close this dialog.
Object[] options = {Res.getString("ok"), Res.getString("cancel"), Res.getString("use.default")};
optionPane = new JOptionPane(tabbedPane, JOptionPane.PLAIN_MESSAGE,
JOptionPane.OK_CANCEL_OPTION, null, options, options[0]);
mainPanel.add(optionPane, BorderLayout.CENTER);
optionsDialog = new JDialog(owner, Res.getString("title.preferences"), true);
optionsDialog.setContentPane(mainPanel);
optionsDialog.pack();
optionsDialog.setLocationRelativeTo(owner);
optionPane.addPropertyChangeListener(this);
optionsDialog.setResizable(true);
optionsDialog.setVisible(true);
optionsDialog.toFront();
optionsDialog.requestFocus();
return true;
}
/**
* PropertyChangeEvent is called when the user either clicks the Cancel or
* OK button.
*
* @param e the property change event.
*/
public void propertyChange(PropertyChangeEvent e) {
String value = (String)optionPane.getValue();
if (Res.getString("cancel").equals(value)) {
optionsDialog.setVisible(false);
}
else if (Res.getString("ok").equals(value)) {
String timeOut = timeOutField.getText();
String port = portField.getText();
String resource = resourceField.getText();
boolean errors = false;
try {
Integer.valueOf(timeOut);
}
catch (NumberFormatException numberFormatException) {
JOptionPane.showMessageDialog(optionsDialog, Res.getString("message.supply.valid.timeout"),
Res.getString("title.error"), JOptionPane.ERROR_MESSAGE);
timeOutField.requestFocus();
errors = true;
}
try {
Integer.valueOf(port);
}
catch (NumberFormatException numberFormatException) {
JOptionPane.showMessageDialog(optionsDialog, Res.getString("message.supply.valid.port"),
Res.getString("title.error"), JOptionPane.ERROR_MESSAGE);
portField.requestFocus();
errors = true;
}
if (!ModelUtil.hasLength(resource)) {
JOptionPane.showMessageDialog(optionsDialog, Res.getString("message.supply.resource"),
Res.getString("title.error"), JOptionPane.ERROR_MESSAGE);
resourceField.requestFocus();
errors = true;
}
if (!errors) {
localPreferences.setTimeOut(Integer.parseInt(timeOut));
localPreferences.setXmppPort(Integer.parseInt(port));
localPreferences.setSSL(useSSLBox.isSelected());
localPreferences.setXmppHost(xmppHostField.getText());
localPreferences.setCompressionEnabled(compressionBox.isSelected());
localPreferences.setDebuggerEnabled(debuggerBox.isSelected());
optionsDialog.setVisible(false);
localPreferences.setResource(resource);
proxyPanel.saveProxySettings();
}
else {
optionPane.removePropertyChangeListener(this);
optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);
optionPane.addPropertyChangeListener(this);
}
}
else {
localPreferences.setTimeOut(30);
localPreferences.setXmppPort(5222);
localPreferences.setSSL(false);
portField.setText("5222");
timeOutField.setText("30");
useSSLBox.setSelected(false);
optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);
}
}
/**
* Internal class to allow setting of proxies within Spark.
*/
private class ProxyPanel extends JPanel {
private JCheckBox useProxyBox = new JCheckBox();
private JComboBox protocolBox = new JComboBox();
private JTextField hostField = new JTextField();
private JTextField portField = new JTextField();
private JTextField usernameField = new JTextField();
private JPasswordField passwordField = new JPasswordField();
/**
* Construct UI.
*/
public ProxyPanel() {
JLabel protocolLabel = new JLabel();
JLabel hostLabel = new JLabel();
JLabel portLabel = new JLabel();
JLabel usernameLabel = new JLabel();
JLabel passwordLabel = new JLabel();
protocolBox.addItem("SOCKS");
protocolBox.addItem("HTTP");
// Add ResourceUtils
ResourceUtils.resButton(useProxyBox, Res.getString("checkbox.use.proxy.server"));
ResourceUtils.resLabel(protocolLabel, protocolBox, Res.getString("label.protocol"));
ResourceUtils.resLabel(hostLabel, hostField, Res.getString("label.host"));
ResourceUtils.resLabel(portLabel, portField, Res.getString("label.port"));
ResourceUtils.resLabel(usernameLabel, usernameField, Res.getString("label.username"));
ResourceUtils.resLabel(passwordLabel, passwordField, Res.getString("label.password"));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?