Revision 2627

tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/AdvancedChartEditorToolBar.java (revision 2627)
251 251
				getEditorPart().getResult().setChartDirty();
252 252
				getEditorPart().setDirty(true);
253 253
				
254
				if (RCPPreferences.getInstance().getBoolean(RCPPreferences.AUTO_UPDATE_EDITOR)) {
254
				// Auto-compute only for some of the widgets, not all
255
				if (RCPPreferences.getInstance().getBoolean(RCPPreferences.AUTO_UPDATE_EDITOR)
256
						|| e.getSource() == showTitleButton
257
						|| e.getSource() == showLegendButton
258
						|| e.getSource() == showGridButton
259
						|| e.getSource() == renderingModeCombo
260
						|| e.getSource() == fontSizeCombo) {
255 261
					// updates or creates chart
256 262
					getEditorPart().compute(update);
257 263
					getEditorPart().setFocus();
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/editors/ProgressionEditor.java (revision 2627)
51 51

  
52 52
/**
53 53
 * Progression command chart editor.
54
 * 
54 55
 * @author sjacquot
55 56
 *
56 57
 */
57 58
public class ProgressionEditor extends ChartEditor<Progression> {
58

  
59
	
59 60
	/** The query widgets. */
60
	protected List<QueryField> queryWidgets = new ArrayList<QueryField>();
61

  
61
	protected List<QueryField> queryWidgets = new ArrayList<>();
62
	
62 63
	/** The chart type. */
63 64
	private boolean cumulative = true;
64

  
65
	
65 66
	/** The linewidth. */
66 67
	private int lineWidth = 2;
67

  
68
	
68 69
	/** The focus composite. */
69 70
	Composite queriesFocusComposite;
70

  
71
	
71 72
	/** The main panel. */
72 73
	Composite mainPanel;
73

  
74
	
74 75
	/** The bande field. */
75 76
	Text bandeField;
76

  
77
	
77 78
	/** The cumu button. */
78 79
	Button cumulativeButton;
79

  
80
	
80 81
	/** The colors. */
81 82
	String[] colors = DefaultTheme.colors;
82

  
83

  
83
	
84
	
84 85
	private ScrolledComposite sc1;
85

  
86
	
86 87
	private Button densityButton;
87

  
88
	
88 89
	private AssistedQueryWidget queryWidget;
89

  
90
	
90 91
	private Label miniInfoLabel;
91

  
92

  
93

  
92
	
93
	
94
	
94 95
	/**
95 96
	 * Queries.
96 97
	 */
97
	@Parameter(key=TXMPreferences.QUERIES)
98
	@Parameter(key = TXMPreferences.QUERIES)
98 99
	protected List<CQLQuery> queryList;
99

  
100
	
100 101
	/**
101 102
	 * Structural unit.
102 103
	 */
103
	@Parameter(key=TXMPreferences.STRUCTURAL_UNIT)
104
	@Parameter(key = TXMPreferences.STRUCTURAL_UNIT)
104 105
	protected StructuralUnitsComboViewer structuralUnitsComboViewer;
105

  
106
	
106 107
	/**
107 108
	 * Structural unit property.
108 109
	 */
109
	@Parameter(key=TXMPreferences.STRUCTURAL_UNIT_PROPERTY)
110
	@Parameter(key = TXMPreferences.STRUCTURAL_UNIT_PROPERTY)
110 111
	protected StructuralUnitPropertiesComboViewer structuralUnitPropertiesComboViewer;
111

  
112
	
112 113
	/**
113 114
	 * Property REGEX.
114 115
	 */
115
	@Parameter(key=ProgressionPreferences.PROPERTY_REGEX)
116
	@Parameter(key = ProgressionPreferences.PROPERTY_REGEX)
116 117
	protected Text propertyRegex;
117

  
118
	
118 119
	/**
119 120
	 * Multiple line styles.
120 121
	 */
121
	@Parameter(key=ChartsEnginePreferences.MULTIPLE_LINE_STROKES)
122
	@Parameter(key = ChartsEnginePreferences.MULTIPLE_LINE_STROKES)
122 123
	protected Button multipleLineStrokes;
123

  
124
	
124 125
	/**
125 126
	 * Repeats or not the same value when displaying the section markers.
126 127
	 */
127
	@Parameter(key=ProgressionPreferences.REPEAT_SAME_VALUES)
128
	@Parameter(key = ProgressionPreferences.REPEAT_SAME_VALUES)
128 129
	protected Button repeatSameValues;
129

  
130

  
131

  
132

  
133

  
130
	
131
	
132
	
133
	
134
	
134 135
	@Override
135 136
	public void __createPartControl() {
136

  
137

  
137
		
138
		
138 139
		// FIXME: tests to use Fields editor and ScopedPreferenceStore for command parameters
139
		//		BooleanFieldEditor field = new BooleanFieldEditor(ChartsEnginePreferences.SHOW_TITLE, "test2 show title store", editor.getParametersComposite());
140
		//		field.setPreferenceStore(new TXMPreferenceStore(TXMPreferences.getId(progression)));
141
		//		field.load();
142
		//		field.store();
143
		//		try {
144
		//			((ScopedPreferenceStore) field.getPreferenceStore()).save();
145
		//		}
146
		//		catch(IOException e) {
147
		//			// TODO Auto-generated catch block
148
		//			e.printStackTrace();
149
		//		}
150

  
151

  
140
		// BooleanFieldEditor field = new BooleanFieldEditor(ChartsEnginePreferences.SHOW_TITLE, "test2 show title store", editor.getParametersComposite());
141
		// field.setPreferenceStore(new TXMPreferenceStore(TXMPreferences.getId(progression)));
142
		// field.load();
143
		// field.store();
144
		// try {
145
		// ((ScopedPreferenceStore) field.getPreferenceStore()).save();
146
		// }
147
		// catch(IOException e) {
148
		// // TODO Auto-generated catch block
149
		// e.printStackTrace();
150
		// }
151
		
152
		
152 153
		// FIXME: to discuss
153
		//		// initialize extended menus for item selection
154
		//		Menu menu = editor.getComposite().getContextMenu(EventCallBack.AREA_ITEM);
155
		//		
156
		//		// send to index
157
		//		MenuItem sendToIndex = new MenuItem(menu.getItem(0).getMenu(), SWT.CASCADE);
158
		//	    sendToIndex.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_INDEX);
159
		//	    sendToIndex.setImage(IImageKeys.getImage(IImageKeys.ACTION_INDEX));
160
		//	    sendToIndex.addSelectionListener(new ProgressionSelectionListener(editor, BaseSelectionListener.SEND_TO_INDEX));
154
		// // initialize extended menus for item selection
155
		// Menu menu = editor.getComposite().getContextMenu(EventCallBack.AREA_ITEM);
161 156
		//
162
		//	    // send to concordance
163
		//		MenuItem sendToConcordance = new MenuItem(menu.getItem(0).getMenu(), SWT.CASCADE);
164
		//	    sendToConcordance.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_CONCORDANCE);
165
		//	    sendToConcordance.setImage(IImageKeys.getImage(IImageKeys.ACTION_CONCORDANCES));
166
		//	    sendToConcordance.addSelectionListener(new ProgressionSelectionListener(editor, BaseSelectionListener.SEND_TO_CONCORDANCE));
167
		//	    
168
		//	    // send to cooccurrence
169
		//		MenuItem sendToCoorccurrence = new MenuItem(menu.getItem(0).getMenu(), SWT.CASCADE);
170
		//	    sendToCoorccurrence.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_COOCCURRENCE);
171
		//	    sendToCoorccurrence.setImage(IImageKeys.getImage(IImageKeys.ACTION_COOCCURRENCE));
172
		//	    sendToCoorccurrence.addSelectionListener(new ProgressionSelectionListener(editor, BaseSelectionListener.SEND_TO_COOCCURRENCE));
173
		//	    //*****************************************************
174

  
175

  
157
		// // send to index
158
		// MenuItem sendToIndex = new MenuItem(menu.getItem(0).getMenu(), SWT.CASCADE);
159
		// sendToIndex.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_INDEX);
160
		// sendToIndex.setImage(IImageKeys.getImage(IImageKeys.ACTION_INDEX));
161
		// sendToIndex.addSelectionListener(new ProgressionSelectionListener(editor, BaseSelectionListener.SEND_TO_INDEX));
162
		//
163
		// // send to concordance
164
		// MenuItem sendToConcordance = new MenuItem(menu.getItem(0).getMenu(), SWT.CASCADE);
165
		// sendToConcordance.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_CONCORDANCE);
166
		// sendToConcordance.setImage(IImageKeys.getImage(IImageKeys.ACTION_CONCORDANCES));
167
		// sendToConcordance.addSelectionListener(new ProgressionSelectionListener(editor, BaseSelectionListener.SEND_TO_CONCORDANCE));
168
		//
169
		// // send to cooccurrence
170
		// MenuItem sendToCoorccurrence = new MenuItem(menu.getItem(0).getMenu(), SWT.CASCADE);
171
		// sendToCoorccurrence.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHARED_SEND_SELECTION_TO_COOCCURRENCE);
172
		// sendToCoorccurrence.setImage(IImageKeys.getImage(IImageKeys.ACTION_COOCCURRENCE));
173
		// sendToCoorccurrence.addSelectionListener(new ProgressionSelectionListener(editor, BaseSelectionListener.SEND_TO_COOCCURRENCE));
174
		// //*****************************************************
175
		
176
		
176 177
		try {
177 178
			// Query:
178 179
			this.getMainParametersComposite().getLayout().numColumns = 4;
......
189 190
			miniInfoLabel.setText(ProgressionUIMessages.noQuery);
190 191
			miniInfoLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
191 192
			
192
//			Label queryLabel = new Label(getMainParametersComposite(), SWT.NONE);
193
//			queryLabel.setText("New query");
194
//			queryLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
195

  
193
			// Label queryLabel = new Label(getMainParametersComposite(), SWT.NONE);
194
			// queryLabel.setText("New query");
195
			// queryLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
196
			
196 197
			// [ (v)]
197 198
			// queryWidget = new QueryWidget(queryArea, SWT.DROP_DOWN);
198 199
			queryWidget = new AssistedQueryWidget(getMainParametersComposite(), SWT.DROP_DOWN, getResult().getCorpus());
199 200
			queryWidget.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
200 201
			queryWidget.addKeyListener(new ComputeKeyListener(this) {
202
				
201 203
				@Override
202 204
				public void keyPressed(KeyEvent e) {
203 205
					if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
204 206
						if (queryWidget.getQueryString().length() > 0 && onPlusButtonPressed(null, queryWidget.getQueryString())) {
205 207
							super.keyPressed(e); // recompute only if the query has been added
206 208
							queryWidget.clearQuery();
207
						} else {
209
						}
210
						else {
208 211
							queryWidget.setText(queryWidget.getQueryString());
209 212
						}
210 213
					}
......
222 225
					if (queryWidget.getQueryString().length() > 0 && onPlusButtonPressed(null, queryWidget.getQueryString())) {
223 226
						compute(true);
224 227
						queryWidget.clearQuery();
225
					} else {
228
					}
229
					else {
226 230
						queryWidget.setText(queryWidget.getQueryString());
227 231
					}
228 232
				}
229 233
				
230 234
				@Override
231
				public void widgetDefaultSelected(SelectionEvent e) { }
235
				public void widgetDefaultSelected(SelectionEvent e) {}
232 236
			});
233 237
			// System.out.println(parent.getLayout());
234 238
			Composite mainPanel = this.getExtendedParametersGroup();
......
237 241
			GridLayout glayout = new GridLayout(2, false);
238 242
			glayout.marginBottom = glayout.marginTop = glayout.marginHeight = glayout.verticalSpacing = 0;
239 243
			mainPanel.setLayout(glayout);
240

  
244
			
241 245
			Composite paramPanel = new Composite(mainPanel, SWT.NONE);
242 246
			glayout = new GridLayout(3, false);
243 247
			glayout.marginBottom = glayout.marginTop = glayout.marginHeight = glayout.verticalSpacing = 0;
244 248
			paramPanel.setLayout(glayout);
245 249
			paramPanel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
246

  
250
			
247 251
			// controls
248 252
			// graph param
249 253
			Label typeLabel = new Label(paramPanel, SWT.NONE);
250 254
			typeLabel.setText(ProgressionUIMessages.chartTypeColon);
251 255
			typeLabel.setAlignment(SWT.CENTER);
252

  
256
			
253 257
			cumulativeButton = new Button(paramPanel, SWT.RADIO);
254 258
			cumulativeButton.setText(ProgressionUIMessages.cumulative);
255 259
			// listeners
256 260
			cumulativeButton.addSelectionListener(new ComputeSelectionListener(this, true) {
261
				
257 262
				@Override
258 263
				public void widgetSelected(SelectionEvent e) {
259 264
					bandeField.setEnabled(densityButton.getSelection());
......
261 266
					super.widgetSelected(e);
262 267
				}
263 268
			});
264

  
269
			
265 270
			densityButton = new Button(paramPanel, SWT.RADIO);
266 271
			densityButton.setText(ProgressionUIMessages.density);
267 272
			// listener
268 273
			densityButton.addSelectionListener(new ComputeSelectionListener(this, true) {
274
				
269 275
				@Override
270 276
				public void widgetSelected(SelectionEvent e) {
271 277
					bandeField.setEnabled(densityButton.getSelection());
......
273 279
					super.widgetSelected(e);
274 280
				}
275 281
			});
276

  
282
			
277 283
			// Bande size
278 284
			typeLabel = new Label(paramPanel, SWT.NONE);
279 285
			typeLabel.setText(ProgressionUIMessages.bandewidthMultiplierColon);
280 286
			typeLabel.setAlignment(SWT.CENTER);
281

  
287
			
282 288
			bandeField = new Text(paramPanel, SWT.BORDER);
283 289
			bandeField.setEnabled(densityButton.getSelection());
284 290
			bandeField.setText("" + this.getResult().getBandeMultiplier()); //$NON-NLS-1$
285 291
			bandeField.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true, 2, 1));
286 292
			bandeField.addKeyListener(computeKeyListener);
287 293
			bandeField.addModifyListener(computeKeyListener);
288

  
289 294
			
290 295
			
296
			
291 297
			// Structural units and properties combo viewers
292 298
			StructuralUnitsCombosGroup structuration = new StructuralUnitsCombosGroup(paramPanel, this, this.getResult().getStructuralUnit(), this.getResult().getStructuralUnitProperty());
293 299
			structuration.setLayout(new GridLayout(4, false));
294 300
			
295 301
			GridData gdata = new GridData(GridData.FILL, GridData.BEGINNING, true, false, 3, 1);
296 302
			structuration.setLayoutData(gdata); // the group must use the full line
297

  
303
			
298 304
			// Structural Unit
299 305
			structuralUnitsComboViewer = structuration.getStructuralUnitsComboViewer();
300

  
306
			
301 307
			// Structural Unit Property
302 308
			structuralUnitPropertiesComboViewer = structuration.getStructuralUnitPropertiesComboViewer();
303

  
304

  
309
			
310
			
305 311
			// property REGEX
306 312
			Label regexLabel = new Label(structuration, SWT.NONE);
307 313
			regexLabel.setText(ProgressionUIMessages.regexColon);
308 314
			regexLabel.setAlignment(SWT.CENTER);
309

  
315
			
310 316
			propertyRegex = new Text(structuration, SWT.SINGLE | SWT.BORDER);
311 317
			propertyRegex.addKeyListener(computeKeyListener);
312 318
			propertyRegex.addModifyListener(computeKeyListener);
313 319
			
314

  
320
			
315 321
			// Repeat same values in part markers
316 322
			repeatSameValues = new Button(structuration, SWT.CHECK);
317 323
			repeatSameValues.setText(ProgressionUIMessages.repeatSameValues);
318 324
			repeatSameValues.addSelectionListener(computeSelectionListener);
319
			repeatSameValues.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 4,1));
