Révision 1268
tmp/org.txm.utils/src/org/txm/utils/BiHashMap.java (revision 1268) | ||
---|---|---|
1 | 1 |
package org.txm.utils; |
2 | 2 |
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Properties; |
|
3 | 5 |
import java.util.Set; |
4 | 6 |
import java.util.concurrent.ConcurrentHashMap; |
5 | 7 |
|
... | ... | |
12 | 14 |
* @param <ValueType> |
13 | 15 |
*/ |
14 | 16 |
public class BiHashMap<KeyType, ValueType>{ |
17 |
|
|
15 | 18 |
private ConcurrentHashMap<KeyType, ValueType> keyToValueMap = new ConcurrentHashMap<KeyType, ValueType>(); |
16 | 19 |
private ConcurrentHashMap<ValueType, KeyType> valueToKeyMap = new ConcurrentHashMap<ValueType, KeyType>(); |
17 | 20 |
|
21 |
public BiHashMap() { |
|
22 |
|
|
23 |
} |
|
24 |
|
|
25 |
public BiHashMap(Properties props) { |
|
26 |
for (Object k : props.keySet()) { |
|
27 |
put((KeyType)k, (ValueType)props.get(k)); |
|
28 |
} |
|
29 |
} |
|
30 |
|
|
18 | 31 |
synchronized public void put(KeyType key, ValueType value){ |
19 | 32 |
keyToValueMap.put(key, value); |
33 |
//FIXME clash because values are not unique |
|
20 | 34 |
valueToKeyMap.put(value, key); |
21 | 35 |
} |
22 | 36 |
|
tmp/org.txm.utils/src/org/txm/utils/io/IOUtils.java (revision 1268) | ||
---|---|---|
54 | 54 |
return matches; |
55 | 55 |
} |
56 | 56 |
|
57 |
public static ArrayList<String> find(File file, String pattern) throws IOException { |
|
58 |
return find(file, UTF8, pattern, false); |
|
59 |
} |
|
60 |
|
|
61 |
public static ArrayList<String> find(File file, String pattern, boolean normalizeSeparators) throws IOException { |
|
62 |
return findWithGroup(file, UTF8, pattern, normalizeSeparators); |
|
63 |
} |
|
64 |
|
|
65 |
public static ArrayList<String> find(File file, String encoding, String pattern) throws IOException { |
|
66 |
return find(file, encoding, pattern, false); |
|
67 |
} |
|
68 |
|
|
69 |
public static ArrayList<String> find(File file, String encoding, String pattern, boolean normalizeSeparators) throws IOException { |
|
70 |
ArrayList<String> matches = new ArrayList<String>(); |
|
71 |
String text = IOUtils.getText(file, encoding); |
|
72 |
//System.out.println(text); |
|
73 |
if (normalizeSeparators) { |
|
74 |
text = text.replaceAll("\\s", " "); |
|
75 |
text = text.replaceAll("\\t", " "); |
|
76 |
text = text.replaceAll("\\n", " "); |
|
77 |
text = text.replaceAll("[ ]+", " "); |
|
78 |
} |
|
79 |
|
|
80 |
Pattern test = Pattern.compile(pattern); |
|
81 |
Matcher m = test.matcher(text); |
|
82 |
while (m.find()) { |
|
83 |
matches.add(m.group()); |
|
84 |
} |
|
85 |
return matches; |
|
86 |
} |
|
87 |
|
|
57 | 88 |
public static BufferedReader getReader(File file) throws UnsupportedEncodingException, FileNotFoundException { |
58 | 89 |
return getReader(file, UTF8); |
59 | 90 |
} |
tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/devtools/ImportFromOneFile.java (revision 1268) | ||
---|---|---|
69 | 69 |
total_update += update; |
70 | 70 |
} |
71 | 71 |
|
72 |
for (File project : h.keySet()) {
|
|
73 |
//h.get(project).saveChanges();
|
|
72 |
for (PluginMessages messages : h.values()) {
|
|
73 |
//messages.saveChanges();
|
|
74 | 74 |
} |
75 | 75 |
|
76 | 76 |
if (total_update == 0) { |
tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/PluginMessages.java (revision 1268) | ||
---|---|---|
89 | 89 |
* plugin.xml file -> contains eventually keys |
90 | 90 |
*/ |
91 | 91 |
protected File pluginXMLFile; |
92 |
|
|
92 |
|
|
93 | 93 |
public File getPluginXMLFile() { |
94 | 94 |
return pluginXMLFile; |
95 | 95 |
} |
... | ... | |
106 | 106 |
* the OSGI-INF/l10n/bundle[_lang].properties OSGI message keys |
107 | 107 |
*/ |
108 | 108 |
TreeSet<String> osgiKeys = new TreeSet<String>(); |
109 |
|
|
109 |
|
|
110 | 110 |
/** |
111 | 111 |
* The OSGI messages stored by properties file |
112 | 112 |
*/ |
113 | 113 |
TreeMap<File, BiHashMap<String, String>> osgiLangs = new TreeMap<File, BiHashMap<String, String>>(); |
114 |
|
|
114 |
|
|
115 | 115 |
/** |
116 | 116 |
* Stores the key modifications for further saves in the source files |
117 | 117 |
*/ |
... | ... | |
145 | 145 |
if (!messagesPackageDir.exists()) { |
146 | 146 |
messagesPackageDir = new File(projectDirectory2, "src/java/"+projectDirectory2.getName().replaceAll("\\.", "/")+"/messages"); |
147 | 147 |
} |
148 |
|
|
148 |
|
|
149 | 149 |
if (!messagesPackageDir.exists()) { |
150 | 150 |
messagesPackageDir = new File(projectDirectory2, "src/main/java/"+projectDirectory2.getName().replaceAll("\\.", "/")+"/messages"); |
151 | 151 |
} |
... | ... | |
233 | 233 |
|
234 | 234 |
//this.createKeysGlobalREGEX(); |
235 | 235 |
this.createUsedKeysFilesIndex(); |
236 |
|
|
236 |
|
|
237 | 237 |
// try loading OSGI messages |
238 | 238 |
if (pluginXMLFile.exists()) { |
239 | 239 |
ArrayList<String> result = IOUtils.findWithGroup(pluginXMLFile, "\"%([^\"]+)\""); |
240 | 240 |
osgiKeys.addAll(result); |
241 |
|
|
241 |
|
|
242 | 242 |
File osgiInf = new File(projectDirectory, "OSGI-INF/l10n"); |
243 | 243 |
if (osgiInf.exists()) { |
244 | 244 |
for (File propFile : osgiInf.listFiles()) { |
Formats disponibles : Unified diff