29 |
29 |
import org.txm.chartsengine.r.core.themes.DefaultTheme;
|
30 |
30 |
import org.txm.chartsengine.rcp.editors.ChartEditor;
|
31 |
31 |
import org.txm.core.results.Parameter;
|
|
32 |
import org.txm.core.results.TXMResult;
|
32 |
33 |
import org.txm.progression.core.functions.Progression;
|
33 |
34 |
import org.txm.progression.core.preferences.ProgressionPreferences;
|
34 |
35 |
import org.txm.progression.rcp.messages.ProgressionUIMessages;
|
... | ... | |
97 |
98 |
* Queries.
|
98 |
99 |
*/
|
99 |
100 |
@Parameter(key=ProgressionPreferences.QUERIES)
|
100 |
|
protected List<Query> queries;
|
|
101 |
protected List<Query> queryList;
|
101 |
102 |
|
102 |
103 |
/**
|
103 |
104 |
* Structural unit.
|
... | ... | |
195 |
196 |
@Override
|
196 |
197 |
public void keyPressed(KeyEvent e) {
|
197 |
198 |
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
|
198 |
|
onPlusButtonPressed(null, queryWidget.getQueryString());
|
199 |
|
super.keyPressed(e);
|
|
199 |
if (onPlusButtonPressed(null, queryWidget.getRawString())) {
|
|
200 |
super.keyPressed(e); // recompute only if the query has been added
|
|
201 |
}
|
200 |
202 |
}
|
201 |
203 |
}
|
202 |
204 |
});
|
... | ... | |
331 |
333 |
String path = dialog.open();
|
332 |
334 |
if (path != null) {
|
333 |
335 |
Properties props = new Properties();
|
|
336 |
int count = 0;
|
334 |
337 |
try {
|
335 |
338 |
props.load(IOUtils.getReader(new File(path)));
|
336 |
339 |
for (Object k : props.keySet()) {
|
337 |
|
onPlusButtonPressed(event, props.get(k).toString());
|
|
340 |
if (onPlusButtonPressed(event, props.get(k).toString())) {
|
|
341 |
count++;
|
|
342 |
}
|
338 |
343 |
}
|
339 |
344 |
} catch (Exception e) {
|
340 |
345 |
// TODO Auto-generated catch block
|
341 |
346 |
e.printStackTrace();
|
342 |
347 |
}
|
|
348 |
if (count > 0) {
|
|
349 |
compute(true);
|
|
350 |
}
|
343 |
351 |
}
|
344 |
352 |
}
|
345 |
353 |
});
|
... | ... | |
347 |
355 |
} catch (Exception e) {
|
348 |
356 |
Log.printStackTrace(e);
|
349 |
357 |
}
|
350 |
|
|
351 |
|
|
352 |
358 |
}
|
353 |
359 |
|
354 |
|
public void onPlusButtonPressed(Event event, String defaultValue) {
|
|
360 |
public boolean onPlusButtonPressed(Event event, String defaultValue) {
|
355 |
361 |
if (colors.length > queryWidgets.size()) {
|
356 |
362 |
Log.info("add query field");
|
357 |
|
QueryField qf = addFocusQueryField();
|
358 |
|
if (qf != null) qf.setQuery(defaultValue);
|
|
363 |
|
|
364 |
QueryField qf = addFocusQueryField(defaultValue);
|
359 |
365 |
sc1.layout(true);
|
360 |
366 |
queriesFocusComposite.layout(true);
|
361 |
367 |
sc1.setMinSize(queriesFocusComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
|
368 |
|
|
369 |
return qf != null;
|
362 |
370 |
}
|
|
371 |
|
|
372 |
return false;
|
363 |
373 |
}
|
364 |
374 |
|
365 |
375 |
|
... | ... | |
372 |
382 |
|
373 |
383 |
protected AssistedQueryWidget focusTextBox;
|
374 |
384 |
|
375 |
|
protected TXMEditor editor;
|
|
385 |
protected TXMEditor<? extends TXMResult> editor;
|
376 |
386 |
|
377 |
387 |
/**
|
378 |
388 |
*
|
... | ... | |
428 |
438 |
public void memorize() {
|
429 |
439 |
focusTextBox.memorize();
|
430 |
440 |
}
|
|
441 |
|
|
442 |
public String getRawString() {
|
|
443 |
return focusTextBox.getRawString();
|
|
444 |
}
|
431 |
445 |
}
|
432 |
446 |
|
433 |
447 |
/**
|
... | ... | |
440 |
454 |
// do not add same query twice
|
441 |
455 |
if (initialQuery != null && initialQuery.length() > 0) { // test only if the initial query is set
|
442 |
456 |
for (int i = 0; i < queryWidgets.size(); i++) {
|
443 |
|
|
444 |
|
if (queryWidgets.get(i).getQuery().getQueryString().equals(initialQuery)) {
|
|
457 |
String existing = queryWidgets.get(i).getRawString();
|
|
458 |
if (existing.equals(initialQuery)) {
|
445 |
459 |
System.out.println("The query already exists: " + initialQuery);
|
446 |
460 |
return null;
|
447 |
461 |
}
|
... | ... | |
473 |
487 |
public void updateEditorFromChart(boolean update) {
|
474 |
488 |
|
475 |
489 |
// create the queries fields
|
476 |
|
if (queries == null) {
|
477 |
|
//addFocusQueryField();
|
478 |
|
}
|
479 |
|
else {
|
480 |
|
for (Query q : queries) {
|
|
490 |
// if (queryList == null) {
|
|
491 |
// //addFocusQueryField();
|
|
492 |
// }
|
|
493 |
if (queryWidgets.size() == 0 && queryList != null) { // initialize query fields
|
|
494 |
for (Query q : queryList) {
|
481 |
495 |
addFocusQueryField(q.getQueryString());
|
482 |
496 |
}
|
483 |
497 |
}
|
... | ... | |
493 |
507 |
@Override
|
494 |
508 |
public void updateResultFromEditor() {
|
495 |
509 |
|
496 |
|
queries = new ArrayList<Query>();
|
|
510 |
queryList = new ArrayList<Query>();
|
497 |
511 |
for (QueryField wid : queryWidgets) {
|
498 |
512 |
if (!wid.getQuery().isEmpty()) { //$NON-NLS-1$
|
499 |
|
queries.add(wid.getQuery());
|
|
513 |
queryList.add(wid.getQuery());
|
500 |
514 |
wid.memorize();
|
501 |
515 |
}
|
502 |
516 |
}
|