320

  
325
			repeatSameValues.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 4, 1));
326
			
321 327
			// Lines styles
322 328
			multipleLineStrokes = new Button(paramPanel, SWT.CHECK);
323 329
			multipleLineStrokes.setText(ChartsUIMessages.multipleLineStrokeStyles);
324 330
			multipleLineStrokes.addSelectionListener(computeSelectionListener);
325

  
326

  
331
			
332
			
327 333
			// Queries
328 334
			sc1 = new ScrolledComposite(mainPanel, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
329 335
			glayout = new GridLayout(1, true);
......
333 339
			sc1.setExpandHorizontal(true);
334 340
			sc1.setExpandVertical(true);
335 341
			sc1.setMinSize(0, 120);
336

  
342
			
337 343
			queriesFocusComposite = new Composite(sc1, SWT.NONE);
338 344
			glayout = new GridLayout(1, true);
339 345
			glayout.marginBottom = glayout.marginTop = glayout.marginHeight = glayout.verticalSpacing = 0;
340 346
			queriesFocusComposite.setLayout(glayout);
341 347
			sc1.setContent(queriesFocusComposite);
342

  
348
			
343 349
			// queries parameters
344 350
			// FIXME: useless?
345
			//			Label focusLabel = new Label(queriesFocusComposite, SWT.NONE);
346
			//			focusLabel.setText(ProgressionUIMessages.ProgressionDialog_8);
347
			//			focusLabel.setAlignment(SWT.CENTER);
348

  
351
			// Label focusLabel = new Label(queriesFocusComposite, SWT.NONE);
352
			// focusLabel.setText(ProgressionUIMessages.ProgressionDialog_8);
353
			// focusLabel.setAlignment(SWT.CENTER);
354
			
349 355
			// add queries from file button
350 356
			Button addQueriesFromFileButton = new Button(queriesFocusComposite, SWT.NONE);
351 357
			addQueriesFromFileButton.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
352 358
			addQueriesFromFileButton.setText(ProgressionUIMessages.addQueriesFromFile);
353

  
359
			
354 360
			addQueriesFromFileButton.addListener(SWT.Selection, new Listener() {
361
				
355 362
				@Override
356 363
				public void handleEvent(Event event) {
357 364
					FileDialog dialog = new FileDialog(event.display.getActiveShell(), SWT.OPEN);
......
367 374
									count++;
368 375
								}
369 376
							}
370
						} catch (Exception e) {
377
						}
378
						catch (Exception e) {
371 379
							// TODO Auto-generated catch block
372 380
							e.printStackTrace();
373 381
						}
......
377 385
					}
