📄 bsprefsdialog.java
字号:
package edu.ou.kmi.buddyspace.gui;
/*
* BSPrefsDialog.java
*
* Project: BuddySpace
* (C) Copyright Knowledge Media Institute 2002
*
*
* Created on 2 October 2002, 15:28
*/
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.util.*;
//import java.beans.*; // Property change stuff
//import edu.ou.kmi.buddyspace.core.BSCore;
/**
* <code>BSPrefsDialog</code> is dialog for editing user preferences.
*
* @author Jiri Komzak, Knowledge Media Institute, Open University, United Kingdom
*/
public class BSPrefsDialog extends JDialog
implements ActionListener {
final int MIN_PRIORITY = 0;
final int MAX_PRIORITY = 10;
private BSMainFrame mainFrame;
private JTabbedPane tabbedPane;
private JButton okButton;
private JButton cancelButton;
// login tab
private JTextField usernameTextField;
private JPasswordField passwordField;
private JTextField resourceTextField;
private JTextField serverTextField;
private JTextField portTextField;
private JCheckBox useSSLCheckBox;
private JComboBox priorityComboBox;
private JCheckBox autoLoginCheckBox;
// file transmission tab
private JTextField proxyTextField;
private JTextField proxyPortTextField;
private JTextField fileServerTextField;
private JTextField fileServerPathTextField;
private JTextField fileServerPortTextField;
// view tab
private JCheckBox compactViewCheckBox;
private JCheckBox onlyOnlineCheckBox;
private JCheckBox dockWindowsCheckBox;
private JCheckBox autoAwayCheckBox;
private JCheckBox showMsgsWinCheckBox;
private JCheckBox forceMsgsIntoChatCheckBox;
private JCheckBox showStatusCheckBox;
private JCheckBox showDebugCheckBox;
private JCheckBox scrollTabsCheckBox;
private JTextField LAFTextField;
//private JTextField logoImgPathTextField;
// alerts tab
private JCheckBox autoSelectCheckBox;
private JTextField newMsgSoundFileNameTextField;
// plugins tab
private JCheckBox simLinkCheckBox;
private JCheckBox buddyFinderCheckBox;
// IX panels tab
//private JTextField ixPropsTextField;
// login values
public String username = null;
public String server = null;
public String resource = null;
public String password = null;
public int port;
public boolean useSSL;
public int priority;
public boolean autoLogin;
// file transmission values
public String fileServer = null;
public String fileServerPath = null;
public String fileServerPort = null;
public String proxy = null;
public String proxyPort = null;
// view values
public boolean compactView;
public boolean onlyOnline;
public boolean dockWindows;
public boolean showMsgsWin;
public boolean forceMsgsIntoChat;
public boolean autoAway;
public boolean showStatus;
public boolean showDebug;
public boolean scrollTabs;
public String LAF;
//public String logoImgPath = null;
// plugins enabled
public boolean pluginSimLink;
public boolean pluginBuddyFinder;
// alerts values
public boolean autoSelect;
public String newMsgSoundFileName = null;
// ix panels values
//public String ixPropsPath = null;
/** Creates new form BSPrefsDialog */
public BSPrefsDialog(BSMainFrame parent, Properties props) {
this(parent,
props.getProperty(BSMainFrame.PREF_NAME_USERNAME, BSMainFrame.DEF_USERNAME),
props.getProperty(BSMainFrame.PREF_NAME_PASSWORD, BSMainFrame.DEF_PASSWORD),
props.getProperty(BSMainFrame.PREF_NAME_RESOURCE, BSMainFrame.DEF_RESOURCE),
props.getProperty(BSMainFrame.PREF_NAME_SERVER, BSMainFrame.DEF_SERVER),
Integer.parseInt(props.getProperty(BSMainFrame.PREF_NAME_PORT, Integer.toString(BSMainFrame.DEF_PORT))),
props.getProperty(BSMainFrame.PREF_NAME_USE_SSL, "false").equals("true"),
Integer.parseInt(props.getProperty(BSMainFrame.PREF_NAME_PRIORITY, Integer.toString(BSMainFrame.DEF_PRIORITY))),
props.getProperty(BSMainFrame.PREF_NAME_AUTO_LOGIN, "true").equals("true"),
props.getProperty(BSMainFrame.PREF_NAME_FILE_SERVER, BSMainFrame.DEF_FILE_SERVER),
props.getProperty(BSMainFrame.PREF_NAME_FILE_SERVER_PATH, BSMainFrame.DEF_FILE_SERVER_PATH),
props.getProperty(BSMainFrame.PREF_NAME_FILE_SERVER_PORT, BSMainFrame.DEF_FILE_SERVER_PORT),
props.getProperty(BSMainFrame.PREF_NAME_PROXY, BSMainFrame.DEF_PROXY),
props.getProperty(BSMainFrame.PREF_NAME_PROXY_PORT, BSMainFrame.DEF_PROXY_PORT),
props.getProperty(BSMainFrame.PREF_NAME_COMPACT_VIEW, "true").equals("true"),
props.getProperty(BSMainFrame.PREF_NAME_ONLY_ONLINE, "true").equals("true"),
props.getProperty(BSMainFrame.PREF_NAME_DOCK_WINDOWS, "false").equals("true"),
props.getProperty(BSMainFrame.PREF_NAME_SHOW_MSGS, "false").equals("true"),
props.getProperty(BSMainFrame.PREF_NAME_FORCE_MSGS_INTO_CHAT, "false").equals("true"),
props.getProperty(BSMainFrame.PREF_NAME_AUTO_AWAY, "true").equals("true"),
props.getProperty(BSMainFrame.PREF_NAME_SHOW_STATUS, "false").equals("true"),
props.getProperty(BSMainFrame.PREF_NAME_SHOW_DEBUG, "false").equals("true"),
props.getProperty(BSMainFrame.PREF_NAME_SCROLL_TABS, "false").equals("true"),
props.getProperty(BSMainFrame.PREF_NAME_LAF, ""),
//props.getProperty(BSMainFrame.PREF_NAME_LOGO_IMG_PATH, BSMainFrame.DEF_LOGO_IMG_PATH),
props.getProperty(BSMainFrame.PREF_NAME_AUTO_SELECT, "true").equals("true"),
props.getProperty(BSMainFrame.PREF_NAME_NEW_MSG_SOUND_FILE_NAME, BSMainFrame.DEF_NEW_MSG_SOUND_FILE_NAME),
props.getProperty(BSMainFrame.PREF_NAME_PLUGIN_SIMLINK, "false").equals("true"),
props.getProperty(BSMainFrame.PREF_NAME_PLUGIN_BUDDYFINDER, "true").equals("true")
//props.getProperty(BSMainFrame.PREF_NAME_IX_PROPS_PATH, BSMainFrame.DEF_IX_PROPS_PATH)
);
}
/** Creates new form BSPrefsDialog */
private BSPrefsDialog(BSMainFrame parent,
String username, String password, String resource,
String server, int port, boolean useSSL, int priority, boolean autoLogin,
String fileServer, String fileServerPath, String fileServerPort,
String proxy, String proxyPort,
boolean compactView, boolean onlyOnline, boolean dockWindows,
boolean showMsgsWin, boolean forceMsgsIntoChat, boolean autoAway,
boolean showStatus, boolean showDebug,
boolean scrollTabs, String LAF,
boolean autoSelect, String newMsgSoundFileName,
boolean pluginSimLink,
boolean pluginBuddyFinder) {
super(parent, "Preferences", true);
this.mainFrame = parent;
getContentPane().setLayout(new BorderLayout());
JPanel buttonsPanel = new JPanel();
okButton = new JButton("Save");
okButton.addActionListener(this);
buttonsPanel.add(okButton);
cancelButton = new JButton("Cancel");
cancelButton.addActionListener(this);
buttonsPanel.add(cancelButton);
getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
tabbedPane = new JTabbedPane();
getContentPane().add(tabbedPane, BorderLayout.CENTER);
initLoginTab(username, password, resource, server, port, useSSL, priority, autoLogin);
initViewTab(compactView, onlyOnline, dockWindows, showMsgsWin, forceMsgsIntoChat, autoAway, showStatus, showDebug, scrollTabs, LAF);
initAlertsTab(autoSelect, newMsgSoundFileName);
initFileTab(fileServer, fileServerPath, fileServerPort, proxy, proxyPort);
initPluginsTab(pluginSimLink, pluginBuddyFinder);
//initIXTab(ixPrefFilePath);
pack();
setLocationRelativeTo(mainFrame);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == okButton)
validateFields();
else if (e.getSource() == cancelButton)
setVisible(false);
}
protected void initLoginTab(String username, String password,
String resource, String server, int port, boolean useSSL,
int priority, boolean autoLogin) {
GridBagConstraints gbc;
JPanel loginPanel = new JPanel(new GridBagLayout());
//loginPanel.getInsets(new Insets(10,10,10,10));
//loginPanel.setPreferredSize(new Dimension(300, 400));
JLabel label = new JLabel("Login:");
gbc = new GridBagConstraints();
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.WEST;
loginPanel.add(label, gbc);
usernameTextField = new JTextField(username);
gbc = new GridBagConstraints();
gbc.gridy = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1;
loginPanel.add(usernameTextField, gbc);
label = new JLabel("Password:");
gbc = new GridBagConstraints();
gbc.gridy = 2;
gbc.anchor = GridBagConstraints.WEST;
loginPanel.add(label, gbc);
passwordField = new JPasswordField(password);
gbc = new GridBagConstraints();
gbc.gridy = 3;
gbc.fill = GridBagConstraints.HORIZONTAL;
loginPanel.add(passwordField, gbc);
label = new JLabel("Resource:");
gbc = new GridBagConstraints();
gbc.gridy = 4;
gbc.anchor = GridBagConstraints.WEST;
loginPanel.add(label, gbc);
resourceTextField = new JTextField(resource);
gbc = new GridBagConstraints();
gbc.gridy = 5;
gbc.fill = GridBagConstraints.HORIZONTAL;
loginPanel.add(resourceTextField, gbc);
label = new JLabel("Host:");
gbc = new GridBagConstraints();
gbc.gridy = 6;
gbc.anchor = GridBagConstraints.WEST;
loginPanel.add(label, gbc);
serverTextField = new JTextField(server);
gbc = new GridBagConstraints();
gbc.gridy = 7;
gbc.fill = GridBagConstraints.HORIZONTAL;
loginPanel.add(serverTextField, gbc);
label = new JLabel("Port:");
gbc = new GridBagConstraints();
gbc.gridy = 8;
gbc.anchor = GridBagConstraints.WEST;
loginPanel.add(label, gbc);
portTextField = new JTextField(Integer.toString(port));
gbc = new GridBagConstraints();
gbc.gridy = 9;
gbc.fill = GridBagConstraints.HORIZONTAL;
loginPanel.add(portTextField, gbc);
useSSLCheckBox = new JCheckBox("Use SSL connection", useSSL);
useSSLCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (useSSLCheckBox.isSelected()
&& "5222".equals(portTextField.getText())) {
portTextField.setText("5223");
}
else if (!useSSLCheckBox.isSelected()
&& "5223".equals(portTextField.getText())) {
portTextField.setText("5222");
}
}
});
gbc = new GridBagConstraints();
gbc.gridy = 10;
gbc.anchor = GridBagConstraints.WEST;
loginPanel.add(useSSLCheckBox, gbc);
label = new JLabel("Default priority:");
gbc = new GridBagConstraints();
gbc.gridy = 11;
gbc.anchor = GridBagConstraints.WEST;
loginPanel.add(label, gbc);
priorityComboBox = new JComboBox();
priorityComboBox.setEditable(false);
for (int i = MIN_PRIORITY; i < MAX_PRIORITY+1; i++)
priorityComboBox.addItem(new Integer(i));
priorityComboBox.setSelectedItem(new Integer(priority));
gbc = new GridBagConstraints();
gbc.gridy = 12;
gbc.fill = GridBagConstraints.HORIZONTAL;
loginPanel.add(priorityComboBox, gbc);
autoLoginCheckBox = new JCheckBox("Auto-log in after start", autoLogin);
gbc = new GridBagConstraints();
gbc.gridy = 13;
gbc.anchor = GridBagConstraints.WEST;
loginPanel.add(autoLoginCheckBox, gbc);
tabbedPane.addTab("Login", loginPanel);
}
protected void initFileTab(String fileServer, String fileServerPath,
String fileServerPort, String proxy,
String proxyPort) {
GridBagConstraints gbc;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -