Added system look and feel preferences.

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@7726 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro
2007-03-27 06:13:13 +00:00
committed by derek
parent c91a7fc4c3
commit fe01a032eb
8 changed files with 53 additions and 21 deletions

Binary file not shown.

View File

@ -16,6 +16,13 @@ import org.jivesoftware.resource.Default;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smackx.debugger.EnhancedDebuggerWindow; import org.jivesoftware.smackx.debugger.EnhancedDebuggerWindow;
import org.jivesoftware.spark.util.log.Log; 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.BorderFactory;
import javax.swing.JFrame; import javax.swing.JFrame;
@ -23,11 +30,6 @@ import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager; 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 * 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> * type of system Spark is running on, and also the arguments which were passed into Spark on startup. The <code>Spark</code>
@ -103,12 +105,15 @@ public final class Spark {
} }
} }
final LocalPreferences preferences = SettingsManager.getLocalPreferences();
boolean useSystemLookAndFeel = preferences.useSystemLookAndFeel();
try { try {
String classname = UIManager.getSystemLookAndFeelClassName(); String classname = UIManager.getSystemLookAndFeelClassName();
if (classname.indexOf("Windows") != -1) { if (classname.indexOf("Windows") != -1) {
try { try {
if (isVista()) { if (useSystemLookAndFeel) {
UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel()); UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
} }
else { else {
@ -123,9 +128,14 @@ public final class Spark {
else if (classname.indexOf("mac") != -1 || classname.indexOf("apple") != -1) { else if (classname.indexOf("mac") != -1 || classname.indexOf("apple") != -1) {
UIManager.setLookAndFeel(classname); UIManager.setLookAndFeel(classname);
} }
else {
if (useSystemLookAndFeel) {
UIManager.setLookAndFeel(classname);
}
else { else {
UIManager.setLookAndFeel(new com.jgoodies.looks.plastic.Plastic3DLookAndFeel()); UIManager.setLookAndFeel(new com.jgoodies.looks.plastic.Plastic3DLookAndFeel());
} }
}
// Update install ui properties. // Update install ui properties.
installBaseUIProperties(); installBaseUIProperties();

View File

@ -15,7 +15,7 @@ LOGIN_DIALOG_LOGIN_TITLE = Spark
LOGIN_DIALOG_AUTHENTICATING = Authenticating... LOGIN_DIALOG_AUTHENTICATING = Authenticating...
#MainWindow #MainWindow
MAIN_IMAGE = images/message.png MAIN_IMAGE = images/spark-16x16.png
MAIN_IMAGE_ICO = images/icon_16.ico MAIN_IMAGE_ICO = images/icon_16.ico
MAIN_ICNS_FILE = images/message.icns MAIN_ICNS_FILE = images/message.icns
SMALL_CHECK = images/smallCheck.png SMALL_CHECK = images/smallCheck.png

View File

@ -362,7 +362,7 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
chatFrame.setState(Frame.NORMAL); chatFrame.setState(Frame.NORMAL);
chatFrame.setVisible(true); chatFrame.setVisible(true);
} }
else if (chatFrame.isVisible() && !chatFrame.isFocusOwner()) { else if (chatFrame.isVisible() && !chatFrame.isInFocus()) {
startFlashing(component); startFlashing(component);
} }
else if (chatFrame.isVisible() && chatFrame.getState() == Frame.ICONIFIED) { else if (chatFrame.isVisible() && chatFrame.getState() == Frame.ICONIFIED) {
@ -442,7 +442,7 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
} }
// Handle when chat frame is visible but the Contact List is not. // Handle when chat frame is visible but the Contact List is not.
else if (chatFrame.isVisible() && !SparkManager.getMainWindow().isVisible() && !chatFrame.isFocusOwner()) { else if (chatFrame.isVisible() && !SparkManager.getMainWindow().isVisible() && !chatFrame.isInFocus()) {
startFlashing(chatRoom); startFlashing(chatRoom);
} }
else if (!chatFrame.isVisible()) { else if (!chatFrame.isVisible()) {

View File

@ -21,6 +21,14 @@ import org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences; import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager; import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JComboBox; import javax.swing.JComboBox;
@ -31,14 +39,6 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
/** /**
* ThemePanel is used for the setting of TranscriptWindows and Emoticon packs. * ThemePanel is used for the setting of TranscriptWindows and Emoticon packs.
*/ */
@ -57,6 +57,8 @@ public class ThemePanel extends JPanel {
private JCheckBox emoticonCheckBox; private JCheckBox emoticonCheckBox;
private JFileChooser fc; private JFileChooser fc;
private JCheckBox systemLookAndFeelBox;
/** /**
* Construct UI * Construct UI
*/ */
@ -76,10 +78,13 @@ public class ThemePanel extends JPanel {
transcript = new TranscriptWindow(); transcript = new TranscriptWindow();
systemLookAndFeelBox = new JCheckBox();
// Set ResourceUtils // Set ResourceUtils
ResourceUtils.resLabel(messageStyleLabel, messageStyleBox, Res.getString("label.message.style") + ":"); ResourceUtils.resLabel(messageStyleLabel, messageStyleBox, Res.getString("label.message.style") + ":");
ResourceUtils.resLabel(emoticonsLabel, emoticonBox, Res.getString("label.emoticons") + ":"); ResourceUtils.resLabel(emoticonsLabel, emoticonBox, Res.getString("label.emoticons") + ":");
ResourceUtils.resButton(emoticonCheckBox, Res.getString("checkbox.enable.emoticons")); ResourceUtils.resButton(emoticonCheckBox, Res.getString("checkbox.enable.emoticons"));
ResourceUtils.resButton(systemLookAndFeelBox, Res.getString("checkbox.use.system.look.and.feel"));
ResourceUtils.resButton(addThemeButton, "&Add..."); ResourceUtils.resButton(addThemeButton, "&Add...");
ResourceUtils.resButton(addEmoticonButton, "A&dd..."); ResourceUtils.resButton(addEmoticonButton, "A&dd...");
@ -105,6 +110,7 @@ public class ThemePanel extends JPanel {
add(emoticonBox, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); add(emoticonBox, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
add(addEmoticonButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(addEmoticonButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
add(emoticonCheckBox, new GridBagConstraints(0, 3, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(emoticonCheckBox, new GridBagConstraints(0, 3, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
add(systemLookAndFeelBox, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
// Activate live one. // Activate live one.
LocalPreferences pref = SettingsManager.getLocalPreferences(); LocalPreferences pref = SettingsManager.getLocalPreferences();
@ -137,6 +143,8 @@ public class ThemePanel extends JPanel {
showSelectedEmoticon(); showSelectedEmoticon();
emoticonCheckBox.setSelected(pref.areEmoticonsEnabled()); emoticonCheckBox.setSelected(pref.areEmoticonsEnabled());
systemLookAndFeelBox.setSelected(pref.useSystemLookAndFeel());
} }
/** /**
@ -206,6 +214,10 @@ public class ThemePanel extends JPanel {
return emoticonCheckBox.isSelected(); return emoticonCheckBox.isSelected();
} }
public boolean useSystemLookAndFeel() {
return systemLookAndFeelBox.isSelected();
}
/** /**
* Adds a new Emoticon pack to Spark. * Adds a new Emoticon pack to Spark.
*/ */

View File

@ -41,7 +41,7 @@ public class ThemePreference implements Preference {
} }
public String getTooltip() { public String getTooltip() {
return "Change the appearance of your conversations."; return "Change the appearance of Spark.";
} }
public String getListName() { public String getListName() {
@ -79,12 +79,12 @@ public class ThemePreference implements Preference {
} }
public void commit() { public void commit() {
final String theme = panel.getSelectedTheme();
final String pack = panel.getSelectedEmoticonPack(); final String pack = panel.getSelectedEmoticonPack();
boolean emotEnabled = panel.areEmoticonsEnabled(); boolean emotEnabled = panel.areEmoticonsEnabled();
LocalPreferences pref = SettingsManager.getLocalPreferences(); LocalPreferences pref = SettingsManager.getLocalPreferences();
pref.setEmoticonPack(pack); pref.setEmoticonPack(pack);
pref.setEmoticonsEnabled(emotEnabled); pref.setEmoticonsEnabled(emotEnabled);
pref.setUseSystemLookAndFeel(panel.useSystemLookAndFeel());
} }

View File

@ -535,6 +535,14 @@ public class LocalPreferences {
return getBoolean("emoticonsEnabled", true); return getBoolean("emoticonsEnabled", true);
} }
public void setUseSystemLookAndFeel(boolean sysLAF) {
setBoolean("useSystemLookAndFeel", sysLAF);
}
public boolean useSystemLookAndFeel() {
return getBoolean("useSystemLookAndFeel", false);
}
private boolean getBoolean(String property, boolean defaultValue) { private boolean getBoolean(String property, boolean defaultValue) {
return Boolean.parseBoolean(props.getProperty(property, Boolean.toString(defaultValue))); return Boolean.parseBoolean(props.getProperty(property, Boolean.toString(defaultValue)));
} }

View File

@ -92,6 +92,7 @@
## Added key: 'label.emoticons' ## Added key: 'label.emoticons'
## Added key: 'checkbox.enable.emoticons' ## Added key: 'checkbox.enable.emoticons'
## Added key: 'message.unable.to.retrieve.last.activity' ## Added key: 'message.unable.to.retrieve.last.activity'
## Added key: 'checkbox.use.system.look.and.feel'
ok = Ok ok = Ok
@ -188,6 +189,7 @@ checkbox.split.chat.window = Dock &Windows (Requires Spark restart)
checkbox.tabs.on.top = &Chat tabs appear on top (Requires Spark restart) checkbox.tabs.on.top = &Chat tabs appear on top (Requires Spark restart)
checkbox.allow.buzz = Allow users to buz&z you. checkbox.allow.buzz = Allow users to buz&z you.
checkbox.enable.emoticons = Enable Em&oticons checkbox.enable.emoticons = Enable Em&oticons
checkbox.use.system.look.and.feel = Use System Look And &Feel (Requires Spark restart)
label.user.on.public.network = User is on a public network label.user.on.public.network = User is on a public network