378 386
				}
379 387
			});
380

  
388
			
381 389
			getTopToolbar().setVisible(TXMEditor.COMPUTING_PARAMETERS_GROUP_ID, false);
382
		} catch (Exception e) {
390
		}
391
		catch (Exception e) {
383 392
			Log.printStackTrace(e);
384 393
		}
385 394
	}
386

  
395
	
387 396
	/**
388 397
	 * 
389 398
	 * @param event
......
404 413
		
405 414
		return false;
406 415
	}
407

  
416
	
408 417
	/**
409 418
	 * 
410 419
	 */
......
419 428
			miniInfoLabel.setText(queryWidgets.size() + ProgressionUIMessages.queries);
420 429
		}
421 430
	}
422

  
431
	
423 432
	/**
424 433
	 * 
425 434
	 * @author mdecorde
......
428 437
	// FIXME: should inherit from AssistedQueryWidget rather than wrapping an instance
429 438
	@Deprecated
430 439
	public class QueryField extends Composite {
431

  
440
		
432 441
		/**
433 442
		 * Assisted query widget.
434 443
		 */
435 444
		protected AssistedQueryWidget assistedQueryWidget;
436

  
445
		
437 446
		/**
438 447
		 * Linked editor.
439 448
		 */
440 449
		protected TXMEditor<? extends TXMResult> editor;
