SPARK-1287, found error when parsing certain color.settings due to whitespaces somewhere

added button to reset all colorsettings to default


polish language updates




git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12263 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Wolf Posdorfer
2011-04-20 07:52:37 +00:00
committed by wolf.posdorfer
parent cfacfaf89c
commit 328ec71c48
7 changed files with 280 additions and 228 deletions

View File

@ -448,40 +448,6 @@ public final class Spark {
} }
// 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

@ -133,7 +133,7 @@ DEFAULT_LOOK_AND_FEEL = org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookA
# all values must be set or it will produce errors # all values must be set or it will produce errors
# they are preconfigured to look nice with the Windowstheme or the SubstanceBusinessBlueSteel Look # they are preconfigured to look nice with the Windowstheme or the SubstanceBusinessBlueSteel Look
ChatInput.SelectedTextColor = 255,255,255,255 ChatInput.SelectedTextColor = 255,255,255,255
ChatInput.SelectionColor = 0,0,255,255 ChatInput.SelectionColor = 10,36,106,255
ContactItemNickname.foreground = 0,0,0,255 ContactItemNickname.foreground = 0,0,0,255
ContactItemDescription.foreground = 128,128,128,255 ContactItemDescription.foreground = 128,128,128,255
ContactItem.background = 240,243,253,255 ContactItem.background = 240,243,253,255

View File

@ -25,15 +25,13 @@ import java.awt.Dimension;
import java.awt.EventQueue; import java.awt.EventQueue;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout; import java.awt.GridBagLayout;
import java.awt.Insets; import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import java.util.Vector; import java.util.Vector;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JLabel; import javax.swing.JLabel;
@ -56,6 +54,13 @@ public class ColorPreferencePanel extends SparkTabbedPane {
private JList _colorliste; private JList _colorliste;
private ColorSettings _colorsettings; private ColorSettings _colorsettings;
private JLabel _colorPreview;
private JLabel _errorlabel;
private JTextField _red;
private JTextField _green;
private JTextField _blue;
private JTextField _alfa;
public ColorPreferencePanel() { public ColorPreferencePanel() {
createUI(); createUI();
@ -76,62 +81,64 @@ public class ColorPreferencePanel extends SparkTabbedPane {
JPanel rightpanel = new JPanel(new GridBagLayout()); JPanel rightpanel = new JPanel(new GridBagLayout());
final JTextField red = new JTextField(); _red = new JTextField();
red.setPreferredSize(new Dimension(80,20)); _red.setPreferredSize(new Dimension(80,20));
JLabel redlabel = new JLabel(Res.getString("lookandfeel.color.red")); JLabel redlabel = new JLabel(Res.getString("lookandfeel.color.red"));
final JTextField green = new JTextField(); _green = new JTextField();
green.setPreferredSize(new Dimension(80,20)); _green.setPreferredSize(new Dimension(80,20));
JLabel greenlabel = new JLabel(Res.getString("lookandfeel.color.green")); JLabel greenlabel = new JLabel(Res.getString("lookandfeel.color.green"));
final JTextField blue = new JTextField(); _blue = new JTextField();
blue.setPreferredSize(new Dimension(80,20)); _blue.setPreferredSize(new Dimension(80,20));
JLabel bluelabel = new JLabel(Res.getString("lookandfeel.color.blue")); JLabel bluelabel = new JLabel(Res.getString("lookandfeel.color.blue"));
final JTextField alfa = new JTextField(); _alfa = new JTextField();
alfa.setPreferredSize(new Dimension(80,20)); _alfa.setPreferredSize(new Dimension(80,20));
JLabel alfalabel = new JLabel(Res.getString("lookandfeel.color.opacity")); //100 = 100%Visible JLabel alfalabel = new JLabel(Res.getString("lookandfeel.color.opacity")); //100 = 100%Visible
final JButton savebutton = new JButton(Res.getString("apply")); final JButton savebutton = new JButton(Res.getString("apply"));
final JLabel errorlabel = new JLabel(""); final JButton restoreDefaults = new JButton(Res.getString("use.default"));
errorlabel.setForeground(Color.red);
_errorlabel = new JLabel("");
_errorlabel.setForeground(Color.red);
final JLabel colorPreview = new JLabel(); _colorPreview = new JLabel();
colorPreview.setBackground(new Color(0,0,0,0)); _colorPreview.setBackground(new Color(0,0,0,0));
colorPreview.setPreferredSize(new Dimension(80,20)); _colorPreview.setPreferredSize(new Dimension(80,20));
colorPreview.setMaximumSize(new Dimension(80,20)); _colorPreview.setMaximumSize(new Dimension(80,20));
colorPreview.setMinimumSize(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(_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(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(_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(new JLabel("0-255"), new GridBagConstraints(2, 1, 1, 1, 1.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); rightpanel.add(new JLabel("0-255"), new GridBagConstraints(2, 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(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(_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(new JLabel("0-255"), new GridBagConstraints(2, 2, 1, 1, 1.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); rightpanel.add(new JLabel("0-255"), new GridBagConstraints(2, 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(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(_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(new JLabel("0-255"), new GridBagConstraints(2, 3, 1, 1, 1.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); rightpanel.add(new JLabel("0-255"), new GridBagConstraints(2, 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(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(_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(new JLabel("0-100%"), new GridBagConstraints(2, 4, 1, 1, 1.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); rightpanel.add(new JLabel("0-100%"), new GridBagConstraints(2, 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(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)); 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));
rightpanel.add(restoreDefaults, new GridBagConstraints(0, 9, 2, 1, 1.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
_colorliste = new JList(keys); _colorliste = new JList(keys);
_jScrollPane = new JScrollPane(_colorliste); _jScrollPane = new JScrollPane(_colorliste);
@ -142,7 +149,6 @@ public class ColorPreferencePanel extends SparkTabbedPane {
_colorliste.addListSelectionListener(new ListSelectionListener() { _colorliste.addListSelectionListener(new ListSelectionListener() {
@Override @Override
public void valueChanged(ListSelectionEvent e) { public void valueChanged(ListSelectionEvent e) {
@ -150,16 +156,16 @@ public class ColorPreferencePanel extends SparkTabbedPane {
Color c = _colorsettings.getColorFromProperty(v); Color c = _colorsettings.getColorFromProperty(v);
red.setText(""+c.getRed()); _red.setText(""+c.getRed());
green.setText(""+c.getGreen()); _green.setText(""+c.getGreen());
blue.setText(""+c.getBlue()); _blue.setText(""+c.getBlue());
alfa.setText(""+(c.getAlpha()*100/255)); _alfa.setText(""+(c.getAlpha()*100/255));
colorPreview.setBackground(new Color(c.getRed(),c.getGreen(),c.getBlue())); _colorPreview.setBackground(new Color(c.getRed(),c.getGreen(),c.getBlue()));
colorPreview.repaint(); _colorPreview.repaint();
colorPreview.revalidate(); _colorPreview.revalidate();
errorlabel.setText(""); _errorlabel.setText("");
} }
}); });
@ -167,15 +173,36 @@ public class ColorPreferencePanel extends SparkTabbedPane {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
savebuttonaction(e);
}
});
restoreDefaults.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ColorSettingManager.restoreDefault();
_colorsettings = ColorSettingManager.getColorSettings();
}
});
}
/**
* Called when the Save-Button is pressed
* @param e
*/
private void savebuttonaction(ActionEvent e)
{
try{ try{
// convert to value between 0 and 255 // convert to value between 0 and 255
final int redvalue = Math.max(0,Math.min(255,Integer.parseInt(red.getText()))); 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 greenvalue = Math.max(0,Math.min(255,Integer.parseInt(_green.getText())));
final int bluevalue = Math.max(0,Math.min(255,Integer.parseInt(blue.getText()))); final int bluevalue = Math.max(0,Math.min(255,Integer.parseInt(_blue.getText())));
// convert to percent // convert to percent
int alfavalue = Math.max(0,Math.min(100,Integer.parseInt(alfa.getText())));
int alfavalue = Math.max(0,Math.min(100,Integer.parseInt(_alfa.getText())));
alfavalue = alfavalue*255/100; alfavalue = alfavalue*255/100;
@ -188,29 +215,29 @@ public class ColorPreferencePanel extends SparkTabbedPane {
@Override @Override
public void run() { public void run() {
colorPreview.setBackground(new Color(redvalue,greenvalue,bluevalue)); _colorPreview.setBackground(new Color(redvalue,greenvalue,bluevalue));
colorPreview.repaint(); _colorPreview.repaint();
colorPreview.revalidate(); _colorPreview.revalidate();
} }
}); });
errorlabel.setText(Res.getString("lookandfeel.color.saved")); _errorlabel.setText(Res.getString("lookandfeel.color.saved"));
} }
catch(Exception ex) catch(Exception ex)
{ {
errorlabel.setText(Res.getString("title.error")); _errorlabel.setText(Res.getString("title.error"));
errorlabel.revalidate(); _errorlabel.revalidate();
} }
} }
});
}
/**
* Sorts the provided List
* @param set
*/
private void sortList(Vector<String> set) private void sortList(Vector<String> set)
{ {
Collections.sort(set); Collections.sort(set);
} }

View File

@ -34,9 +34,10 @@ import org.jivesoftware.spark.util.log.Log;
public class ColorSettingManager { public class ColorSettingManager {
private static HashMap<String,String> _propertyHashMap = new HashMap<String, String>(); private static HashMap<String, String> _propertyHashMap = new HashMap<String, String>();
private static ColorSettings _colorsettings; private static ColorSettings _colorsettings;
public ColorSettingManager() { public ColorSettingManager() {
} }
@ -48,17 +49,17 @@ public class ColorSettingManager {
*/ */
public static ColorSettings getColorSettings() { public static ColorSettings getColorSettings() {
File settings = getSettingsFile(); File settings = getSettingsFile();
_colorsettings = load(settings); _colorsettings = loadSettings(settings);
return _colorsettings; return _colorsettings;
} }
public static boolean exists() { public static boolean exists() {
return getSettingsFile().exists(); return getSettingsFile().exists();
} }
/** /**
* Returns the file or creates it * Returns the file or creates it
*
* @return * @return
*/ */
public static File getSettingsFile() { public static File getSettingsFile() {
@ -76,42 +77,41 @@ public class ColorSettingManager {
return f; return f;
} }
/** /**
* Save all settings * Save all settings
*/ */
public static void saveColorSettings() { public static void saveColorSettings() {
final Properties props = new Properties(); final Properties props = new Properties();
for(String key : _propertyHashMap.keySet()) for (String key : _propertyHashMap.keySet()) {
{ String value = _propertyHashMap.get(key);
String value =_propertyHashMap.get(key);
props.setProperty(key, value); props.setProperty(key, value);
} }
try { try {
props.store(new FileOutputStream(getSettingsFile()), "Storing Spark Color Settings"); props.store(new FileOutputStream(getSettingsFile()),
} "Storing Spark Color Settings");
catch (Exception e) { } catch (Exception e) {
Log.error("Error saving settings.", e); Log.error("Error saving settings.", e);
} }
} }
/** /**
* load the Settingfile * load the Settingfile
*
* @param file * @param file
* @return * @return
*/ */
private static ColorSettings load(File file) { private static ColorSettings loadSettings(File file) {
// load from file
loadSettingsToMap(file);
loadMap(file);
if (_propertyHashMap.size() == 0) { if (_propertyHashMap.size() == 0) {
Properties p = new Properties(); Properties p = new Properties();
try { try {
p.load(new FileInputStream(getSettingsFile())); p.load(new FileInputStream(getSettingsFile()));
initialLoad(p); initialLoad(p);
loadMap(file); loadSettingsToMap(file);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
Log.error("Error saving settings.", e); Log.error("Error saving settings.", e);
@ -119,6 +119,8 @@ public class ColorSettingManager {
Log.error("Error saving settings.", e); Log.error("Error saving settings.", e);
} }
} else if (_propertyHashMap.size() != getDefaultColors().size()) {
compareSettings(_propertyHashMap, getDefaultColors());
} }
ColorSettings settings = new ColorSettings(_propertyHashMap); ColorSettings settings = new ColorSettings(_propertyHashMap);
@ -127,22 +129,46 @@ public class ColorSettingManager {
} }
/**
* Compares two Hashmaps, if defaultmap has keys that are not within mymap
*
* @param mymap
* HashMap < String,String >
* @param defaultmap
* HashMap < String,String >
*/
private static void compareSettings(HashMap<String, String> mymap,
HashMap<String, String> defaultmap) {
boolean changesmade = false;
for (String key : defaultmap.keySet()) {
if (mymap.get(key) == null) // key doesnt exist in mymap
{
mymap.put(key, defaultmap.get(key));
changesmade = true;
}
}
if (changesmade) {
saveColorSettings();
}
}
/** /**
* loads all Properties into a HashMap * loads all Properties into a HashMap from the File specified
*
* @param file * @param file
*/ */
private static void loadMap(File file) { private static void loadSettingsToMap(File file) {
Properties props = new Properties(); Properties props = new Properties();
try { try {
props.load(new FileInputStream(file)); props.load(new FileInputStream(file));
Enumeration<Object> xx2 = props.keys(); Enumeration<Object> enume = props.keys();
while (xx2.hasMoreElements()) { while (enume.hasMoreElements()) {
String object = (String) xx2.nextElement(); String object = (String) enume.nextElement();
_propertyHashMap.put(object, props.getProperty(object)); _propertyHashMap.put(object, props.getProperty(object));
} }
@ -152,63 +178,42 @@ public class ColorSettingManager {
Log.error("Error saving settings.", e); Log.error("Error saving settings.", e);
} }
} }
/** public static HashMap<String, String> getDefaultColors() {
* Used to set the Default values HashMap<String, String> hashmap = new HashMap<String, String>();
* @param props
*/
private static void initialLoad(Properties props) {
Enumeration<String> enu = Default.getAllKeys(); Enumeration<String> enu = Default.getAllKeys();
while (enu.hasMoreElements()) { while (enu.hasMoreElements()) {
String s = enu.nextElement(); String s = enu.nextElement();
if (Default.getString(s).matches("[0-9]*,[0-9]*,[0-9]*,[0-9]*")) { if (Default.getString(s).replace(" ", "")
props.setProperty(s, Default.getString(s)); .matches("[0-9]*,[0-9]*,[0-9]*,[0-9]*")) {
hashmap.put(s, Default.getString(s));
} }
} }
// props.setProperty("ChatInput.SelectedTextColor", Default.getString("ChatInput.SelectedTextColor")); return hashmap;
// 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")); * Used to set the Default values
// props.setProperty("ContactItemOffline.color", Default.getString("ContactItemOffline.color")); *
// props.setProperty("Link.foreground", Default.getString("Link.foreground")); * @param props
// props.setProperty("List.selectionBackground", Default.getString("List.selectionBackground")); */
// props.setProperty("List.selectionForeground", Default.getString("List.selectionForeground")); private static void initialLoad(Properties props) {
// props.setProperty("List.selectionBorder", Default.getString("List.selectionBorder"));
// props.setProperty("List.foreground", Default.getString("List.foreground")); HashMap<String, String> map = getDefaultColors();
// props.setProperty("List.background", Default.getString("List.background")); for (String key : map.keySet()) {
// props.setProperty("TextField.lightforeground", Default.getString("TextField.lightforeground")); props.setProperty(key, map.get(key));
// 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"));
// props.setProperty("Chat.activeTabColor", Default.getString("Chat.activeTabColor"));
// props.setProperty("Chat.inactiveTabColor", Default.getString("Chat.inactiveTabColor"));
// props.setProperty("Chat.unreadMessageColor", Default.getString("Chat.unreadMessageColor"));
try { try {
props.store(new FileOutputStream(getSettingsFile()), "Storing Spark Color Settings"); props.store(new FileOutputStream(getSettingsFile()),
"Storing Spark Color Settings");
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
Log.error("Error saving settings.", e); Log.error("Error saving settings.", e);
} catch (IOException e) { } catch (IOException e) {
@ -216,4 +221,12 @@ public class ColorSettingManager {
} }
} }
/**
* Restores the Default Settings
*/
public static void restoreDefault() {
_propertyHashMap = getDefaultColors();
saveColorSettings();
}
} }

View File

@ -20,20 +20,15 @@
package org.jivesoftware.spark.ui.themes; package org.jivesoftware.spark.ui.themes;
import java.awt.Color; import java.awt.Color;
import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.Set; import java.util.Set;
import org.jivesoftware.resource.Default;
public class ColorSettings { public class ColorSettings {
private HashMap<String, String> _hashmap; private HashMap<String, String> _hashmap;
public ColorSettings(HashMap<String, String> settingmap) { public ColorSettings(HashMap<String, String> settingmap) {
_hashmap = settingmap; _hashmap = settingmap;
addMissingValues();
} }
public void setColorForProperty(String propertyname, Color color) public void setColorForProperty(String propertyname, Color color)
@ -72,30 +67,6 @@ public class ColorSettings {
return _hashmap.keySet(); return _hashmap.keySet();
} }
/**
* Checks the default.properties for missing values and adds them
*/
public void addMissingValues()
{
boolean save = false;
Enumeration<String> enu = Default.getAllKeys();
while(enu.hasMoreElements())
{
String s = enu.nextElement();
if(Default.getString(s).matches("[0-9]*,[0-9]*,[0-9]*,[0-9]*"))
{
if (!_hashmap.containsKey(s)) {
_hashmap.put(s, Default.getString(s));
save = true;
}
}
}
if (save) {
ColorSettingManager.saveColorSettings();
}
}
} }

View File

@ -19,10 +19,7 @@
*/ */
package org.jivesoftware.sparkimpl.plugin.systray; package org.jivesoftware.sparkimpl.plugin.systray;
import java.awt.Menu;
import java.awt.MenuItem;
import java.awt.MouseInfo; import java.awt.MouseInfo;
import java.awt.PopupMenu;
import java.awt.SystemTray; import java.awt.SystemTray;
import java.awt.TrayIcon; import java.awt.TrayIcon;
import java.awt.Window; import java.awt.Window;
@ -450,12 +447,14 @@ public class SysTrayPlugin implements Plugin, NativeHandler,
// For Typing // For Typing
@Override @Override
public void cancelledNotification(String from, String packetID) { public void cancelledNotification(String from, String packetID) {
System.out.println("set available");
trayIcon.setImage(availableIcon.getImage()); trayIcon.setImage(availableIcon.getImage());
} }
@Override @Override
public void composingNotification(String from, String packetID) { public void composingNotification(String from, String packetID) {
if (pref.isTypingNotificationShown()) { if (pref.isTypingNotificationShown()) {
System.out.println("set typing");
trayIcon.setImage(typingIcon.getImage()); trayIcon.setImage(typingIcon.getImage());
} }
} }

View File

@ -238,6 +238,43 @@
## Added key: 'lookandfeel.color.saved' ## Added key: 'lookandfeel.color.saved'
## Added key: 'label.time.till.idlemessage' ## Added key: 'label.time.till.idlemessage'
## Added key: 'message.search.input.short' ## Added key: 'message.search.input.short'
## Added key: 'menuitem.revoke.member'
## Added key: 'menuitem.revoke.admin'
## Added key: 'menuitem.revoke.owner'
## Added key: 'menuitem.grant.member'
## Added key: 'menuitem.grant.admin'
## Added key: 'menutiem.grant.owner'
## Added key: 'menuitem.affiliation'
## Added key: 'privacy.title.preferences'
## Added key: 'privacy.title.panel'
## Added key: 'privacy.label.iq.desc'
## Added key: 'privacy.label.pin.desc'
## Added key: 'privacy.label.pout.desc'
## Added key: 'privacy.label.msg.desc'
## Added key: 'privacy.border.information'
## Added key: 'privacy.label.information'
## Added key: 'privacy.root.node'
## Added key: 'privacy.label.preferences'
## Added key: 'pricacy.tooltip.preferences'
## Added key: 'privacy.label.list.is.active'
## Added key: 'privacy.label.list.is.default'
## Added key: 'privacy.border.block'
## Added key: 'privacy.pick.one.or.more'
## Added key: 'privacy.title.add.picker'
## Added key: 'privacy.node.contacts'
## Added key: 'privacy.node.groups'
## Added key: 'privacy.menu.add.contacts'
## Added key: 'privacy.menu.add.groups'
## Added key: 'privacy.menu.add.rem.items'
## Added key: 'privacy.menu.remove'
## Added key: 'privacy.menu.avtivate.list'
## Added key: 'privacy.menu.default.list'
## Added key: 'privacy.menu.add.list'
## Added key: 'privacy.menu.remove.list'
## Added key: 'privacy.dialog.add.list'
## Added key: 'privacy.dialog.rem.list'
## Added key: 'privacy.status.menu.entry'
## Added key: 'privacy.name.for.default.list'
## ##
## Polish translation made by Martini26 ## Polish translation made by Martini26
@ -543,7 +580,11 @@ menuitem.edit.my.profile = Edytuj m\u00f3j profil
menuitem.edit.status.message = Edytuj opis statusu menuitem.edit.status.message = Edytuj opis statusu
menuitem.enter.login.information = Wprowad\u017a informacje logowania menuitem.enter.login.information = Wprowad\u017a informacje logowania
menuitem.exit = Wyjd\u017a menuitem.exit = Wyjd\u017a
menuitem.affiliation = Przynale\u017cno\u015b\u0107
menuitem.grant.moderator = Zezw\u00f3l na moderowanie menuitem.grant.moderator = Zezw\u00f3l na moderowanie
menuitem.grant.member = Przydziel uprawnienia cz\u0142onkowskie
menuitem.grant.admin = Przydziel uprawnienia administratora
menuitem.grant.owner = Przydziel uprawnienia w\u0142asno\u015bci
menuitem.grant.voice = Zezw\u00f3l na po\u0142\u0105czenie g\u0142osowe menuitem.grant.voice = Zezw\u00f3l na po\u0142\u0105czenie g\u0142osowe
menuitem.help = Pomoc menuitem.help = Pomoc
menuitem.hide = Ukryj menuitem.hide = Ukryj
@ -573,6 +614,9 @@ menuitem.remove.service = Usu\u0144 us\u0142ug\u0119
menuitem.rename = Zmie\u0144 nazw\u0119 menuitem.rename = Zmie\u0144 nazw\u0119
menuitem.revoke.moderator = Odbierz uprawnienia moderatora menuitem.revoke.moderator = Odbierz uprawnienia moderatora
menuitem.revoke.voice = Odbierz uprawnienia do po\u0142\u0105czenia g\u0142osowego menuitem.revoke.voice = Odbierz uprawnienia do po\u0142\u0105czenia g\u0142osowego
menuitem.revoke.member = Odbierz uprawnienia cz\u0142onkowskie
menuitem.revoke.admin = Odbierz uprawnienia administratora
menuitem.revoke.owner = Odbierz uprawnienia w\u0142asno\u015bci
menuitem.save = Zapisz menuitem.save = Zapisz
menuitem.save.as = Zapisz jako menuitem.save.as = Zapisz jako
menuitem.send.a.file = Wy\u015blij plik menuitem.send.a.file = Wy\u015blij plik
@ -1019,4 +1063,36 @@ lookandfeel.color.red = Czerwony
lookandfeel.color.green = Zielony lookandfeel.color.green = Zielony
lookandfeel.color.blue = Niebieski lookandfeel.color.blue = Niebieski
lookandfeel.color.opacity = Nieprzezroczysto\u015b\u0107 lookandfeel.color.opacity = Nieprzezroczysto\u015b\u0107
lookandfeel.color.saved = Kolor zapisany#!# lookandfeel.color.saved = Kolor zapisany
privacy.title.preferences = W\u0142a\u015bciwo\u015bci prywatno\u015bci Sparka
privacy.title.panel = Prosz\u0119 u\u017cyj prawego przycisku myszy
privacy.label.iq.desc = Zapytanie
privacy.label.pin.desc = Obecno\u015b\u0107
privacy.label.pout.desc = Nieobecno\u015b\u0107
privacy.label.msg.desc = Wiadomo\u015bci
privacy.border.information = Informacje o prywatno\u015bci
privacy.label.information = U\u017cyj prawego przycisku myszy i menu aby doda\u0107 lub usun\u0105\u0107 listy albo przedmioty
privacy.root.node = Listy prywatno\u015bci
privacy.label.preferences = Wytczka prywatno\u015bci
pricacy.tooltip.preferences = Ustawienia prywatno\u015bci Sparka
privacy.label.list.is.active = AKTYWNA
privacy.label.list.is.default = DOMY\u015aLNA
privacy.border.block = Zablokuj
privacy.pick.one.or.more = Wybierz jeden lub wi\u0119cej przedmiot\u00f3w aby doda\u0107 do listy
privacy.title.add.picker = Dodaj przedmioty do listy
privacy.node.contacts = Kontakty
privacy.node.groups = Grupy
privacy.menu.add.contacts = Dodaj kontakty do listy
privacy.menu.add.groups = Dodaj grupy do listy
privacy.menu.add.rem.items = Usu\u0144 {0} przedmiot\u00f3w z listy
privacy.menu.remove = Usu\u0144
privacy.menu.avtivate.list = Aktywuj
privacy.menu.default.list = Ustaw jako domy\u015blne
privacy.menu.add.list = Dodaj list\u0119
privacy.menu.remove.list = Usu\u0144 list\u0119
privacy.dialog.add.list = Wpisz nazw\u0119 listy
privacy.dialog.rem.list = Czy na pewno chcesz usun\u0105\u0107 {0}?
privacy.status.menu.entry = Listy prywatno\u015bci
privacy.name.for.default.list = Domy\u015blna
#!#