* Added Font Size preferences.

* Added enabling of debugger through advanced login page.

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@8395 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro
2007-05-25 18:29:12 +00:00
committed by derek
parent d23ba5ceb8
commit cc665a14eb
9 changed files with 150 additions and 38 deletions

View File

@ -724,6 +724,9 @@ public final class LoginDialog {
if (!hasErrors) {
localPref = SettingsManager.getLocalPreferences();
if (localPref.isDebuggerEnabled()) {
XMPPConnection.DEBUG_ENABLED = true;
}
SmackConfiguration.setPacketReplyTimeout(localPref.getTimeOut() * 1000);

View File

@ -89,6 +89,8 @@ public class LoginSettingDialog implements PropertyChangeListener {
private JCheckBox useSSOBox = new JCheckBox();
private JTextField ssoServerField = new JTextField();
private JCheckBox debuggerBox = new JCheckBox();
/**
* Empty Constructor.
*/
@ -136,6 +138,7 @@ public class LoginSettingDialog implements PropertyChangeListener {
ResourceUtils.resLabel(resourceLabel, resourceField, Res.getString("label.resource"));
ResourceUtils.resButton(compressionBox, "Use Co&mpression");
ResourceUtils.resButton(useSSOBox, "&Use Single Sign-On (SSO)");
ResourceUtils.resButton(debuggerBox, "Start &Debugger on startup");
inputPanel.add(autoDiscoverBox, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
@ -171,6 +174,7 @@ public class LoginSettingDialog implements PropertyChangeListener {
inputPanel.add(useSSLBox, new GridBagConstraints(0, 4, 2, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
inputPanel.add(compressionBox, new GridBagConstraints(0, 5, 2, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
inputPanel.add(debuggerBox, new GridBagConstraints(0, 6, 2, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
// Create the title panel for this dialog
titlePanel = new TitlePanel("Advanced Connection Preferences", "", SparkRes.getImageIcon(SparkRes.BLANK_24x24), true);
@ -232,6 +236,8 @@ public class LoginSettingDialog implements PropertyChangeListener {
}
});
debuggerBox.setSelected(localPreferences.isDebuggerEnabled());
// Construct main panel w/ layout.
final JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
@ -317,6 +323,7 @@ public class LoginSettingDialog implements PropertyChangeListener {
localPreferences.setSSL(useSSLBox.isSelected());
localPreferences.setXmppHost(xmppHostField.getText());
localPreferences.setCompressionEnabled(compressionBox.isSelected());
localPreferences.setDebuggerEnabled(debuggerBox.isSelected());
optionsDialog.setVisible(false);
localPreferences.setResource(resource);

View File

@ -14,22 +14,21 @@ import de.javasoft.plaf.synthetica.SyntheticaBlueMoonLookAndFeel;
import de.javasoft.plaf.synthetica.SyntheticaLookAndFeel;
import org.jivesoftware.resource.Default;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smackx.debugger.EnhancedDebuggerWindow;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
import java.awt.Color;
import java.awt.Font;
import java.io.File;
import java.io.IOException;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.Color;
import java.awt.Font;
import java.io.File;
import java.io.IOException;
/**
* In many cases, you will need to know the structure of the Spark installation, such as the directory structures, what
* type of system Spark is running on, and also the arguments which were passed into Spark on startup. The <code>Spark</code>
@ -59,11 +58,6 @@ public final class Spark {
}
public void startup() {
EnhancedDebuggerWindow.PERSISTED_DEBUGGER = true;
EnhancedDebuggerWindow.MAX_TABLE_ROWS = 10;
XMPPConnection.DEBUG_ENABLED = true;
String current = System.getProperty("java.library.path");
String classPath = System.getProperty("java.class.path");
@ -308,6 +302,7 @@ public final class Spark {
public static String getUserHome() {
return USER_HOME;
}
/**
* Returns the Spark directory for the current user (user.home). The user home is where all user specific
* files are placed to run Spark within a multi-user system.

View File

@ -18,6 +18,8 @@ import org.jivesoftware.spark.util.BrowserLauncher;
import org.jivesoftware.spark.util.ModelUtil;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
import javax.swing.AbstractAction;
import javax.swing.Action;
@ -99,6 +101,12 @@ public class ChatArea extends JTextPane implements MouseListener, MouseMotionLis
public ChatArea() {
emoticonManager = EmoticonManager.getInstance();
// Set Default Font
final LocalPreferences pref = SettingsManager.getLocalPreferences();
int fs = pref.getChatRoomFontSize();
fontSize = fs;
setFontSize(fs);
// Cut Action
final Action cutAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {

View File

@ -27,6 +27,8 @@ import org.jivesoftware.spark.util.ModelUtil;
import org.jivesoftware.spark.util.TaskEngine;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.profile.VCardManager;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
import javax.imageio.ImageIO;
import javax.swing.Icon;
@ -69,6 +71,7 @@ public class ContactItem extends JPanel {
private JLabel sideIcon;
private int fontSize;
/**
* Creates a new instance of a contact.
@ -79,6 +82,10 @@ public class ContactItem extends JPanel {
public ContactItem(String nickname, String fullyQualifiedJID) {
setLayout(new GridBagLayout());
// Set Default Font
final LocalPreferences pref = SettingsManager.getLocalPreferences();
fontSize = pref.getContactListFontSize();
// Set default presence
presence = new Presence(Presence.Type.unavailable);
@ -94,7 +101,7 @@ public class ContactItem extends JPanel {
nicknameLabel.setText(nickname);
descriptionLabel.setFont(new Font("Dialog", Font.PLAIN, 11));
descriptionLabel.setFont(new Font("Dialog", Font.PLAIN, fontSize));
descriptionLabel.setForeground((Color)UIManager.get("ContactItemDescription.foreground"));
descriptionLabel.setHorizontalTextPosition(JLabel.LEFT);
descriptionLabel.setHorizontalAlignment(JLabel.LEFT);
@ -375,7 +382,7 @@ public class ContactItem extends JPanel {
isAvailable = true;
}
else if (!presence.isAvailable()) {
getNicknameLabel().setFont(new Font("Dialog", Font.PLAIN, 11));
getNicknameLabel().setFont(new Font("Dialog", Font.PLAIN, fontSize));
getNicknameLabel().setForeground((Color)UIManager.get("ContactItemOffline.color"));
RosterEntry entry = SparkManager.getConnection().getRoster().getEntry(getJID());
@ -383,13 +390,13 @@ public class ContactItem extends JPanel {
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus()) {
// Do not move out of group.
setIcon(SparkRes.getImageIcon(SparkRes.SMALL_QUESTION));
getNicknameLabel().setFont(new Font("Dialog", Font.PLAIN, 11));
getNicknameLabel().setFont(new Font("Dialog", Font.PLAIN, fontSize));
setStatusText("Pending");
}
else {
setIcon(null);
setFont(new Font("Dialog", Font.PLAIN, 11));
getNicknameLabel().setFont(new Font("Dialog", Font.PLAIN, 11));
setFont(new Font("Dialog", Font.PLAIN, fontSize));
getNicknameLabel().setFont(new Font("Dialog", Font.PLAIN, fontSize));
setAvailable(false);
if (ModelUtil.hasLength(status)) {
setStatusText(status);
@ -425,7 +432,7 @@ public class ContactItem extends JPanel {
if (isAvailable) {
getNicknameLabel().setFont(new Font("Dialog", Font.PLAIN, 11));
getNicknameLabel().setFont(new Font("Dialog", Font.PLAIN, fontSize));
if ("Online".equals(status) || Res.getString("available").equalsIgnoreCase(status)) {
setStatusText("");
}
@ -434,7 +441,7 @@ public class ContactItem extends JPanel {
}
}
else if (presence.isAvailable()) {
getNicknameLabel().setFont(new Font("Dialog", Font.ITALIC, 11));
getNicknameLabel().setFont(new Font("Dialog", Font.ITALIC, fontSize));
getNicknameLabel().setForeground(Color.gray);
if (status != null) {
setStatusText(status);
@ -475,7 +482,7 @@ public class ContactItem extends JPanel {
*/
public void showUserComingOnline() {
// Change Font
getNicknameLabel().setFont(new Font("Dialog", Font.BOLD, 11));
getNicknameLabel().setFont(new Font("Dialog", Font.BOLD, fontSize));
getNicknameLabel().setForeground(new Color(255, 128, 0));
}
@ -484,7 +491,7 @@ public class ContactItem extends JPanel {
*/
public void showUserGoingOfflineOnline() {
// Change Font
getNicknameLabel().setFont(new Font("Dialog", Font.BOLD, 11));
getNicknameLabel().setFont(new Font("Dialog", Font.BOLD, fontSize));
getNicknameLabel().setForeground(Color.red);
}

View File

@ -23,21 +23,6 @@ import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JComponent;
@ -53,6 +38,21 @@ import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
/**
* The <CODE>TranscriptWindow</CODE> class. Provides a default implementation
* of a Chat Window. In general, extensions could override this class
@ -70,7 +70,7 @@ public class TranscriptWindow extends ChatArea {
/**
* The default font used in the chat window for all messages.
*/
private Font defaultFont = new Font("Dialog", Font.PLAIN, 12);
private Font defaultFont;
private Date lastPost;
@ -80,6 +80,12 @@ public class TranscriptWindow extends ChatArea {
public TranscriptWindow() {
setEditable(false);
// Set Default Font
final LocalPreferences pref = SettingsManager.getLocalPreferences();
int fontSize = pref.getChatRoomFontSize();
defaultFont = new Font("Dialog", Font.PLAIN, fontSize);
addMouseListener(this);
addMouseMotionListener(this);
setDragEnabled(true);
@ -467,7 +473,7 @@ public class TranscriptWindow extends ChatArea {
writer.write(buf.toString());
writer.close();
JOptionPane.showMessageDialog(SparkManager.getMainWindow(), "Chat transcript has been saved.",
"Chat Transcript Saved", JOptionPane.INFORMATION_MESSAGE);
"Chat Transcript Saved", JOptionPane.INFORMATION_MESSAGE);
}
}
catch (Exception ex) {
@ -477,7 +483,7 @@ public class TranscriptWindow extends ChatArea {
}
public void cleanup(){
public void cleanup() {
clear();
}

View File

@ -29,6 +29,7 @@ import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.text.BadLocationException;
import java.awt.Color;
@ -54,6 +55,12 @@ public class ThemePanel extends JPanel {
private JButton addThemeButton;
private JButton addEmoticonButton;
private JTextField contactListFontField;
private JLabel contactListFontLabel;
private JTextField chatRoomFontField;
private JLabel chatRoomFontLabel;
private JCheckBox emoticonCheckBox;
private JFileChooser fc;
@ -80,6 +87,13 @@ public class ThemePanel extends JPanel {
systemLookAndFeelBox = new JCheckBox();
contactListFontField = new JTextField();
contactListFontLabel = new JLabel();
chatRoomFontField = new JTextField();
chatRoomFontLabel = new JLabel();
// Set ResourceUtils
ResourceUtils.resLabel(messageStyleLabel, messageStyleBox, Res.getString("label.message.style") + ":");
ResourceUtils.resLabel(emoticonsLabel, emoticonBox, Res.getString("label.emoticons") + ":");
@ -89,6 +103,9 @@ public class ThemePanel extends JPanel {
ResourceUtils.resButton(addThemeButton, "&Add...");
ResourceUtils.resButton(addEmoticonButton, "A&dd...");
ResourceUtils.resLabel(contactListFontLabel, contactListFontField, "Contact &List font size:");
ResourceUtils.resLabel(chatRoomFontLabel, chatRoomFontField, "Chat &Room font size:");
// Build UI
buildUI();
}
@ -114,6 +131,12 @@ public class ThemePanel extends JPanel {
if (Spark.isWindows()) {
add(systemLookAndFeelBox, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
}
add(chatRoomFontLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
add(chatRoomFontField, new GridBagConstraints(1, 5, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0));
add(contactListFontLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
add(contactListFontField, new GridBagConstraints(1, 6, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0));
// Activate live one.
LocalPreferences pref = SettingsManager.getLocalPreferences();
String theme = pref.getTheme();
@ -147,6 +170,17 @@ public class ThemePanel extends JPanel {
emoticonCheckBox.setSelected(pref.areEmoticonsEnabled());
systemLookAndFeelBox.setSelected(pref.useSystemLookAndFeel());
try {
int chatRoomFontSize = pref.getChatRoomFontSize();
int contactListFontSize = pref.getContactListFontSize();
chatRoomFontField.setText(Integer.toString(chatRoomFontSize));
contactListFontField.setText(Integer.toString(contactListFontSize));
}
catch (Exception e) {
Log.error(e);
}
}
/**
@ -284,4 +318,12 @@ public class ThemePanel extends JPanel {
}
}
public String getChatRoomFontSize(){
return chatRoomFontField.getText();
}
public String getContactListFontSize(){
return contactListFontField.getText();
}
}

View File

@ -12,6 +12,7 @@ package org.jivesoftware.spark.ui.themes;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.spark.preference.Preference;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
@ -85,6 +86,17 @@ public class ThemePreference implements Preference {
pref.setEmoticonPack(pack);
pref.setEmoticonsEnabled(emotEnabled);
pref.setUseSystemLookAndFeel(panel.useSystemLookAndFeel());
try {
String chatRoomFontSize = panel.getChatRoomFontSize();
String contactListFontSize = panel.getContactListFontSize();
pref.setChatRoomFontSize(Integer.parseInt(chatRoomFontSize));
pref.setContactListFontSize(Integer.parseInt(contactListFontSize));
}
catch (NumberFormatException e) {
Log.error(e);
}
}

View File

@ -559,6 +559,30 @@ public class LocalPreferences {
return getBoolean("ssoEnabled", false);
}
public void setDebuggerEnabled(boolean enabled) {
setBoolean("debuggerEnabled", enabled);
}
public boolean isDebuggerEnabled() {
return getBoolean("debuggerEnabled", false);
}
public void setContactListFontSize(int fontSize) {
setInt("contactListFontSize", fontSize);
}
public int getContactListFontSize() {
return getInt("contactListFontSize", 11);
}
public void setChatRoomFontSize(int fontSize) {
setInt("chatRoomFontSize", fontSize);
}
public int getChatRoomFontSize() {
return getInt("chatRoomFontSize", 12);
}
private boolean getBoolean(String property, boolean defaultValue) {
return Boolean.parseBoolean(props.getProperty(property, Boolean.toString(defaultValue)));
}
@ -567,4 +591,12 @@ public class LocalPreferences {
props.setProperty(property, Boolean.toString(value));
}
private int getInt(String property, int defaultValue) {
return Integer.parseInt(props.getProperty(property, Integer.toString(defaultValue)));
}
private void setInt(String property, int value) {
props.setProperty(property, Integer.toString(value));
}
}