Index: tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/PluginMessagesManager.java
===================================================================
--- tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/PluginMessagesManager.java	(revision 1288)
+++ tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/PluginMessagesManager.java	(revision 1289)
@@ -192,8 +192,8 @@
 
 		if (debug) {
 			System.out.println("********************************************************************************************************************");
-			System.out.println("PluginMessages.PluginMessages(): project root directory = " + this.projectDirectory);
-			System.out.println("PluginMessages.PluginMessages(): java message file = " + this.javaMessageFile);
+			System.out.println("PluginMessagesManager.PluginMessages(): project root directory = " + this.projectDirectory);
+			System.out.println("PluginMessagesManager.PluginMessages(): java message file = " + this.javaMessageFile);
 		}
 
 
@@ -285,7 +285,7 @@
 	//		this.keysGlobalREGEX = Pattern.compile("(" + buffer + ")");
 	//		
 	//		if(debug)	{
-	//			System.out.println("PluginMessages.createKeysGlobalREGEX(): REGEX created: " + this.keysGlobalREGEX + ".");
+	//			System.out.println("PluginMessagesManager.createKeysGlobalREGEX(): REGEX created: " + this.keysGlobalREGEX + ".");
 	//		}
 	//		
 	//	}
@@ -300,7 +300,7 @@
 		//for (String key : messageKeys) {
 
 		//		if(debug) {
