Révision 2275

tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 2275)
141 141
 * @author mdecorde.
142 142
 */
143 143
public class ConcordanceEditor extends TXMEditor<Concordance> {
144

  
144
	
145 145
	public static final String ID = ConcordanceEditor.class.getName();
146

  
147
	String locale = Locale.getDefault().getLanguage();//RCPPreferences.getInstance().getString(RCPPreferences.CONFIG_LOCALE);
148

  
146
	
147
	String locale = Locale.getDefault().getLanguage();// RCPPreferences.getInstance().getString(RCPPreferences.CONFIG_LOCALE);
148
	
149 149
	private static final String BACKTOTEXT_COMMAND_ID = "org.txm.rcp.extensionpoint.backtotext"; //$NON-NLS-1$
150

  
150
	
151 151
	/** The lineids. */
152 152
	List<String> lineids;
153

  
153
	
154 154
	/** The standard comparators. */
155 155
	private List<LineComparator> standardComparators;
156

  
156
	
157 157
	/** The user defined comparators. */
158 158
	private List<LineComparator> userDefinedComparators;
159

  
159
	
160 160
	/** The complexsorter. */
161 161
	ComplexSortSelector complexsorter;
162
	
162 163
	org.eclipse.swt.widgets.Text cqlSeparator;
163

  
164
	
164 165
	private Concordance concordance;
165

  
166
	
166 167
	/** The standard comparator class name. */
167 168
	private LineComparator[] standardComparatorClassName = {
168 169
			new NullComparator(), new LexicographicKeywordComparator(),
169 170
			new LexicographicLeftContextComparator(),
170 171
			new LexicographicRightContextComparator(),
171 172
			new PropertiesReferenceComparator() };
172

  
173
	//	/** The n line per page. */
174
	//	private int concordance.getNLinePerPage();
173
	
174
	// /** The n line per page. */
175
	// private int concordance.getNLinePerPage();
175 176
	//
176
	//	/** The top line. */
177
	//	private int topLine;
177
	// /** The top line. */
178
	// private int topLine;
178 179
	//
179
	//	/** The bottom line. */
180
	//	private int bottomLine;
181

  
180
	// /** The bottom line. */
181
	// private int bottomLine;
182
	
182 183
	/** The current comparator. */
183 184
	protected LineComparator currentComparator;
184

  
185
	//	/** The left context size. */
186
	//	private int leftContextSize;
185
	
186
	// /** The left context size. */
187
	// private int leftContextSize;
187 188
	//
188
	//	/** The right context size. */
189
	//	private int rightContextSize;
190

  
189
	// /** The right context size. */
190
	// private int rightContextSize;
191
	
191 192
	/** The mouseposition. */
192 193
	private Point mouseposition;
193

  
194
	
194 195
	/** The line table viewer. */
195 196
	protected TableViewer viewerRight, viewerLeft;
196

  
197
	
197 198
	/** The reference column. */
198 199
	private TableColumn referenceColumn;
199

  
200
	
200 201
	/** The first column. */
201 202
	private TableColumn firstColumn; // due to a restriction on some platforms
202 203
	// (actually, MS Windows), the first
203 204
	// column is always left aligned. The
204 205
	// work around is to have a 0 width
205 206
	// first column
207
	
206 208
	/** The left context column. */
207 209
	private TableColumn leftContextColumn;
210
	
208 211
	/** The keyword column. */
209 212
	private TableColumn keywordColumn;
213
	
210 214
	/** The right context column. */
211 215
	private TableColumn rightContextColumn;
212

  
213
	//	/** The view properties label. */
214
	//	private Label viewPropertiesLabel;
215

  
216
	
217
	// /** The view properties label. */
218
	// private Label viewPropertiesLabel;
219
	
216 220
	/** The set sort property action. */
217 221
	private Action setSortPropertyAction;
218

  
222
	
219 223
	/** The set context size action. */
220 224
	private Action setContextSizeAction;
221

  
225
	
222 226
	/** The set line number action. */
223 227
	private Action setLineNumberAction;
224

  
228
	
225 229
	/** The define view reference pattern action. */
226 230
	protected Action defineViewReferencePatternAction;
227

  
231
	
228 232
	/** The define sort reference pattern action. */
229
	protected Action defineSortReferencePatternAction;	
230

  
233
	protected Action defineSortReferencePatternAction;
234
	
231 235
	/** The set view property action. */
232 236
	protected Action setViewPropertyAction;
233

  
237
	
234 238
	/** The attached browser editor. */
235 239
	protected TXMBrowser attachedBrowserEditor;
236

  
240
	
237 241
	/** The progresslistener. */
238 242
	protected ProgressListener progresslistener;
239

  
243
	
240 244
	/** The textid. */
241 245
	protected String textid;
242

  
246
	
243 247
	/** The opened page. */
244 248
	Page openedPage;
245

  
249
	
246 250
	/** The query area. */
247 251
	private Composite queryArea;
248

  
252
	
249 253
	/** The navigation area. */
250 254
	private NavigationWidget navigationWidget;
251

  
252

  
253
	/** The hide btn: hides the form
254
	 * TODO: remove the button when the TXMEditorToolbar is fully functionnal. */
255
	
256
	
257
	/**
258
	 * The hide btn: hides the form
259
	 * TODO: remove the button when the TXMEditorToolbar is fully functionnal.
260
	 */
255 261
	private Button deleteLineButton;
256

  
262
	
257 263
	/** The query size. */
258 264
	protected Point querySize;
259

  
260

  
265
	
261 266
	private Sash sash;
262

  
267
	
263 268
	private Listener tableResizeListener;
264

  
269
	
265 270
	private Table leftTable;
266

  
271
	
267 272
	private Table rightTable;
268

  
273
	
269 274
	private ScrollBar vBarLeft;
270

  
275
	
271 276
	private ScrollBar vBarRight;
272

  
277
	
273 278
	private Label queryLabel;
274

  
279
	
275 280
	private Composite navigationArea;
276

  
277

  
281
	
282
	
278 283
	/** The query widget. */
279
	@Parameter(key=ConcordancePreferences.QUERY)
284
	@Parameter(key = ConcordancePreferences.QUERY)
280 285
	protected AssistedChoiceQueryWidget queryWidget;
281

  
282
	@Parameter(key=ConcordancePreferences.LEFT_ANALYSIS_PROPERTIES)
286
	
287
	@Parameter(key = ConcordancePreferences.LEFT_ANALYSIS_PROPERTIES)
283 288
	private PropertiesSelector<WordProperty> leftSortProperties;
284
	@Parameter(key=ConcordancePreferences.ANALYSIS_REFERENCE_PATTERN)
289
	
290
	@Parameter(key = ConcordancePreferences.ANALYSIS_REFERENCE_PATTERN)
285 291
	private PropertiesSelector<Property> refSortProperties;
286
	@Parameter(key=ConcordancePreferences.KEYWORD_ANALYSIS_PROPERTIES)
292
	
293
	@Parameter(key = ConcordancePreferences.KEYWORD_ANALYSIS_PROPERTIES)
287 294
	private PropertiesSelector<WordProperty> keywordSortProperties;
288
	@Parameter(key=ConcordancePreferences.RIGHT_VIEW_PROPERTIES)
295
	
296
	@Parameter(key = ConcordancePreferences.RIGHT_VIEW_PROPERTIES)
289 297
	private PropertiesSelector<WordProperty> rightViewProperties;
290
	@Parameter(key=ConcordancePreferences.KEYWORD_VIEW_PROPERTIES)
298
	
299
	@Parameter(key = ConcordancePreferences.KEYWORD_VIEW_PROPERTIES)
291 300
	private PropertiesSelector<WordProperty> keywordViewProperties;
292
	@Parameter(key=ConcordancePreferences.LEFT_VIEW_PROPERTIES)
301
	
302
	@Parameter(key = ConcordancePreferences.LEFT_VIEW_PROPERTIES)
293 303
	private PropertiesSelector<WordProperty> leftViewProperties;
294
	@Parameter(key=ConcordancePreferences.VIEW_REFERENCE_PATTERN)
304
	
305
	@Parameter(key = ConcordancePreferences.VIEW_REFERENCE_PATTERN)
295 306
	private PropertiesSelector<Property> refViewProperties;
296
	@Parameter(key=ConcordancePreferences.RIGHT_ANALYSIS_PROPERTIES)
307
	
308
	@Parameter(key = ConcordancePreferences.RIGHT_ANALYSIS_PROPERTIES)
297 309
	private PropertiesSelector<WordProperty> rightSortProperties;
298
	@Parameter(key=ConcordancePreferences.LEFT_CONTEXT_SIZE)
310
	
311
	@Parameter(key = ConcordancePreferences.LEFT_CONTEXT_SIZE)
299 312
	private Spinner leftSizeSpinner;
300
	@Parameter(key=ConcordancePreferences.RIGHT_CONTEXT_SIZE)
313
	
314
	@Parameter(key = ConcordancePreferences.RIGHT_CONTEXT_SIZE)
301 315
	private Spinner rightSizeSpinner;
302

  
303
	//	private PropertiesSelector<Property> propsArea;
304

  
305

  
306

  
307

  
308

  
316
	
317
	// private PropertiesSelector<Property> propsArea;
318
	
319
	
320
	
321
	
322
	
309 323
	@Override
310 324
	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
325
		
311 326
		super.init(site, input);
312

  
313
		if (!(this.result instanceof Concordance)) {
314
			throw new PartInitException(ConcordanceUIMessages.bind(ConcordanceUIMessages.canNotOpenConcordanceEditorWithP0, result));
315
		}
316
		this.concordance = (Concordance)this.result;
317

  
327
		
328
		if (!(this.result instanceof Concordance)) { throw new PartInitException(ConcordanceUIMessages.bind(ConcordanceUIMessages.canNotOpenConcordanceEditorWithP0, result)); }
329
		this.concordance = (Concordance) this.result;
330
		
318 331
		this.standardComparators = new ArrayList<LineComparator>();
319 332
		this.userDefinedComparators = new ArrayList<LineComparator>();
320 333
		this.setStandardComparators();
321 334
		concordance.setNLinePerPage(ConcordancePreferences.getInstance().getInt(ConcordancePreferences.N_LINES_PER_PAGE));
322 335
	}
