Révision 589
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CQPPreferences.java (revision 589) | ||
---|---|---|
1 | 1 |
package org.txm.searchengine.cqp; |
2 | 2 |
|
3 |
import java.io.File; |
|
4 |
|
|
3 | 5 |
import org.eclipse.core.runtime.preferences.DefaultScope; |
4 | 6 |
import org.osgi.framework.FrameworkUtil; |
5 | 7 |
import org.osgi.service.prefs.Preferences; |
... | ... | |
12 | 14 |
|
13 | 15 |
public static String PREFERENCES_NODE = FrameworkUtil.getBundle(CQPPreferences.class).getSymbolicName(); |
14 | 16 |
|
15 |
/** The Constant CQI_SERVER_HOST. */ |
|
16 |
public static final String CQI_SERVER_HOST = "cqi_server_host"; //$NON-NLS-1$ |
|
17 | 17 |
|
18 |
/** The Constant CQI_SERVER_PORT. */ |
|
19 |
public static final String CQI_SERVER_PORT = "cqi_server_port"; //$NON-NLS-1$ |
|
20 |
|
|
21 |
/** The Constant CQI_SERVER_LOGIN. */ |
|
22 |
public static final String CQI_SERVER_LOGIN = "cqi_server_login"; //$NON-NLS-1$ |
|
23 |
|
|
24 |
/** The Constant CQI_SERVER_PASSWORD. */ |
|
25 |
public static final String CQI_SERVER_PASSWORD = "cqi_server_password"; //$NON-NLS-1$ |
|
26 |
|
|
27 |
/** The Constant CQI_SERVER_PATH_TO_EXECUTABLE. */ |
|
28 |
public static final String CQI_SERVER_PATH_TO_EXECUTABLE = "cqi_server_path_to_executable"; //$NON-NLS-1$ |
|
29 |
|
|
30 |
public static final String CQI_SERVER_PATH_TO_CQPLIB = "cqi_server_path_to_cqplib"; //$NON-NLS-1$ |
|
31 |
|
|
32 |
/** The Constant CQI_SERVER_PATH_TO_INIT_FILE. */ |
|
33 |
public static final String CQI_SERVER_PATH_TO_INIT_FILE = "cqi_server_path_to_init_file"; //$NON-NLS-1$ |
|
34 |
|
|
35 |
/** The Constant CQI_SERVER_ADDITIONAL_OPTIONS. */ |
|
36 |
public static final String CQI_SERVER_ADDITIONAL_OPTIONS = "cqi_server_additional_options"; //$NON-NLS-1$ |
|
37 |
|
|
38 |
/** The Constant CQI_SERVER_MONITOR_OUTPUT. */ |
|
39 |
public static final String CQI_SERVER_MONITOR_OUTPUT = "cqi_server_monitor_output"; //$NON-NLS-1$ |
|
40 |
|
|
41 |
/** The Constant CQI_SERVER_IS_REMOTE. */ |
|
42 |
public static final String CQI_SERVER_IS_REMOTE = "cqi_server_is_remote"; //$NON-NLS-1$ |
|
43 |
|
|
44 |
/** The Constant CQI_SERVER_MODE. */ |
|
45 |
public static final String CQI_NETWORK_MODE = "cqi_server_mode"; //$NON-NLS-1$ |
|
46 |
|
|
47 |
public static final String CQP_EMPTY_VALUE_CODE = "cqp_empty_value_code"; |
|
48 |
|
|
49 | 18 |
/** The Constant MAXVALUE. */ |
50 | 19 |
public static final String MAXVALUE = "diag_max_value"; //$NON-NLS-1$ |
51 | 20 |
|
52 |
|
|
53 | 21 |
@Override |
54 | 22 |
public void initializeDefaultPreferences() { |
55 | 23 |
Log.info(TXMCoreMessages.Toolbox_4 + TBXPreferences.getID()); |
... | ... | |
57 | 25 |
Preferences preferences = DefaultScope.INSTANCE.getNode(PREFERENCES_NODE); |
58 | 26 |
|
59 | 27 |
preferences.putInt(MAXVALUE, 10); |
60 |
|
|
61 |
preferences.put(CQI_SERVER_ADDITIONAL_OPTIONS, "-b 1000000 -d OFF"); //$NON-NLS-1$ |
|
62 |
preferences.put(CQI_SERVER_PORT, "4877"); //$NON-NLS-1$ |
|
63 |
preferences.put(CQI_SERVER_HOST, "localhost"); //$NON-NLS-1$ |
|
64 |
preferences.put(CQI_SERVER_LOGIN, "anonymous"); //$NON-NLS-1$ |
|
65 |
preferences.put(CQI_SERVER_PASSWORD, ""); //$NON-NLS-1$ |
|
66 |
preferences.put(CQI_SERVER_IS_REMOTE, "" + false); //$NON-NLS-1$ |
|
67 |
preferences.putBoolean(CQI_NETWORK_MODE, false); //$NON-NLS-1$ |
|
68 |
preferences.put(CQP_EMPTY_VALUE_CODE, ""); //$NON-NLS-1$ |
|
69 | 28 |
} |
70 | 29 |
} |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CQPEngine.java (revision 589) | ||
---|---|---|
10 | 10 |
import org.txm.core.preferences.TBXPreferences; |
11 | 11 |
import org.txm.core.preferences.TXMPreferences; |
12 | 12 |
import org.txm.importer.cwb.PatchCwbRegistry; |
13 |
import org.txm.libs.cqp.CQPLibPreferences; |
|
13 | 14 |
import org.txm.objects.Base; |
14 | 15 |
import org.txm.searchengine.core.SearchEngine; |
15 | 16 |
import org.txm.searchengine.core.SearchEngines; |
... | ... | |
45 | 46 |
|
46 | 47 |
boolean cqiserverok = false; |
47 | 48 |
|
48 |
useNetCQi = Boolean.parseBoolean(TXMPreferences.getString(CQPPreferences.CQI_NETWORK_MODE, CQPPreferences.PREFERENCES_NODE));
|
|
49 |
useNetCQi = Boolean.parseBoolean(TXMPreferences.getString(CQPLibPreferences.CQI_NETWORK_MODE, CQPLibPreferences.PREFERENCES_NODE));
|
|
49 | 50 |
|
50 | 51 |
Log.warning("Killing CQP and RServe process if any"); |
51 | 52 |
killSearchEngine(); |
52 | 53 |
|
53 | 54 |
|
54 |
boolean remote = Boolean.parseBoolean(TXMPreferences.getString(CQPPreferences.CQI_SERVER_IS_REMOTE, CQPPreferences.PREFERENCES_NODE));
|
|
55 |
boolean remote = Boolean.parseBoolean(TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_IS_REMOTE, CQPLibPreferences.PREFERENCES_NODE));
|
|
55 | 56 |
state = false; |
56 | 57 |
// test if must-have properties for CWB are set |
57 | 58 |
|
... | ... | |
82 | 83 |
if (reg_path.length() > 0) reg_path = reg_path.substring(path_separator.length()); // remove first path_separator |
83 | 84 |
reg_path = reg_path.replace("\\\\", "//"); // fix the UNC paths for mingw |
84 | 85 |
|
85 |
String init_path = TXMPreferences.getString(CQPPreferences.CQI_SERVER_PATH_TO_INIT_FILE, CQPPreferences.PREFERENCES_NODE);
|
|
86 |
String init_path = TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_PATH_TO_INIT_FILE, CQPLibPreferences.PREFERENCES_NODE);
|
|
86 | 87 |
|
87 | 88 |
|
88 | 89 |
if (!remote) { |
... | ... | |
91 | 92 |
try { |
92 | 93 |
cqiServer = new MemCqiServer(reg_path, |
93 | 94 |
init_path, |
94 |
TXMPreferences.getString(CQPPreferences.CQI_SERVER_ADDITIONAL_OPTIONS, CQPPreferences.PREFERENCES_NODE)
|
|
95 |
+ " -P " + TXMPreferences.getString(CQPPreferences.CQI_SERVER_PORT, CQPPreferences.PREFERENCES_NODE), //$NON-NLS-1$
|
|
96 |
Boolean.parseBoolean(TXMPreferences.getString(CQPPreferences.CQI_SERVER_MONITOR_OUTPUT, CQPPreferences.PREFERENCES_NODE)));
|
|
95 |
TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_ADDITIONAL_OPTIONS, CQPLibPreferences.PREFERENCES_NODE)
|
|
96 |
+ " -P " + TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_PORT, CQPLibPreferences.PREFERENCES_NODE), //$NON-NLS-1$
|
|
97 |
Boolean.parseBoolean(TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_MONITOR_OUTPUT, CQPLibPreferences.PREFERENCES_NODE)));
|
|
97 | 98 |
} catch (Exception e) { |
98 | 99 |
// TODO Auto-generated catch block |
99 | 100 |
org.txm.utils.logger.Log.printStackTrace(e); |
100 | 101 |
} |
101 | 102 |
} else { |
102 | 103 |
|
103 |
String exec_path = TXMPreferences.getString(CQPPreferences.CQI_SERVER_PATH_TO_EXECUTABLE, CQPPreferences.PREFERENCES_NODE);
|
|
104 |
String exec_path = TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_PATH_TO_EXECUTABLE, CQPLibPreferences.PREFERENCES_NODE);
|
|
104 | 105 |
|
105 | 106 |
if (exec_path == null || exec_path.length() == 0) { |
106 |
System.out.println("Error: the '"+CQPPreferences.CQI_SERVER_PATH_TO_EXECUTABLE+"' preference is not set."); |
|
107 |
System.out.println("Error: the '"+CQPLibPreferences.CQI_SERVER_PATH_TO_EXECUTABLE+"' preference is not set.");
|
|
107 | 108 |
} |
108 | 109 |
if (new File(exec_path).exists()) { |
109 |
System.out.println("Error: the '"+CQPPreferences.CQI_SERVER_PATH_TO_EXECUTABLE+"' preference is not set."); |
|
110 |
System.out.println("Error: the '"+CQPLibPreferences.CQI_SERVER_PATH_TO_EXECUTABLE+"' preference is not set.");
|
|
110 | 111 |
} |
111 | 112 |
|
112 | 113 |
cqiServer = new NetCqiServer(exec_path, |
113 | 114 |
reg_path, |
114 | 115 |
init_path, |
115 |
TXMPreferences.getString(CQPPreferences.CQI_SERVER_ADDITIONAL_OPTIONS, CQPPreferences.PREFERENCES_NODE)
|
|
116 |
+ " -P " + TXMPreferences.getString(CQPPreferences.CQI_SERVER_PORT, CQPPreferences.PREFERENCES_NODE), //$NON-NLS-1$
|
|
117 |
Boolean.parseBoolean(TXMPreferences.getString(CQPPreferences.CQI_SERVER_MONITOR_OUTPUT, CQPPreferences.PREFERENCES_NODE)));
|
|
116 |
TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_ADDITIONAL_OPTIONS, CQPLibPreferences.PREFERENCES_NODE)
|
|
117 |
+ " -P " + TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_PORT, CQPLibPreferences.PREFERENCES_NODE), //$NON-NLS-1$
|
|
118 |
Boolean.parseBoolean(TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_MONITOR_OUTPUT, CQPLibPreferences.PREFERENCES_NODE)));
|
|
118 | 119 |
} |
119 | 120 |
|
120 | 121 |
if (cqiServer != null) |
... | ... | |
133 | 134 |
cqiserverok = false; |
134 | 135 |
} |
135 | 136 |
} else { |
136 |
int port = Integer.parseInt(TXMPreferences.getString(CQPPreferences.CQI_SERVER_PORT, CQPPreferences.PREFERENCES_NODE));
|
|
137 |
String host = TXMPreferences.getString(CQPPreferences.CQI_SERVER_HOST, CQPPreferences.PREFERENCES_NODE);
|
|
137 |
int port = Integer.parseInt(TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_PORT, CQPLibPreferences.PREFERENCES_NODE));
|
|
138 |
String host = TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_HOST, CQPLibPreferences.PREFERENCES_NODE);
|
|
138 | 139 |
cqiClient = new NetCqiClient(host, port); |
139 | 140 |
} |
140 | 141 |
} |
141 | 142 |
} catch (NumberFormatException e1) { |
142 |
Log.severe(TXMCoreMessages.Toolbox_wrong_port + TXMPreferences.getString(CQPPreferences.CQI_SERVER_PORT, CQPPreferences.PREFERENCES_NODE));
|
|
143 |
Log.severe(TXMCoreMessages.Toolbox_wrong_port + TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_PORT, CQPLibPreferences.PREFERENCES_NODE));
|
|
143 | 144 |
} catch (ServerNotFoundException e1) { |
144 |
Log.severe(TXMCoreMessages.Error_CONNECTION_FAILED + TXMPreferences.getString(CQPPreferences.CQI_SERVER_HOST, CQPPreferences.PREFERENCES_NODE)
|
|
145 |
+ TXMCoreMessages.Toolbox_27 + TXMPreferences.getString(CQPPreferences.CQI_SERVER_PORT, CQPPreferences.PREFERENCES_NODE));
|
|
145 |
Log.severe(TXMCoreMessages.Error_CONNECTION_FAILED + TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_HOST, CQPLibPreferences.PREFERENCES_NODE)
|
|
146 |
+ TXMCoreMessages.Toolbox_27 + TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_PORT, CQPLibPreferences.PREFERENCES_NODE));
|
|
146 | 147 |
} |
147 | 148 |
|
148 | 149 |
// try connecting to the CWB server |
149 | 150 |
try { |
150 | 151 |
if (cqiserverok) { |
151 |
String login = TXMPreferences.getString(CQPPreferences.CQI_SERVER_LOGIN, CQPPreferences.PREFERENCES_NODE);
|
|
152 |
String password = TXMPreferences.getString(CQPPreferences.CQI_SERVER_PASSWORD, CQPPreferences.PREFERENCES_NODE);
|
|
152 |
String login = TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_LOGIN, CQPLibPreferences.PREFERENCES_NODE);
|
|
153 |
String password = TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_PASSWORD, CQPLibPreferences.PREFERENCES_NODE);
|
|
153 | 154 |
state = cqiClient.connect(login, password); |
154 | 155 |
} |
155 | 156 |
} catch (Exception e1) { |
... | ... | |
158 | 159 |
|
159 | 160 |
if (state == false) { |
160 | 161 |
System.out.println(TXMCoreMessages.Toolbox_29); |
161 |
if (cqiClient instanceof NetCqiClient) System.out.println(TXMCoreMessages.Toolbox_30 + TXMPreferences.getString(CQPPreferences.CQI_SERVER_LOGIN, CQPPreferences.PREFERENCES_NODE) + " " + TXMPreferences.getString(CQPPreferences.CQI_SERVER_PASSWORD, CQPPreferences.PREFERENCES_NODE) + TXMPreferences.getString(CQPPreferences.CQI_SERVER_HOST, CQPPreferences.PREFERENCES_NODE) + " " + Integer.parseInt(TXMPreferences.getString(CQPPreferences.CQI_SERVER_PORT, CQPPreferences.PREFERENCES_NODE))); //$NON-NLS-1$ //$NON-NLS-2$
|
|
162 |
if (cqiClient instanceof NetCqiClient) System.out.println(TXMCoreMessages.Toolbox_30 + TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_LOGIN, CQPLibPreferences.PREFERENCES_NODE) + " " + TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_PASSWORD, CQPLibPreferences.PREFERENCES_NODE) + TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_HOST, CQPLibPreferences.PREFERENCES_NODE) + " " + Integer.parseInt(TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_PORT, CQPLibPreferences.PREFERENCES_NODE))); //$NON-NLS-1$ //$NON-NLS-2$
|
|
162 | 163 |
if (cqiServer != null && cqiServer instanceof NetCqiServer) |
163 | 164 |
System.out.println(TXMCoreMessages.Toolbox_33 + cqiServer.getLastCmdLine()); |
164 | 165 |
} else { |
... | ... | |
306 | 307 |
* kill cqpserver process. |
307 | 308 |
*/ |
308 | 309 |
private static void killSearchEngine() { |
309 |
if (!TXMPreferences.getBoolean(CQPPreferences.CQI_SERVER_IS_REMOTE, CQPPreferences.PREFERENCES_NODE))
|
|
310 |
if (!TXMPreferences.getBoolean(CQPLibPreferences.CQI_SERVER_IS_REMOTE, CQPLibPreferences.PREFERENCES_NODE))
|
|
310 | 311 |
// Windows OS |
311 | 312 |
if (OSDetector.isFamilyWindows()) { |
312 | 313 |
try { |
... | ... | |
339 | 340 |
} |
340 | 341 |
// Mac, Linux |
341 | 342 |
else { |
342 |
String cmd = TXMCoreMessages.Toolbox_37 + TXMPreferences.getString(CQPPreferences.CQI_SERVER_PORT, CQPPreferences.PREFERENCES_NODE) + TXMCoreMessages.Toolbox_38;
|
|
343 |
String cmd = TXMCoreMessages.Toolbox_37 + TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_PORT, CQPLibPreferences.PREFERENCES_NODE) + TXMCoreMessages.Toolbox_38;
|
|
343 | 344 |
try { |
344 | 345 |
//Process p = Runtime.getRuntime().exec("killall -9 cqpserver"); //$NON-NLS-1$ |
345 | 346 |
// System.out.println("kill `ps aux | grep cqpserver | awk '/-P " |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/MemCqiServer.java (revision 589) | ||
---|---|---|
38 | 38 |
|
39 | 39 |
import org.apache.commons.lang.ArrayUtils; |
40 | 40 |
import org.apache.commons.lang.StringUtils; |
41 |
import org.txm.Toolbox; |
|
42 | 41 |
import org.txm.core.preferences.TXMPreferences; |
42 |
import org.txm.libs.cqp.CQPLibPreferences; |
|
43 | 43 |
import org.txm.searchengine.cqp.clientExceptions.ServerNotFoundException; |
44 | 44 |
import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException; |
45 | 45 |
import org.txm.searchengine.cqp.serverException.CqiCqpErrorNoSuchCorpus; |
... | ... | |
167 | 167 |
|
168 | 168 |
try { |
169 | 169 |
|
170 |
String cqplibpath = TXMPreferences.getString(CQPPreferences.CQI_SERVER_PATH_TO_CQPLIB, CQPPreferences.PREFERENCES_NODE);
|
|
170 |
String cqplibpath = TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_PATH_TO_CQPLIB, CQPLibPreferences.PREFERENCES_NODE);
|
|
171 | 171 |
if (cqplibpath == null || cqplibpath.length() == 0) { |
172 | 172 |
System.out.println("Error: cqp lib path is not set in preferences"); |
173 | 173 |
return false; |
... | ... | |
455 | 455 |
String[] strings = {"je", "jamais"}; |
456 | 456 |
int[] strucpos = {0, 1, 2, 3 , 4}; |
457 | 457 |
|
458 |
TXMPreferences.put(CQPPreferences.PREFERENCES_NODE, CQPPreferences.CQI_SERVER_PATH_TO_CQPLIB, pathToCQPLibDirectory);
|
|
458 |
TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQPLibPreferences.CQI_SERVER_PATH_TO_CQPLIB, pathToCQPLibDirectory);
|
|
459 | 459 |
|
460 | 460 |
MemCqiServer server = new MemCqiServer(pathToRegistry, pathToInitFile, " -b 10000000 -d OFF", false); |
461 | 461 |
if (server.start()) System.out.println("Mem Server ok"); |
tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbEncode.java (revision 589) | ||
---|---|---|
39 | 39 |
import org.txm.core.messages.TXMCoreMessages; |
40 | 40 |
import org.txm.core.preferences.TBXPreferences; |
41 | 41 |
import org.txm.core.preferences.TXMPreferences; |
42 |
import org.txm.libs.cqp.CQPLibPreferences; |
|
42 | 43 |
import org.txm.searchengine.cqp.CQPPreferences; |
43 | 44 |
import org.txm.searchengine.cqp.clientExceptions.ServerNotFoundException; |
44 | 45 |
import org.txm.stat.utils.ConsoleProgressBar; |
... | ... | |
182 | 183 |
*/ |
183 | 184 |
|
184 | 185 |
// Warning !! for WINDOWS ONLY the "" value does not work with the ProcessBuilder we must set the value to "\"\"" |
185 |
String empty_value_code = TXMPreferences.getString(CQPPreferences.CQP_EMPTY_VALUE_CODE, CQPPreferences.PREFERENCES_NODE);
|
|
186 |
String empty_value_code = TXMPreferences.getString(CQPLibPreferences.CQP_EMPTY_VALUE_CODE, CQPLibPreferences.PREFERENCES_NODE);
|
|
186 | 187 |
if (OSDetector.isFamilyWindows()) { |
187 | 188 |
if (empty_value_code == null) empty_value_code = "\"\""; |
188 | 189 |
empty_value_code = empty_value_code.trim(); |
tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbProcess.java (revision 589) | ||
---|---|---|
37 | 37 |
|
38 | 38 |
import org.apache.commons.lang.StringUtils; |
39 | 39 |
import org.txm.core.messages.TXMCoreMessages; |
40 |
import org.txm.core.preferences.TBXPreferences; |
|
41 | 40 |
import org.txm.core.preferences.TXMPreferences; |
41 |
import org.txm.libs.cqp.CQPLibPreferences; |
|
42 | 42 |
import org.txm.searchengine.cqp.CQPPreferences; |
43 | 43 |
import org.txm.searchengine.cqp.clientExceptions.ServerNotFoundException; |
44 | 44 |
import org.txm.utils.logger.Log; |
... | ... | |
244 | 244 |
*/ |
245 | 245 |
public static String getCWBLocation() |
246 | 246 |
{ |
247 |
String cwbLoc = TXMPreferences.getString(CQPPreferences.CQI_SERVER_PATH_TO_CQPLIB, CQPPreferences.PREFERENCES_NODE)+File.separator;
|
|
247 |
String cwbLoc = TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_PATH_TO_CQPLIB, CQPLibPreferences.PREFERENCES_NODE)+File.separator;
|
|
248 | 248 |
|
249 | 249 |
if (!new File(cwbLoc).exists()) { |
250 | 250 |
System.out.println(TXMCoreMessages.CwbProcess_5+cwbLoc); |
tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/preferences/RPreferences.java (revision 589) | ||
---|---|---|
1 | 1 |
package org.txm.statsengine.r.core.preferences; |
2 | 2 |
|
3 | 3 |
|
4 |
import java.io.File; |
|
5 |
import java.io.IOException; |
|
6 |
|
|
4 | 7 |
import org.eclipse.core.runtime.preferences.DefaultScope; |
5 | 8 |
import org.osgi.framework.FrameworkUtil; |
9 |
import org.osgi.framework.Version; |
|
6 | 10 |
import org.osgi.service.prefs.Preferences; |
7 | 11 |
import org.txm.core.preferences.TXMPreferences; |
12 |
import org.txm.utils.BundleUtils; |
|
13 |
import org.txm.utils.logger.Log; |
|
8 | 14 |
|
9 | 15 |
/** |
10 | 16 |
* Default preferences initializer. |
... | ... | |
56 | 62 |
public static final String FILE_TRANSFERT = PREFERENCES_PREFIX + "file_transfert"; //$NON-NLS-1$ |
57 | 63 |
public static final String SVG_DEVICE = PREFERENCES_PREFIX + "svg_device"; //$NON-NLS-1$ |
58 | 64 |
|
65 |
/** Last version since R Preferences have been set -> the setting is done only ONE time.*/ |
|
66 |
public static final String VERSION = "version"; |
|
67 |
|
|
59 | 68 |
/** |
60 | 69 |
* |
61 | 70 |
*/ |
... | ... | |
67 | 76 |
public void initializeDefaultPreferences() { |
68 | 77 |
Preferences preferences = DefaultScope.INSTANCE.getNode(PREFERENCES_NODE); |
69 | 78 |
|
70 |
//FIXME: need to define here the PATH_TO_EXECUTABLE preference according to current OS and the current TXM install directory |
|
71 |
// If the paths are different according to the current OS, a good way could be to have the same projects as for CQP |
|
72 |
// Project: org.txm.r |
|
73 |
// Fragment: org.txm.r.win64 |
|
74 |
// Fragment: org.txm.r.linux |
|
75 |
// and the fragment should initialize this preference |
|
76 |
preferences.put(PATH_TO_EXECUTABLE, "undefined"); |
|
77 |
|
|
78 | 79 |
preferences.putBoolean(IS_MANDATORY, false); |
79 | 80 |
preferences.put(SERVER_ADDRESS, "127.0.0.1"); |
80 | 81 |
preferences.putBoolean(REMOTE, false); |
... | ... | |
88 | 89 |
preferences.putBoolean(FILE_TRANSFERT, false); |
89 | 90 |
preferences.put(SVG_DEVICE, "svg"); |
90 | 91 |
|
92 |
|
|
93 |
String RFRAGMENT = "org.txm.statsengine.r.core."+System.getProperty("osgi.os"); |
|
94 |
Log.info("R.DoInstallStep.preInstall()"); |
|
95 |
String saved = TXMPreferences.getString(RPreferences.VERSION, RPreferences.PREFERENCES_NODE); |
|
96 |
Version currentVersion = BundleUtils.getBundleVersion(RFRAGMENT); // the RFRAGMENT plugin contains the right version |
|
97 |
|
|
98 |
if (saved != null && saved.length() > 0) { |
|
99 |
Version savedVersion = new Version(saved); |
|
100 |
if (currentVersion.compareTo(savedVersion) <= 0) { |
|
101 |
Log.info("No post-installation of R plugin to do"); |
|
102 |
return; // nothing to do |
|
103 |
} |
|
104 |
} |
|
105 |
Log.info("Updating R preferences for R plugin version="+currentVersion); |
|
106 |
|
|
107 |
String os = "win"; |
|
108 |
String ext = ""; |
|
109 |
String osname = System.getProperty("os.name").toLowerCase(); |
|
110 |
if (osname.contains("windows")) { //$NON-NLS-1$ |
|
111 |
if (System.getProperty("os.arch").contains("64")) { os = "win64"; } |
|
112 |
else { os = "win32"; } |
|
113 |
ext = ".exe"; |
|
114 |
} else if (osname.contains("mac")) { //$NON-NLS-1$ |
|
115 |
os = "macosx"; |
|
116 |
} else { |
|
117 |
os = "linux32"; |
|
118 |
if (System.getProperty("os.arch").contains("64")) |
|
119 |
os = "linux64"; |
|
120 |
} |
|
121 |
|
|
122 |
File bundleDir = BundleUtils.getBundleFile(RFRAGMENT); |
|
123 |
if (bundleDir == null) { |
|
124 |
System.out.println("Error while retrieving "+RFRAGMENT+" bundle directory."); |
|
125 |
return; |
|
126 |
} |
|
127 |
File cwbDir = new File(bundleDir, "res"); |
|
128 |
File OSDir = new File(cwbDir, os); |
|
129 |
File execFile = new File(OSDir, "bin/R"+ext); |
|
130 |
execFile.setExecutable(true); |
|
131 |
preferences.put(PATH_TO_EXECUTABLE, execFile.getAbsolutePath()); |
|
132 |
|
|
133 |
|
|
134 |
if (!osname.contains("windows")) { |
|
135 |
try { |
|
136 |
Log.info("Setting execution file rights to: "+OSDir.getAbsolutePath()); |
|
137 |
Runtime.getRuntime().exec("chmod -R +x "+OSDir.getAbsolutePath()).waitFor(); |
|
138 |
} catch (Exception e) { |
|
139 |
System.out.println("Error while setting execution file rights to: "+OSDir.getAbsolutePath()); |
|
140 |
e.printStackTrace(); |
|
141 |
return; |
|
142 |
} |
|
143 |
} |
|
144 |
|
|
145 |
if (!execFile.exists()) { |
|
146 |
System.out.println("Cannot find CQP executable file: "+execFile); |
|
147 |
return; |
|
148 |
} |
|
149 |
|
|
150 |
if (!execFile.canExecute()) { |
|
151 |
System.out.println("File right setting error, cannot execute: "+execFile); |
|
152 |
return; |
|
153 |
} |
|
154 |
|
|
155 |
Log.warning("SearchEngine preferences set with: "+OSDir.getAbsolutePath()+" and "+execFile.getAbsolutePath()); |
|
156 |
TXMPreferences.put(RPreferences.PREFERENCES_NODE, RPreferences.VERSION, currentVersion.toString()); |
|
157 |
|
|
158 |
|
|
91 | 159 |
} |
92 | 160 |
|
93 | 161 |
} |
tmp/org.txm.rcp.feature/feature.xml (revision 589) | ||
---|---|---|
83 | 83 |
id="org.eclipse.babel.nls_eclipse_ru" |
84 | 84 |
version="0.0.0"/> |
85 | 85 |
|
86 |
<includes |
|
87 |
id="org.txm.statsengine.r.feature" |
|
88 |
version="0.0.0"/> |
|
89 |
|
|
90 |
<includes |
|
91 |
id="org.txm.searchengine.cqp.feature" |
|
92 |
version="0.0.0"/> |
|
93 |
|
|
86 | 94 |
<requires> |
95 |
<import plugin="org.txm.statsengine.r.core" version="1.0.0" match="greaterOrEqual"/> |
|
87 | 96 |
<import plugin="org.eclipse.core.runtime" version="3.10.0" match="greaterOrEqual"/> |
88 | 97 |
<import plugin="org.txm.lexicaltable.core"/> |
89 | 98 |
<import plugin="org.eclipse.osgi" version="3.10.2" match="greaterOrEqual"/> |
90 | 99 |
<import plugin="org.eclipse.ui" version="3.106.1" match="greaterOrEqual"/> |
91 | 100 |
<import plugin="org.txm.chartsengine.rcp"/> |
92 | 101 |
<import plugin="org.eclipse.core.expressions" version="3.4.600" match="greaterOrEqual"/> |
102 |
<import plugin="org.txm.statsengine.r.rcp" version="1.0.0" match="greaterOrEqual"/> |
|
93 | 103 |
<import plugin="org.txm.ca.core"/> |
94 | 104 |
<import plugin="org.eclipse.core.commands" version="3.6.100" match="greaterOrEqual"/> |
95 | 105 |
<import plugin="org.txm.utils"/> |
... | ... | |
105 | 115 |
<import plugin="org.eclipse.osgi.util" version="3.2.0" match="greaterOrEqual"/> |
106 | 116 |
<import plugin="org.eclipse.core.net"/> |
107 | 117 |
<import plugin="org.txm.libs.rserve"/> |
108 |
<import plugin="org.txm.statsengine.r.rcp"/> |
|
109 |
<import plugin="org.txm.searchengine.cqp.core"/> |
|
110 | 118 |
<import plugin="org.apache.xerces" version="2.9.0" match="greaterOrEqual"/> |
111 |
<import plugin="org.eclipse.jface"/> |
|
112 | 119 |
<import plugin="org.txm.partition.core"/> |
113 | 120 |
<import plugin="org.txm.concordance.rcp"/> |
114 | 121 |
<import plugin="org.txm.synopticeditor.rcp"/> |
... | ... | |
158 | 165 |
<import plugin="org.eclipse.equinox.p2.reconciler.dropins" version="1.1.200" match="greaterOrEqual"/> |
159 | 166 |
<import plugin="org.eclipse.ui.views.log" version="1.0.500" match="greaterOrEqual"/> |
160 | 167 |
<import plugin="org.txm.groovy.core"/> |
161 |
<import plugin="org.eclipse.ui.workbench" version="3.106.2" match="greaterOrEqual"/> |
|
162 |
<import plugin="org.txm.statsengine.r.core"/> |
|
163 |
<import plugin="org.eclipse.jface.text" version="3.9.2" match="greaterOrEqual"/> |
|
164 |
<import plugin="org.eclipse.ui.console" version="3.5.300" match="greaterOrEqual"/> |
|
165 |
<import plugin="org.eclipse.ui.ide" version="3.10.2" match="greaterOrEqual"/> |
|
166 | 168 |
<import plugin="org.eclipse.ui.browser" version="3.4.100" match="greaterOrEqual"/> |
167 | 169 |
<import plugin="org.eclipse.jface.databinding" version="1.6.200" match="greaterOrEqual"/> |
170 |
<import plugin="org.eclipse.jface.text" version="3.9.2" match="greaterOrEqual"/> |
|
168 | 171 |
<import plugin="org.eclipse.core.net" version="1.2.200" match="greaterOrEqual"/> |
169 | 172 |
<import plugin="org.txm.specificities.core"/> |
170 | 173 |
<import plugin="org.txm.lexicaltable.rcp"/> |
... | ... | |
189 | 192 |
<import plugin="org.eclipse.e4.ui.workbench3" version="0.12.0" match="greaterOrEqual"/> |
190 | 193 |
<import plugin="org.eclipse.e4.ui.workbench.addons.swt" version="0.10.0" match="greaterOrEqual"/> |
191 | 194 |
<import plugin="org.eclipse.emf.ecore" version="2.7.0" match="greaterOrEqual"/> |
192 |
<import plugin="com.ibm.icu"/> |
|
193 |
<import plugin="javax.annotation"/> |
|
194 |
<import plugin="javax.inject"/> |
|
195 |
<import plugin="org.eclipse.e4.core.commands"/> |
|
196 |
<import plugin="org.eclipse.e4.ui.services"/> |
|
197 |
<import plugin="org.eclipse.emf.common"/> |
|
198 |
<import plugin="javax.xml"/> |
|
195 |
<import plugin="org.txm.searchengine.cqp.core" version="1.1.0" match="greaterOrEqual"/> |
|
196 |
<import plugin="org.txm.libs.cqp" version="1.0.0" match="greaterOrEqual"/> |
|
199 | 197 |
</requires> |
200 | 198 |
|
201 | 199 |
<plugin |
... | ... | |
386 | 384 |
unpack="false"/> |
387 | 385 |
|
388 | 386 |
<plugin |
389 |
id="org.txm.libs.cqp" |
|
390 |
download-size="0" |
|
391 |
install-size="0" |
|
392 |
version="1.0.0.qualifier" |
|
393 |
unpack="false"/> |
|
394 |
|
|
395 |
<plugin |
|
396 | 387 |
id="org.txm.libs.groovy-all" |
397 | 388 |
download-size="0" |
398 | 389 |
install-size="0" |
... | ... | |
434 | 425 |
unpack="false"/> |
435 | 426 |
|
436 | 427 |
<plugin |
437 |
id="org.txm.links.rcp" |
|
438 |
download-size="0" |
|
439 |
install-size="0" |
|
440 |
version="1.0.0.qualifier" |
|
441 |
unpack="false"/> |
|
442 |
|
|
443 |
<plugin |
|
444 | 428 |
id="org.txm.partition.core" |
445 | 429 |
download-size="0" |
446 | 430 |
install-size="0" |
... | ... | |
497 | 481 |
unpack="false"/> |
498 | 482 |
|
499 | 483 |
<plugin |
500 |
id="org.txm.searchengine.cqp.core" |
|
501 |
download-size="0" |
|
502 |
install-size="0" |
|
503 |
version="1.1.0.qualifier" |
|
504 |
unpack="false"/> |
|
505 |
|
|
506 |
<plugin |
|
507 |
id="org.txm.searchengine.cqp.rcp" |
|
508 |
download-size="0" |
|
509 |
install-size="0" |
|
510 |
version="1.0.0.qualifier" |
|
511 |
unpack="false"/> |
|
512 |
|
|
513 |
<plugin |
|
514 | 484 |
id="org.txm.specificities.core" |
515 | 485 |
download-size="0" |
516 | 486 |
install-size="0" |
... | ... | |
525 | 495 |
unpack="false"/> |
526 | 496 |
|
527 | 497 |
<plugin |
528 |
id="org.txm.statsengine.r.core" |
|
529 |
download-size="0" |
|
530 |
install-size="0" |
|
531 |
version="1.0.0.qualifier" |
|
532 |
unpack="false"/> |
|
533 |
|
|
534 |
<plugin |
|
535 |
id="org.txm.statsengine.r.rcp" |
|
536 |
download-size="0" |
|
537 |
install-size="0" |
|
538 |
version="1.0.0.qualifier" |
|
539 |
unpack="false"/> |
|
540 |
|
|
541 |
<plugin |
|
542 | 498 |
id="org.txm.synopticeditor.rcp" |
543 | 499 |
download-size="0" |
544 | 500 |
install-size="0" |
... | ... | |
567 | 523 |
unpack="false"/> |
568 | 524 |
|
569 | 525 |
<plugin |
570 |
id="org.txm.textsbalance.core" |
|
571 |
download-size="0" |
|
572 |
install-size="0" |
|
573 |
version="0.0.0" |
|
574 |
unpack="false"/> |
|
575 |
|
|
576 |
<plugin |
|
577 |
id="org.txm.textsbalance.rcp" |
|
578 |
download-size="0" |
|
579 |
install-size="0" |
|
580 |
version="0.0.0" |
|
581 |
unpack="false"/> |
|
582 |
|
|
583 |
<plugin |
|
584 | 526 |
id="org.txm.wordcloud.core" |
585 | 527 |
download-size="0" |
586 | 528 |
install-size="0" |
tmp/org.txm.rcp/TXM.sh (revision 589) | ||
---|---|---|
1 |
#!/bin/bash |
|
2 |
./TXM -standalone |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/preferences/ImportPreferencePage.java (revision 589) | ||
---|---|---|
45 | 45 |
import org.eclipse.ui.preferences.ScopedPreferenceStore; |
46 | 46 |
import org.txm.core.preferences.TBXPreferences; |
47 | 47 |
import org.txm.core.preferences.TXMPreferences; |
48 |
import org.txm.libs.cqp.CQPLibPreferences; |
|
48 | 49 |
import org.txm.rcp.Application; |
49 | 50 |
import org.txm.rcp.RCPMessages; |
50 | 51 |
import org.txm.rcp.TxmPreferences; |
... | ... | |
147 | 148 |
l.setLayoutData(ldata); |
148 | 149 |
addField(defaultlang); |
149 | 150 |
|
150 |
empty_code = new StringFieldEditor(CQPPreferences.CQP_EMPTY_VALUE_CODE, "Empty property value code", getFieldEditorParent()); |
|
151 |
empty_code = new StringFieldEditor(CQPLibPreferences.CQP_EMPTY_VALUE_CODE, "Empty property value code", getFieldEditorParent());
|
|
151 | 152 |
addField(empty_code); |
152 | 153 |
|
153 | 154 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java (revision 589) | ||
---|---|---|
543 | 543 |
|
544 | 544 |
// set the install directory preference |
545 | 545 |
String installpath = Platform.getInstallLocation().getURL().getFile(); // the TXM.exe file path |
546 |
File installDirectory = new File(installpath, ".."); //$NON-NLS-1$
|
|
546 |
File installDirectory = new File(installpath);
|
|
547 | 547 |
//installDirectory = installDirectory.getCanonicalFile(); |
548 | 548 |
TXMPreferences.put(TBXPreferences.PREFERENCES_NODE, TBXPreferences.INSTALL_DIR, installDirectory.getAbsolutePath()); |
549 | 549 |
|
550 |
File preferenceFile = new File(installDirectory, "install.prefs"); //$NON-NLS-1$ |
|
551 |
if (preferenceFile.exists()) { |
|
552 |
System.out.println(NLS.bind(RCPMessages.ApplicationWorkbenchAdvisor_25, preferenceFile)); |
|
553 |
if (Util.isWindows()) //NSIS has generated ISO-8859-1 preference file |
|
554 |
TxmPreferences.importFromFile(preferenceFile, "ISO-8859-1", false); //$NON-NLS-1$ |
|
555 |
else |
|
556 |
TxmPreferences.importFromFile(preferenceFile); |
|
557 |
} else { |
|
558 |
System.out.println("No installation preference file found in the installation directory: "+preferenceFile); |
|
559 |
installPreferenceRestored = false; |
|
560 |
return true; |
|
561 |
} |
|
550 |
//TODO: ensure all preferences of install.prefs file are now stored in the default preferences |
|
551 |
// File preferenceFile = new File(installDirectory, "install.prefs"); //$NON-NLS-1$ |
|
552 |
// if (preferenceFile.exists()) { |
|
553 |
// System.out.println(NLS.bind(RCPMessages.ApplicationWorkbenchAdvisor_25, preferenceFile)); |
|
554 |
// if (Util.isWindows()) //NSIS has generated ISO-8859-1 preference file |
|
555 |
// TxmPreferences.importFromFile(preferenceFile, "ISO-8859-1", false); //$NON-NLS-1$ |
|
556 |
// else |
|
557 |
// TxmPreferences.importFromFile(preferenceFile); |
|
558 |
// } else { |
|
559 |
// System.out.println("No installation preference file found in the installation directory: "+preferenceFile); |
|
560 |
// installPreferenceRestored = false; |
|
561 |
// return true; |
|
562 |
// } |
|
562 | 563 |
// restore previous TreeTagger preferences |
563 | 564 |
File previousPreferenceFile = new File(System.getProperty("java.io.tmpdir"), //$NON-NLS-1$ |
564 | 565 |
"org.txm.rcp.prefs"); //$NON-NLS-1$ |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/Application.java (revision 589) | ||
---|---|---|
27 | 27 |
// |
28 | 28 |
package org.txm.rcp; |
29 | 29 |
|
30 |
import java.io.File; |
|
30 | 31 |
import java.io.IOException; |
31 | 32 |
import java.util.Arrays; |
32 | 33 |
import java.util.List; |
... | ... | |
51 | 52 |
import org.eclipse.ui.preferences.ScopedPreferenceStore; |
52 | 53 |
import org.osgi.framework.Bundle; |
53 | 54 |
import org.osgi.framework.ServiceReference; |
55 |
import org.txm.Toolbox; |
|
54 | 56 |
import org.txm.core.preferences.TBXPreferences; |
55 | 57 |
import org.txm.core.preferences.TXMPreferences; |
58 |
import org.txm.libs.cqp.CQPLibPreferences; |
|
59 |
import org.txm.objects.Workspace; |
|
56 | 60 |
import org.txm.searchengine.cqp.CQPPreferences; |
57 | 61 |
import org.txm.statsengine.r.core.preferences.RPreferences; |
62 |
import org.txm.utils.BundleUtils; |
|
63 |
import org.txm.utils.DeleteDir; |
|
58 | 64 |
import org.txm.utils.logger.Log; |
59 | 65 |
|
60 | 66 |
// TODO: Auto-generated Javadoc |
... | ... | |
70 | 76 |
public static final String FIRST_LAUNCH = "first_launch"; //$NON-NLS-1$ |
71 | 77 |
|
72 | 78 |
private static ApplicationWorkbenchAdvisor awa; |
73 |
|
|
79 |
|
|
74 | 80 |
//public static OpenDocumentEventProcessor openDocProcessor = new OpenDocumentEventProcessor(); |
75 | 81 |
/* |
76 | 82 |
* (non-Javadoc) |
... | ... | |
80 | 86 |
@Override |
81 | 87 |
public Object start(IApplicationContext context) throws Exception { |
82 | 88 |
Map args = context.getArguments(); |
83 |
|
|
89 |
|
|
84 | 90 |
List<String> argsList = Arrays.asList((String[])(args.get("application.args"))); |
85 | 91 |
System.out.println(RCPMessages.Application_0+argsList); |
86 | 92 |
if (argsList.contains("-log")) { //$NON-NLS-1$ |
... | ... | |
94 | 100 |
} |
95 | 101 |
if (argsList.contains("-run")) { //$NON-NLS-1$ |
96 | 102 |
//System.out.println("Running TXM"); |
103 |
} else if (argsList.contains("-standalone")) { //$NON-NLS-1$ |
|
104 |
File userhomeDirectory = new File("workspace").getAbsoluteFile(); // eclipse default workspace directory |
|
105 |
File defaultWorkspaceFile = new File("workspace/workspaces/default.xml"); |
|
106 |
if (!defaultWorkspaceFile.exists()) { |
|
107 |
System.out.println("Stand alone launch, creating minimal TXM user home directory in "+userhomeDirectory.getAbsolutePath()); |
|
108 |
System.out.println("Sample corpora, scripts, import scripts and macros files are not yet installed."); |
|
109 |
|
|
110 |
TXMPreferences.put(TBXPreferences.PREFERENCES_NODE, TBXPreferences.USER_TXM_HOME, userhomeDirectory.getAbsolutePath()); |
|
111 |
TXMPreferences.put(TBXPreferences.PREFERENCES_NODE, TBXPreferences.INSTALL_DIR, userhomeDirectory.getParentFile().getAbsolutePath()); |
|
112 |
|
|
113 |
File corpusworkspaceDirectory = new File(userhomeDirectory, "workspaces"); |
|
114 |
corpusworkspaceDirectory.mkdirs(); |
|
115 |
|
|
116 |
String createfolders[] = { |
|
117 |
"corpora", "clipboard", //$NON-NLS-1$ //$NON-NLS-2$ |
|
118 |
"workspaces", "css", "scripts", "scripts/lib", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
119 |
"scripts/macro", "scripts/user", "xsl", "samples", "schema", "R"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
120 |
|
|
121 |
for (String folder : createfolders) { |
|
122 |
new File(userhomeDirectory, folder).mkdir(); |
|
123 |
} |
|
124 |
|
|
125 |
Workspace.createEmptyWorkspace(new File(corpusworkspaceDirectory, "default.xml")); //$NON-NLS-1$ |
|
126 |
BundleUtils.copyFiles("org.txm.core", "res", "org/txm", "css", new File(userhomeDirectory, "css")); |
|
127 |
BundleUtils.copyFiles("org.txm.core", "res", "org/txm/xml", "xsl", new File(userhomeDirectory, "xsl")); |
|
128 |
BundleUtils.copyFiles("org.txm.core", "res", "org/txm/xml", "schema", new File(userhomeDirectory, "schema")); |
|
129 |
File scriptsDirectory = new File(userhomeDirectory, "scripts"); |
|
130 |
new File(scriptsDirectory, "user").mkdir(); |
|
131 |
new File(scriptsDirectory, "import").mkdir(); |
|
132 |
new File(scriptsDirectory, "lib").mkdir(); |
|
133 |
new File(scriptsDirectory, "macro").mkdir(); |
|
134 |
new File(scriptsDirectory, "samples").mkdir(); |
|
135 |
} |
|
97 | 136 |
} else { |
98 | 137 |
System.out.println("TXM must be launch with the argument '-run' to start."); //$NON-NLS-1$ |
99 | 138 |
System.out.println(RCPMessages.Application_4); |
... | ... | |
112 | 151 |
|
113 | 152 |
Display display = PlatformUI.createDisplay(); |
114 | 153 |
//display.addListener(SWT.OpenDocument, openDocProcessor); |
115 |
|
|
154 |
|
|
116 | 155 |
//Lock the RCP workspace, thus there is only one TXM instance running |
117 | 156 |
Log.warning(RCPMessages.Application_8); |
118 | 157 |
if (!Platform.getInstanceLocation().lock()){ |
... | ... | |
154 | 193 |
@Override |
155 | 194 |
public void stop() { |
156 | 195 |
// TODO Auto-generated method stub |
157 |
|
|
196 |
|
|
158 | 197 |
} |
159 | 198 |
|
160 | 199 |
/** |
... | ... | |
162 | 201 |
*/ |
163 | 202 |
private void activateProxyService() { |
164 | 203 |
String sys_proxy_host = System.getProperty("http.proxyHost"); // must be called before IProxyService is used |
165 |
|
|
204 |
|
|
166 | 205 |
Bundle bundle = Platform.getBundle("org.eclipse.ui.ide"); //$NON-NLS-1$ |
167 | 206 |
IProxyService proxyService = null; |
168 | 207 |
if (bundle != null) { |
... | ... | |
175 | 214 |
} else { |
176 | 215 |
//System.out.println("FIRST RUN TEST RESULT: "+ApplicationWorkbenchAdvisor.firstLaunchAfterInstallation()); |
177 | 216 |
// force active provider as "Manual" on Mac OS X |
178 |
if (Util.isMac() && sys_proxy_host != null && ApplicationWorkbenchAdvisor.testTXMHOMEPreferenceAndDirectory()) {
|
|
179 |
System.out.println("System proxy detected. Force network provider to manual with proxy_host="+sys_proxy_host);
|
|
180 |
proxyService.setProxiesEnabled(true);
|
|
181 |
}
|
|
182 |
|
|
217 |
if (Util.isMac() && sys_proxy_host != null && ApplicationWorkbenchAdvisor.testTXMHOMEPreferenceAndDirectory()) {
|
|
218 |
System.out.println("System proxy detected. Force network provider to manual with proxy_host="+sys_proxy_host);
|
|
219 |
proxyService.setProxiesEnabled(true);
|
|
220 |
}
|
|
221 |
|
|
183 | 222 |
if (Util.isMac()) { // configure only for Mac OS X |
184 |
// String proxy_conf = ""; |
|
185 |
// ProxyConf conf = new ProxyConf(this); |
|
186 |
// if (conf.mustSetProxyConfiguration()) { // there is a system proxy configured |
|
187 |
// System.out.println(Messages.bind(Messages.Application_11, proxy_conf)); |
|
188 |
// proxyService.setProxiesEnabled(true); |
|
189 |
// //proxyService.setSystemProxiesEnabled(false); |
|
190 |
// |
|
191 |
// // prepare a new proxy configuration |
|
192 |
// boolean requiresAuthentication = conf.proxy_user != null && conf.proxy_user.length() > 0; |
|
193 |
// IProxyData[] proxies = new IProxyData[1]; |
|
194 |
// proxies[0] = new ProxyData(IProxyData.HTTP_PROXY_TYPE, conf.proxy_host, conf.proxy_port, requiresAuthentication, ""); |
|
195 |
// proxies[0].setPassword(conf.proxy_password); |
|
196 |
// proxies[0].setUserid(conf.proxy_user); |
|
197 |
// |
|
198 |
// try { |
|
199 |
// proxyService.setProxyData(proxies); // apply the new proxy configuration |
|
200 |
// System.out.println("TXM proxy configuration set: "+Arrays.toString(proxies)); |
|
201 |
// } catch (Exception e) { |
|
202 |
// System.out.println("Failed to set TXM proxy configuration: "+Arrays.toString(proxies)); |
|
203 |
// Log.printStackTrace(e); |
|
204 |
// } |
|
205 |
// } |
|
223 |
// String proxy_conf = "";
|
|
224 |
// ProxyConf conf = new ProxyConf(this);
|
|
225 |
// if (conf.mustSetProxyConfiguration()) { // there is a system proxy configured
|
|
226 |
// System.out.println(Messages.bind(Messages.Application_11, proxy_conf));
|
|
227 |
// proxyService.setProxiesEnabled(true);
|
|
228 |
// //proxyService.setSystemProxiesEnabled(false);
|
|
229 |
//
|
|
230 |
// // prepare a new proxy configuration
|
|
231 |
// boolean requiresAuthentication = conf.proxy_user != null && conf.proxy_user.length() > 0;
|
|
232 |
// IProxyData[] proxies = new IProxyData[1];
|
|
233 |
// proxies[0] = new ProxyData(IProxyData.HTTP_PROXY_TYPE, conf.proxy_host, conf.proxy_port, requiresAuthentication, "");
|
|
234 |
// proxies[0].setPassword(conf.proxy_password);
|
|
235 |
// proxies[0].setUserid(conf.proxy_user);
|
|
236 |
//
|
|
237 |
// try {
|
|
238 |
// proxyService.setProxyData(proxies); // apply the new proxy configuration
|
|
239 |
// System.out.println("TXM proxy configuration set: "+Arrays.toString(proxies));
|
|
240 |
// } catch (Exception e) {
|
|
241 |
// System.out.println("Failed to set TXM proxy configuration: "+Arrays.toString(proxies));
|
|
242 |
// Log.printStackTrace(e);
|
|
243 |
// }
|
|
244 |
// }
|
|
206 | 245 |
} |
207 | 246 |
} |
208 | 247 |
} |
... | ... | |
217 | 256 |
private boolean parseCommandLine() { |
218 | 257 |
boolean exit = false; |
219 | 258 |
String[] optionsForPreferences = { |
220 |
CQPPreferences.CQI_SERVER_PATH_TO_EXECUTABLE, |
|
221 |
CQPPreferences.CQI_SERVER_PATH_TO_INIT_FILE, |
|
222 |
// TBXPreferences.CQI_SERVER_PATH_TO_REGISTRY, |
|
259 |
CQPLibPreferences.CQI_SERVER_PATH_TO_EXECUTABLE,
|
|
260 |
CQPLibPreferences.CQI_SERVER_PATH_TO_INIT_FILE,
|
|
261 |
// TBXPreferences.CQI_SERVER_PATH_TO_REGISTRY,
|
|
223 | 262 |
RPreferences.PATH_TO_EXECUTABLE, |
224 | 263 |
TBXPreferences.INSTALL_DIR }; |
225 | 264 |
String setPrefAndExit = "setPrefAndExit"; //$NON-NLS-1$ |
tmp/org.txm.rcp/rcpapplication.product (revision 589) | ||
---|---|---|
79 | 79 |
</win> |
80 | 80 |
</launcher> |
81 | 81 |
|
82 |
|
|
83 | 82 |
<vm> |
84 | 83 |
<linux include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7</linux> |
85 | 84 |
<macos include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7</macos> |
tmp/org.txm.rcp/build.properties (revision 589) | ||
---|---|---|
17 | 17 |
css/,\ |
18 | 18 |
p2.inf,\ |
19 | 19 |
bin/,\ |
20 |
OSGI-INF/ |
|
20 |
OSGI-INF/,\ |
|
21 |
TXM.sh |
|
21 | 22 |
bin.excludes = lib/batik/ |
tmp/org.txm.backtomedia.rcp/plugin.xml (revision 589) | ||
---|---|---|
75 | 75 |
<extension |
76 | 76 |
point="org.eclipse.ui.preferencePages"> |
77 | 77 |
<page |
78 |
category="org.txm.rcpapplication.preferences.UserPreferencePage"
|
|
78 |
category="org.txm.rcp.preferences.UserPreferencePage" |
|
79 | 79 |
class="org.txm.backtomedia.preferences.BackToMediaPreferencePage" |
80 | 80 |
id="org.txm.backtomedia.preferences.BackToMediaPreferencePage" |
81 | 81 |
name="%page.name"> |
tmp/org.txm.libs.cqp/plugin.xml (revision 589) | ||
---|---|---|
9 | 9 |
name="org.txm.libs.cqp.DoInstallStep"> |
10 | 10 |
</PostInstallationStep> |
11 | 11 |
</extension> |
12 |
<extension |
|
13 |
point="org.eclipse.core.runtime.preferences"> |
|
14 |
<initializer |
|
15 |
class="org.txm.libs.cqp.CQPLibPreferences"> |
|
16 |
</initializer> |
|
17 |
</extension> |
|
12 | 18 |
|
13 | 19 |
</plugin> |
tmp/org.txm.libs.cqp/META-INF/MANIFEST.MF (revision 589) | ||
---|---|---|
4 | 4 |
Bundle-SymbolicName: org.txm.libs.cqp;singleton:=true |
5 | 5 |
Bundle-Version: 1.0.0.qualifier |
6 | 6 |
Bundle-Activator: org.txm.libs.cqp.Activator |
7 |
Require-Bundle: org.txm.utils;bundle-version="1.0.0", |
|
8 |
org.eclipse.core.runtime, |
|
9 |
org.txm.core, |
|
10 |
org.eclipse.jface, |
|
11 |
org.eclipse.ui.workbench |
|
7 |
Require-Bundle: org.txm.utils;bundle-version="1.0.0";visibility:=reexport, |
|
8 |
org.txm.core;visibility:=reexport |
|
12 | 9 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 |
13 | 10 |
Bundle-ActivationPolicy: lazy |
14 | 11 |
Export-Package: org.txm.libs.cqp |
tmp/org.txm.libs.cqp/src/org/txm/libs/cqp/DoInstallStep.java (revision 589) | ||
---|---|---|
1 | 1 |
package org.txm.libs.cqp; |
2 | 2 |
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
|
|
6 |
import org.eclipse.jface.util.Util; |
|
7 |
import org.osgi.framework.Version; |
|
8 | 3 |
import org.txm.PostInstallationStep; |
9 |
import org.txm.core.preferences.TBXPreferences; |
|
10 |
import org.txm.core.preferences.TXMPreferences; |
|
11 |
import org.txm.utils.BundleUtils; |
|
12 |
import org.txm.utils.logger.Log; |
|
13 | 4 |
|
14 | 5 |
public class DoInstallStep extends PostInstallationStep { |
15 | 6 |
|
... | ... | |
27 | 18 |
@Override |
28 | 19 |
public void preInstall() { |
29 | 20 |
|
30 |
String CQPFRAGMENT = "org.txm.libs.cqp."+System.getProperty("osgi.os"); |
|
31 |
//TODO: fix preferneces logic between org.txm.cqp.lib et org.txm.searchengine.cqp |
|
32 |
Log.info("CQP.DoInstallStep.preInstall()"); |
|
33 |
String saved = TXMPreferences.getString(CQPLibPreferences.VERSION, CQPLibPreferences.PREFERENCES_NODE); |
|
34 |
Version currentVersion = BundleUtils.getBundleVersion(CQPFRAGMENT); // the CQPFRAGMENT plugin contains the right version |
|
35 |
|
|
36 |
if (saved != null && saved.length() > 0) { |
|
37 |
Version savedVersion = new Version(saved); |
|
38 |
if (currentVersion.compareTo(savedVersion) <= 0) { |
|
39 |
Log.info("No post-installation of CQP to do"); |
|
40 |
return; // nothing to do |
|
41 |
} |
|
42 |
} |
|
43 |
Log.info("Updating CWB preferences for CQP version="+currentVersion); |
|
44 |
|
|
45 |
String os = "win"; |
|
46 |
String ext = ""; |
|
47 |
if (Util.isWindows()) { //$NON-NLS-1$ |
|
48 |
if (System.getProperty("os.arch").contains("64")) { os = "win64"; } |
|
49 |
else { os = "win32"; } |
|
50 |
ext = ".exe"; |
|
51 |
} else if (Util.isMac()) { //$NON-NLS-1$ |
|
52 |
os = "macosx"; |
|
53 |
} else { |
|
54 |
os = "linux32"; |
|
55 |
if (System.getProperty("os.arch").contains("64")) |
|
56 |
os = "linux64"; |
|
57 |
} |
|
58 |
|
|
59 |
File bundleDir = BundleUtils.getBundleFile(CQPFRAGMENT); |
|
60 |
if (bundleDir == null) { |
|
61 |
System.out.println("Error while retrieving TreeTaggerInstaller bundle directory."); |
|
62 |
return; |
|
63 |
} |
|
64 |
File cwbDir = new File(bundleDir, "res"); |
|
65 |
File initFile = new File(cwbDir, "cqpserver.init"); |
|
66 |
File OSDir = new File(cwbDir, os); |
|
67 |
|
|
68 |
int n; |
|
69 |
try { // extract all gz files |
|
70 |
n = Utils.unGzipFilesInDirectory(OSDir); |
|
71 |
|
|
72 |
if (n == 0) { |
|
73 |
System.out.println("Error while extracting CQP files: no file extracted."); |
|
74 |
return; |
|
75 |
} |
|
76 |
} catch (IOException e1) { |
|
77 |
System.out.println("Error while extracting CQP files: "+e1); |
|
78 |
return; |
|
79 |
} |
|
80 |
|
|
81 |
File execFile = new File(OSDir, "cqpserver"+ext); |
|
82 |
|
|
83 |
TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQPLibPreferences.CQI_SERVER_PATH_TO_CQPLIB, OSDir.getAbsolutePath()); |
|
84 |
TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQPLibPreferences.CQI_SERVER_PATH_TO_INIT_FILE, initFile.getAbsolutePath()); |
|
85 |
TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQPLibPreferences.CQI_SERVER_PATH_TO_EXECUTABLE, execFile.getAbsolutePath()); |
|
86 |
if (!Util.isWindows()) { |
|
87 |
try { |
|
88 |
Log.info("Setting execution file rights to: "+OSDir.getAbsolutePath()); |
|
89 |
Runtime.getRuntime().exec("chmod -R +x "+OSDir.getAbsolutePath()).waitFor(); |
|
90 |
} catch (Exception e) { |
|
91 |
System.out.println("Error while setting execution file rights to: "+OSDir.getAbsolutePath()); |
|
92 |
e.printStackTrace(); |
|
93 |
return; |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
if (!execFile.exists()) { |
|
98 |
System.out.println("Cannot find CQP executable file: "+execFile); |
|
99 |
return; |
|
100 |
} |
|
101 |
|
|
102 |
if (!execFile.canExecute()) { |
|
103 |
System.out.println("File right setting error, cannot execute: "+execFile); |
|
104 |
return; |
|
105 |
} |
|
106 |
|
|
107 |
Log.warning("SearchEngine preferences set with: "+OSDir.getAbsolutePath()+ ", "+initFile.getAbsolutePath()+ " and "+execFile.getAbsolutePath()); |
|
108 |
TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQPLibPreferences.VERSION, currentVersion.toString()); |
|
21 |
// String CQPFRAGMENT = "org.txm.libs.cqp."+System.getProperty("osgi.os");
|
|
22 |
// //TODO: fix preferneces logic between org.txm.cqp.lib et org.txm.searchengine.cqp
|
|
23 |
// Log.info("CQP.DoInstallStep.preInstall()");
|
|
24 |
// String saved = TXMPreferences.getString(CQPLibPreferences.VERSION, CQPLibPreferences.PREFERENCES_NODE);
|
|
25 |
// Version currentVersion = BundleUtils.getBundleVersion(CQPFRAGMENT); // the CQPFRAGMENT plugin contains the right version
|
|
26 |
// |
|
27 |
// if (saved != null && saved.length() > 0) {
|
|
28 |
// Version savedVersion = new Version(saved);
|
|
29 |
// if (currentVersion.compareTo(savedVersion) <= 0) {
|
|
30 |
// Log.info("No post-installation of CQP to do");
|
|
31 |
// return; // nothing to do
|
|
32 |
// }
|
|
33 |
// }
|
|
34 |
// Log.info("Updating CWB preferences for CQP version="+currentVersion);
|
|
35 |
// |
|
36 |
// String os = "win";
|
|
37 |
// String ext = "";
|
|
38 |
// if (Util.isWindows()) { //$NON-NLS-1$
|
|
39 |
// if (System.getProperty("os.arch").contains("64")) { os = "win64"; }
|
|
40 |
// else { os = "win32"; }
|
|
41 |
// ext = ".exe";
|
|
42 |
// } else if (Util.isMac()) { //$NON-NLS-1$
|
|
43 |
// os = "macosx";
|
|
44 |
// } else {
|
|
45 |
// os = "linux32";
|
|
46 |
// if (System.getProperty("os.arch").contains("64"))
|
|
47 |
// os = "linux64";
|
|
48 |
// }
|
|
49 |
// |
|
50 |
// File bundleDir = BundleUtils.getBundleFile(CQPFRAGMENT);
|
|
51 |
// if (bundleDir == null) {
|
|
52 |
// System.out.println("Error while retrieving TreeTaggerInstaller bundle directory.");
|
|
53 |
// return;
|
|
54 |
// }
|
|
55 |
// File cwbDir = new File(bundleDir, "res");
|
|
56 |
// File initFile = new File(cwbDir, "cqpserver.init");
|
|
57 |
// File OSDir = new File(cwbDir, os);
|
|
58 |
// |
|
59 |
// int n;
|
|
60 |
// try { // extract all gz files
|
|
61 |
// n = Utils.unGzipFilesInDirectory(OSDir);
|
|
62 |
// |
|
63 |
// if (n == 0) {
|
|
64 |
// System.out.println("Error while extracting CQP files: no file extracted.");
|
|
65 |
// return;
|
|
66 |
// }
|
|
67 |
// } catch (IOException e1) {
|
|
68 |
// System.out.println("Error while extracting CQP files: "+e1);
|
|
69 |
// return;
|
|
70 |
// }
|
|
71 |
// |
|
72 |
// File execFile = new File(OSDir, "cqpserver"+ext);
|
|
73 |
// |
|
74 |
// TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQPLibPreferences.CQI_SERVER_PATH_TO_CQPLIB, OSDir.getAbsolutePath());
|
|
75 |
// TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQPLibPreferences.CQI_SERVER_PATH_TO_INIT_FILE, initFile.getAbsolutePath());
|
|
76 |
// TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQPLibPreferences.CQI_SERVER_PATH_TO_EXECUTABLE, execFile.getAbsolutePath());
|
|
77 |
// if (!Util.isWindows()) {
|
|
78 |
// try {
|
|
79 |
// Log.info("Setting execution file rights to: "+OSDir.getAbsolutePath());
|
|
80 |
// Runtime.getRuntime().exec("chmod -R +x "+OSDir.getAbsolutePath()).waitFor();
|
|
81 |
// } catch (Exception e) {
|
|
82 |
// System.out.println("Error while setting execution file rights to: "+OSDir.getAbsolutePath());
|
|
83 |
// e.printStackTrace();
|
|
84 |
// return;
|
|
85 |
// }
|
|
86 |
// }
|
|
87 |
// |
|
88 |
// if (!execFile.exists()) {
|
|
89 |
// System.out.println("Cannot find CQP executable file: "+execFile);
|
|
90 |
// return;
|
|
91 |
// }
|
|
92 |
// |
|
93 |
// if (!execFile.canExecute()) {
|
|
94 |
// System.out.println("File right setting error, cannot execute: "+execFile);
|
|
95 |
// return;
|
|
96 |
// }
|
|
97 |
// |
|
98 |
// Log.warning("SearchEngine preferences set with: "+OSDir.getAbsolutePath()+ ", "+initFile.getAbsolutePath()+ " and "+execFile.getAbsolutePath());
|
|
99 |
// TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQPLibPreferences.VERSION, currentVersion.toString());
|
|
109 | 100 |
} |
110 | 101 |
} |
tmp/org.txm.libs.cqp/src/org/txm/libs/cqp/Activator.java (revision 589) | ||
---|---|---|
1 | 1 |
package org.txm.libs.cqp; |
2 | 2 |
|
3 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
4 | 3 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
5 | 4 |
import org.osgi.framework.BundleContext; |
6 | 5 |
|
... | ... | |
47 | 46 |
public static Activator getDefault() { |
48 | 47 |
return plugin; |
49 | 48 |
} |
50 |
|
|
51 |
/** |
|
52 |
* Returns an image descriptor for the image file at the given |
|
53 |
* plug-in relative path |
|
54 |
* |
|
55 |
* @param path the path |
|
56 |
* @return the image descriptor |
|
57 |
*/ |
|
58 |
public static ImageDescriptor getImageDescriptor(String path) { |
|
59 |
return imageDescriptorFromPlugin(PLUGIN_ID, path); |
|
60 |
} |
|
61 | 49 |
} |
tmp/org.txm.libs.cqp/src/org/txm/libs/cqp/CQPLibPreferences.java (revision 589) | ||
---|---|---|
1 | 1 |
package org.txm.libs.cqp; |
2 | 2 |
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
|
|
3 | 6 |
import org.eclipse.core.runtime.preferences.DefaultScope; |
4 | 7 |
import org.osgi.framework.FrameworkUtil; |
8 |
import org.osgi.framework.Version; |
|
5 | 9 |
import org.osgi.service.prefs.Preferences; |
6 | 10 |
import org.txm.core.messages.TXMCoreMessages; |
7 | 11 |
import org.txm.core.preferences.TBXPreferences; |
8 | 12 |
import org.txm.core.preferences.TXMPreferences; |
13 |
import org.txm.utils.BundleUtils; |
|
9 | 14 |
import org.txm.utils.logger.Log; |
10 | 15 |
|
11 | 16 |
public class CQPLibPreferences extends TXMPreferences { |
... | ... | |
24 | 29 |
/** The Constant CQI_SERVER_PATH_TO_INIT_FILE. */ |
25 | 30 |
public static final String CQI_SERVER_PATH_TO_INIT_FILE = "cqi_server_path_to_init_file"; //$NON-NLS-1$ |
26 | 31 |
|
32 |
/** The Constant CQI_SERVER_HOST. */ |
|
33 |
public static final String CQI_SERVER_HOST = "cqi_server_host"; //$NON-NLS-1$ |
|
34 |
|
|
35 |
/** The Constant CQI_SERVER_PORT. */ |
|
36 |
public static final String CQI_SERVER_PORT = "cqi_server_port"; //$NON-NLS-1$ |
|
37 |
|
|
38 |
/** The Constant CQI_SERVER_LOGIN. */ |
|
39 |
public static final String CQI_SERVER_LOGIN = "cqi_server_login"; //$NON-NLS-1$ |
|
40 |
|
|
41 |
/** The Constant CQI_SERVER_PASSWORD. */ |
|
42 |
public static final String CQI_SERVER_PASSWORD = "cqi_server_password"; //$NON-NLS-1$ |
|
43 |
|
|
44 |
/** The Constant CQI_SERVER_ADDITIONAL_OPTIONS. */ |
|
45 |
public static final String CQI_SERVER_ADDITIONAL_OPTIONS = "cqi_server_additional_options"; //$NON-NLS-1$ |
|
46 |
|
|
47 |
/** The Constant CQI_SERVER_MONITOR_OUTPUT. */ |
|
48 |
public static final String CQI_SERVER_MONITOR_OUTPUT = "cqi_server_monitor_output"; //$NON-NLS-1$ |
|
49 |
|
|
50 |
/** The Constant CQI_SERVER_IS_REMOTE. */ |
|
51 |
public static final String CQI_SERVER_IS_REMOTE = "cqi_server_is_remote"; //$NON-NLS-1$ |
|
52 |
|
|
53 |
/** The Constant CQI_SERVER_MODE. */ |
|
54 |
public static final String CQI_NETWORK_MODE = "cqi_server_mode"; //$NON-NLS-1$ |
|
55 |
|
|
56 |
public static final String CQP_EMPTY_VALUE_CODE = "cqp_empty_value_code"; |
|
57 |
|
|
27 | 58 |
@Override |
28 | 59 |
public void initializeDefaultPreferences() { |
60 |
|
|
61 |
|
|
29 | 62 |
Log.info(TXMCoreMessages.Toolbox_4 + TBXPreferences.getID()); |
30 | 63 |
|
31 | 64 |
Preferences preferences = DefaultScope.INSTANCE.getNode(PREFERENCES_NODE); |
65 |
|
|
66 |
preferences.put(CQI_SERVER_ADDITIONAL_OPTIONS, "-b 1000000 -d OFF"); //$NON-NLS-1$ |
|
67 |
preferences.put(CQI_SERVER_PORT, "4877"); //$NON-NLS-1$ |
|
68 |
preferences.put(CQI_SERVER_HOST, "localhost"); //$NON-NLS-1$ |
|
69 |
preferences.put(CQI_SERVER_LOGIN, "anonymous"); //$NON-NLS-1$ |
|
70 |
preferences.put(CQI_SERVER_PASSWORD, ""); //$NON-NLS-1$ |
|
71 |
preferences.put(CQI_SERVER_IS_REMOTE, "" + false); //$NON-NLS-1$ |
|
72 |
preferences.putBoolean(CQI_NETWORK_MODE, false); //$NON-NLS-1$ |
|
73 |
preferences.put(CQP_EMPTY_VALUE_CODE, ""); //$NON-NLS-1$ |
|
32 | 74 |
|
75 |
String CQPFRAGMENT = "org.txm.libs.cqp."+System.getProperty("osgi.os"); |
|
76 |
//TODO: fix preferneces logic between org.txm.cqp.lib et org.txm.searchengine.cqp |
|
77 |
Log.info("CQP.DoInstallStep.preInstall()"); |
|
78 |
String saved = TXMPreferences.getString(CQPLibPreferences.VERSION, CQPLibPreferences.PREFERENCES_NODE); |
|
79 |
Version currentVersion = BundleUtils.getBundleVersion(CQPFRAGMENT); // the CQPFRAGMENT plugin contains the right version |
|
80 |
|
|
81 |
if (saved != null && saved.length() > 0) { |
|
82 |
Version savedVersion = new Version(saved); |
|
83 |
if (currentVersion.compareTo(savedVersion) <= 0) { |
|
84 |
Log.info("No post-installation of CQP to do"); |
|
85 |
return; // nothing to do |
|
86 |
} |
|
87 |
} |
|
88 |
Log.info("Updating CWB preferences for CQP version="+currentVersion); |
|
89 |
|
|
90 |
String os = "win"; |
|
91 |
String ext = ""; |
|
92 |
String osname = System.getProperty("os.name").toLowerCase(); |
|
93 |
if (osname.contains("windows")) { //$NON-NLS-1$ |
|
94 |
if (System.getProperty("os.arch").contains("64")) { os = "win64"; } |
|
95 |
else { os = "win32"; } |
|
96 |
ext = ".exe"; |
|
97 |
} else if (osname.contains("mac")) { //$NON-NLS-1$ |
|
98 |
os = "macosx"; |
|
99 |
} else { |
|
100 |
os = "linux32"; |
|
101 |
if (System.getProperty("os.arch").contains("64")) |
|
102 |
os = "linux64"; |
|
103 |
} |
|
104 |
|
|
105 |
File bundleDir = BundleUtils.getBundleFile(CQPFRAGMENT); |
|
106 |
if (bundleDir == null) { |
|
107 |
System.out.println("Error while retrieving "+CQPFRAGMENT+" bundle directory."); |
|
108 |
return; |
|
109 |
} |
|
110 |
File cwbDir = new File(bundleDir, "res"); |
|
111 |
File initFile = new File(cwbDir, "cqpserver.init"); |
|
112 |
File OSDir = new File(cwbDir, os); |
|
113 |
|
|
114 |
int n; |
|
115 |
try { // extract all gz files |
|
116 |
n = Utils.unGzipFilesInDirectory(OSDir); |
|
117 |
|
|
118 |
if (n == 0) { |
|
119 |
System.out.println("Error while extracting CQP files: no file extracted."); |
|
120 |
return; |
|
121 |
} |
|
122 |
} catch (IOException e1) { |
|
123 |
System.out.println("Error while extracting CQP files: "+e1); |
|
124 |
return; |
|
125 |
} |
|
126 |
|
|
127 |
File execFile = new File(OSDir, "cqpserver"+ext); |
|
128 |
preferences.put(CQI_SERVER_PATH_TO_CQPLIB, OSDir.getAbsolutePath()); |
|
129 |
preferences.put(CQI_SERVER_PATH_TO_INIT_FILE, initFile.getAbsolutePath()); |
|
130 |
preferences.put(CQI_SERVER_PATH_TO_EXECUTABLE, execFile.getAbsolutePath()); |
|
131 |
|
|
132 |
if (!osname.contains("windows")) { |
|
133 |
try { |
|
134 |
Log.info("Setting execution file rights to: "+OSDir.getAbsolutePath()); |
|
135 |
Runtime.getRuntime().exec("chmod -R +x "+OSDir.getAbsolutePath()).waitFor(); |
|
136 |
} catch (Exception e) { |
|
137 |
System.out.println("Error while setting execution file rights to: "+OSDir.getAbsolutePath()); |
|
138 |
e.printStackTrace(); |
|
139 |
return; |
|
140 |
} |
|
141 |
} |
|
142 |
|
|
143 |
if (!execFile.exists()) { |
|
144 |
System.out.println("Cannot find CQP executable file: "+execFile); |
|
145 |
return; |
|
146 |
} |
|
147 |
|
|
148 |
if (!execFile.canExecute()) { |
|
149 |
System.out.println("File right setting error, cannot execute: "+execFile); |
|
150 |
return; |
|
151 |
} |
|
152 |
|
|
153 |
Log.warning("SearchEngine preferences set with: "+OSDir.getAbsolutePath()+ ", "+initFile.getAbsolutePath()+ " and "+execFile.getAbsolutePath()); |
|
154 |
TXMPreferences.put(CQPLibPreferences.PREFERENCES_NODE, CQPLibPreferences.VERSION, currentVersion.toString()); |
|
155 |
|
|
156 |
|
|
157 |
|
|
33 | 158 |
} |
34 | 159 |
} |
tmp/org.txm.core/plugin.xml (revision 589) | ||
---|---|---|
9 | 9 |
<initializer |
10 | 10 |
class="org.txm.core.preferences.TBXPreferences"> |
11 | 11 |
</initializer> |
12 |
<scope |
|
13 |
class="org.txm.objects.BasePreferenceScope" |
|
14 |
name="binarycorpus"> |
|
15 |
</scope> |
|
16 | 12 |
</extension> |
17 | 13 |
|
18 | 14 |
</plugin> |
tmp/org.txm.core/META-INF/MANIFEST.MF (revision 589) | ||
---|---|---|
12 | 12 |
org.eclipse.osgi;visibility:=reexport, |
13 | 13 |
org.eclipse.ui.workbench;visibility:=reexport, |
14 | 14 |
org.eclipse.core.commands;visibility:=reexport, |
15 |
org.eclipse.core.resources |
|
15 |
org.eclipse.core.resources;visibility:=reexport
|
|
16 | 16 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 |
17 | 17 |
Export-Package: EDU.oswego.cs.dl.util.concurrent, |
18 | 18 |
EDU.oswego.cs.dl.util.concurrent.misc, |
tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 589) | ||
---|---|---|
997 | 997 |
*/ |
998 | 998 |
public static String findNodeQualifier(String nodeQualifier, TXMResult result, String key) { |
999 | 999 |
|
1000 |
if (result == null) return nodeQualifier; |
|
1001 |
|
|
1000 | 1002 |
boolean keyExists = (result != null && resultScopeKeyExists(result, key)); |
1001 | 1003 |
|
1002 | 1004 |
// get the result scope preference |
tmp/org.txm.core/src/java/org/txm/utils/BundleUtils.java (revision 589) | ||
---|---|---|
21 | 21 |
public static Version getBundleVersion(String bundle_id) { |
22 | 22 |
Bundle bundle = Platform.getBundle(bundle_id); |
23 | 23 |
if (bundle == null) { |
24 |
System.out.println("Error while initializing Oriflamms plugin: bundle not found.");
|
|
24 |
System.out.println("Error while initializing "+bundle_id+" plugin: bundle not found.");
|
|
25 | 25 |
return null; |
26 | 26 |
} |
27 | 27 |
return bundle.getVersion(); |
tmp/org.txm.libs.cqp.linux/META-INF/MANIFEST.MF (revision 589) | ||
---|---|---|
3 | 3 |
Bundle-Name: CQP.linux |
4 | 4 |
Bundle-SymbolicName: org.txm.libs.cqp.linux |
5 | 5 |
Bundle-Version: 1.1.0.qualifier |
6 |
Fragment-Host: org.txm.libs.cqp;bundle-version="1.0.0.qualifier"
|
|
6 |
Fragment-Host: org.txm.libs.cqp |
|
7 | 7 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 |
8 | 8 |
Bundle-Vendor: Textometrie.org |
9 | 9 |
Eclipse-PlatformFilter: (osgi.os=linux) |
tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/preferences/CQPPreferencePage.java (revision 589) | ||
---|---|---|
37 | 37 |
import org.eclipse.jface.util.PropertyChangeEvent; |
38 | 38 |
import org.eclipse.ui.IWorkbench; |
39 | 39 |
import org.osgi.service.prefs.Preferences; |
40 |
import org.txm.libs.cqp.CQPLibPreferences; |
|
40 | 41 |
import org.txm.rcp.Application; |
41 | 42 |
import org.txm.rcp.preferences.TXMPreferencePage; |
42 | 43 |
import org.txm.rcp.preferences.TXMPreferenceStore; |
... | ... | |
103 | 104 |
@Override |
104 | 105 |
public void createFieldEditors() { |
105 | 106 |
|
106 |
cqi_use_network = new BooleanFieldEditor(CQPPreferences.CQI_NETWORK_MODE, |
|
107 |
cqi_use_network = new BooleanFieldEditor(CQPLibPreferences.CQI_NETWORK_MODE,
|
|
107 | 108 |
Messages.CQPPreferencePage_1, |
108 | 109 |
BooleanFieldEditor.DEFAULT, getFieldEditorParent()); |
109 | 110 |
cqi_server_path_to_cqplib = new DirectoryFieldEditor( |
110 |
CQPPreferences.CQI_SERVER_PATH_TO_CQPLIB, Messages.CQPPreferencePage_0, |
|
111 |
CQPLibPreferences.CQI_SERVER_PATH_TO_CQPLIB, Messages.CQPPreferencePage_0,
|
|
111 | 112 |
getFieldEditorParent()); |
112 |
cqi_server_is_remote = new BooleanFieldEditor(CQPPreferences.CQI_SERVER_IS_REMOTE, |
|
113 |
cqi_server_is_remote = new BooleanFieldEditor(CQPLibPreferences.CQI_SERVER_IS_REMOTE,
|
|
113 | 114 |
Messages.CQPPreferencePage_10, |
114 | 115 |
BooleanFieldEditor.DEFAULT, getFieldEditorParent()); |
115 |
cqi_server_host = new StringFieldEditor(CQPPreferences.CQI_SERVER_HOST, |
|
116 |
cqi_server_host = new StringFieldEditor(CQPLibPreferences.CQI_SERVER_HOST,
|
|
116 | 117 |
Messages.CQPPreferencePage_11, getFieldEditorParent()); |
117 | 118 |
|
118 |
cqi_server_port = new IntegerFieldEditor(CQPPreferences.CQI_SERVER_PORT, |
|
119 |
cqi_server_port = new IntegerFieldEditor(CQPLibPreferences.CQI_SERVER_PORT,
|
|
119 | 120 |
Messages.CQPPreferencePage_12, getFieldEditorParent()); |
120 | 121 |
|
121 |
cqi_server_user = new StringFieldEditor(CQPPreferences.CQI_SERVER_LOGIN, |
|
122 |
cqi_server_user = new StringFieldEditor(CQPLibPreferences.CQI_SERVER_LOGIN,
|
|
122 | 123 |
Messages.CQPPreferencePage_13, getFieldEditorParent()); |
123 | 124 |
|
124 |
cqi_server_password = new StringFieldEditor(CQPPreferences.CQI_SERVER_PASSWORD, |
|
125 |
cqi_server_password = new StringFieldEditor(CQPLibPreferences.CQI_SERVER_PASSWORD,
|
|
125 | 126 |
Messages.CQPPreferencePage_14, getFieldEditorParent()); |
126 | 127 |
|
127 | 128 |
cqi_server_path_to_executable = new FileFieldEditor( |
128 |
CQPPreferences.CQI_SERVER_PATH_TO_EXECUTABLE, Messages.CQPPreferencePage_15, |
|
129 |
CQPLibPreferences.CQI_SERVER_PATH_TO_EXECUTABLE, Messages.CQPPreferencePage_15,
|
|
129 | 130 |
getFieldEditorParent()); |
130 | 131 |
|
131 | 132 |
// cqi_server_path_to_registry = new DirectoryFieldEditor( |
132 | 133 |
// CQI_SERVER_PATH_TO_REGISTRY, Messages.CQPPreferencePage_16, |
133 | 134 |
// getFieldEditorParent()); |
134 | 135 |
cqi_server_path_to_init_file = new FileFieldEditor( |
135 |
CQPPreferences.CQI_SERVER_PATH_TO_INIT_FILE, Messages.CQPPreferencePage_17, |
|
136 |
CQPLibPreferences.CQI_SERVER_PATH_TO_INIT_FILE, Messages.CQPPreferencePage_17,
|
|
136 | 137 |
getFieldEditorParent()); |
137 | 138 |
cqi_server_additional_options = new StringFieldEditor( |
138 |
CQPPreferences.CQI_SERVER_ADDITIONAL_OPTIONS, Messages.CQPPreferencePage_18, |
|
139 |
CQPLibPreferences.CQI_SERVER_ADDITIONAL_OPTIONS, Messages.CQPPreferencePage_18,
|
|
139 | 140 |
getFieldEditorParent()); |
140 | 141 |
|
141 | 142 |
addField(cqi_use_network); |
... | ... | |
152 | 153 |
|
153 | 154 |
Preferences preferences = org.eclipse.core.runtime.preferences.InstanceScope.INSTANCE.getNode(Application.PLUGIN_ID); |
154 | 155 |
boolean useNetwork = preferences.getBoolean( |
155 |
CQPPreferences.CQI_NETWORK_MODE, |
|
156 |
CQPLibPreferences.CQI_NETWORK_MODE,
|
|
156 | 157 |
false); |
157 | 158 |
boolean serverIsRemote = preferences.getBoolean( |
158 |
CQPPreferences.CQI_SERVER_IS_REMOTE, |
|
159 |
CQPLibPreferences.CQI_SERVER_IS_REMOTE,
|
|
159 | 160 |
false); |
160 | 161 |
updateFieldsState(useNetwork, serverIsRemote); |
161 | 162 |
} |
... | ... | |
211 | 212 |
*/ |
212 | 213 |
@Override |
213 | 214 |
public void init(IWorkbench workbench) { |
214 |
this.setPreferenceStore(new TXMPreferenceStore(CQPPreferences.PREFERENCES_NODE)); |
|
215 |
this.setPreferenceStore(new TXMPreferenceStore(CQPLibPreferences.PREFERENCES_NODE));
|
|
215 | 216 |
} |
216 | 217 |
|
217 | 218 |
/* (non-Javadoc) |
... | ... | |
223 | 224 |
boolean serverIsRemote = false; |
224 | 225 |
boolean update = false; |
225 | 226 |
if (((FieldEditor) event.getSource()).getPreferenceName().equals( |
226 |
CQPPreferences.CQI_SERVER_IS_REMOTE)) { |
|
227 |
CQPLibPreferences.CQI_SERVER_IS_REMOTE)) {
|
|
227 | 228 |
useNetwork = cqi_use_network.getBooleanValue(); |
228 | 229 |
serverIsRemote = (Boolean) event.getNewValue(); |
229 | 230 |
update = true; |
230 | 231 |
} else if (((FieldEditor) event.getSource()).getPreferenceName().equals( |
231 |
CQPPreferences.CQI_NETWORK_MODE)) { |
|
232 |
CQPLibPreferences.CQI_NETWORK_MODE)) {
|
|
232 | 233 |
useNetwork = (Boolean) event.getNewValue(); |
233 | 234 |
serverIsRemote = cqi_server_is_remote.getBooleanValue(); |
234 | 235 |
update = true; |
tmp/org.txm.statsengine.core/.classpath (revision 589) | ||
---|---|---|
3 | 3 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> |
4 | 4 |
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> |
5 | 5 |
<classpathentry kind="src" path="src"/> |
6 |
<classpathentry kind="src" path="res"/> |
|
6 | 7 |
<classpathentry kind="output" path="bin"/> |
7 | 8 |
</classpath> |
Formats disponibles : Unified diff