441

  
450
		
442 451
		protected Button deleteButton;
443 452
		
444 453
		
......
449 458
		 */
450 459
		public QueryField(Composite parent, int style) {
451 460
			super(parent, style);
452

  
461
			
453 462
			GridLayout glayout = new GridLayout(2, false);
454 463
			glayout.marginBottom = glayout.marginTop = glayout.marginHeight = glayout.verticalSpacing = 0;
455

  
464
			
456 465
			this.setLayout(glayout);
457

  
466
			
458 467
			queryWidgets.add(this);
459 468
			updateMiniInfoLabelText();
460 469
			
461 470
			assistedQueryWidget = new AssistedQueryWidget(this, SWT.BORDER, getResult().getCorpus());
462 471
			assistedQueryWidget.setFocus();
463 472
			assistedQueryWidget.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
464

  
473
			
465 474
			// key listener
466 475
			assistedQueryWidget.addKeyListener(new ComputeKeyListener(ProgressionEditor.this) {
476
				
477
				@Override
467 478
				public void keyPressed(KeyEvent e) {
468 479
					if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
469
						if (!assistedQueryWidget.getRawString().isEmpty() && !queryExists(assistedQueryWidget.getRawString(), 1))	{
480
						if (!assistedQueryWidget.getRawString().isEmpty() && !queryExists(assistedQueryWidget.getRawString(), 1)) {
470 481
							super.keyPressed(e);
471 482
						}
472
					} else {
483
					}
484
					else {
473 485
						ProgressionEditor.this.setDirty(true);
474 486
					}
475 487
				}
476 488
			});
477 489
			
478

  
490
			
479 491
			// delete query button
480 492
			deleteButton = new Button(this, SWT.NONE);
481 493
			deleteButton.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
482 494
			deleteButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_DELETE));
