SPARK-1258, SPARK-1257

updates to default.properties customization of colors
added new preference panel Color

Color-Panel and Appearance Panel are now tabbed

ill post a guide on how to configure the default.properties in the forum

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12185 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Wolf Posdorfer
2011-03-25 15:29:00 +00:00
committed by wolf.posdorfer
parent 11eb9afd28
commit 8331b41590
15 changed files with 737 additions and 86 deletions

View File

@ -19,6 +19,7 @@
*/
package org.jivesoftware;
import org.jivesoftware.resource.Default;
import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.spark.component.TitlePanel;
@ -468,6 +469,26 @@ public class LoginSettingDialog implements PropertyChangeListener {
if (ModelUtil.hasLength(localPreferences.getProtocol())) {
protocolBox.setSelectedItem(localPreferences.getProtocol());
}
if(Default.getString("PROXY_PROTOCOL").length()>0)
{
protocolBox.setSelectedItem(Default.getString("PROXY_PROTOCOL"));
protocolBox.disable();
useProxyBox.setSelected(true);
useProxyBox.setVisible(false);
}
if(Default.getString("PROXY_HOST").length()>0)
{
hostField.setText(Default.getString("PROXY_HOST"));
hostField.disable();
useProxyBox.setSelected(true);
useProxyBox.setVisible(false);
}
if(Default.getString("PROXY_PORT").length()>0)
{
portField.setText(Default.getString("PROXY_PORT"));
portField.disable();
}
}

View File