323

  
324

  
336
	
325 337
	@Override
326 338
	public void _createPartControl() {
327

  
339
		
328 340
		Composite controlArea = getExtendedParametersGroup();
329

  
341
		
330 342
		try {
331 343
			composeControlArea(controlArea);
332 344
			Composite d = new Composite(getResultArea(), SWT.NONE);
......
336 348
			if (complexsorter != null) {
337 349
				complexsorter.setComparators(this);
338 350
			}
339
		} catch(Exception e) {
351
		}
352
		catch (Exception e) {
340 353
			System.out.println(ConcordanceUIMessages.bind(ConcordanceUIMessages.errorWhileBuildingInterfaceColonP0, e.getLocalizedMessage()));
341 354
			Log.printStackTrace(e);
342 355
		}
343 356
	}
344

  
357
	
345 358
	/**
346 359
	 * Compose display area.
347 360
	 *
348 361
	 * @param displayArea the display area
349 362
	 */
350 363
	private void composeDisplayArea(final Composite displayArea) throws Exception {
351
		//		tableLayout = new TableColumnLayout();
364
		
365
		// tableLayout = new TableColumnLayout();
352 366
		displayArea.setLayout(new FormLayout());
353

  
367
		
354 368
		viewerLeft = new TableViewer(displayArea, SWT.MULTI | SWT.BORDER | SWT.VIRTUAL);
355 369
		
356 370
		viewerLeft.setLabelProvider(new LineLabelProvider(this) {
371
			
357 372
			@Override
358 373
			public String getColumnText(Object element, int columnIndex) {
374
				
359 375
				Line line = (Line) element;
360 376
				return line.getViewRef().toString();
361 377
			}
......
363 379
		viewerLeft.setContentProvider(new ConcordancesProvider());
364 380
		viewerLeft.getTable().setLinesVisible(true);
365 381
		viewerLeft.getTable().setHeaderVisible(true);
366

  
367
		//		firstColumn = new TableColumn(viewer2.getTable(), SWT.LEFT);
368
		//		firstColumn.setWidth(10);
369

  
370
		referenceColumn = new TableColumn(viewerLeft.getTable(), SWT.LEFT|SWT.H_SCROLL);
382
		
383
		// firstColumn = new TableColumn(viewer2.getTable(), SWT.LEFT);
384
		// firstColumn.setWidth(10);
385
		
386
		referenceColumn = new TableColumn(viewerLeft.getTable(), SWT.LEFT | SWT.H_SCROLL);
371 387
		refreshReferenceColumnTitle();
372 388
		referenceColumn.setToolTipText(ConcordanceUIMessages.reference);
373 389
		referenceColumn.addSelectionListener(new SelectionListener() {
390
			
374 391
			@Override
375 392
			public void widgetSelected(SelectionEvent e) {
393
				
376 394
				StatusLine.setMessage(ConcordanceUIMessages.sortingReferenceColumn);
377 395
				LineComparator comparator = new PropertiesReferenceComparator();
378 396
				if (viewerLeft.getTable().getSortColumn() != referenceColumn) {
379 397
					viewerLeft.getTable().setSortColumn(null);
380 398
					viewerLeft.getTable().setSortColumn(referenceColumn);
381 399
					viewerLeft.getTable().setSortDirection(SWT.UP);
382
				} else if (viewerLeft.getTable().getSortDirection() == SWT.UP) {
400
				}
401
				else if (viewerLeft.getTable().getSortDirection() == SWT.UP) {
383 402
					viewerLeft.getTable().setSortDirection(SWT.DOWN);
384 403
					comparator = new ReverseComparator(comparator);
385
				} else {
404
				}
405
				else {
386 406
					viewerLeft.getTable().setSortDirection(SWT.UP);
387 407
				}
388 408
				comparator.initialize(concordance.getCorpus());
389 409
				currentComparator = comparator;
390
				complexsorter.setKey(4);//set ref key
410
				complexsorter.setKey(4);// set ref key
391 411
				sort();
392 412
				StatusLine.setMessage(""); //$NON-NLS-1$
393 413
			}
394

  
414
			
395 415
			@Override
396
			public void widgetDefaultSelected(SelectionEvent e) {
397
			}
416
			public void widgetDefaultSelected(SelectionEvent e) {}
398 417
		});
399 418
		referenceColumn.setWidth(100);
400

  
419
		
401 420
		sash = new Sash(displayArea, SWT.VERTICAL);
402 421
		sash.addSelectionListener(new SelectionAdapter() {
422
			
403 423
			public void widgetSelected(SelectionEvent event) {
424
				
404 425
				((FormData) sash.getLayoutData()).left = new FormAttachment(0, event.x);
405 426
				sash.getParent().layout();
406 427
			}
407 428
		});
408 429
		viewerRight = new TableViewer(displayArea, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER
409
				//				| SWT.VIRTUAL
430
				// | SWT.VIRTUAL
410 431
				);
411

  
412
		//viewer.setLabelProvider(new LineLabelProvider(this));
432
		
433
		// viewer.setLabelProvider(new LineLabelProvider(this));
413 434
		viewerRight.setContentProvider(new ConcordancesProvider());
414 435
		viewerRight.getTable().setLinesVisible(true);
415 436
		viewerRight.getTable().setHeaderVisible(true);
416

  
437
		
417 438
		String f = concordance.getCorpus().getFont();
418 439
		if (f != null && f.length() > 0) {
419 440
			Font old = viewerRight.getTable().getFont();
420 441
			FontData fD = old.getFontData()[0];
421
			Font font = new Font(Display.getCurrent(), f, fD.getHeight(), fD.getStyle()); 
442
			Font font = new Font(Display.getCurrent(), f, fD.getHeight(), fD.getStyle());
422 443
			viewerRight.getTable().setFont(font);
423 444
			viewerLeft.getTable().setFont(font);
424 445
		}
425

  
446
		
426 447
		tableResizeListener = new Listener() {
448
			
427 449
			@Override
428 450
			public void handleEvent(Event event) {
451
				
429 452
				ScrollBar bar = viewerRight.getTable().getHorizontalBar();
430
				float l=leftContextColumn.getWidth();
431
				float k=keywordColumn.getWidth();
432
				float r=rightContextColumn.getWidth();
433
				float t=viewerRight.getTable().getClientArea().width;//the width of the visible part of the table; l+k+r>=t
434
				float x=l+k/2-t/2; //the abcisse the visible rectangle must have for the keyword column to be centered
435
				float M=bar.getMaximum();
436
				float T=bar.getThumb();
437
				bar.setSelection(Math.round(x*(M-T)/(l+k+r-t)));//this is how x translate in terms of bar selection
453
				float l = leftContextColumn.getWidth();
454
				float k = keywordColumn.getWidth();
455
				float r = rightContextColumn.getWidth();
456
				float t = viewerRight.getTable().getClientArea().width;// the width of the visible part of the table; l+k+r>=t
457
				float x = l + k / 2 - t / 2; // the abcisse the visible rectangle must have for the keyword column to be centered
458
				float M = bar.getMaximum();
459
				float T = bar.getThumb();
460
				bar.setSelection(Math.round(x * (M - T) / (l + k + r - t)));// this is how x translate in terms of bar selection
438 461
			}
439 462
		};
440

  
463
		
441 464
		// try to center on keyword column
442 465
		viewerRight.getTable().addListener(SWT.Resize, tableResizeListener);
443

  
444
		//TODO: to enable line deletion, Concordance code must updated -> replace with key binding
466
		
467
		// TODO: to enable line deletion, Concordance code must updated -> replace with key binding
445 468
		KeyListener kldelete = new KeyListener() {
469
			
446 470
			@Override
447
			public void keyReleased(KeyEvent e) {	}
471
			public void keyReleased(KeyEvent e) {}
472
			
448 473
			@Override
449 474
			public void keyPressed(KeyEvent e) {
450
				if (e.keyCode != SWT.DEL ) { return; }
475
				
476
				if (e.keyCode != SWT.DEL) { return; }
451 477
				DeleteLines.deleteConcordanceLines(ConcordanceEditor.this);
452 478
			}
453 479
		};
454 480
		viewerRight.getTable().addKeyListener(kldelete);
455 481
		viewerLeft.getTable().addKeyListener(kldelete);
456

  
482
		
457 483
		TableKeyListener tlistener = new TableKeyListener(viewerLeft, viewerRight);
458 484
		viewerRight.getTable().addKeyListener(tlistener);
459 485
		viewerLeft.getTable().addKeyListener(tlistener);
......
461 487
		firstColumn = new TableColumn(viewerRight.getTable(), SWT.LEFT);
462 488
		firstColumn.setWidth(0);
463 489
		firstColumn.setResizable(false);
464

  
490
		
465 491
		TableViewerColumn leftColumnViewer = new TableViewerColumn(viewerRight, SWT.RIGHT);
466 492
		leftContextColumn = leftColumnViewer.getColumn();
467 493
		leftContextColumn.setText(ConcordanceUIMessages.leftContext);
468 494
		leftContextColumn.setToolTipText(ConcordanceUIMessages.leftContext);
469 495
		leftContextColumn.setAlignment(SWT.RIGHT);
470 496
		leftColumnViewer.setLabelProvider(new ColumnLabelProvider() {
497
			
471 498
			@Override
472 499
			public String getText(Object element) {
500
				
473 501
				Line line = (Line) element;
474 502
				return line.leftContextToString();
475 503
			}
476 504
		});
505
		
477 506
		leftContextColumn.addSelectionListener(new SelectionListener() {
507
			
478 508
			@Override
479 509
			public void widgetSelected(SelectionEvent e) {
510
				
480 511
				StatusLine.setMessage(ConcordanceUIMessages.sortingLeftContextColumn);
481 512
				LineComparator comparator = new LexicographicLeftContextComparator();
482 513
				if (viewerRight.getTable().getSortColumn() != leftContextColumn) {
483 514
					viewerRight.getTable().setSortColumn(leftContextColumn);
484 515
					viewerRight.getTable().setSortDirection(SWT.UP);
485
				} else if (viewerRight.getTable().getSortDirection() == SWT.UP) {
516
				}
517
				else if (viewerRight.getTable().getSortDirection() == SWT.UP) {
486 518
					viewerRight.getTable().setSortDirection(SWT.DOWN);
487 519
					comparator = new ReverseComparator(comparator);
488
				} else
520
				}
521
				else
489 522
					viewerRight.getTable().setSortDirection(SWT.UP);
490 523
				comparator.initialize(concordance.getCorpus());
491 524
				currentComparator = comparator;
492
				complexsorter.setKey(2);//set ref key
525
				complexsorter.setKey(2);// set ref key
493 526
				sort();
494 527
				StatusLine.setMessage(""); //$NON-NLS-1$
495 528
			}
496

  
529
			
497 530
			@Override
498
			public void widgetDefaultSelected(SelectionEvent e) {
499
			}
531
			public void widgetDefaultSelected(SelectionEvent e) {}
500 532
		});
501

  
533
		
502 534
		TableViewerColumn keywordColumnViewer = new TableViewerColumn(viewerRight, SWT.CENTER);
503 535
		keywordColumn = keywordColumnViewer.getColumn();
504 536
		keywordColumn.setText(ConcordanceUIMessages.keyword);
505 537
		keywordColumn.setToolTipText(ConcordanceUIMessages.keyword);
506 538
		keywordColumn.setAlignment(SWT.CENTER);
507 539
		keywordColumnViewer.setLabelProvider(new ColumnLabelProvider() {
540
			
508 541
			@Override
509 542
			public String getText(Object element) {
543
				
510 544
				Line line = (Line) element;
511 545
				return line.keywordToString();
512 546
			}
513 547
		});
548
		
514 549
		keywordColumn.addSelectionListener(new SelectionListener() {
550
			
515 551
			@Override
516 552
			public void widgetSelected(SelectionEvent e) {
553
				
517 554
				StatusLine.setMessage(ConcordanceUIMessages.sortingKeywordColumn);
518 555
				LineComparator comparator = new LexicographicKeywordComparator();
519 556
				if (viewerRight.getTable().getSortColumn() != keywordColumn) {
......
529 566
				}
530 567
				comparator.initialize(concordance.getCorpus());
531 568
				currentComparator = comparator;
532
				complexsorter.setKey(1);//set ref key
569
				complexsorter.setKey(1);// set ref key
533 570
				sort();
534 571
				StatusLine.setMessage(""); //$NON-NLS-1$
535 572
			}
536

  
573
			
537 574
			@Override
538
			public void widgetDefaultSelected(SelectionEvent e) {
539
			}
575
			public void widgetDefaultSelected(SelectionEvent e) {}
540 576
		});
541

  
542

  
577
		
543 578
		TableViewerColumn rightContextColumnViewer = new TableViewerColumn(viewerRight, SWT.LEFT);
544 579
		rightContextColumn = rightContextColumnViewer.getColumn();
545 580
		rightContextColumn.setText(ConcordanceUIMessages.rightContext);
546 581
		rightContextColumn.setToolTipText(ConcordanceUIMessages.rightContext);
547 582
		rightContextColumn.setAlignment(SWT.LEFT);
548 583
		rightContextColumnViewer.setLabelProvider(new ColumnLabelProvider() {
584
			
549 585
			@Override
550 586
			public String getText(Object element) {
587
				
551 588
				Line line = (Line) element;
552 589
				return line.rightContextToString();
553 590
			}
554 591
		});
555 592
		rightContextColumn.addSelectionListener(new SelectionListener() {
593
			
556 594
			@Override
557 595
			public void widgetSelected(SelectionEvent e) {
596
				
558 597
				StatusLine.setMessage(ConcordanceUIMessages.sortingRightContextColumn);
559 598
				LineComparator comparator = new LexicographicRightContextComparator();
560

  
599
				
561 600
				if (viewerRight.getTable().getSortColumn() != rightContextColumn) {
562 601
					viewerRight.getTable().setSortColumn(rightContextColumn);
563 602
				}
......
570 609
				}
571 610
				comparator.initialize(concordance.getCorpus());
572 611
				currentComparator = comparator;
573
				complexsorter.setKey(3); //set ref key
612
				complexsorter.setKey(3); // set ref key
574 613
				sort();
575 614
				StatusLine.setMessage(""); //$NON-NLS-1$
576 615
			}
577

  
616
			
578 617
			@Override
579
			public void widgetDefaultSelected(SelectionEvent e) {
580
			}
618
			public void widgetDefaultSelected(SelectionEvent e) {}
581 619
		});
582

  
583
		//		firstColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
584
		//		firstColumn.setWidth(0);
585
		//		firstColumn.setResizable(false);
586

  
620
		
621
		// firstColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
622
		// firstColumn.setWidth(0);
623
		// firstColumn.setResizable(false);
624
		
587 625
		leftContextColumn.setWidth(200);
588 626
		keywordColumn.setWidth(100);
589 627
		rightContextColumn.setWidth(200);
590

  
591
		//resetColumnWidths(); // set column widths
592

  
593

  
594
		//		// And now, a sweet piece of code :)
595
		//		// When the window is resized, the scrollbar is adjusted so that the
596
		//		// keywords remain centered
597
		//		viewer.getTable().addListener(SWT.Resize, new Listener() {
598
		//			@Override
599
		//			public void handleEvent(Event event) {
600
		//				ScrollBar bar = viewer.getTable().getHorizontalBar();
601
		//				//float l = leftContextColumn.getWidth();
602
		//				//float k = keywordColumn.getWidth();
603
		//				rightContextColumn.getWidth();
604
		//				//float t = lineTableViewer.getTable().getClientArea().width;
605
		//				bar.getMaximum();
606
		//				bar.getThumb();
607
		//			}
608
		//		});
609

  
628
		
629
		// resetColumnWidths(); // set column widths
630
		
631
		
632
		// // And now, a sweet piece of code :)
633
		// // When the window is resized, the scrollbar is adjusted so that the
634
		// // keywords remain centered
635
		// viewer.getTable().addListener(SWT.Resize, new Listener() {
636
		// @Override
637
		// public void handleEvent(Event event) {
638
		// ScrollBar bar = viewer.getTable().getHorizontalBar();
639
		// //float l = leftContextColumn.getWidth();
640
		// //float k = keywordColumn.getWidth();
641
		// rightContextColumn.getWidth();
642
		// //float t = lineTableViewer.getTable().getClientArea().width;
643
		// bar.getMaximum();
644
		// bar.getThumb();
645
		// }
646
		// });
647
		
610 648
		// back to text mouse listener
611 649
		MouseListener ms = new MouseListener() {
650
			
612 651
			int c = 0;
652
			
613 653
			@Override
614 654
			public synchronized void mouseDoubleClick(MouseEvent e) {
655
				
615 656
				if (e.count == 2 && c == 0) {
616 657
					c++;
617 658
					
......
621 662
					c--;
622 663
				}
623 664
			}
624

  
665
			
625 666
			@Override
626
			public void mouseDown(MouseEvent e) { }
667
			public void mouseDown(MouseEvent e) {}
668
			
627 669
			@Override
628
			public void mouseUp(MouseEvent e) {	}
670
			public void mouseUp(MouseEvent e) {}
629 671
		};
630 672
		viewerRight.getTable().addMouseListener(ms);
631 673
		viewerLeft.getTable().addMouseListener(ms);
632

  
674
		
633 675
		// On Windows, the selection is gray if the table does not have focus.
634 676
		// To make both tables appear in focus, draw the selection background
635 677
		// here.
636 678
		// This part only works on version 3.2 or later.
637 679
		Listener eraseListener = new Listener() {
680
			
638 681
			@Override
639 682
			public void handleEvent(Event event) {
683
				
640 684
				event.detail &= ~SWT.HOT;
641 685
				if ((event.detail & SWT.SELECTED) != 0) {
642 686
					GC gc = event.gc;
......
650 694
				}
651 695
			}
652 696
		};
653

  
697
		
654 698
		// Listeners to avoid 0 width columns
655 699
		referenceColumn.addControlListener(new ConcordanceColumnSizeControlListener(referenceColumn));
656 700
		leftContextColumn.addControlListener(new ConcordanceColumnSizeControlListener(leftContextColumn));
657 701
		keywordColumn.addControlListener(new ConcordanceColumnSizeControlListener(keywordColumn));
658 702
		rightContextColumn.addControlListener(new ConcordanceColumnSizeControlListener(rightContextColumn));
659

  
703
		
660 704
		viewerRight.getTable().addListener(SWT.EraseItem, eraseListener);
661

  
705
		
662 706
		leftTable = viewerLeft.getTable();
663 707
		rightTable = viewerRight.getTable();
664 708
		viewerLeft.getTable().addSelectionListener(new SelectionListener() {
709
			
665 710
			@Override
666 711
			public void widgetSelected(SelectionEvent e) {
712
				
667 713
				rightTable.deselectAll();
668 714
				rightTable.select(leftTable.getSelectionIndices());
669 715
			}
716
			
670 717
			@Override
671
			public void widgetDefaultSelected(SelectionEvent e) { }
718
			public void widgetDefaultSelected(SelectionEvent e) {}
672 719
		});
720
		
673 721
		vBarLeft = viewerLeft.getTable().getVerticalBar();
674 722
		vBarLeft.addListener(SWT.Selection, new Listener() {
723
			
675 724
			@Override
676 725
			public void handleEvent(Event event) {
726
				
677 727
				if (Util.isLinux()) {
678 728
					vBarRight.setSelection(vBarLeft.getSelection());
679
				} else {
729
				}
730
				else {
680 731
					viewerRight.getTable().setTopIndex(viewerLeft.getTable().getTopIndex());
681 732
				}
682 733
			}
683 734
		});
735
		
684 736
		viewerRight.getTable().addSelectionListener(new SelectionListener() {
737
			
685 738
			@Override
686 739
			public void widgetSelected(SelectionEvent e) {
740
				
687 741
				leftTable.deselectAll();
688 742
				leftTable.select(rightTable.getSelectionIndices());
689 743
			}
744
			
690 745
			@Override
691
			public void widgetDefaultSelected(SelectionEvent e) { }
746
			public void widgetDefaultSelected(SelectionEvent e) {}
692 747
		});
748
		
693 749
		vBarRight = viewerRight.getTable().getVerticalBar();
694 750
		vBarRight.addListener(SWT.Selection, new Listener() {
751
			
695 752
			@Override
696 753
			public void handleEvent(Event event) {
754
				
697 755
				if (Util.isLinux()) {
698 756
					vBarLeft.setSelection(vBarRight.getSelection());
699
				} else {
700
					viewerLeft.getTable().setTopIndex(viewerRight.getTable().getTopIndex());					
701 757
				}
758
				else {
759
					viewerLeft.getTable().setTopIndex(viewerRight.getTable().getTopIndex());
760
				}
702 761
			}
703 762
		});
704

  
763
		
705 764
		// set Layout datas
706 765
		FormData data = new FormData();
707
		data.top = new FormAttachment(0); 
708
		data.bottom = new FormAttachment(100); 
766
		data.top = new FormAttachment(0);
767
		data.bottom = new FormAttachment(100);
709 768
		data.left = new FormAttachment(0);
710
		data.right = new FormAttachment(sash,0);
769
		data.right = new FormAttachment(sash, 0);
711 770
		viewerLeft.getTable().setLayoutData(data);
712

  
771
		
713 772
		FormData data2 = new FormData();
714
		data2.top = new FormAttachment(0, 0); 
715
		data2.bottom = new FormAttachment(100, 0); 
773
		data2.top = new FormAttachment(0, 0);
774
		data2.bottom = new FormAttachment(100, 0);
716 775
		data2.left = new FormAttachment(10);
717 776
		sash.setLayoutData(data2);
718

  
777
		
719 778
		FormData data3 = new FormData();
720
		data3.top = new FormAttachment(0); 
721
		data3.bottom = new FormAttachment(100); 
722
		data3.left = new FormAttachment(sash,0);
779
		data3.top = new FormAttachment(0);
780
		data3.bottom = new FormAttachment(100);
781
		data3.left = new FormAttachment(sash, 0);
723 782
		data3.right = new FormAttachment(100);
724 783
		viewerRight.getTable().setLayoutData(data3);
725

  
784
		
726 785
		createContextMenu();
727 786
	}
