Révision 614
tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 614) | ||
---|---|---|
10 | 10 |
import java.io.StringWriter; |
11 | 11 |
import java.util.ArrayList; |
12 | 12 |
import java.util.Arrays; |
13 |
import java.util.HashMap; |
|
13 | 14 |
import java.util.Iterator; |
14 | 15 |
import java.util.Set; |
15 | 16 |
|
... | ... | |
891 | 892 |
return getKeys(DefaultScope.INSTANCE, nodeQualifier); |
892 | 893 |
} |
893 | 894 |
|
895 |
public static HashMap<String, Object> getKeysAndValuesAsMap(IScopeContext scope, String nodeQualifier) { |
|
896 |
|
|
897 |
HashMap<String, Object> str = new HashMap<String, Object>(); |
|
898 |
|
|
899 |
IEclipsePreferences preferences = scope.getNode(nodeQualifier); |
|
900 |
|
|
901 |
try { |
|
902 |
String[] keys = preferences.keys(); |
|
903 |
Arrays.sort(keys); |
|
904 |
for(int i = 0; i < keys.length; i++) { |
|
905 |
str.put(keys[i],preferences.get(keys[i], "")); |
|
906 |
} |
|
907 |
} |
|
908 |
catch(BackingStoreException e) { |
|
909 |
// TODO Auto-generated catch block |
|
910 |
e.printStackTrace(); |
|
911 |
} |
|
912 |
|
|
913 |
return str; |
|
914 |
} |
|
894 | 915 |
|
895 |
|
|
896 | 916 |
public static String getKeysAndValues(IScopeContext scope, String nodeQualifier) { |
897 | 917 |
|
898 | 918 |
StringBuilder str = new StringBuilder(); |
... | ... | |
914 | 934 |
} |
915 | 935 |
|
916 | 936 |
return str.toString(); |
917 |
|
|
918 | 937 |
} |
919 | 938 |
|
920 | 939 |
|
tmp/org.txm.core/src/java/org/txm/core/results/Parameter.java (revision 614) | ||
---|---|---|
41 | 41 |
* @return |
42 | 42 |
*/ |
43 | 43 |
public int type() default Parameter.COMPUTING; |
44 |
|
|
45 | 44 |
} |
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 614) | ||
---|---|---|
237 | 237 |
|
238 | 238 |
} |
239 | 239 |
|
240 |
|
|
241 |
// FIXME: not used? |
|
242 | 240 |
public HashMap<String, Object> getLastParameters() { |
243 | 241 |
return lastParameters; |
244 | 242 |
} |
243 |
|
|
244 |
// FIXME: not used? |
|
245 |
public String htmlDumpLastParameters() { |
|
246 |
StringBuilder builder = new StringBuilder(); |
|
247 |
builder.append("<h4>Last compute parameters</h4>"); |
|
248 |
|
|
249 |
if (lastParameters.keySet().size() == 0) { |
|
250 |
builder.append("<p>not computed yet.</p>"); |
|
251 |
} else { |
|
252 |
builder.append("<ul>\n"); |
|
253 |
for (String k : lastParameters.keySet()) { |
|
254 |
builder.append("<li>"+k+" = "+lastParameters.get(k)+"</li>\n"); |
|
255 |
} |
|
256 |
builder.append("<ul>\n"); |
|
257 |
} |
|
258 |
|
|
259 |
|
|
260 |
|
|
261 |
return builder.toString(); |
|
262 |
} |
|
245 | 263 |
|
246 | 264 |
|
247 | 265 |
|
... | ... | |
315 | 333 |
|
316 | 334 |
return str.toString(); |
317 | 335 |
} |
336 |
|
|
337 |
/** |
|
338 |
* Dumps the command and default preferences of the result preferences node qualifier. |
|
339 |
* @return |
|
340 |
*/ |
|
341 |
public String htmlDumpPreferences() { |
|
318 | 342 |
|
343 |
StringBuilder str = new StringBuilder(); |
|
344 |
|
|
345 |
str.append("<h4>"+this.getClass().getSimpleName()+" command preferences</h4>\n"); //$NON-NLS-1$ |
|
346 |
str.append("<ul>\n"); //$NON-NLS-1$ |
|
347 |
HashMap<String, Object> map = TXMPreferences.getKeysAndValuesAsMap(TXMPreferences.scope, this.preferencesNodeQualifier); |
|
348 |
for (String k : map.keySet()) { |
|
349 |
str.append("<li>"+k+" = "+map.get(k)+"</li>\n"); |
|
350 |
} |
|
351 |
str.append("</ul>\n"); //$NON-NLS-1$ |
|
352 |
|
|
353 |
str.append("\n<h4>"+this.getClass().getSimpleName()+" command default preferences</h4>\n"); //$NON-NLS-1$ |
|
354 |
str.append("<ul>\n"); //$NON-NLS-1$ |
|
355 |
map = TXMPreferences.getKeysAndValuesAsMap(DefaultScope.INSTANCE, this.preferencesNodeQualifier); |
|
356 |
for (String k : map.keySet()) { |
|
357 |
str.append("<li>"+k+" = "+map.get(k)+"</li>\n"); |
|
358 |
} |
|
359 |
str.append("</ul>\n"); //$NON-NLS-1$ |
|
360 |
|
|
361 |
return str.toString(); |
|
362 |
} |
|
363 |
|
|
319 | 364 |
/** |
320 | 365 |
* Dumps the result computing parameters (Parameter annotation). |
321 | 366 |
* @return |
322 | 367 |
*/ |
323 | 368 |
public String dumpParameters() { |
324 |
return this.dumpParameters(Parameter.COMPUTING);
|
|
369 |
return this.dumpParameters(null, false);
|
|
325 | 370 |
} |
326 |
|
|
327 | 371 |
|
328 | 372 |
/** |
373 |
* Dumps the result computing parameters (Parameter annotation). |
|
374 |
* @return |
|
375 |
*/ |
|
376 |
public String htmlDumpParameters() { |
|
377 |
return this.dumpParameters(null, true); |
|
378 |
} |
|
379 |
|
|
380 |
/** |
|
329 | 381 |
* Dumps the result parameters (Parameter annotation) of the specified type. |
330 | 382 |
* @param parametersType |
331 | 383 |
* @return |
332 | 384 |
*/ |
333 |
public String dumpParameters(int parametersType) {
|
|
385 |
public String dumpParameters(Integer parametersType, boolean html) {
|
|
334 | 386 |
|
335 | 387 |
StringBuilder str = new StringBuilder(); |
336 |
|
|
337 |
str.append("Parameters (type = " + parametersType + " / " + Parameter.types[parametersType] + ")\n"); //$NON-NLS-1$ |
|
338 |
|
|
388 |
if (html) str.append("<h4>"); |
|
389 |
str.append("Current parameters"); |
|
390 |
if (parametersType != null) { |
|
391 |
str.append(" (type = " + parametersType + " / " + Parameter.types[parametersType] + ")\n"); //$NON-NLS-1$ |
|
392 |
} |
|
393 |
if (html) str.append("</h4>"); |
|
394 |
|
|
339 | 395 |
List<Field> fields = new ArrayList<Field>(); |
340 | 396 |
Class<?> clazz = this.getClass(); |
341 | 397 |
while (clazz != Object.class) { |
... | ... | |
343 | 399 |
clazz = clazz.getSuperclass(); |
344 | 400 |
} |
345 | 401 |
|
402 |
if (html) str.append("<ul>"); |
|
346 | 403 |
for (Field f : fields) { |
347 | 404 |
Parameter parameter = f.getAnnotation(Parameter.class); |
348 |
if (parameter == null || parameter.type() != parametersType) {
|
|
405 |
if (parameter == null) { |
|
349 | 406 |
continue; |
350 | 407 |
} |
408 |
if (parametersType != null && parameter.type() != parametersType) { |
|
409 |
continue; |
|
410 |
} |
|
351 | 411 |
f.setAccessible(true); |
352 | 412 |
|
413 |
String key = parameter.key(); |
|
414 |
if (key == null) continue; |
|
415 |
|
|
353 | 416 |
String name; |
354 |
if(!parameter.key().isEmpty()) {
|
|
417 |
if(!key.isEmpty()) {
|
|
355 | 418 |
name = parameter.key(); |
356 | 419 |
} |
357 | 420 |
else { |
358 | 421 |
name = f.getName(); |
359 | 422 |
} |
360 |
|
|
423 |
int type = parameter.type(); |
|
361 | 424 |
try { |
362 |
str.append(name + " = " + f.get(this) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
425 |
if (html) str.append("<li>"); |
|
426 |
str.append(name + "("+Parameter.types[type]+") = " + f.get(this) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
427 |
if (html) str.append("</li>"); |
|
363 | 428 |
} |
364 |
catch (IllegalArgumentException e) {
|
|
429 |
catch (Exception e) { |
|
365 | 430 |
// TODO Auto-generated catch block |
366 | 431 |
e.printStackTrace(); |
367 | 432 |
} |
368 |
catch (IllegalAccessException e) { |
|
369 |
// TODO Auto-generated catch block |
|
370 |
e.printStackTrace(); |
|
371 |
} |
|
372 | 433 |
} |
434 |
if (html) str.append("</ul>"); |
|
373 | 435 |
return str.toString(); |
374 | 436 |
} |
375 | 437 |
|
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/cmdparameters/ParametersView.java (revision 614) | ||
---|---|---|
27 | 27 |
// |
28 | 28 |
package org.txm.rcp.views.cmdparameters; |
29 | 29 |
|
30 |
import java.util.Arrays; |
|
31 |
|
|
32 |
import org.apache.commons.lang.ArrayUtils; |
|
33 | 30 |
import org.eclipse.swt.SWT; |
31 |
import org.eclipse.swt.browser.Browser; |
|
34 | 32 |
import org.eclipse.swt.widgets.Composite; |
35 | 33 |
import org.eclipse.swt.widgets.Label; |
36 | 34 |
import org.eclipse.ui.IPartListener; |
... | ... | |
50 | 48 |
*/ |
51 | 49 |
public class ParametersView extends ViewPart implements IPartListener { |
52 | 50 |
|
53 |
Label currentEditorLabel;
|
|
51 |
Browser currentEditorLabel;
|
|
54 | 52 |
|
55 | 53 |
/** The ID. */ |
56 | 54 |
public static String ID = ParametersView.class.getName(); //$NON-NLS-1$ |
... | ... | |
89 | 87 |
if (editor instanceof TXMEditorPart) { |
90 | 88 |
TXMEditorPart reditor = (TXMEditorPart)editor; |
91 | 89 |
StringBuffer buffer = new StringBuffer(); |
90 |
|
|
92 | 91 |
TXMResult result = reditor.getResultData(); |
93 |
buffer.append("Result: " + result.toString() + "\n"); |
|
94 |
buffer.append("UUID: " + result.getUUID() + "\n"); |
|
95 |
buffer.append("Simple name: " + result.getSimpleName() + "\n"); |
|
96 |
buffer.append("Name: " + result.getName() + "\n"); |
|
97 |
buffer.append("Valid filename: " + result.getValidFileName() + "\n"); |
|
98 |
buffer.append("Details: " + result.getDetails() + "\n\n"); |
|
99 |
|
|
92 |
buffer.append("<h4>"+result.getClass().getSimpleName()+" details</h4>"); |
|
93 |
buffer.append("<p><ul>"); |
|
94 |
buffer.append("<li>Result: <br/>" + result.toString() + "</li>\n"); |
|
95 |
buffer.append("<li>UUID: <br/>" + result.getUUID() + "</li>\n"); |
|
96 |
buffer.append("<li>Simple name: <br/>" + result.getSimpleName() + "</li>\n"); |
|
97 |
buffer.append("<li>Name: <br/>" + result.getName() + "</li>\n"); |
|
98 |
buffer.append("<li>Valid filename: <br/>" + result.getValidFileName() + "</li>\n"); |
|
99 |
buffer.append("<li>Compute details: <br/>" + result.getDetails() + "</li>\n\n"); |
|
100 |
buffer.append("</ul></p>"); |
|
100 | 101 |
|
101 | 102 |
try { |
102 | 103 |
// Command preferences |
103 |
buffer.append(result.dumpPreferences()); |
|
104 |
buffer.append("\n"); |
|
104 |
buffer.append(result.htmlDumpPreferences()); |
|
105 | 105 |
|
106 | 106 |
// Object parameters |
107 |
buffer.append(result.dumpParameters());
|
|
107 |
buffer.append(result.htmlDumpParameters());
|
|
108 | 108 |
|
109 |
// Object parameters |
|
110 |
buffer.append(result.htmlDumpLastParameters()); |
|
109 | 111 |
|
110 | 112 |
} |
111 |
catch(Exception e) { |
|
112 |
System.out.println("Error: "+e.getLocalizedMessage()); |
|
113 |
catch (Exception e) { |
|
114 |
System.out.println("Error: "+e); |
|
115 |
e.printStackTrace(); |
|
113 | 116 |
} |
114 | 117 |
|
115 | 118 |
|
... | ... | |
147 | 150 |
@Override |
148 | 151 |
public void createPartControl(Composite parent) { |
149 | 152 |
System.out.println("createPartControl: "+parent); |
150 |
currentEditorLabel = new Label(parent, SWT.NONE);
|
|
153 |
currentEditorLabel = new Browser(parent, SWT.NONE);
|
|
151 | 154 |
updateEditorParameters(); |
152 | 155 |
} |
153 | 156 |
|
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/results/ChartResult.java (revision 614) | ||
---|---|---|
188 | 188 |
return false; |
189 | 189 |
} |
190 | 190 |
|
191 |
|
|
192 |
@Override |
|
193 |
public String dumpParameters() { |
|
194 |
return super.dumpParameters() + "\n" + this.dumpParameters(Parameter.RENDERING); |
|
195 |
} |
|
196 |
|
|
197 | 191 |
/** |
198 | 192 |
* Updates the parameters used for last rendering. |
199 | 193 |
* |
Formats disponibles : Unified diff