@ -448,7 +448,7 @@ public final class MainWindow extends ChatFrame implements ActionListener {
if (!Spark.isMac() && !Default.getBoolean("DISABLE_EXIT")) {
connectMenu.add(exitMenuItem);
}
JMenuItem updateMenu= new JMenuItem("", SparkRes.getImageIcon(SparkRes.DOWNLOAD_16x16));
ResourceUtils.resButton(updateMenu, Res.getString("menuitem.check.for.updates"));
updateMenu.addActionListener(new ActionListener() {
@ -505,7 +505,9 @@ public final class MainWindow extends ChatFrame implements ActionListener {
}
// Build Help Menu
if(!Default.getBoolean(Default.DISABLE_UPDATES)){
helpMenu.add(updateMenu);
}
helpMenu.addSeparator();
helpMenu.add(viewErrors);
helpMenu.add(menuAbout);

View File

@ -39,6 +39,8 @@ import javax.swing.UIDefaults;
import javax.swing.UIManager;
import org.jivesoftware.resource.Default;
import org.jivesoftware.spark.ui.themes.ColorSettingManager;
import org.jivesoftware.spark.ui.themes.ColorSettings;
import org.jivesoftware.spark.util.ModelUtil;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
@ -381,10 +383,6 @@ public final class Spark {
if (isLinux()) {
return ".Spark";
}
/*else if (isWindows()) {
return "Spark";
} (not needed really)*/
return "Spark";
}
@ -426,47 +424,53 @@ public final class Spark {
*/
public static void installBaseUIProperties() {
setApplicationFont(new Font("Dialog", Font.PLAIN, 11));
UIManager.put("TextField.lightforeground", Color.gray);
UIManager.put("TextField.foreground", Color.BLACK);
UIManager.put("TextField.caretForeground", Color.black);
//UIManager.put("TextField.font", new Font("Dialog", Font.PLAIN, 11));
UIManager.put("List.selectionBackground", new Color(217, 232, 250));
UIManager.put("List.selectionForeground", Color.black);
UIManager.put("List.selectionBorder", new Color(187, 195, 215));
UIManager.put("List.foreground", Color.black);
UIManager.put("List.background", Color.white);
UIManager.put("MenuItem.selectionBackground", new Color(217, 232, 250));
UIManager.put("MenuItem.selectionForeground", Color.black);
UIManager.put("TextPane.foreground", Color.black);
UIManager.put("TextPane.background", Color.white);
UIManager.put("TextPane.inactiveForeground", Color.white);
UIManager.put("TextPane.caretForeground", Color.black);
UIManager.put("ChatInput.SelectedTextColor", Color.white);
UIManager.put("ChatInput.SelectionColor", new Color(209, 223, 242));
UIManager.put("ContactItemNickname.foreground", Color.black);
UIManager.put("ContactItemDescription.foreground", Color.gray);
UIManager.put("ContactItem.background", new Color(240, 243, 253));
UIManager.put("ContactItem.border", BorderFactory.createLineBorder(Color.white));
UIManager.put("ContactItemOffline.color", Color.gray);
UIManager.put("Table.foreground", Color.black);
UIManager.put("Table.background", Color.white);
//UIManager.put("TextField.font", new Font("Dialog", Font.PLAIN, 11));
//UIManager.put("Label.font", new Font("Dialog", Font.PLAIN, 11));
// Chat Area Text Settings
UIManager.put("Link.foreground", Color.blue);
UIManager.put("Address.foreground", new Color(212, 160, 0));
UIManager.put("User.foreground", Color.blue);
UIManager.put("OtherUser.foreground", Color.red);
UIManager.put("Notification.foreground", new Color(0, 128, 0));
UIManager.put("Error.foreground", Color.red);
UIManager.put("Question.foreground", Color.red);
UIManager.put("History.foreground", Color.darkGray);
UIManager.put("SparkTabbedPane.startColor", new Color(236, 236, 236));
UIManager.put("SparkTabbedPane.endColor", new Color(236, 236, 236));
UIManager.put("SparkTabbedPane.borderColor", Color.lightGray);
ColorSettings colorsettings = ColorSettingManager.getColorSettings();
for(String property : colorsettings.getKeys())
{
Color c = colorsettings.getColorFromProperty(property);
UIManager.put(property, c);
}
// UIManager.put("TextField.lightforeground", Color.gray);
// UIManager.put("TextField.foreground", Color.BLACK);
// UIManager.put("TextField.caretForeground", Color.black);
// UIManager.put("List.selectionBackground", new Color(217, 232, 250));
// UIManager.put("List.selectionForeground", Color.black);
// UIManager.put("List.selectionBorder", new Color(187, 195, 215));
// UIManager.put("List.foreground", Color.black);
// UIManager.put("List.background", Color.white);
// UIManager.put("MenuItem.selectionBackground", new Color(217, 232, 250));
// UIManager.put("MenuItem.selectionForeground", Color.black);
// UIManager.put("TextPane.foreground", Color.black);
// UIManager.put("TextPane.background", new Color(255,255,255,0));
// UIManager.put("TextPane.inactiveForeground", Color.white);
// UIManager.put("TextPane.caretForeground", Color.black);
// UIManager.put("ChatInput.SelectedTextColor", Color.white);
// UIManager.put("ChatInput.SelectionColor", Color.blue);
// UIManager.put("ContactItemNickname.foreground", Color.black);
// UIManager.put("ContactItemDescription.foreground", Color.gray);
// UIManager.put("ContactItem.background", new Color(240, 243, 253,0));
// UIManager.put("ContactItemOffline.color", Color.gray);
// UIManager.put("Table.foreground", Color.black);
// UIManager.put("Table.background", Color.white);
// // Chat Area Text Settings
// UIManager.put("Link.foreground", Color.blue);
// UIManager.put("Address.foreground", new Color(212, 160, 0));
// UIManager.put("User.foreground", Color.blue);
// UIManager.put("OtherUser.foreground", Color.red);
// UIManager.put("Notification.foreground", new Color(0, 128, 0));
// UIManager.put("Error.foreground", Color.red);
// UIManager.put("Question.foreground", Color.red);
// UIManager.put("History.foreground", Color.darkGray);
// UIManager.put("SparkTabbedPane.startColor", new Color(236, 236, 236));
// UIManager.put("SparkTabbedPane.endColor", new Color(236, 236, 236));
// UIManager.put("SparkTabbedPane.borderColor", Color.lightGray);
}
/**

View File

@ -320,6 +320,7 @@ public class SparkRes {
public static final String OFFLINE_IMAGE = "OFFLINE_IMAGE";
public static final String TASK_DELETE_IMAGE = "TASK_DELETE_IMAGE";
public static final String TRANSPORT_ICON = "TRANSPORT_ICON";
public static final String COLOR_ICON = "COLOR_ICON";
static ClassLoader cl = SparkRes.class.getClassLoader();

View File

@ -14,68 +14,75 @@ SECONDARY_BACKGROUND_IMAGE = images/steel.png
# Changing the Hostname will also be prohibited if set
HOST_NAME =
# Proxy Settings
PROXY_HOST =
PROXY_PORT =
# Protocols are HTTP or SOCKS , case sensitive!!!
PROXY_PROTOCOL =
PROXY_HOST =
PROXY_PORT =
# Remove account creation Button from Loginwindow
# Users wont be able to register new Accounts from within Spark
ACCOUNT_DISABLED =
# Remove Advanced Configuration Button from Loginwindow
# Users wont be able to access the advanced configuration
ADVANCED_DISABLED =
# Branding only
# Branded images appear in the Top-Right corner, and must be included in the classpath
# place them in src/resource/images and path will be "images/file.jpg"
# BRANDED_IMAGE = images/my-corporation-logo.png
BRANDED_IMAGE =
# Shows a powered by logo below the Main Image of Spark
SHOW_POWERED_BY =
# Disables updateability, you should set this, if you have a custom Spark-build
# or are in an environment where installfiles are distributed via network
DISABLE_UPDATES =
#If true, Spark cannot shut down
# If true, Spark cannot shut down
# users wont be able to shut down Spark
DISABLE_EXIT =
#################################################
################## Main Window ##################
#################################################
# [Not yet implemented:]
# Changing this wont have any effect
# Roster Management
HOVER_TEXT_COLOR =
TEXT_COLOR =
CONTACT_GROUP_START_COLOR =
CONTACT_GROUP_END_COLOR =
TAB_START_COLOR =
TAB_END_COLOR =
#HOVER_TEXT_COLOR =
#TEXT_COLOR =
#CONTACT_GROUP_START_COLOR =
#CONTACT_GROUP_END_COLOR =
#TAB_START_COLOR =
#TAB_END_COLOR =
# [/NYI]
#################################################
################ Settings Window ################
#################################################
# Disables adding of contacts
# The User wont be able to add contacts,
# usefull for shared roster management
ADD_CONTACT_DISABLED =
# Disables adding contact groups
# The User wont be able to add contact groups,
# usefull for shared roster management
ADD_CONTACT_GROUP_DISABLED =
# Change Password Disabled
# Users wont be able to change their password
CHANGE_PASSWORD_DISABLED =
# Disable Look&Feel change || "true" = disabled , anything else = enabled
LOOK_AND_FEEL_DISABLED =
# you can use org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel for example
# If Setting this you should also consider disabling the above
DEFAULT_LOOK_AND_FEEL =
# Sets the Location of the Userguide
#Default is http://www.igniterealtime.org/builds/spark/docs/spark_user_guide.pdf
HELP_USER_GUIDE = http://www.igniterealtime.org/builds/spark/docs/spark_user_guide.pdf
# Set to true, if you dont want this displayed
HELP_USER_GUIDE_DISABLED =
# Sets the Location of the Help-Forum
#Default is http://www.igniterealtime.org/forum/forum.jspa?forumID=49
HELP_FORUM = http://www.igniterealtime.org/forum/forum.jspa?forumID=49
# Set to true, if you dont want this displayed
HELP_FORUM_DISABLED =
# Following Text will be displayed instead of "Spark forum"
# leave blank for default
@ -93,3 +100,64 @@ INSTALL_PLUGINS_DISABLED =
# Disable deleting of Plugins
# set true if you want to disable deinstalling of Plugins
DEINSTALL_PLUGINS_DISABLED =
#################################################
######### Color + LookandFeel ###########
#################################################
# Disable Look&Feel change || "true" = disabled , anything else = enabled
# By Default the user can Change his Look&Feel in the Preferences Menu,
#if you dont want this then set it to true
# Preferences -> Appearence -> Customization Tab
LOOK_AND_FEEL_DISABLED =
# Disable if you dont want Users to be able to Change the Textcolors in the Preference Menu
# the colors will be loaded from below
# Preferences -> Appearence -> ColorTab
CHANGE_COLORS_DISABLED =
# Changes the Default Look&Feel, if empty it will load the SystemSkin
# Default Spark skin is SubstanceBusinessBlueSteelLookAndFeel
DEFAULT_LOOK_AND_FEEL = org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel
# Below are Single Color Elements
# They are Stored as Redvalue,Greenvalue,Bluevalue,Alphavalue
# Ranging from 0 - 255
# an Alpha value of 255 means it is completly opaque
# an Alpha value of 0 means it is transparent
# all values must be set or it will produce errors
# they are preconfigured to look nice with the Windowstheme or the SubstanceBusinessBlueSteel Look
ChatInput.SelectedTextColor = 255,255,255,255
ChatInput.SelectionColor = 0,0,255,255
ContactItemNickname.foreground = 0,0,0,255
ContactItemDescription.foreground = 128,128,128,255
ContactItem.background = 240,243,253,255
ContactItemOffline.color = 128,128,128,255
Link.foreground = 0,0,255,255
List.selectionBackground = 217,232,250,255
List.selectionForeground = 0,0,0,255
List.selectionBorder = 187,195,215,255
List.foreground = 0,0,0,255
List.background = 255,255,255,255
TextField.lightforeground = 128,128,128,255
TextField.foreground = 0,0,0,255
TextField.caretForeground = 0,0,0,255
TextPane.foreground = 0,0,0,255
TextPane.background = 255,255,255,0
TextPane.inactiveForeground = 255,255,255,255
TextPane.caretForeground = 0,0,0,255
MenuItem.selectionBackground = 217,232,250,255
MenuItem.selectionForeground = 0,0,0,255
Table.foreground = 0,0,0,255
Table.background = 255,255,255,255
## ChatWindow Colors: ##
Address.foreground = 212,160,0,255
User.foreground = 0,0,255,255
OtherUser.foreground = 255,0,0,255
Notification.foreground = 0,128,0,255
Error.foreground = 255,0,0,255
Question.foreground = 255,0,0,255
History.foreground = 64,64,64,255
SparkTabbedPane.startColor = 236,236,236,255
SparkTabbedPane.endColor = 236,236,236,255
SparkTabbedPane.borderColor = 192,192,192,255

View File

@ -128,6 +128,7 @@ REFRESH_IMAGE = images/refresh.png
CLOSE_WHITE_X_IMAGE = images/close_white.png
CLOSE_DARK_X_IMAGE = images/close_dark.png
PALETTE_24x24_IMAGE = images/palette_24x24.png
COLOR_ICON = images/colors.png
DEFAULT_AVATAR_16x16_IMAGE = images/default_avatar_16x16.png
DEFAULT_AVATAR_32x32_IMAGE = images/default_avatar_32x32.png
DEFAULT_AVATAR_64x64_IMAGE = images/default_avatar_64x64.png

View File

@ -19,6 +19,7 @@
*/
package org.jivesoftware.spark.ui;
import org.jivesoftware.resource.Default;
import org.jivesoftware.resource.Res;
import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.RosterEntry;
@ -131,8 +132,12 @@ public class RosterDialog implements PropertyChangeListener, ActionListener {
panel.add(groupLabel, new GridBagConstraints(0, 4, 1, 1, 0.0D, 0.0D, 17, 2, new Insets(5, 5, 5, 5), 0, 0));
panel.add(groupBox, new GridBagConstraints(1, 4, 1, 1, 1.0D, 0.0D, 17, 2, new Insets(5, 5, 5, 5), 0, 0));
if(!Default.getBoolean("ADD_CONTACT_GROUP_DISABLED")){
panel.add(newGroupButton, new GridBagConstraints(2, 4, 1, 1, 0.0D, 0.0D, 17, 2, new Insets(5, 5, 5, 5), 0, 0));
}
newGroupButton.addActionListener(this);
panel.add(networkPanel, new GridBagConstraints(0, 5, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

View File

@ -0,0 +1,207 @@
package org.jivesoftware.spark.ui.themes;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.IndexColorModel;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.Vector;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.jivesoftware.spark.component.tabbedPane.SparkTabbedPane;
public class ColorPreferencePanel extends SparkTabbedPane {
private static final long serialVersionUID = -3594152276094474130L;
private JScrollPane _jScrollPane;
private JList _colorliste;
private ColorSettings _colorsettings;
public ColorPreferencePanel() {
createUI();
}
private void createUI() {
_colorsettings = ColorSettingManager.getColorSettings();
Set<String> sets = _colorsettings.getKeys();
Vector<String> keys= new Vector<String>();
for(String s : sets)
{
keys.add(s);
}
sortList(keys);
JPanel rightpanel = new JPanel(new GridBagLayout());
final JTextField red = new JTextField();
red.setPreferredSize(new Dimension(80,20));
JLabel redlabel = new JLabel("(0-255) Red:");
final JTextField green = new JTextField();
green.setPreferredSize(new Dimension(80,20));
JLabel greenlabel = new JLabel("(0-255) Green:");
final JTextField blue = new JTextField();
blue.setPreferredSize(new Dimension(80,20));
JLabel bluelabel = new JLabel("(0-255) Blue:");
final JTextField alfa = new JTextField();
alfa.setPreferredSize(new Dimension(80,20));
JLabel alfalabel = new JLabel("(0-100%) Opacity:"); //100 = 100%Visible
final JButton savebutton = new JButton("Save Color");
final JLabel errorlabel = new JLabel("");
errorlabel.setForeground(Color.red);
final JLabel colorPreview = new JLabel();
colorPreview.setBackground(new Color(0,0,0,0));
colorPreview.setPreferredSize(new Dimension(80,20));
colorPreview.setMaximumSize(new Dimension(80,20));
colorPreview.setMinimumSize(new Dimension(80,20));
rightpanel.add(colorPreview, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
rightpanel.add(redlabel , new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0,GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
rightpanel.add(red, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
rightpanel.add(greenlabel , new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
rightpanel.add(green, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
rightpanel.add(bluelabel , new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
rightpanel.add(blue, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
rightpanel.add(alfalabel , new GridBagConstraints(0, 4, 1, 1, 1.0, 0.0,GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
rightpanel.add(alfa, new GridBagConstraints(1, 4, 1, 1, 1.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
rightpanel.add(savebutton, new GridBagConstraints(0, 5, 2, 1, 1.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
rightpanel.add(errorlabel, new GridBagConstraints(0, 6, 2, 1, 0.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
_colorliste = new JList(keys);
_jScrollPane = new JScrollPane(_colorliste);
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
add(_jScrollPane);
add(rightpanel);
_colorliste.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
String v = (String) _colorliste.getSelectedValue();
Color c = _colorsettings.getColorFromProperty(v);
red.setText(""+c.getRed());
green.setText(""+c.getGreen());
blue.setText(""+c.getBlue());
alfa.setText(""+(c.getAlpha()*100/255));
colorPreview.setBackground(new Color(c.getRed(),c.getGreen(),c.getBlue()));
colorPreview.repaint();
colorPreview.revalidate();
errorlabel.setText("");
}
});
savebutton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try{
// convert to value between 0 and 255
final int redvalue = Math.max(0,Math.min(255,Integer.parseInt(red.getText())));
final int greenvalue = Math.max(0,Math.min(255,Integer.parseInt(green.getText())));
final int bluevalue = Math.max(0,Math.min(255,Integer.parseInt(blue.getText())));
// convert to percent
int alfavalue = Math.max(0,Math.min(100,Integer.parseInt(alfa.getText())));
alfavalue = alfavalue*255/100;
Color c = new Color(redvalue,greenvalue,bluevalue,alfavalue);
_colorsettings.setColorForProperty((String)_colorliste.getSelectedValue(), c);
UIManager.put((String)_colorliste.getSelectedValue(), c);
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
colorPreview.setBackground(new Color(redvalue,greenvalue,bluevalue));
colorPreview.repaint();
colorPreview.revalidate();
}
});
errorlabel.setText("Saved Color");
}
catch(Exception ex)
{
errorlabel.setText("Insert valid number between 0-255");
errorlabel.revalidate();
}
}
});
}
private void sortList(Vector<String> set)
{
Collections.sort(set);
}
private BufferedImage createImageLabel(int[] pixels)
{
BufferedImage image = new BufferedImage(80, 20, BufferedImage.TYPE_INT_RGB);
WritableRaster raster = image.getRaster();
raster.setPixels(0, 0, 80, 20, pixels);
return image;
}
}

View File

@ -0,0 +1,233 @@
package org.jivesoftware.spark.ui.themes;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Properties;
import org.jivesoftware.Spark;
import org.jivesoftware.resource.Default;
import org.jivesoftware.spark.util.log.Log;
import sun.security.action.PutAllAction;
public class ColorSettingManager {
private static HashMap<String,String> _propertyHashMap = new HashMap<String, String>();
private static ColorSettings _colorsettings;
public ColorSettingManager() {
}
/**
* Returns the ColorSettingagent
*
* @return ColorSettingagent
*/
public static ColorSettings getColorSettings() {
File settings = getSettingsFile();
_colorsettings = load(settings);
return _colorsettings;
}
public static boolean exists() {
return getSettingsFile().exists();
}
/**
* Returns the file or creates it
* @return
*/
public static File getSettingsFile() {
File path = new File(Spark.getSparkUserHome());
if (!path.exists()) {
path.mkdirs();
}
File f = new File(path, "color.settings");
if (!f.exists())
try {
f.createNewFile();
} catch (IOException e) {
Log.error("Error saving settings.", e);
}
return f;
}
/**
* Save all settings
*/
public static void saveColorSettings() {
final Properties props = new Properties();
for(String key : _propertyHashMap.keySet())
{
String value =_propertyHashMap.get(key);
props.setProperty(key, value);
}
try {
props.store(new FileOutputStream(getSettingsFile()), "Storing Spark Color Settings");
}
catch (Exception e) {
Log.error("Error saving settings.", e);
}
}
/**
* load the Settingfile
* @param file
* @return
*/
private static ColorSettings load(File file) {
loadMap(file);
if (_propertyHashMap.size() == 0) {
Properties p = new Properties();
try {
System.out.println("loading again");
p.load(new FileInputStream(getSettingsFile()));
initialLoad(p);
loadMap(file);
} catch (FileNotFoundException e) {
Log.error("Error saving settings.", e);
} catch (IOException e) {
Log.error("Error saving settings.", e);
}
}
ColorSettings settings = new ColorSettings(_propertyHashMap);
return settings;
}
/**
* loads all Properties into a HashMap
* @param file
*/
private static void loadMap(File file) {
Properties props = new Properties();
try {
props.load(new FileInputStream(file));
Enumeration<Object> xx2 = props.keys();
while (xx2.hasMoreElements()) {
String object = (String) xx2.nextElement();
_propertyHashMap.put(object, props.getProperty(object));
}
} catch (FileNotFoundException e) {
Log.error("Error saving settings.", e);
} catch (IOException e) {
Log.error("Error saving settings.", e);
}
}
/**
* Used to set the Default values
* @param props
*/
private static void initialLoad(Properties props)
{
// if(Default.getBoolean("USE_COLORS_FROM_BELOW"))
// {
props.setProperty("ChatInput.SelectedTextColor", Default.getString("ChatInput.SelectedTextColor"));
props.setProperty("ChatInput.SelectionColor", Default.getString("ChatInput.SelectionColor" ));
props.setProperty("ContactItemNickname.foreground", Default.getString("ContactItemNickname.foreground"));
props.setProperty("ContactItemDescription.foreground", Default.getString("ContactItemDescription.foreground"));
props.setProperty("ContactItem.background", Default.getString("ContactItem.background"));
props.setProperty("ContactItemOffline.color", Default.getString("ContactItemOffline.color"));
props.setProperty("Link.foreground", Default.getString("Link.foreground"));
props.setProperty("List.selectionBackground", Default.getString("List.selectionBackground"));
props.setProperty("List.selectionForeground", Default.getString("List.selectionForeground"));
props.setProperty("List.selectionBorder", Default.getString("List.selectionBorder"));
props.setProperty("List.foreground", Default.getString("List.foreground"));
props.setProperty("List.background", Default.getString("List.background"));
props.setProperty("TextField.lightforeground", Default.getString("TextField.lightforeground"));
props.setProperty("TextField.foreground", Default.getString("TextField.foreground"));
props.setProperty("TextField.caretForeground", Default.getString("TextField.caretForeground"));
props.setProperty("TextPane.foreground", Default.getString("TextPane.foreground"));
props.setProperty("TextPane.background", Default.getString("TextPane.background"));
props.setProperty("TextPane.inactiveForeground", Default.getString("TextPane.inactiveForeground"));
props.setProperty("TextPane.caretForeground", Default.getString("TextPane.caretForeground"));
props.setProperty("MenuItem.selectionBackground", Default.getString("MenuItem.selectionBackground"));
props.setProperty("MenuItem.selectionForeground", Default.getString("MenuItem.selectionForeground"));
props.setProperty("Table.foreground", Default.getString("Table.foreground"));
props.setProperty("Table.background", Default.getString("Table.background"));
props.setProperty("Address.foreground", Default.getString("Address.foreground"));
props.setProperty("User.foreground", Default.getString("User.foreground"));
props.setProperty("OtherUser.foreground", Default.getString("OtherUser.foreground"));
props.setProperty("Notification.foreground", Default.getString("Notification.foreground"));
props.setProperty("Error.foreground", Default.getString("Error.foreground"));
props.setProperty("History.foreground", Default.getString("History.foreground"));
props.setProperty("SparkTabbedPane.startColor", Default.getString("SparkTabbedPane.startColor"));
props.setProperty("SparkTabbedPane.endColor", Default.getString("SparkTabbedPane.endColor"));
props.setProperty("SparkTabbedPane.borderColor", Default.getString("SparkTabbedPane.borderColor"));
// }
// else{
// // These are initial reference Values
// // if you want your own modify the default.properties file
// // and enable USE_CUSTOM_COLORS
// props.setProperty("TextField.lightforeground", "128,128,128,255");
// props.setProperty("TextField.foreground", "0,0,0,255");
// props.setProperty("TextField.caretForeground", "0,0,0,255");
// props.setProperty("List.selectionBackground", "217,232,250,255");
// props.setProperty("List.selectionForeground", "0,0,0,255");
// props.setProperty("List.selectionBorder", "187,195,215,255");
// props.setProperty("List.foreground", "0,0,0,255");
// props.setProperty("List.background", "255,255,255,255");
// props.setProperty("MenuItem.selectionBackground", "217,232,250,255");
// props.setProperty("MenuItem.selectionForeground", "0,0,0,255");
// props.setProperty("TextPane.foreground", "0,0,0,255");
// props.setProperty("TextPane.background", "255,255,255,0,255");
// props.setProperty("TextPane.inactiveForeground", "255,255,255,255");
// props.setProperty("TextPane.caretForeground", "0,0,0,255");
// props.setProperty("ChatInput.SelectedTextColor", "255,255,255,255");
// props.setProperty("ChatInput.SelectionColor", "0,0,255,255");
// props.setProperty("ContactItemNickname.foreground", "0,0,0,255");
// props.setProperty("ContactItemDescription.foreground", "128,128,128,255");
// props.setProperty("ContactItem.background", "240,243,253,0");
// props.setProperty("ContactItemOffline.color", "128,128,128,255");
// props.setProperty("Table.foreground", "0,0,0,255");
// props.setProperty("Table.background", "255,255,255,255");
// props.setProperty("Link.foreground", "0,0,255,255");
// props.setProperty("Address.foreground", "212,160,0,255");
// props.setProperty("User.foreground", "0,0,255,255");
// props.setProperty("OtherUser.foreground", "255,0,0,255");
// props.setProperty("Notification.foreground", "0,128,0,255");
// props.setProperty("Error.foreground", "255,0,0,255");
// props.setProperty("Question.foreground", "255,0,0,255");
// props.setProperty("History.foreground", "64,64,64,255");
// props.setProperty("SparkTabbedPane.startColor", "236,236,236,255");
// props.setProperty("SparkTabbedPane.endColor", "236,236,236,255");
// props.setProperty("SparkTabbedPane.borderColor", "192,192,192,255");
// }
try {
props.store(new FileOutputStream(getSettingsFile()), "Storing Spark Color Settings");
} catch (FileNotFoundException e) {
Log.error("Error saving settings.", e);
} catch (IOException e) {
Log.error("Error saving settings.", e);
}
}
}

View File

@ -0,0 +1,53 @@
package org.jivesoftware.spark.ui.themes;
import java.awt.Color;
import java.util.HashMap;
import java.util.Set;
public class ColorSettings {
private HashMap<String, String> _hashmap;
public ColorSettings(HashMap<String, String> settingmap) {
_hashmap = settingmap;
}
public void setColorForProperty(String propertyname, Color color)
{
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
int a = color.getAlpha();
String c = r + "," + g + "," + b + "," + a;
_hashmap.put(propertyname, c );
}
public Color getColorFromProperty(String propertyname) {
String s = _hashmap.get(propertyname).replaceAll(" ","");
s = s.replaceAll("[a-zA-Z]","");
String[] items = s.split(",");
Color c = new Color(Integer.parseInt(items[0]),
Integer.parseInt(items[1]), Integer.parseInt(items[2]),
Integer.parseInt(items[3]));
return c;
}
/**
* Returns all the PropertyNames
* @return
*/
public Set<String> getKeys()
{
return _hashmap.keySet();
}
}

View File

@ -0,0 +1,51 @@
package org.jivesoftware.spark.ui.themes;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import org.jivesoftware.resource.Default;
import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.spark.component.VerticalFlowLayout;
public class MainThemePanel extends JPanel {
/**
*
*/
private static final long serialVersionUID = 6014253744953992190L;
private ThemePanel _themepanel;
private ColorPreferencePanel _colorpanel;
public MainThemePanel()
{
setLayout(new VerticalFlowLayout());
_themepanel = new ThemePanel();
_colorpanel = new ColorPreferencePanel();
JTabbedPane tabs = new JTabbedPane();
tabs.addTab(Res.getString("title.appearance.preferences"),SparkRes.getImageIcon(SparkRes.PALETTE_24x24_IMAGE), _themepanel);
if(!Default.getBoolean("CHANGE_COLORS_DISABLED")){
tabs.addTab("Color",SparkRes.getImageIcon(SparkRes.COLOR_ICON),_colorpanel);
}
add(tabs);
}
public ThemePanel getThemePanel()
{
return _themepanel;
}
public ColorPreferencePanel getColorPanel()
{
return _colorpanel;
}
}

View File

@ -91,15 +91,15 @@ public class ThemePanel extends JPanel {
private Vector<String> _lookandfeelname = new Vector<String>();
private JCheckBox _useTabsForTransports;
private ThemePanel _thispanel;
private ThemePanel _themepanel;
/**
* Construct UI
*/
public ThemePanel() {
_thispanel = this;
setLayout(new GridBagLayout());
setBorder(BorderFactory.createTitledBorder(Res.getString("title.appearance.preferences")));
_themepanel = this;
_themepanel.setLayout(new GridBagLayout());
LookAndFeelInfo[] ui = UIManager.getInstalledLookAndFeels();
@ -197,15 +197,15 @@ public class ThemePanel extends JPanel {
//WTF
}
SwingUtilities.updateComponentTreeUI(_thispanel);
SwingUtilities.updateComponentTreeUI(_thispanel.getParent());
SwingUtilities.updateComponentTreeUI(_themepanel);
SwingUtilities.updateComponentTreeUI(_themepanel.getParent());
SwingUtilities.updateComponentTreeUI(SparkManager.getMainWindow());
SwingUtilities.updateComponentTreeUI(SparkManager.getChatManager().getChatContainer());
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
_thispanel.invalidate();
_thispanel.repaint();
_thispanel.validate();
_themepanel.invalidate();
_themepanel.repaint();
_themepanel.validate();
}
};

View File

@ -34,7 +34,7 @@ import javax.swing.JComponent;
*/
public class ThemePreference implements Preference {
private ThemePanel panel;
private MainThemePanel panel;
public static String NAMESPACE = "themes";
@ -64,8 +64,7 @@ public class ThemePreference implements Preference {
}
public JComponent getGUI() {
panel = new ThemePanel();
panel = new MainThemePanel();
return panel;
}
@ -78,7 +77,7 @@ public class ThemePreference implements Preference {
*/
public String getLookAndFeel()
{
return panel.getLookAndFeel();
return panel.getThemePanel().getLookAndFeel();
}
public void loadFromFile() {
@ -102,21 +101,21 @@ public class ThemePreference implements Preference {
}
public void commit() {
final String pack = panel.getSelectedEmoticonPack();
boolean emotEnabled = panel.areEmoticonsEnabled();
final String pack = panel.getThemePanel().getSelectedEmoticonPack();
boolean emotEnabled = panel.getThemePanel().areEmoticonsEnabled();
LocalPreferences pref = SettingsManager.getLocalPreferences();
if(pack != null){
pref.setEmoticonPack(pack);
}
pref.setEmoticonsEnabled(emotEnabled);
pref.setLookAndFeel(panel.getLookAndFeel());
pref.setAvatarVisible(panel.areAvatarsVisible());
pref.setContactListIconSize(panel.getContactListIconSize());
pref.setVCardsVisible(panel.areVCardsVisible());
pref.setLookAndFeel(panel.getThemePanel().getLookAndFeel());
pref.setAvatarVisible(panel.getThemePanel().areAvatarsVisible());
pref.setContactListIconSize(panel.getThemePanel().getContactListIconSize());
pref.setVCardsVisible(panel.getThemePanel().areVCardsVisible());
try {
String chatRoomFontSize = panel.getChatRoomFontSize();
String contactListFontSize = panel.getContactListFontSize();
String chatRoomFontSize = panel.getThemePanel().getChatRoomFontSize();
String contactListFontSize = panel.getThemePanel().getContactListFontSize();
pref.setChatRoomFontSize(Integer.parseInt(chatRoomFontSize));
pref.setContactListFontSize(Integer.parseInt(contactListFontSize));
@ -124,6 +123,9 @@ public class ThemePreference implements Preference {
catch (NumberFormatException e) {
Log.error(e);
}
ColorSettingManager.saveColorSettings();
SettingsManager.saveSettings();
}

View File

@ -20,6 +20,7 @@
package org.jivesoftware.sparkimpl.preference.notifications;
import org.jivesoftware.resource.Default;
import org.jivesoftware.resource.Res;
import org.jivesoftware.spark.component.VerticalFlowLayout;
import org.jivesoftware.spark.util.ResourceUtils;
@ -77,7 +78,9 @@ public class NotificationsUI extends JPanel {
betaCheckBox = new JCheckBox();
ResourceUtils.resButton(betaCheckBox, Res.getString("menuitem.check.for.updates"));
if(!Default.getBoolean(Default.DISABLE_UPDATES)){
add(betaCheckBox);
}
windowFocusBox.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent ce){

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB