src/Tools/jEdit/patches/sorted_properties
author wenzelm
Mon, 06 Jul 2015 11:32:15 +0200
changeset 60658 c5ce9d3f0893
parent 59571 1081f91c0662
permissions -rw-r--r--
tuned;

diff -ru 5.2.0/jEdit/org/gjt/sp/jedit/MiscUtilities.java 5.2.0/jEdit-patched/org/gjt/sp/jedit/MiscUtilities.java
--- 5.2.0/jEdit/org/gjt/sp/jedit/MiscUtilities.java	2015-02-02 02:14:29.000000000 +0100
+++ 5.2.0/jEdit-patched/org/gjt/sp/jedit/MiscUtilities.java	2015-02-28 20:56:21.612292958 +0100
@@ -1505,6 +1505,27 @@
 
 	//}}}
 
+	//{{{ storeProperties() method
+	/**
+	 * Stores properties with sorted keys.
+	 * @param props  Given properties.
+	 * @param out  Output stream.
+	 * @param comments  Description of the property list.
+	 * @since jEdit 5.3
+	 */
+	public static void storeProperties(Properties props, OutputStream out, String comments)
+	 	throws IOException
+	{
+	   Properties sorted = new Properties() {
+		   @Override
+		   public synchronized Enumeration<Object> keys() {
+			   return Collections.enumeration(new TreeSet<Object>(super.keySet()));
+		   }
+	   };
+	   sorted.putAll(props);
+	   sorted.store(out, comments);
+	} //}}}
+
 	static VarCompressor svc = null;
 
 	//{{{ VarCompressor class
diff -ru 5.2.0/jEdit/org/gjt/sp/jedit/PropertyManager.java 5.2.0/jEdit-patched/org/gjt/sp/jedit/PropertyManager.java
--- 5.2.0/jEdit/org/gjt/sp/jedit/PropertyManager.java	2015-02-02 02:14:29.000000000 +0100
+++ 5.2.0/jEdit-patched/org/gjt/sp/jedit/PropertyManager.java	2015-02-28 20:56:21.612292958 +0100
@@ -77,7 +77,7 @@
 	void saveUserProps(OutputStream out)
 		throws IOException
 	{
-		user.store(out,"jEdit properties");
+		MiscUtilities.storeProperties(user, out, "jEdit properties");
 	} //}}}
 
 	//{{{ loadPluginProps() method
diff -ru 5.2.0/jEdit/org/jedit/keymap/KeymapImpl.java 5.2.0/jEdit-patched/org/jedit/keymap/KeymapImpl.java
--- 5.2.0/jEdit/org/jedit/keymap/KeymapImpl.java	2015-02-02 02:14:25.000000000 +0100
+++ 5.2.0/jEdit-patched/org/jedit/keymap/KeymapImpl.java	2015-02-28 20:56:21.612292958 +0100
@@ -32,6 +32,7 @@
 import java.io.InputStream;
 import java.util.Properties;
 
+import org.gjt.sp.jedit.MiscUtilities;
 import org.gjt.sp.util.IOUtilities;
 import org.gjt.sp.util.Log;
 //}}}
@@ -150,7 +151,7 @@
 			try
 			{
 				out = new BufferedOutputStream(new FileOutputStream(userKeymapFile));
-				props.store(out, "jEdit's keymap " + name);
+				MiscUtilities.storeProperties(props, out, "jEdit's keymap " + name);
 			}
 			catch (IOException e)
 			{