728

  
787
	
729 788
	/**
730 789
	 * Sort.
731 790
	 */
732 791
	public void sort() {
792
		
733 793
		if (concordance != null && currentComparator != null) {
734

  
735
			//System.out.println("concordance sort props: "+concordance.getLeftCAnalysisProperty()+", "+concordance.getKeywordAnalysisProperty()+", "+concordance.getRightCAnalysisProperty());
794
			
795
			// System.out.println("concordance sort props: "+concordance.getLeftCAnalysisProperty()+", "+concordance.getKeywordAnalysisProperty()+", "+concordance.getRightCAnalysisProperty());
736 796
			concordance.resetLines();
737

  
797
			
738 798
			try {
739 799
				Log.fine(NLS.bind(ConcordanceUIMessages.sortingWithP0, currentComparator.getName()));
740 800
				if (currentComparator instanceof CompositeComparator) {
741 801
					Log.fine(((CompositeComparator) currentComparator).getComparators().toString());
742 802
				}
743 803
				JobHandler jobhandler = new JobHandler("Sorting...") { //$NON-NLS-1$
804
					
744 805
					@Override
745 806
					protected IStatus run(IProgressMonitor monitor) {
807
						
746 808
						this.runInit(monitor);
747 809
						JobsTimer.start();
748 810
						try {
......
752 814
							concordance.setTopIndex(0);
753 815
							concordance.setCurrentMonitor(null);
754 816
							syncExec(new Runnable() {
817
								
755 818
								@Override
756 819
								public void run() {
820
									
757 821
									StatusLine.setMessage(TXMUIMessages.sortDone);
758 822
									try {
759 823
										refresh(true);
760
									} catch (Exception e1) {
824
									}
825
									catch (Exception e1) {
761 826
										// TODO Auto-generated catch block
762 827
										e1.printStackTrace();
763 828
									}
764 829
								}
765 830
							});
766

  
767
						} catch (ThreadDeath td) {
831
							
832
						}
833
						catch (ThreadDeath td) {
768 834
							return Status.CANCEL_STATUS;
769
						} catch (Exception e) {
835
						}
836
						catch (Exception e) {
770 837
							System.err.println(NLS.bind(ConcordanceUIMessages.anErrorOccurredWhileRetrievingTheConcordanceLinesColonP0, e));
771 838
							org.txm.utils.logger.Log.printStackTrace(e);
772
						} catch (Error e) {
773
							System.err.println(ConcordanceUIMessages.bind(ConcordanceUIMessages.fatalErrorColonP0,e));
839
						}
840
						catch (Error e) {
841
							System.err.println(ConcordanceUIMessages.bind(ConcordanceUIMessages.fatalErrorColonP0, e));
774 842
							e.printStackTrace();
775
						} finally {
843
						}
844
						finally {
776 845
							monitor.done();
777 846
							JobsTimer.stopAndPrint();
778 847
						}
779 848
						return Status.OK_STATUS;
780 849
					}
781 850
				};
782

  
851
				
783 852
				jobhandler.startJob();
784
			} catch (Exception e) {
853
			}
854
			catch (Exception e) {
785 855
				System.err.println(NLS.bind(ConcordanceUIMessages.anErrorOccurredWhileRetrievingTheConcordanceLinesColonP0, e));
786 856
				org.txm.utils.logger.Log.printStackTrace(e);
787 857
			}
788 858
		}
789 859
	}