483 495
			deleteButton.addListener(SWT.Selection, new Listener() {
496
				
484 497
				@Override
485 498
				public void handleEvent(Event event) {
486 499
					if (queryWidgets.size() > 1) {
......
504 517
			this.updateDeleteButtonStates();
505 518
			
506 519
		}
507

  
508

  
520
		
521
		
509 522
		/**
510 523
		 * Updates the delete button states.
511 524
		 */
512
		public void updateDeleteButtonStates()	{
525
		public void updateDeleteButtonStates() {
513 526
			for (int i = 0; i < queryWidgets.size(); i++) {
514 527
				queryWidgets.get(i).getDeleteButton().setEnabled(!(queryWidgets.size() == 1));
515 528
			}
......
517 530
		
518 531
		/**
519 532
		 * Gets the delete button.
533
		 * 
520 534
		 * @return
521 535
		 */
522
		public Button getDeleteButton()	{
536
		public Button getDeleteButton() {
523 537
			return this.deleteButton;
524 538
		}
525 539
		
......
529 543
		 */
530 544
		public void setQuery(String query) {
531 545
			// fix the query, remove the double quotes
532
			//query = query.replaceAll("^\"(.*)\"$","$1"); //$NON-NLS-1$
546
			// query = query.replaceAll("^\"(.*)\"$","$1"); //$NON-NLS-1$
533 547
			assistedQueryWidget.setText(query);
534 548
		}
535

  
549
		
536 550
		public IQuery getQuery() {
537 551
			return assistedQueryWidget.getQuery();
538 552
		}
539

  
553
		
540 554
		public void memorize() {
541 555
			assistedQueryWidget.memorize();
542 556
		}
543

  
557
		
544 558
		public String getRawString() {
545 559
			return assistedQueryWidget.getRawString();
546 560
		}
......
549 563
	@Override
550 564
	public void setFocus() {
551 565
		// Give the focus to the query widget only if the result has not yet been computed (otherwise it breaks the synchronous Concordance/Edition)
552
		if(!this.getResult().hasBeenComputedOnce())	{
566
		if (!this.getResult().hasBeenComputedOnce()) {
553 567
			if (queryWidget != null && !queryWidget.isDisposed()) {
554 568
				queryWidget.setFocus();
555 569
			}
556 570
		}
557
		else	{
571
		else {
558 572
			super.setFocus();
559 573
		}
560 574
	}
561

  
575
	
562 576
	/**
563 577
	 * Checks if the specified query already exists or not.
578
	 * 
564 579
	 * @param query
565 580
	 * @return true if the specified query already exists, otherwise false
566 581
	 */
567
	protected boolean queryExists(String query)	{
582
	protected boolean queryExists(String query) {
568 583
		return this.queryExists(query, 0);
569 584
	}
570 585
	
571 586
	/**
572 587
	 * Checks if the specified query already exists more than the specified max count.
588
	 * 
573 589
	 * @param query
574 590
	 * @param maxCount
575 591
	 * @return
576 592
	 */
577
	protected boolean queryExists(String query, int maxCount)	{
593
	protected boolean queryExists(String query, int maxCount) {
578 594
		int count = 0;
579 595
		for (int i = 0; i < queryWidgets.size(); i++) {
580
			if (queryWidgets.get(i).getRawString().equals(query) || queryWidgets.get(i).getQuery().toString().equals(query))	{
596
			if (queryWidgets.get(i).getRawString().equals(query) || queryWidgets.get(i).getQuery().toString().equals(query)) {
581 597
				count++;
582 598
			}
583 599
		}
584 600
		
585
		if(count > maxCount)	{
601
		if (count > maxCount) {
586 602
			MessageDialog d = new MessageDialog(this.getShell(), TXMCoreMessages.error_error2, null,
587
					NLS.bind(ProgressionUIMessages.error_theQueryIsAlreadyRepresentedByACurveInTheGraphic, query), 0, new String[] { TXMCoreMessages.common_ok}, 0);
603
					NLS.bind(ProgressionUIMessages.error_theQueryIsAlreadyRepresentedByACurveInTheGraphic, query), 0, new String[] { TXMCoreMessages.common_ok }, 0);
588 604
			d.open();
589 605
			return true;
590 606
		}
......
598 614
	 * @return the assisted query widget
599 615
	 */
600 616
	private QueryField addFocusQueryField(String query) {
601

  
617
		
602 618
		// do not add same query twice
603
		if(!query.isEmpty() && this.queryExists(query))	{
619
		if (!query.isEmpty() && this.queryExists(query)) {
604 620
			return null;
605 621
		}
606

  
622
		
607 623
		QueryField queryField = new QueryField(this.queriesFocusComposite, SWT.NONE);
608 624
		// avoid null pointer exception
609 625
		if (query != null) {
......
611 627
		}
612 628
		GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, false);
613 629
		queryField.setLayoutData(gridData);
614

  
630
		
615 631
		this.queriesFocusComposite.layout(true);
616

  
632
		
617 633
		return queryField;
618 634
	}
619

  
635
	
620 636
	/**
621 637
	 * Adds an empty query field.
638
	 * 
622 639
	 * @return the added QueryField
623 640
	 */
624 641
	private QueryField addFocusQueryField() {
625 642
		return this.addFocusQueryField(""); //$NON-NLS-1$
626 643
	}
627

  
628

  
644
	
645
	
629 646
	@Override
630 647
	public void updateEditorFromChart(boolean update) {
631

  
632
		//queryList = this.getResult().getQueries();
633 648
		
634
		 // initialize query fields
649
		// queryList = this.getResult().getQueries();
650
		
651
		// initialize query fields
635 652
		if (queryWidgets.size() == 0 && queryList != null) {
636 653
			for (IQuery q : queryList) {
637
				addFocusQueryField(q.getQueryString()); 
654
				addFocusQueryField(q.getQueryString());
638 655
			}
639 656
		}
640 657
		
......
643 660
		densityButton.setSelection(!cumulative);
644 661
		bandeField.setEnabled(densityButton.getSelection());
645 662
	}
646

  
647

  
663
	
664
	
648 665
	@Override
649 666
	public void updateResultFromEditor() {
650

  
667
		
651 668
		// create query list from widget
652
		queryList = new ArrayList<CQLQuery>();
669
		queryList = new ArrayList<>();
653 670
		for (QueryField wid : queryWidgets) {
654 671
			if (!wid.getQuery().isEmpty()) {
655 672
				queryList.add((CQLQuery) wid.getQuery());
656 673
				wid.memorize();
657 674
			}
658 675
		}
659

  
676
		
660 677
		cumulative = cumulativeButton.getSelection();
661

  
678
		
662 679
		String smultibande = bandeField.getText();
663 680
		float bandeMultiplier = 1.0f;
664 681
		if (smultibande != null && smultibande.length() > 0) {
665 682
			try {
666 683
				bandeMultiplier = Float.parseFloat(smultibande);
667
			} catch(Exception e) {
684
			}
685
			catch (Exception e) {
668 686
				bandeMultiplier = 1.0f;
669 687
				Log.severe(NLS.bind(ProgressionUIMessages.stripMultiplierErrorColonP0, e));
670 688
				StatusLine.error(NLS.bind(ProgressionUIMessages.stripMultiplierErrorColonP0, e));
671 689
			}
672 690
		}
673
		else	{
691
		else {
674 692
			bandeMultiplier = 1.0f;
675 693
		}
676 694
	}
677

  
678
}
695
	
696
}

Also available in: Unified diff