-		//			System.out.println("PluginMessages.createUsedKeysIndex(): looking for key " + this.getKeyFullName(key) + " in project source files...");
+		//			System.out.println("PluginMessagesManager.createUsedKeysIndex(): looking for key " + this.getKeyFullName(key) + " in project source files...");
 		//		}
 
 		for (File file : this.srcFiles) {
@@ -332,7 +332,7 @@
 	 */
 	public void dumpUsedKeysFilesIndex()	{
 
-		System.out.println("PluginMessages.dumpUsedKeysIndex(): dumping used keys files index...");
+		System.out.println("PluginMessagesManager.dumpUsedKeysIndex(): dumping used keys files index...");
 
 		for (Map.Entry<String, TreeSet<File>> entry : this.usedKeysFilesIndex.entrySet()) {
 			System.out.println("key: " + this.getKeyFullName(entry.getKey()));
@@ -387,7 +387,7 @@
 			if(entry.getValue().isEmpty())	{
 
 				if(debug)	{
-					System.out.println("PluginMessages.getUnusedKeys(): unused key found: " + entry.getKey() + ".");
+					System.out.println("PluginMessagesManager.getUnusedKeys(): unused key found: " + entry.getKey() + ".");
 				}
 
 				unusedKeys.add(entry.getKey());
@@ -523,8 +523,16 @@
 
 		// write message File
 		File newJavaMessageFile = new File(javaMessageFile.getParentFile(), javaMessageFile.getName()+".new");
+		
+		ArrayList<String> lines = IOUtils.getLines(javaMessageFile, "UFT-8");
+		TreeSet<String> oldKeys = new TreeSet<String>(IOUtils.findWithGroup(javaMessageFile, "public static String ([^\"=;]+);"));
+		TreeSet<String> newKeys = new TreeSet<String>(messageKeys);
+		newKeys.removeAll(oldKeys);
+		System.out.println("OLD1="+oldKeys);
+		System.out.println("NEW1="+newKeys);
+		newKeys.removeAll(keyModifications.values());
+		System.out.println("NEW2="+newKeys);
 		if (replaceFiles) {
-			javaMessageFile.delete();
 			newJavaMessageFile = javaMessageFile;
 		}
 
@@ -532,46 +540,39 @@
 		String name = getMessageName();
 		String classPackage = getMessageFullClassName().substring(0, getMessageFullClassName().length() - getMessageClassName().length() - 1);
 
-		PrintWriter out = IOUtils.getWriter(newJavaMessageFile, ENCODING);
-
-		// write start
-		out.println("package "+classPackage+";\n");
-
-		out.println("import org.eclipse.osgi.util.NLS;");
-		out.println("import org.txm.utils.messages.Utf8NLS;\n");
-
-		out.println("/**\n * "+name+" messages.\n * @author sjacquot, mdecorde \n */");
-
-		out.println("public class "+className+" extends NLS {\n");
-
-		out.println("	private static final String BUNDLE_NAME = \""+classPackage+".messages\"; //$NON-NLS-1$\n");
-
-		//write keys
-		ArrayList<String> keys = new ArrayList<String>(this.getMessageKeys());
-		Collections.sort(keys, comp);
-		for (String key : keys) {
-			out.println("	public static String "+key+";");
-		}
-
-		// write end
-		out.println("\n	/**");
-		out.println("	 * @param message the message containing parameters {0}...{N}");
-		out.println("	 * @param bindings the parameters ");
-		out.println("	 * @return the given message's substitution locations with the given string values.");
-		out.println("	 */");
-		out.println("	public static String bind(String message, Object... bindings) {");
-		out.println("		return NLS.bind(message, bindings);");
-		out.println("	}");
-
-		out.println("\n	static {");
-		out.println("		// initialize resource bundle");
-		out.println("		Utf8NLS.initializeMessages(BUNDLE_NAME, "+className+".class);");
-		out.println("	}");
-
-		out.println("	private "+className+"() { }");
-		out.println("}");
-
-		out.close();
+//		PrintWriter out = IOUtils.getWriter(newJavaMessageFile, ENCODING);
+//		
+//		// update lines
+//		for (String line : lines) {
+//			String l = line.trim();// remove tabs
+//			String comments = "";
+//			int idx = l.indexOf("//"); // remove comments
+//			if (idx > 0) {
+//				comments = l.substring(idx).trim();
+//				l = l.substring(0, idx).trim();
+//			}
+//			
+//			if (l.startsWith("private static final String BUNDLE_NAME")) {
+//				out.println(line);
+//				
+//				// write the totally new keys
+//			} else if (l.startsWith("public static String") && l.endsWith(";") && !l.contains("=") && !l.contains("\"")) {
+//				
+//				String key = l.substring(21, l.length() -1);
+//				if (messageKeys.contains(key)) {
+//					out.println(line); // keep the line
+//				} else if (keyModifications.containsKey(key)){
+//					// the key has been renamed
+//					out.println("\t\tpublic static String "+keyModifications.get(key)+"; "+comments);
+//				} else {
+//					// the key has been removed
+//				}
+//			} else {
+//				out.println(line);
+//			}
+//		}
+//		
+//		out.close();
 	}
 
 	public void summary() {
@@ -615,7 +616,7 @@
 					) {
 
 				if (debug) {
-					System.out.println("PluginMessages.createSourceFilesList(): adding source files " + file + ".");
+					System.out.println("PluginMessagesManager.createSourceFilesList(): adding source files " + file + ".");
 				}
 				else	{
 					//System.out.print(".");
@@ -632,14 +633,14 @@
 	public void createSourceFilesList()	{
 
 		if (debug) {
-			System.out.println("PluginMessages.loadSourceFilesList(): creating source files list for extensions [" + StringUtils.join(this.srcFilesExtensions, ", ") + "]...");
+			System.out.println("PluginMessagesManager.loadSourceFilesList(): creating source files list for extensions [" + StringUtils.join(this.srcFilesExtensions, ", ") + "]...");
 		}
 
 		this.createSourceFilesList(this.projectDirectory);
 
 
 		if(debug) {
-			System.out.println("PluginMessages.loadSourceFilesList(): done. Source files count = " + this.srcFiles.size() + ".");
+			System.out.println("PluginMessagesManager.loadSourceFilesList(): done. Source files count = " + this.srcFiles.size() + ".");
 		}
 	}
 
@@ -654,19 +655,18 @@
 	public void renameKey(String oldName, String newName) {
 
 		if (!messageKeys.contains(oldName)) {
-			System.err.println("PluginMessages.renameKey(): key=" + oldName + " not found, aborting renaming to " + newName + ".");
+			System.err.println("PluginMessagesManager.renameKey(): key=" + oldName + " not found, aborting renaming to " + newName + ".");
 			return;
 		}
 
 		// continue only if key name has changed
 		if(oldName.equals(newName))	{
 			if(debug)	{
-				System.out.println("PluginMessages.renameKey(): no changes, skipped key: " + oldName + " = " + newName);
+				System.out.println("PluginMessagesManager.renameKey(): no changes, skipped key: " + oldName + " = " + newName);
 			}
 			return;
 		}
 
-
 		messageKeys.remove(oldName);
 		messageKeys.add(newName);
 
@@ -688,7 +688,7 @@
 	 */
 	public void removeKey(String key) {
 		if (!messageKeys.contains(key)) {
-			System.err.println("PluginMessages.removeKey(): key=" + key + " not found, aborting removing.");
+			System.err.println("PluginMessagesManager.removeKey(): key=" + key + " not found, aborting removing.");
 			return;
 		}
 
@@ -735,7 +735,7 @@
 	 */
 	public void dump(BiHashMap<String, String> messages)	{
 		for (String key : messages.getKeys()) {
-			System.out.println("PluginMessages.dump(): " + key + "=" + messages.get(key));
+			System.out.println("PluginMessagesManager.dump(): " + key + "=" + messages.get(key));
 		}
 	}
 
@@ -744,9 +744,9 @@
 	 * Dumps the keys replacements table.
 	 */
 	public void dumpKeysReplacements()	{
-		System.out.println("PluginMessages.dumpKeysReplacements(): keys replacements table");
+		System.out.println("PluginMessagesManager.dumpKeysReplacements(): keys replacements table");
 		for (String key : this.keyModifications.keySet()) {
-			System.out.println("PluginMessages.dumpKeysReplacements(): " + key + "=>" + this.keyModifications.get(key));
+			System.out.println("PluginMessagesManager.dumpKeysReplacements(): " + key + "=>" + this.keyModifications.get(key));
 		}
 	}
 
@@ -794,8 +794,8 @@
 		//dict.summary();
 
 
-		//pmManager.saveChanges(true);
+		pmManager.saveChanges(true);
 
-		System.out.println("PluginMessages.main(): done.");
+		System.out.println("PluginMessagesManager.main(): done.");
 	}
 }
\ No newline at end of file