790

  
860
	
791 861
	/**
792 862
	 * Lazy loads the concordance lines range and fills the display area.
793 863
	 *
......
795 865
	 * @param to the to
796 866
	 */
797 867
	public void fillDisplayArea(boolean update) {
798
		if (viewerRight == null) {
799
			return;
800
		}
801

  
868
		
869
		if (viewerRight == null) { return; }
870
		
802 871
		int from = concordance.getTopIndex();
803 872
		from = Math.max(from, 0);
804

  
873
		
805 874
		int to = from + concordance.getNLinePerPage();
806 875
		to = Math.min(to, concordance.getNLines()) - 1;
807

  
876
		
808 877
		viewerRight.getControl().setRedraw(false);
809 878
		viewerLeft.getControl().setRedraw(false);
810

  
879
		
811 880
		List<Line> lines = null;
812 881
		if (concordance.getNLines() > 0) {
813 882
			try {
814 883
				lines = concordance.getLines(from, to);
815
			} catch (Exception e) {
884
			}
885
			catch (Exception e) {
816 886
				System.err.println(NLS.bind(ConcordanceUIMessages.anErrorOccurredWhileRetrievingTheConcordanceLinesColonP0, e));
817 887
				org.txm.utils.logger.Log.printStackTrace(e);
818 888
			}
......
820 890
		else {
821 891
			lines = new ArrayList<Line>();
822 892
		}
823

  
893
		
824 894
		viewerRight.setInput(lines);
825 895
		viewerLeft.setInput(lines);
826

  
827
		navigationWidget.setInfoLineText("" + (from+1), " - " + (to+1) + " / " + concordance.getNLines()); //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-3$
828

  
896
		
897
		navigationWidget.setInfoLineText("" + (from + 1), " - " + (to + 1) + " / " + concordance.getNLines()); //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-3$
898
		
829 899
		navigationWidget.setPreviousEnabled(concordance.getTopIndex() > 0);
830 900
		navigationWidget.setFirstEnabled(concordance.getTopIndex() > 0);
831 901
		navigationWidget.setNextEnabled((concordance.getTopIndex() + concordance.getNLinePerPage()) < concordance.getNLines() - 1);
832 902
		navigationWidget.setLastEnabled((concordance.getTopIndex() + concordance.getNLinePerPage()) < concordance.getNLines() - 1);
833 903
		navigationWidget.layout();
834 904
		navigationWidget.getParent().layout();
835

  
905
		
836 906
		refreshReferenceColumnTitle();
837 907
		viewerRight.getControl().setRedraw(true);
838 908
		viewerLeft.getControl().setRedraw(true);
839 909
	}
840

  
910
	
841 911
	/**
842 912
	 * Get the Composite that contains the query and sort forms
843 913
	 * 
......
846 916
	 * @return
847 917
	 */
848 918
	public Composite getQueryArea() {
919
		
849 920
		return queryArea;
850 921
	}
851

  
922
	
852 923
	/**
853 924
	 * Get the Composite that contains the navigation buttons
854 925
	 * 
......
857 928
	 * @return
858 929
	 */
859 930
	public Composite getNavigationArea() {
931
		
860 932
		return queryArea;
861 933
	}
862

  
934
	
863 935
	/**
864 936
	 * Compose control area.
865 937
	 *
866 938
	 * @param controlArea the control area
867 939
	 */
868 940
	private void composeControlArea(final Composite controlArea) {
869

  
870

  
941
		
871 942
		// Modified computing listeners to manage multi lines query widgets
872 943
		ComputeKeyListener computeKeyListener = new ComputeKeyListener(this) {
944
			
873 945
			@Override
874 946
			public void keyPressed(KeyEvent e) {
947
				
875 948
				if (queryWidget.getQuery() == null) return;
876 949
				if (!queryWidget.getQuery().getSearchEngine().hasMultiLineQueries()) super.keyPressed(e);
877 950
			}
878 951
		};
879

  
952
		
880 953
		GridLayout controlLayout = new GridLayout(1, false);
881 954
		controlLayout.verticalSpacing = 0;
882 955
		controlLayout.marginWidth = 0;
883 956
		controlLayout.marginHeight = 0;
884 957
		controlArea.setLayout(controlLayout);
885

  
958
		
886 959
		// Query Area: query itself + view properties
887 960
		queryArea = new Composite(controlArea, SWT.NONE);
888 961
		queryArea.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
889 962
		queryArea.setLayout(new GridLayout(4, false));
890

  
963
		
891 964
		////////////////////////////////
892
		//composeAnnotationArea(controlArea);
965
		// composeAnnotationArea(controlArea);
893 966
		//////////////////////////////////
894

  
967
		
895 968
		navigationArea = new Composite(controlArea, SWT.NONE);
896 969
		navigationArea.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
897
		GridLayout navigationLayout = new GridLayout(7, false); 
970
		GridLayout navigationLayout = new GridLayout(7, false);
898 971
		navigationLayout.verticalSpacing = 0;
899 972
		navigationLayout.marginWidth = 0;
900 973
		navigationLayout.marginHeight = 0;
901 974
		navigationArea.setLayout(navigationLayout);
902 975
		///////////////////////////
903 976
		// | Query: [ (v)] [Search] |
904

  
977
		
905 978
		// Query:
906 979
		getMainParametersComposite().getLayout().numColumns = 2;
907 980
		// make
908 981
		getMainParametersComposite().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
909

  
982
		
910 983
		queryLabel = new Label(getMainParametersComposite(), SWT.NONE);
911 984
		queryLabel.setText(TXMUIMessages.ampQuery);
912 985
		queryLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
913

  
986
		
914 987
		// [ (v)]
915
		queryWidget = new AssistedChoiceQueryWidget(this.getMainParametersComposite(), SWT.DROP_DOWN|SWT.MULTI| SWT.WRAP | SWT.V_SCROLL, concordance.getCorpus());
988
		queryWidget = new AssistedChoiceQueryWidget(this.getMainParametersComposite(), SWT.DROP_DOWN | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL, concordance.getCorpus());
916 989
		queryWidget.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
917 990
		queryWidget.addKeyListener(computeKeyListener);
918 991
		queryWidget.getQueryWidget().addModifyListener(computeKeyListener);
919

  
992
		
920 993
		// FIXME: SJ: for computing when changing the query from history combo box
921 994
		// FIXME: SJ: commented because it doesn't work, the computing is launched as soon as we click on the arrow of the combo box
922
		//queryWidget.getQueryWidget().addSelectionListener(new ComputeSelectionListener(this));
923

  
995
		// queryWidget.getQueryWidget().addSelectionListener(new ComputeSelectionListener(this));
996
		
924 997
		// hide the parameters panel
925
		//getTopToolbar().setVisible(TXMEditor.COMPUTING_PARAMETERS_GROUP_ID, false); // the settings are not necessary to compute the concordance
926

  
998
		// getTopToolbar().setVisible(TXMEditor.COMPUTING_PARAMETERS_GROUP_ID, false); // the settings are not necessary to compute the concordance
999
		
927 1000
		// | Properties: word/pos [Edit] |
928
		//		propsArea = new PropertiesSelector<Property>(queryArea, SWT.NONE);
929
		//		propsArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
930
		//		propsArea.setLayout(new GridLayout(3, false));
931
		//		this.propsArea.setProperties(concordance.getAvailableKeywordViewProperties(), concordance.getKeywordViewProperties());
932
		//		propsArea.addValueChangeListener(new Listener() {
933
		//			@Override
934
		//			public void handleEvent(Event event) {
935
		//				concordance.setKeywordViewProperties(propsArea.getSelectedProperties());
936
		//				refreshViewProperties();
937
		//			}
938
		//		});
939

  
1001
		// propsArea = new PropertiesSelector<Property>(queryArea, SWT.NONE);
1002
		// propsArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
1003
		// propsArea.setLayout(new GridLayout(3, false));
1004
		// this.propsArea.setProperties(concordance.getAvailableKeywordViewProperties(), concordance.getKeywordViewProperties());
1005
		// propsArea.addValueChangeListener(new Listener() {
1006
		// @Override
1007
		// public void handleEvent(Event event) {
1008
		// concordance.setKeywordViewProperties(propsArea.getSelectedProperties());
1009
		// refreshViewProperties();
1010
		// }
1011
		// });
1012
		
940 1013
		// [Search]
941
		//		Button go = new Button(queryArea, SWT.PUSH);
942
		//		go.setText(TXMUIMessages.SEARCH);
1014
		// Button go = new Button(queryArea, SWT.PUSH);
1015
		// go.setText(TXMUIMessages.SEARCH);
943 1016
		//
944
		//		Font f = go.getFont();
945
		//		FontData defaultFont = f.getFontData()[0];
946
		//		defaultFont.setStyle(SWT.BOLD);
947
		//		Font newf = new Font(go.getDisplay(), defaultFont);
948
		//		go.setFont(newf);
1017
		// Font f = go.getFont();
1018
		// FontData defaultFont = f.getFontData()[0];
1019
		// defaultFont.setStyle(SWT.BOLD);
1020
		// Font newf = new Font(go.getDisplay(), defaultFont);
1021
		// go.setFont(newf);
949 1022
		//
950
		//		go.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
951
		//		go.addSelectionListener(new ComputeSelectionListener(this));
952

  
1023
		// go.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
1024
		// go.addSelectionListener(new ComputeSelectionListener(this));
1025
		
953 1026
		// Complex sort chooser (full line)
954 1027
		complexsorter = new ComplexSortSelector(queryArea, SWT.NONE);
955 1028
		complexsorter.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true, 4, 1));
956

  
1029
		
957 1030
		// properties widget like in the portal version
958 1031
		GLComposite propertiesPanel = new GLComposite(queryArea, SWT.BORDER, ConcordanceUIMessages.propertiesPanel);
959 1032
		propertiesPanel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true, 4, 1));
960 1033
		propertiesPanel.getLayout().numColumns = 5;
961 1034
		propertiesPanel.getLayout().makeColumnsEqualWidth = false;
962

  
1035
		
963 1036
		try {
964 1037
			Label l = new Label(propertiesPanel, SWT.NONE);
965 1038
			l.setText(ConcordanceUIMessages.editor_21);
966
			l.setLayoutData(new GridData(GridData.CENTER,GridData.CENTER, false, false));
1039
			l.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
967 1040
			l = new Label(propertiesPanel, SWT.NONE);
968 1041
			l.setText(ConcordanceUIMessages.references);
969
			l.setLayoutData(new GridData(GridData.CENTER,GridData.CENTER, true, false));
1042
			l.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, true, false));
970 1043
			l = new Label(propertiesPanel, SWT.NONE);
971 1044
			l.setText(ConcordanceUIMessages.left);
972
			l.setLayoutData(new GridData(GridData.CENTER,GridData.CENTER, true, false));
1045
			l.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, true, false));
973 1046
			l = new Label(propertiesPanel, SWT.NONE);
974 1047
			l.setText(ConcordanceUIMessages.keyword);
975
			l.setLayoutData(new GridData(GridData.CENTER,GridData.CENTER, true, false));
1048
			l.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, true, false));
976 1049
			l = new Label(propertiesPanel, SWT.NONE);
977 1050
			l.setText(ConcordanceUIMessages.right);
978
			l.setLayoutData(new GridData(GridData.CENTER,GridData.CENTER, true, false));
979

  
1051
			l.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, true, false));
1052
			
980 1053
			l = new Label(propertiesPanel, SWT.NONE);
981 1054
			l.setText(ConcordanceUIMessages.view);
982
			l.setLayoutData(new GridData(GridData.CENTER,GridData.CENTER, false, false));
1055
			l.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
983 1056
			refViewProperties = new PropertiesSelector<Property>(propertiesPanel, SWT.NONE);
984 1057
			refViewProperties.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
985 1058
			refViewProperties.setTitle(ConcordanceUIMessages.editor_21);
986 1059
			refViewProperties.setButtonText(ConcordanceUIMessages.editor_19);
987 1060
			refViewProperties.setProperties(ReferencePattern.getPossibleValues(getCorpus()));
988 1061
			refViewProperties.addSelectionListener(new ComputeSelectionListener(this) {
1062
				
989 1063
				@Override
990 1064
				public void widgetSelected(SelectionEvent e) {
1065
					
991 1066
					concordance.setRefViewPattern(new ReferencePattern(refViewProperties.getSelectedProperties()));
992 1067
					super.widgetSelected(e);
993 1068
				}
......
998 1073
			leftViewProperties.setProperties(getCorpus().getOrderedProperties());
999 1074
			leftViewProperties.setButtonText(ConcordanceUIMessages.editor_19);
1000 1075
			leftViewProperties.addSelectionListener(new ComputeSelectionListener(this) {
1076
				
1001 1077
				@Override
1002 1078
				public void widgetSelected(SelectionEvent e) {
1079
					
1003 1080
					concordance.setLeftViewProperties(leftViewProperties.getSelectedProperties());
1004 1081
					super.widgetSelected(e);
1005 1082
				}
......
1010 1087
			keywordViewProperties.setProperties(getCorpus().getOrderedProperties());
1011 1088
			keywordViewProperties.setButtonText(ConcordanceUIMessages.editor_19);
1012 1089
			keywordViewProperties.addSelectionListener(new ComputeSelectionListener(this) {
1090
				
1013 1091
				@Override
1014 1092
				public void widgetSelected(SelectionEvent e) {
1093
					
1015 1094
					concordance.setKeywordViewProperties(keywordViewProperties.getSelectedProperties());
1016 1095
					super.widgetSelected(e);
1017 1096
				}
......
1022 1101
			rightViewProperties.setProperties(getCorpus().getOrderedProperties());
1023 1102
			rightViewProperties.setButtonText(ConcordanceUIMessages.editor_19);
1024 1103
			rightViewProperties.addSelectionListener(new ComputeSelectionListener(this) {
1104
				
1025 1105
				@Override
1026 1106
				public void widgetSelected(SelectionEvent e) {
1107
					
1027 1108
					concordance.setRightViewProperties(rightViewProperties.getSelectedProperties());
1028 1109
					super.widgetSelected(e);
1029 1110
				}
1030 1111
			});
1031

  
1112
			
1032 1113
			l = new Label(propertiesPanel, SWT.NONE);
1033 1114
			l.setText(ConcordanceUIMessages.sort);
1034
			l.setLayoutData(new GridData(GridData.CENTER,GridData.CENTER, false, false));
1115
			l.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
1035 1116
			refSortProperties = new PropertiesSelector<Property>(propertiesPanel, SWT.NONE);
1036 1117
			refSortProperties.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
1037 1118
			refSortProperties.setTitle(ConcordanceUIMessages.editor_21);
1038 1119
			refSortProperties.setButtonText(ConcordanceUIMessages.editor_19);
1039 1120
			refSortProperties.setProperties(ReferencePattern.getPossibleValues(getCorpus()));
1040 1121
			refSortProperties.addSelectionListener(new ComputeSelectionListener(this) {
1122
				
1041 1123
				@Override
1042 1124
				public void widgetSelected(SelectionEvent e) {
1125
					
1043 1126
					concordance.setRefAnalysePattern(new ReferencePattern(refSortProperties.getSelectedProperties()));
1044 1127
					super.widgetSelected(e);
1045 1128
				}
......
1050 1133
			leftSortProperties.setButtonText(ConcordanceUIMessages.editor_19);
1051 1134
			leftSortProperties.setProperties(getCorpus().getOrderedProperties());
1052 1135
			leftSortProperties.addSelectionListener(new ComputeSelectionListener(this) {
1136
				
1053 1137
				@Override
1054 1138
				public void widgetSelected(SelectionEvent e) {
1139
					
1055 1140
					concordance.setLeftAnalysisProperties(leftSortProperties.getSelectedProperties());
1056 1141
					super.widgetSelected(e);
1057 1142
				}
......
1062 1147
			keywordSortProperties.setButtonText(ConcordanceUIMessages.editor_19);
1063 1148
			keywordSortProperties.setProperties(getCorpus().getOrderedProperties());
1064 1149
			keywordSortProperties.addSelectionListener(new ComputeSelectionListener(this) {
1150
				
1065 1151
				@Override
1066 1152
				public void widgetSelected(SelectionEvent e) {
1153
					
1067 1154
					concordance.setKeywordAnalysisProperties(keywordSortProperties.getSelectedProperties());
1068 1155
					super.widgetSelected(e);
1069 1156
				}
......
1074 1161
			rightSortProperties.setButtonText(ConcordanceUIMessages.editor_19);
1075 1162
			rightSortProperties.setProperties(getCorpus().getOrderedProperties());
1076 1163
			rightSortProperties.addSelectionListener(new ComputeSelectionListener(this) {
1164
				
1077 1165
				@Override
1078 1166
				public void widgetSelected(SelectionEvent e) {
1167
					
1079 1168
					concordance.setRightAnalysisProperties(rightSortProperties.getSelectedProperties());
1080 1169
					super.widgetSelected(e);
1081 1170
				}
1082 1171
			});
1083

  
1172
			
1084 1173
			l = new Label(propertiesPanel, SWT.NONE);
1085 1174
			l.setText(ConcordanceUIMessages.size);
1086
			l.setLayoutData(new GridData(GridData.CENTER,GridData.CENTER, false, false));
1175
			l.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
1087 1176
			new Label(propertiesPanel, SWT.NONE);
1088 1177
			leftSizeSpinner = new Spinner(propertiesPanel, SWT.BORDER);
1089 1178
			leftSizeSpinner.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
1090 1179
			leftSizeSpinner.addSelectionListener(new ComputeSelectionListener(this) {
1180
				
1091 1181
				@Override
1092 1182
				public void widgetSelected(SelectionEvent e) {
1183
					
1093 1184
					concordance.setLeftContextSize(leftSizeSpinner.getSelection());
1094 1185
					super.widgetSelected(e);
1095 1186
				}
1096 1187
			});
1097 1188
			leftSizeSpinner.addKeyListener(new KeyListener() {
1189
				
1098 1190
				@Override
1099 1191
				public void keyReleased(KeyEvent e) {
1192
					
1100 1193
					if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
1101 1194
						concordance.setLeftContextSize(leftSizeSpinner.getSelection());
1102 1195
						ConcordanceEditor.this.compute(true);
1103 1196
					}
1104 1197
				}
1198
				
1105 1199
				@Override
1106
				public void keyPressed(KeyEvent e) { }
1200
				public void keyPressed(KeyEvent e) {}
1107 1201
			});
1108 1202
			new Label(propertiesPanel, SWT.NONE);
1109 1203
			rightSizeSpinner = new Spinner(propertiesPanel, SWT.BORDER);
1110 1204
			rightSizeSpinner.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
1111 1205
			rightSizeSpinner.addSelectionListener(new ComputeSelectionListener(this) {
1206
				
1112 1207
				@Override
1113 1208
				public void widgetSelected(SelectionEvent e) {
1209
					
1114 1210
					concordance.setRightContextSize(rightSizeSpinner.getSelection());
1115 1211
					super.widgetSelected(e);
1116 1212
				}
1117 1213
			});
1118 1214
			rightSizeSpinner.addKeyListener(new KeyListener() {
1215
				
1119 1216
				@Override
1120 1217
				public void keyReleased(KeyEvent e) {
1218
					
1121 1219
					if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
1122 1220
						concordance.setRightContextSize(rightSizeSpinner.getSelection());
1123 1221
						ConcordanceEditor.this.compute(true);
1124 1222
					}
1125 1223
				}
1224
				
1126 1225
				@Override
1127
				public void keyPressed(KeyEvent e) { }
1226
				public void keyPressed(KeyEvent e) {}
1128 1227
			});
1129
		} catch (Exception e1) {
1228
		}
1229
		catch (Exception e1) {
1130 1230
			// TODO Auto-generated catch block
1131 1231
			e1.printStackTrace();
1132 1232
		}
1133

  
1233
		
1134 1234
		// Delete line button
1135 1235
		deleteLineButton = new Button(navigationArea, SWT.PUSH);
1136 1236
		deleteLineButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
1137 1237
		deleteLineButton.setToolTipText(ConcordanceUIMessages.deleteSelectedLines);
1138 1238
		deleteLineButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_DELETE));
1139 1239
		deleteLineButton.addSelectionListener(new SelectionListener() {
1240
			
1140 1241
			@Override
1141 1242
			public void widgetSelected(SelectionEvent e) {
1243
				
1142 1244
				DeleteLines.deleteConcordanceLines(ConcordanceEditor.this);
1143 1245
			}
1144

  
1246
			
1145 1247
			@Override
1146
			public void widgetDefaultSelected(SelectionEvent e) { }
1248
			public void widgetDefaultSelected(SelectionEvent e) {}
1147 1249
		});
1148

  
1250
		
1149 1251
		// Navigation Area: infoLine and buttons
1150 1252
		GLComposite navigationAreaComposite = getBottomToolbar().installGLComposite(ConcordanceUIMessages.navigation, 1, false);
1151 1253
		navigationAreaComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
1152

  
1254
		
1153 1255
		navigationWidget = new NavigationWidget(navigationAreaComposite, SWT.NONE);
1154 1256
		navigationWidget.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
1155

  
1257
		
1156 1258
		// | [|<] [<] infos [>] [>|] |
1157 1259
		// [|<]
1158 1260
		navigationWidget.addFirstListener(new SelectionListener() {
1261
			
1159 1262
			@Override
1160
			public void widgetDefaultSelected(SelectionEvent arg0) {
1161
			}
1162

  
1263
			public void widgetDefaultSelected(SelectionEvent arg0) {}
1264
			
1163 1265
			@Override
1164 1266
			public void widgetSelected(SelectionEvent arg0) {
1267
				
1165 1268
				concordance.setTopIndex(0);
1166 1269
				try {
1167 1270
					refresh(false);
1168 1271
					viewerRight.getTable().setTopIndex(0);
1169
				} catch (Exception e1) {
1272
				}
1273
				catch (Exception e1) {
1170 1274
					// TODO Auto-generated catch block
1171 1275
					e1.printStackTrace();
1172 1276
				}
1173 1277
			}
1174 1278
		});
1175

  
1279
		
1176 1280
		// [<]
1177 1281
		navigationWidget.addPreviousListener(new SelectionListener() {
1282
			
1178 1283
			@Override
1179
			public void widgetDefaultSelected(SelectionEvent e) {
1180
			}
1181

  
1284
			public void widgetDefaultSelected(SelectionEvent e) {}
1285
			
1182 1286
			@Override
1183 1287
			public void widgetSelected(SelectionEvent e) {
1288
				
1184 1289
				int top = concordance.getTopIndex() - concordance.getNLinePerPage();
1185 1290
				if (top < 0)
1186 1291
					top = 0;
......
1188 1293
				try {
1189 1294
					refresh(false);
1190 1295
					viewerRight.getTable().setTopIndex(0);
1191
				} catch (Exception e1) {
1296
				}
1297
				catch (Exception e1) {
1192 1298
					// TODO Auto-generated catch block
1193 1299
					e1.printStackTrace();
1194 1300
				}
1195 1301
			}
1196 1302
		});
1197

  
1303
		
1198 1304
		// [>]
1199 1305
		navigationWidget.addNextListener(new SelectionListener() {
1306
			
1200 1307
			@Override
1201
			public void widgetDefaultSelected(SelectionEvent e) {
1202
			}
1203

  
1308
			public void widgetDefaultSelected(SelectionEvent e) {}
1309
			
1204 1310
			@Override
1205 1311
			public void widgetSelected(SelectionEvent e) {
1312
				
1206 1313
				concordance.setTopIndex(concordance.getTopIndex() + concordance.getNLinePerPage());
1207 1314
				try {
1208 1315
					refresh(false);
1209 1316
					viewerRight.getTable().setTopIndex(0);
1210
				} catch (Exception e1) {
1317
				}
1318
				catch (Exception e1) {
1211 1319
					// TODO Auto-generated catch block
1212 1320
					e1.printStackTrace();
1213 1321
				}
1214 1322
			}
1215 1323
		});
1216

  
1324
		
1217 1325
		// [>|]
1218 1326
		navigationWidget.addLastListener(new SelectionListener() {
1327
			
1219 1328
			@Override
1220
			public void widgetDefaultSelected(SelectionEvent e) {
1221
			}
1222

  
1329
			public void widgetDefaultSelected(SelectionEvent e) {}
1330
			
1223 1331
			@Override
1224 1332
			public void widgetSelected(SelectionEvent e) {
1333
				
1225 1334
				int top = (concordance.getNLines() / concordance.getNLinePerPage()) * concordance.getNLinePerPage();
1226 1335
				// FIXME: SJ: became useless?
1227
				//int bottom = top + concordance.getNLinePerPage() -1;
1336
				// int bottom = top + concordance.getNLinePerPage() -1;
1228 1337
				concordance.setTopIndex(top);
1229 1338
				try {
1230 1339
					refresh(false);
1231 1340
					viewerRight.getTable().setTopIndex(0);
1232
				} catch (Exception e1) {
1341
				}
1342
				catch (Exception e1) {
1233 1343
					// TODO Auto-generated catch block
1234 1344
					e1.printStackTrace();
1235 1345
				}
1236 1346
			}
1237 1347
		});
1238

  
1348
		
1239 1349
		queryArea.layout();
1240 1350
	}
1241

  
1351
	
1242 1352
	/**
1243 1353
	 * refresh
1354
	 * 
1244 1355
	 * @param top
1245 1356
	 * @param bottom
1246 1357
	 */
1247 1358
	public void updateEditorFromResult(boolean update) {
1359
		
1248 1360
		StatusLine.setMessage(ConcordanceUIMessages.startComputingConcordance);
1249

  
1361
		
1250 1362
		try {
1251 1363
			QueriesView.refresh();
1252

  
1364
			
1253 1365
			this.fillDisplayArea(update);
1254 1366
			
1255 1367
			boolean b = concordance.getQueryResultParameter() == null;
1256 1368
			this.queryWidget.setEnabled(b); // disable the widget if a QueryResult was provided
1257 1369
			
1258 1370
			this.queryWidget.memorize();
1259

  
1371
			
1260 1372
			if (update) {
1261 1373
				resetColumnWidths();
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff