Révision 3799

TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java (revision 3799)
2 2

  
3 3
import java.io.File;
4 4
import java.net.URL;
5
import java.nio.file.Paths;
6 5
import java.util.ArrayList;
7 6
import java.util.Arrays;
8 7
import java.util.Collection;
......
45 44
import org.txm.objects.Project;
46 45
import org.txm.objects.Text;
47 46
import org.txm.rcp.StatusLine;
48
import org.txm.rcp.commands.ShowSelected;
49 47
import org.txm.rcp.editors.CommandLink;
50 48
import org.txm.rcp.editors.TXMBrowserEditor;
51 49
import org.txm.rcp.editors.menu.PagePropertiesMenu;
......
54 52
import org.txm.utils.logger.Log;
55 53

  
56 54
public class EditionPanel extends BrowserViewer implements ISelectionProvider {
57
	
55

  
58 56
	private ProgressListener progressListener;
59
	
57

  
60 58
	// private List<String> wordids;
61 59
	// private List<String> lineids;
62 60
	/** The edition. */
63 61
	Text currentText;
64
	
62

  
65 63
	String editionName;
66
	
64

  
67 65
	Edition currentEdition;
68
	
66

  
69 67
	Page currentPage;
70
	
68

  
71 69
	protected SynopticEditionEditor synopticEditionEditor;
72
	
70

  
73 71
	private ISelectionProvider selProvider;
74
	
72

  
75 73
	private MenuManager menuManager;
76
	
74

  
77 75
	private HashSet<int[]> highlightedAreas = null;
78
	
76

  
79 77
	// HashMap<String, ArrayList<RGBA>> highlightedColorSpans = new HashMap<String, ArrayList<RGBA>>(); // background color
80
	
78

  
81 79
	HashMap<String, ArrayList<RGBA>> highlightedColorPerWordIDS = new HashMap<>(); // background color
82
	
80

  
83 81
	public static final String STYLE_NORMAL = "normal"; //$NON-NLS-1$
84
	
82

  
85 83
	public static final String STYLE_ITALIC = "italic"; //$NON-NLS-1$
86
	
84

  
87 85
	public static final String STYLE_OBLIQUE = "oblique"; //$NON-NLS-1$
88
	
86

  
89 87
	HashMap<String, String> fontStylePerWordIDS = new HashMap<>();
90
	
88

  
91 89
	public static final String WEIGHT_NORMAL = "normal"; //$NON-NLS-1$
92
	
90

  
93 91
	public static final String WEIGHT_BOLD = "bold"; //$NON-NLS-1$
94
	
92

  
95 93
	HashMap<String, String> fontWeightPerWordIDS = new HashMap<>();
96
	
94

  
97 95
	HashMap<String, ArrayList<RGBA>> fontColorPerWordIDS = new HashMap<>();
98
	
96

  
99 97
	public static final String SIZE_SMALL = "small"; //$NON-NLS-1$
100
	
98

  
101 99
	public static final String SIZE_MEDIUM = "medium"; //$NON-NLS-1$
102
	
100

  
103 101
	public static final String SIZE_LARGE = "larger"; //$NON-NLS-1$
104
	
102

  
105 103
	public static final String SIZE_SMALLER = "smaller"; //$NON-NLS-1$
106
	
104

  
107 105
	public static final String SIZE_LARGER = "larger"; //$NON-NLS-1$
108
	
106

  
109 107
	HashMap<String, String> fontSizePerWordIDS = new HashMap<>();
110
	
108

  
111 109
	public static final String FAMILLY_TIMES = "\"Times New Roman\", Times"; //$NON-NLS-1$
112
	
110

  
113 111
	public static final String FAMILLY_ARIAL = "Arial"; //$NON-NLS-1$
114
	
112

  
115 113
	public static final String FAMILLY_COURIER = "\"Courier New\", Courier"; //$NON-NLS-1$
116
	
114

  
117 115
	HashMap<String, String> fontFamillyPerWordIDS = new HashMap<>();
118
	
116

  
119 117
	public static final String VARIANT_NORMAL = "normal"; //$NON-NLS-1$
120
	
118

  
121 119
	public static final String VARIANT_SMALLCAPS = "small-caps"; //$NON-NLS-1$
122
	
120

  
123 121
	HashMap<String, String> fontVariantPerWordIDS = new HashMap<>();
124
	
122

  
125 123
	String focusedWordID = null;
126
	
124

  
127 125
	public static final String highlightscript = "try { var elt = document.getElementById(\"%s\");" + //$NON-NLS-1$
128 126
			"elt.style.backgroundColor=\"rgb(%s,%s,%s)\";" + //$NON-NLS-1$
129 127
			// "elt.style.paddingLeft=\"3px\";" + //$NON-NLS-1$
......
131 129
			// "elt.style.paddingTop=\"1px\";" + //$NON-NLS-1$
132 130
			// "elt.style.paddingBottom=\"1px\";" + //$NON-NLS-1$
133 131
			"} catch (e) { };"; //$NON-NLS-1$
134
	
132

  
135 133
	public static final String highlightscriptRuleFast = "sheet.insertRule(\"#%s {background-color:rgba(%s,%s,%s,%s);}\", 0);"; //$NON-NLS-1$
136
	
134

  
137 135
	public static final String colorscriptRuleFast = "sheet.insertRule(\"#%s {color:rgba(%s,%s,%s,%s);}\", 0);"; //$NON-NLS-1$
138
	
136

  
139 137
	public static final String sizescriptRuleFast = "sheet.insertRule(\"#%s {font-size:%s;}\", 0);"; //$NON-NLS-1$
140
	
138

  
141 139
	public static final String stylescriptRuleFast = "sheet.insertRule(\"#%s {font-style:%s;}\", 0);"; //$NON-NLS-1$
142
	
140

  
143 141
	public static final String variantscriptRuleFast = "sheet.insertRule(\"#%s {font-variant:%s;}\", 0);"; //$NON-NLS-1$
144
	
142

  
145 143
	public static final String famillyscriptRuleFast = "sheet.insertRule(\"#%s {font-familly:%s;}\", 0);"; //$NON-NLS-1$
146
	
144

  
147 145
	public static final String weightscriptRuleFast = "sheet.insertRule(\"#%s {font-weight:%s;}\", 0);"; //$NON-NLS-1$
148
	
146

  
149 147
	public static final String highlightscriptRule = "sheet.insertRule(\"span[id=\\\"%s\\\"] {background-color:rgba(%s,%s,%s,%s); }\", 0);"; //$NON-NLS-1$
150
	
148

  
151 149
	public static final String clearhighlightscript = "try { var elt = document.getElementById(\"%s\"); elt.style.backgroundColor=\"white\";elt.style.fontWeight=\"\";" + //$NON-NLS-1$
152 150
			"} catch (e) { };"; //$NON-NLS-1$
153
	
151

  
154 152
	public String functions = ""// "alert(\"loading functions\");" //$NON-NLS-1$
155 153
			+ "\ngetNodeText = function getNodeText(node) {" //$NON-NLS-1$
156 154
			+ "\n	if (typeof node == 'string') return node;" //$NON-NLS-1$
......
262 260
			+ "\n	};" //$NON-NLS-1$
263 261
			+ "\n}" //$NON-NLS-1$
264 262
			+ "\n} catch(e) {Element.prototype.scrollIntoViewIfNeeded = Element.prototype.scrollIntoView}"; //$NON-NLS-1$
265
	
263

  
266 264
	protected boolean fastWordHighLight = SynopticEditionPreferences.getInstance().getBoolean(SynopticEditionPreferences.FAST_HIGHLIGHT);
267
	
265

  
268 266
	private ArrayList<ProgressListener> beforeHighlighListeners;
269
	
267

  
270 268
	public ArrayList<ProgressListener> getBeforeHighlighListeners() {
271
		
269

  
272 270
		return beforeHighlighListeners;
273 271
	}
274
	
272

  
275 273
	private ArrayList<ProgressListener> afterHighlighListeners;
276
	
274

  
277 275
	private CommandLink cmdLink;
278
	
276

  
279 277
	private EditionLink editionLink;
280
	
278

  
281 279
	public ArrayList<ProgressListener> getAfterHighlighListeners() {
282
		
280

  
283 281
		return beforeHighlighListeners;
284 282
	}
285
	
283

  
286 284
	public Object evaluate(String code) {
287
		
285

  
288 286
		if (Log.getLevel().intValue() <= Level.FINEST.intValue()) System.out.println(code);
289
		
287

  
290 288
		try {
291 289
			if (getBrowser() == null) return null;
292 290
			return getBrowser().evaluate(code);
......
298 296
		}
299 297
		return null;
300 298
	}
301
	
299

  
302 300
	public boolean execute(String code) {
303
		
301

  
304 302
		if (Log.getLevel().intValue() <= Level.FINEST.intValue()) System.out.println(code);
305 303
		try {
306 304
			//System.out.println("EXECUTE: "+code.replace("\n", " RET ").subSequence(0, Math.min(200, code.length())));
......
312 310
		}
313 311
		return false;
314 312
	}
315
	
313

  
316 314
	public EditionPanel(SynopticEditionEditor synopticEditionEditor, Composite parent, int style, String editionName) {
317
		
315

  
318 316
		super(parent, style);
319 317
		this.synopticEditionEditor = synopticEditionEditor;
320 318
		this.editionName = editionName;
321 319
		// this.currentEdition = edition;
322 320
		// this.currentText = currentEdition.getText();
323
		
321

  
324 322
		File functionsFile = null;
325 323
		try {
326 324
			Bundle bundle = Platform.getBundle("org.txm.edition.rcp"); //$NON-NLS-1$
......
333 331
			Log.severe(EditionUIMessages.bind(EditionUIMessages.error_while_reading, functionsFile, e.getLocalizedMessage()));
334 332
			Log.printStackTrace(e);
335 333
		}
336
		
334

  
337 335
		beforeHighlighListeners = new ArrayList<>();
338 336
		afterHighlighListeners = new ArrayList<>();
339
		
337

  
340 338
		//		this.browser.addLocationListener(new LocationListener() {
341 339
		//			
342 340
		//			@Override
......
352 350
		//				if (editionLink != null) cmdLink.dispose();
353 351
		//			}
354 352
		//		});
355
		
356
		
353

  
354

  
357 355
		this.addDisposeListener(new DisposeListener() { // clean the BrowserFunction s
358
			
356

  
359 357
			@Override
360 358
			public void widgetDisposed(DisposeEvent e) {
361 359
				//				System.out.println("dispose listener called");
......
364 362
				if (browser!= null && !browser.isDisposed()) browser.dispose();
365 363
			}
366 364
		});
367
		
365

  
368 366
		if (cmdLink == null) {
369 367
			cmdLink = new CommandLink(synopticEditionEditor, browser);
370 368
		}
......
389 387
		//				editionLink = new EditionLink(synopticEditionEditor, browser);
390 388
		//			}
391 389
		//		});
392
		
390

  
393 391
		progressListener = new ProgressListener() {
394
			
392

  
395 393
			@Override
396 394
			public void changed(ProgressEvent event) {}
397
			
395

  
398 396
			@Override
399 397
			public synchronized void completed(ProgressEvent event) {
400
				
398

  
401 399
				Browser browser = getBrowser();
402 400
				Object o = browser.evaluate("return typeof " + CommandLink.FCT + ";");
403 401
				if ("undefined".equals(o)) {
......
415 413
					editionLink = new EditionLink(synopticEditionEditor, browser);
416 414
					//System.out.println("rebuild editionLink");
417 415
				}
418
				
419
				
420
				
416

  
417

  
418

  
421 419
				Object rez = evaluate("return typeof sheet;"); //$NON-NLS-1$
422 420
				if ("undefined".equals(rez)) { //$NON-NLS-1$
423 421
					Object loadResult = evaluate(functions);
......
429 427
						Log.finer("JS functions loaded.");
430 428
					}
431 429
				}
432
				
430

  
433 431
				// do something before the highlight is done
434 432
				for (ProgressListener pl : beforeHighlighListeners) {
435 433
					pl.completed(event);
436 434
				}
437
				
435

  
438 436
				// System.out.println("highlight: "+highlightedColorPerWordIDS);
439 437
				StringBuilder buffer = new StringBuilder();
440 438
				// buffer.append("alert(\"\"+sheet);\n");
......
446 444
				else {
447 445
					buffer.append("try { while(sheet.cssRules.length > 0) sheet.deleteRule(0); } catch (e) {};\n"); // empty style //$NON-NLS-1$
448 446
				}
449
				
447

  
450 448
				if (buffer.length() > 0) {
451 449
					if (!execute(buffer.toString())) {
452 450
						Log.fine("JS execution error (delete cssRules) with=" + buffer);
453 451
					}
454 452
				}
455
				
456
				
453

  
454

  
457 455
				buffer = new StringBuilder();
458 456
				Log.finest("EditionPanel " + currentEdition + " reload " + currentPage);
459 457
				if (currentPage != null && currentEdition != null) { // avoid null pointer
460
					
458

  
461 459
					String firstWord = currentPage.getWordId();
462 460
					Page nextPage = currentEdition.getNextPage(currentPage);
463 461
					String lastWord = "w_999999999"; //$NON-NLS-1$
......
476 474
					// System.out.println("firstWord="+firstWord+" lastWord="+lastWord);
477 475
					// int n = 0;
478 476
					// long start = System.currentTimeMillis();
479
					
477

  
480 478
					for (String wordid : highlightedColorPerWordIDS.keySet()) {
481 479
						// Log.finest("words to highlight: "+highlightedColorPerWordIDS);
482 480
						if (highlightedColorPerWordIDS.get(wordid).size() == 0) continue; // error
483
						
481

  
484 482
						// if (!slowWordHighLight) { //TODO: this code must be replaced with word position instead of word id comparaison
485 483
						if (Edition.isFirstGTthanSecond(wordid, firstWord) < 0) continue; // skip the word to highlight
486 484
						if (Edition.isFirstGTthanSecond(lastWord, wordid) < 0) continue; // skip the word to highlight
......
488 486
						// n++;
489 487
						RGBA composite = new RGBA(0, 0, 0, 0f);
490 488
						int size = highlightedColorPerWordIDS.get(wordid).size();
491
						
489

  
492 490
						for (RGBA color : highlightedColorPerWordIDS.get(wordid)) {
493 491
							composite.r += color.r;
494 492
							composite.g += color.g;
495 493
							composite.b += color.b;
496 494
							composite.a += color.a;
497 495
						}
498
						
496

  
499 497
						composite.r /= size;
500 498
						composite.g /= size;
501 499
						composite.b /= size;
502
						
500

  
503 501
						String s = null;
504 502
						if (!fastWordHighLight) {
505 503
							// s = String.format(highlightscriptRule, wordid, composite.r, composite.g, composite.b, composite.a);
......
516 514
							s = String.format(highlightscriptRuleFast, wordid.replace(" ", "\\ "), composite.r, composite.g, composite.b, composite.a); //$NON-NLS-1$ //$NON-NLS-2$
517 515
							// s = String.format(highlightscriptRuleFast, wordid, composite.r, composite.g, composite.b, composite.a);
518 516
						}
519
						
517

  
520 518
						buffer.append(s + "\n"); //$NON-NLS-1$
521 519
					}
522 520
				}
523
				
521

  
524 522
				if (buffer.length() > 0) {
525 523
					if (!execute(buffer.toString())) {
526 524
						Log.fine("JS execution (highlight) error with=" + buffer);
527 525
					}
528 526
				}
529
				
530
				
527

  
528

  
531 529
				buffer = new StringBuilder();
532
				
530

  
533 531
				// for (String wordidslist : highlightedColorSpans.keySet()) {
534 532
				// RGBA composite = new RGBA(0,0,0,0f);
535 533
				// int size = highlightedColorSpans.get(wordidslist).size();
......
549 547
				// cmd += "wrap(l, \""+wordidslist+"\";\n";
550 548
				// buffer.append(cmd+"\n");
551 549
				// }
552
				
550

  
553 551
				for (String wordid : fontColorPerWordIDS.keySet()) {
554 552
					RGBA composite = new RGBA(0, 0, 0, 0f);
555 553
					int size = fontColorPerWordIDS.get(wordid).size();
556
					
554

  
557 555
					for (RGBA color : fontColorPerWordIDS.get(wordid)) {
558 556
						composite.r += color.r;
559 557
						composite.g += color.g;
560 558
						composite.b += color.b;
561 559
						composite.a += color.a;
562 560
					}
563
					
561

  
564 562
					composite.r /= size;
565 563
					composite.g /= size;
566 564
					composite.b /= size;
567
					
565

  
568 566
					String s = String.format(colorscriptRuleFast, wordid, composite.r, composite.g, composite.b, composite.a);
569 567
					buffer.append(s + "\n"); //$NON-NLS-1$
570 568
				}
571
				
569

  
572 570
				if (buffer.length() > 0) {
573 571
					if (!execute(buffer.toString())) {
574 572
						Log.fine("JS execution (color) error with=" + buffer);
575 573
					}
576 574
				}
577
				
578
				
575

  
576

  
579 577
				buffer = new StringBuilder();
580
				
578

  
581 579
				for (String wordid : fontSizePerWordIDS.keySet()) {
582 580
					String s = String.format(sizescriptRuleFast, wordid, fontSizePerWordIDS.get(wordid));
583 581
					buffer.append(s + "\n"); //$NON-NLS-1$
584 582
				}
585
				
583

  
586 584
				for (String wordid : fontWeightPerWordIDS.keySet()) {
587 585
					String s = null;
588 586
					if (!fastWordHighLight) {
......
608 606
					}
609 607
					buffer.append(s + "\n"); //$NON-NLS-1$
610 608
				}
611
				
609

  
612 610
				for (String wordid : fontFamillyPerWordIDS.keySet()) {
613 611
					String s = String.format(famillyscriptRuleFast, wordid, fontFamillyPerWordIDS.get(wordid));
614 612
					buffer.append(s + "\n"); //$NON-NLS-1$
615 613
				}
616
				
614

  
617 615
				if (buffer.length() > 0) {
618 616
					if (!execute(buffer.toString())) {
619 617
						Log.fine("JS execution (font) error with=" + buffer);
620 618
					}
621 619
				}
622
				
623
				
620

  
621

  
624 622
				buffer = new StringBuilder();
625
				
623

  
626 624
				if (focusedWordID != null) {
627 625
					// System.out.println("Focus on: "+focusedWordID);
628 626
					String s = "try { showElementIfNeeded(document.getElementById(\"" + focusedWordID + "\")); } catch (e) {document.getElementById(\"" + focusedWordID + "\").scrollIntoView();};"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
629 627
					//String s = "document.getElementById(\"" + focusedWordID + "\").scrollIntoView();"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
630 628
					buffer.append(s + "\n"); //$NON-NLS-1$
631 629
				}
632
				
630

  
633 631
				if (buffer.length() > 0) {
634 632
					//Object rez2 = execute(buffer.toString());
635 633
					if (execute(buffer.toString())) {
......
639 637
						Log.fine("JS execution (focus) error with script=" + buffer);
640 638
					}
641 639
				}
642
				
640

  
643 641
				buffer = new StringBuilder();
644
				
642

  
645 643
				if (highlightedAreas != null) {
646 644
					for (int[] pos : highlightedAreas) {
647 645
						if (pos == null || pos.length != 4) continue;
......
650 648
						break;// one word only for now
651 649
					}
652 650
				}
653
				
651

  
654 652
				// System.out.println(buffer);
655 653
				if (buffer.length() > 0) {
656 654
					if (!execute(buffer.toString())) {
......
658 656
					}
659 657
				}
660 658
				// System.out.println("n="+n+" time="+(System.currentTimeMillis()-start));
661
				
659

  
662 660
				// do something after the highlight is done
663 661
				for (ProgressListener pl : afterHighlighListeners) {
664 662
					pl.completed(event);
665 663
				}
666 664
			}
667 665
		};
668
		
666

  
669 667
		getBrowser().addMouseListener(new MouseListener() {
670
			
668

  
671 669
			boolean dblClick = false;
672
			
670

  
673 671
			boolean debug = true;
674
			
672

  
675 673
			private int t, x, y;
676
			
674

  
677 675
			@Override
678 676
			public void mouseDoubleClick(MouseEvent e) {
679
				
677

  
680 678
				if (debug) Log.finest("DOUBLE CLICK"); //$NON-NLS-1$
681 679
				dblClick = true;
682 680
			}
683
			
681

  
684 682
			@Override
685 683
			public void mouseDown(MouseEvent e) {
686
				
684

  
687 685
				if (debug) Log.finest("MOUSE DOWN"); //$NON-NLS-1$
688 686
				dblClick = false;
689 687
				t = e.time;
690 688
				x = e.x;
691 689
				y = e.y;
692 690
			}
693
			
691

  
694 692
			@Override
695 693
			public void mouseUp(MouseEvent e) {
696
				
694

  
697 695
				if (dblClick) { // doucle click raised by mouseDoubleClick
698 696
					dblClick = false;
699 697
					return; // stop right now ! :-o
700 698
				}
701 699
				if (debug) Log.finest("MOUSE UP"); //$NON-NLS-1$
702 700
				EditionPanel panel = EditionPanel.this;
703
				
701

  
704 702
				// filter click that are not a left simple click (no drag)
705 703
				// System.out.println("click count="+e.count+" button="+e.button+" time="+e.time+" diff="+(e.time-t)+" dist="+(Math.abs(e.x - x) + Math.abs(e.y - y)));
706 704
				if (e.count > 1) {
......
708 706
					// System.out.println("not a simple click");
709 707
					return;
710 708
				}
711
				
709

  
712 710
				int dist = Math.abs(e.x - x) + Math.abs(e.y - y);
713 711
				int deltat = (e.time - t);
714 712
				// System.out.println("deltat ="+deltat);
715 713
				if (dist >= 0 && (deltat > 0 || dist > 0)) {
716 714
					// System.out.println(" DRAG dist="+dist+" deltat="+deltat);
717 715
					String[] ids = panel.getWordSelection(); // may be null
718
					
716

  
719 717
					panel.expandSelectionTo(ids);
720 718
					return;
721 719
				}
722 720
			}
723 721
		});
724
		
722

  
725 723
		browser.addMouseWheelListener(new MouseWheelListener() {
726
			
724

  
727 725
			@Override
728 726
			public void mouseScrolled(MouseEvent e) {
729
				
727

  
730 728
				if ((e.stateMask & SWT.CTRL) == SWT.CTRL) {
731 729
					if (e.count > 0) {
732 730
						TXMBrowserEditor.zoomIn(getBrowser());
......
736 734
				}
737 735
			}
738 736
		});
739
		
737

  
740 738
		KeyListener kListener = new KeyListener() {
741
			
739

  
742 740
			boolean debug = true;
743
			
741

  
744 742
			@Override
745 743
			public void keyReleased(KeyEvent e) {
746
				
744

  
747 745
				if (debug) Log.finest(" KEY RELEASED: " + e); //$NON-NLS-1$
748 746
			}
749
			
747

  
750 748
			@Override
751 749
			public void keyPressed(KeyEvent e) {
752
				
750

  
753 751
				if (debug) Log.finest(" KEY PRESSED: " + e); //$NON-NLS-1$
754 752
				if (e.keyCode == 'f' && (e.stateMask & SWT.CTRL) != 0) {
755 753
					synopticEditionEditor.getSearchEditionToolbar().openSearch(getTextSelection());
......
758 756
		};
759 757
		getBrowser().setCapture(true);
760 758
		getBrowser().addKeyListener(kListener);
761
		
759

  
762 760
		getBrowser().addProgressListener(progressListener);
763 761
	}
764
	
762

  
765 763
	/**
766 764
	 * Bypass BrowserViewer restriction on the getBrowser method
767 765
	 */
768 766
	@Override
769 767
	public Browser getBrowser() {
770
		
768

  
771 769
		return super.getBrowser();
772 770
	}
773
	
771

  
774 772
	/**
775 773
	 * Bypass BrowserViewer restriction on the getBrowser method
776 774
	 */
777 775
	public String getDOM() {
778
		
776

  
779 777
		return "";// execute("return document.innerHTML"; //$NON-NLS-1$
780 778
	}
781
	
779

  
782 780
	public ISelectionProvider getSelectionProvider() {
783
		
781

  
784 782
		return selProvider;
785 783
	}
786
	
784

  
787 785
	public void setHighlightWordsById(RGBA color, HashSet<String> wordids) {
788
		
786

  
789 787
		for (String wordid : wordids) {
790 788
			if (this.highlightedColorPerWordIDS.get(wordid) != null) {
791 789
				removeHighlightWordsById(color, wordid);
......
795 793
			hs.add(color);
796 794
		}
797 795
	}
798
	
796

  
799 797
	public void addHighlightWordsById(RGBA color, String wordid) {
800
		
798

  
801 799
		if (!this.highlightedColorPerWordIDS.containsKey(wordid)) {
802 800
			this.highlightedColorPerWordIDS.put(wordid, new ArrayList<RGBA>());
803 801
		}
804 802
		this.highlightedColorPerWordIDS.get(wordid).add(color);
805 803
	}
806
	
804

  
807 805
	/**
808 806
	 * Can be called to refresh the page word styles but only when the page is loaded
809 807
	 */
810 808
	public void updateWordStyles() {
811
		
809

  
812 810
		progressListener.completed(null);
813 811
	}
814
	
812

  
815 813
	public void addHighlightWordsById(RGBA color, Collection<String> wordids) {
816
		
814

  
817 815
		for (String wordid : wordids) {
818 816
			addHighlightWordsById(color, wordid);
819 817
		}
820 818
	}
821
	
819

  
822 820
	public void removeHighlightWordsById(RGBA color, Collection<String> wordids) {
823
		
821

  
824 822
		// System.out.println("Call removeHighlightWordsById: "+wordids+" color="+color);
825 823
		StringBuffer buffer = new StringBuffer();
826 824
		for (String wordid : wordids) {
......
829 827
				buffer.append(String.format(clearhighlightscript, wordid) + "\n"); //$NON-NLS-1$
830 828
			}
831 829
		}
832
		
830

  
833 831
		if (buffer.length() > 0) execute(buffer.toString());
834 832
	}
835
	
833

  
836 834
	public void removeHighlightWordsById(RGBA color, String wordid) {
837
		
835

  
838 836
		if (highlightedColorPerWordIDS.get(wordid) == null) return; // nothing to do
839
		
837

  
840 838
		// System.out.println("remove color="+color+" from id="+wordid);
841 839
		this.highlightedColorPerWordIDS.get(wordid).remove(color);
842
		
840

  
843 841
		if (this.highlightedColorPerWordIDS.get(wordid).size() == 0) {
844 842
			this.highlightedColorPerWordIDS.remove(wordid);
845 843
		}
846 844
	}
847
	
845

  
848 846
	/**
849 847
	 * Open the page containing the word with ID=$line_wordid
850 848
	 * 
......
852 850
	 * @return true if the page changed
853 851
	 */
854 852
	public boolean backToText(Text text, String line_wordid) {
855
		
853

  
856 854
		// String name = currentEdition.getName();
857 855
		Edition edition = text.getEdition(editionName);
858
		
856

  
859 857
		if (edition == null) {
860 858
			String s = EditionUIMessages.bind(EditionUIMessages.noEditionFoundForTextEqualsP0AndEditionEqualsP1, text, editionName);
861 859
			Log.warning(s);
......
877 875
				updateWordStyles(); // no need to change the page, but still update the focus&styles
878 876
			}
879 877
		}
880
		
878

  
881 879
		return false;
882 880
	}
883
	
881

  
884 882
	/**
885 883
	 * First page.
886 884
	 */
887 885
	public void firstPage() {
888
		
886

  
889 887
		if (currentEdition == null) return;
890
		
888

  
891 889
		// System.out.println(Messages.TxmBrowser_1+currentPage);
892 890
		currentPage = currentEdition.getFirstPage();
893 891
		currentText = currentEdition.getText();
......
895 893
			System.out.println(EditionUIMessages.bind(EditionUIMessages.failToRetrieveFirstPageOfEditionEqualsP0AndTextEqualsP1, currentEdition.getName(), currentText.getName()));
896 894
			return;
897 895
		}
898
		
896

  
899 897
		reloadPage();
900
		
898

  
901 899
		// page_label.setText(makePageLabel());
902 900
	}
903
	
901

  
902
	private static String fromEncodeString = "é-è-ê-ë-ē-á-à-â-ä-å-ó-ò-ô-ö-ő-õ-ø-î-ï-ì-í-ù-û-ü-ú-ű-ŭ-ÿ-ŷ-ỳ-ý-ŕ-ŝ-ẑ-ĝ-ģ-ĥ-ḧ-ĵ-ẅ-ŵ-ẍ-ĉ-ç-č-ñ";
903
	private static String toEncodeString = "%C3%A9-%C3%A8-%C3%AA-%C3%AB-%C4%93-%C3%A1-%C3%A0-%C3%A2-%C3%A4-%C3%A5-%C3%B3-%C3%B2-%C3%B4-%C3%B6-%C5%91-%C3%B5-%C3%B8-%C3%AE-%C3%AF-%C3%AC-%C3%AD-%C3%B9-%C3%BB-%C3%BC-%C3%BA-%C5%B1-%C5%AD-%C3%BF-%C5%B7-%E1%BB%B3-%C3%BD-%C5%95-%C5%9D-%E1%BA%91-%C4%9D-%C4%A3-%C4%A5-%E1%B8%A7-%C4%B5-%E1%BA%85-%C5%B5-%E1%BA%8D-%C4%89-%C3%A7-%C4%8D-%C3%B1%0A";
904
	private static String[] fromEncode, toEncode;
905
	static { // GTK webkit URL encoding differs from Java File.toURI() encoding
906
		if ("gtk".equals(System.getProperty("osgi.ws"))) {
907
			fromEncode = fromEncodeString.split("-");
908
			toEncode = toEncodeString.split("-");
909
		}
910
	}
911

  
904 912
	@Override
905 913
	public void setURL(String url) {
906
		
914

  
907 915
		if (!this.browser.isDisposed()) {
908
			
916
			if (fromEncode != null) {
917
				for (int i = 0 ; i < fromEncode.length ; i++) {
918
					url = url.replace(fromEncode[i], toEncode[i]);
919
				}
920
			}
909 921
			super.setURL(url);
910
			
911
//			if ("webkit".equals(this.browser.getBrowserType())) {
912
//				String u = URLUtils.encodeURL(url);
913
//				Log.finer("setting encoded URL: "+u);
914
//				super.setURL(u);
915
//			} else {
916
//				Log.finer("setting URL: "+url);
917
//				super.setURL(url);
918
//			}
919
//			
920
//			// fix when the webbrowser can't open the URL -> but encoding&security are not well managed
921
//			URL url2;
922
//			try {
923
//				url2 = new URL(url);
924
//				String content = IOUtils.getText(url2, "UTF-8");
925
//				super.getBrowser().setText(content);
926
//			}
927
//			catch (Exception e) {
928
//				// TODO Auto-generated catch block
929
//				e.printStackTrace();
930
//			}
931
			
922

  
923
			//			if ("webkit".equals(this.browser.getBrowserType())) {
924
			//				String u = URLUtils.encodeURL(url);
925
			//				Log.finer("setting encoded URL: "+u);
926
			//				super.setURL(u);
927
			//			} else {
928
			//				Log.finer("setting URL: "+url);
929
			//				super.setURL(url);
930
			//			}
931
			//			
932
			//			// fix when the webbrowser can't open the URL -> but encoding&security are not well managed
933
			//			URL url2;
934
			//			try {
935
			//				url2 = new URL(url);
936
			//				String content = IOUtils.getText(url2, "UTF-8");
937
			//				super.getBrowser().setText(content);
938
			//			}
939
			//			catch (Exception e) {
940
			//				// TODO Auto-generated catch block
941
			//				e.printStackTrace();
942
			//			}
943

  
932 944
		}
933 945
	}
934
	
946

  
935 947
	/**
936 948
	 * Last page.
937 949
	 */
938 950
	public void lastPage() {
939 951
		// System.out.println(Messages.TxmBrowser_2+currentPage);
940 952
		if (currentEdition == null) return;
941
		
953

  
942 954
		if (currentPage != null && currentPage.getFile().equals(currentEdition.getLastPage().getFile())) {
943 955
			return;
944 956
		}
......
946 958
		currentText = currentEdition.getText();
947 959
		reloadPage();
948 960
	}
949
	
961

  
950 962
	/**
951 963
	 * Previous page.
952 964
	 */
953 965
	public void previousPage() {
954
		
966

  
955 967
		if (currentEdition == null) return;
956
		
968

  
957 969
		// System.out.println(Messages.TxmBrowser_3+currentPage);
958 970
		if (currentPage != null) {
959 971
			Page previous = currentEdition.getPreviousPage(currentPage);
960
			
972

  
961 973
			if (previous == currentPage) {
962 974
				previousText(true);
963 975
			}
......
972 984
		}
973 985
		// page_label.setText(makePageLabel());
974 986
	}
975
	
976
	
977
	
987

  
988

  
989

  
978 990
	/**
979 991
	 * Next page.
980 992
	 */
981 993
	public void nextPage() {
982
		
994

  
983 995
		if (currentEdition == null) return;
984
		
996

  
985 997
		// System.out.println(Messages.TxmBrowser_4+currentPage);
986 998
		if (currentPage != null) {
987 999
			Page next = currentEdition.getNextPage(currentPage);
......
999 1011
		}
1000 1012
		// page_label.setText(makePageLabel());
1001 1013
	}
1002
	
1003
	
1014

  
1015

  
1004 1016
	public void firstText() {
1005
		
1017

  
1006 1018
		// Text current = this.currentPage.getEdition().getText();
1007 1019
		Project project = currentText.getProject();
1008 1020
		String id;
......
1014 1026
			return;
1015 1027
		}
1016 1028
		Text firstText = project.getText(id);
1017
		
1029

  
1018 1030
		if (firstText != null) {
1019 1031
			String editionName = currentEdition.getName();
1020 1032
			Edition tmp = firstText.getEdition(editionName);
......
1032 1044
			reloadPage();
1033 1045
		}
1034 1046
	}
1035
	
1047

  
1036 1048
	/**
1037 1049
	 * Next text.
1038 1050
	 */
1039 1051
	public void lastText() {
1040
		
1052

  
1041 1053
		// Text current = this.currentPage.getEdition().getText();
1042 1054
		Project project = currentText.getProject();
1043 1055
		String id;
......
1050 1062
			return;
1051 1063
		}
1052 1064
		Text lastText = project.getText(id);
1053
		
1065

  
1054 1066
		if (lastText != null) {
1055 1067
			String editionName = currentEdition.getName();
1056 1068
			Edition tmp = lastText.getEdition(editionName);
......
1058 1070
				System.out.println(EditionUIMessages.bind(EditionUIMessages.noEditionWithNameEqualsP0AvailableForTextEqualsP1, editionName, lastText.getName()));
1059 1071
				return;
1060 1072
			}
1061
			
1073

  
1062 1074
			currentEdition = tmp;
1063 1075
			currentPage = currentEdition.getFirstPage();
1064 1076
			currentText = lastText;
......
1066 1078
				StatusLine.setMessage("No text next"); //$NON-NLS-1$
1067 1079
				return;
1068 1080
			}
1069
			
1081

  
1070 1082
			reloadPage();
1071 1083
			// page_label.setText(makePageLabel());
1072 1084
		}
1073 1085
		// System.out.println("Next texts "+nextText);
1074 1086
	}
1075
	
1087

  
1076 1088
	/**
1077 1089
	 * Previous text.
1078 1090
	 * 
1079 1091
	 * @param fromNextText if true it means the user was reading the next text and then we show the last page of the previous text
1080 1092
	 */
1081 1093
	public void previousText(boolean fromNextText) {
1082
		
1094

  
1083 1095
		Project project = currentText.getProject();
1084 1096
		String id;
1085 1097
		try {
......
1100 1112
			return;
1101 1113
		}
1102 1114
		Text previousText = project.getText(id);
1103
		
1115

  
1104 1116
		if (previousText != null) {
1105 1117
			String editionName = currentEdition.getName();
1106
			
1118

  
1107 1119
			Edition tmp = previousText.getEdition(editionName);
1108 1120
			if (tmp == null) {
1109 1121
				System.out.println(EditionUIMessages.bind(EditionUIMessages.noEditionWithNameEqualsP0AvailableForTextEqualsP1, editionName, previousText.getName()));
......
1117 1129
			else {
1118 1130
				currentPage = currentEdition.getFirstPage();
1119 1131
			}
1120
			
1132

  
1121 1133
			if (currentPage == null) {
1122 1134
				StatusLine.setMessage("No previous text"); //$NON-NLS-1$
1123 1135
				return;
......
1126 1138
		}
1127 1139
		// System.out.println("Previous texts "+previousText);
1128 1140
	}
1129
	
1141

  
1130 1142
	/**
1131 1143
	 * Next text.
1132 1144
	 */
1133 1145
	public void nextText() {
1134
		
1146

  
1135 1147
		// Text current = this.currentPage.getEdition().getText();
1136 1148
		Project project = currentText.getProject();
1137 1149
		String id;
......
1153 1165
			return;
1154 1166
		}
1155 1167
		Text nextText = project.getText(id);
1156
		
1168

  
1157 1169
		if (nextText != null) {
1158 1170
			String editionName = currentEdition.getName();
1159 1171
			Edition tmp = nextText.getEdition(editionName);
......
1162 1174
				return;
1163 1175
			}
1164 1176
			currentEdition = tmp;
1165
			
1177

  
1166 1178
			currentPage = currentEdition.getFirstPage();
1167 1179
			currentText = nextText;
1168 1180
			if (currentPage == null) {
1169 1181
				StatusLine.setMessage("No text next"); //$NON-NLS-1$
1170 1182
				return;
1171 1183
			}
1172
			
1184

  
1173 1185
			reloadPage();
1174 1186
			// page_label.setText(makePageLabel());
1175 1187
		}
1176 1188
		// System.out.println("Next texts "+nextText);
1177 1189
	}
1178
	
1179
	
1190

  
1191

  
1180 1192
	public void setText(Text text, boolean refresh) {
1181
		
1193

  
1182 1194
		// String editionName = currentEdition.getName();
1183 1195
		Edition tmp = text.getEdition(this.editionName);
1184 1196
		if (tmp == null) {
1185 1197
			System.out.println(EditionUIMessages.bind(EditionUIMessages.noEditionWithNameEqualsP0AvailableForTextEqualsP1, this.editionName, text.getName()));
1186 1198
			return;
1187 1199
		}
1188
		
1200

  
1189 1201
		currentEdition = tmp;
1190
		
1202

  
1191 1203
		currentText = text;
1192
		
1204

  
1193 1205
		if (refresh) {
1194 1206
			currentPage = currentEdition.getFirstPage();
1195 1207
			if (currentPage == null) {
......
1200 1212
		}
1201 1213
		// page_label.setText(makePageLabel());
1202 1214
	}
1203
	
1215

  
1204 1216
	/**
1205 1217
	 * Gets the current page.
1206 1218
	 *
1207 1219
	 * @return the current page
1208 1220
	 */
1209 1221
	public Page getCurrentPage() {
1210
		
1222

  
1211 1223
		return currentPage;
1212 1224
	}
1213
	
1225

  
1214 1226
	/**
1215 1227
	 * Gets the current text.
1216 1228
	 *
1217 1229
	 * @return the current page
1218 1230
	 */
1219 1231
	public Text getCurrentText() {
1220
		
1232

  
1221 1233
		return currentText;
1222 1234
	}
1223
	
1235

  
1224 1236
	/**
1225 1237
	 * Make page label.
1226 1238
	 *
1227 1239
	 * @return the string
1228 1240
	 */
1229 1241
	public String makePageLabel() {
1230
		
1242

  
1231 1243
		return currentPage.getName() + " / " + currentPage.getEdition().getNumPages(); //$NON-NLS-1$
1232 1244
	}
1233
	
1245

  
1234 1246
	/**
1235 1247
	 * Show page.
1236 1248
	 *
1237 1249
	 * @param page the page
1238 1250
	 */
1239 1251
	public void showPage(Page page) {
1240
		
1252

  
1241 1253
		if (currentEdition == null) return;
1242 1254
		// System.out.println("SHOW PAGE "+page);
1243 1255
		currentEdition = page.getEdition();
......
1245 1257
		currentPage = page;
1246 1258
		reloadPage();
1247 1259
	}
1248
	
1260

  
1249 1261
	/**
1250 1262
	 * Reload the browser with the currentPage URL
1251 1263
	 */
1252 1264
	public void reloadPage() {
1253
		
1265

  
1254 1266
		this.setURL(currentPage.toURL());
1255 1267
	}
1256
	
1268

  
1257 1269
	// /**
1258 1270
	// * Sets the edition.
1259 1271
	// *
......
1262 1274
	// public void setEdition(Edition edition) {
1263 1275
	// this.currentEdition = edition;
1264 1276
	// }
1265
	
1277

  
1266 1278
	String EMPTYSELECTIONTEST =
1267 1279
			"if (typeof window.getSelection != \"undefined\") {" + // modern Web browsers //$NON-NLS-1$
1268 1280
					"var sel = window.getSelection();" + //$NON-NLS-1$
......
1273 1285
					"}" + //$NON-NLS-1$
1274 1286
					"}" + //$NON-NLS-1$
1275 1287
					"return false"; //$NON-NLS-1$
1276
	
1288

  
1277 1289
	String SCRIPT01 = 
1278 1290
			"var html = \"\";" + //$NON-NLS-1$
1279
			"if (typeof window.getSelection != \"undefined\") {" + // modern Web browsers //$NON-NLS-1$
1280
				"var sel = window.getSelection();" + //$NON-NLS-1$
1281
				"if (sel.rangeCount) {" + //$NON-NLS-1$
1291
					"if (typeof window.getSelection != \"undefined\") {" + // modern Web browsers //$NON-NLS-1$
1292
					"var sel = window.getSelection();" + //$NON-NLS-1$
1293
					"if (sel.rangeCount) {" + //$NON-NLS-1$
1282 1294
					"var container = document.createElement(\"div\");" + //$NON-NLS-1$
1283 1295
					"for (var i = 0, len = sel.rangeCount; i < len; ++i) {" + //$NON-NLS-1$
1284
						"container.appendChild(sel.getRangeAt(i).cloneContents());" + //$NON-NLS-1$
1296
					"container.appendChild(sel.getRangeAt(i).cloneContents());" + //$NON-NLS-1$
1285 1297
					"}" + //$NON-NLS-1$
1286 1298
					"html = container.innerHTML;" + //$NON-NLS-1$
1287 1299
					"container = null;" +
1288 1300
					//"container.parentNode.removeChild(container);" +
1289
				"}" + //$NON-NLS-1$
1290
			"} else if (typeof document.selection != \"undefined\") {" + // for IE < 11 //$NON-NLS-1$
1291
				"if (document.selection.type == \"Text\") {" + //$NON-NLS-1$
1301
					"}" + //$NON-NLS-1$
1302
					"} else if (typeof document.selection != \"undefined\") {" + // for IE < 11 //$NON-NLS-1$
1303
					"if (document.selection.type == \"Text\") {" + //$NON-NLS-1$
1292 1304
					"html = document.selection.createRange().htmlText;" + //$NON-NLS-1$
1293
				"}" + //$NON-NLS-1$
1294
			"}" + //$NON-NLS-1$
1295
			"return html"; //$NON-NLS-1$
1296
	
1305
					"}" + //$NON-NLS-1$
1306
					"}" + //$NON-NLS-1$
1307
					"return html"; //$NON-NLS-1$
1308

  
1297 1309
	public String getTextSelectionDOM() {
1298
		
1310

  
1299 1311
		String t = ((String) evaluate(SCRIPT01));
1300 1312
		Log.finest("HTML text selection=" + t);
1301 1313
		return t;
1302 1314
	}
1303
	
1315

  
1304 1316
	/**
1305 1317
	 * 
1306 1318
	 * @return array of 2 word id, if only one word is selected 2nd value is null
1307 1319
	 */
1308 1320
	public String[] getWordSelection() {
1309
		
1321

  
1310 1322
		// System.out.println("getWordSelection");
1311 1323
		String SCRIPT02_getspans = ""// functions //$NON-NLS-1$
1312 1324
				+ "var all = [];" //$NON-NLS-1$
......
1341 1353
				+ "\n}" //$NON-NLS-1$
1342 1354
				// +"alert('result='+all)"
1343 1355
				+ "\nreturn all;"; //$NON-NLS-1$
1344
		
1356

  
1345 1357
		// System.out.println(functions);
1346 1358
		// System.out.println(SCRIPT02_getspans);
1347
		
1359

  
1348 1360
		Object ret = evaluate(SCRIPT02_getspans);
1349 1361
		if (ret instanceof Object[]) {
1350 1362
			Log.finer("selection word ids=" + Arrays.toString((Object[]) ret)); //$NON-NLS-1$
......
1368 1380
			return null;
1369 1381
		}
1370 1382
	}
1371
	
1383

  
1372 1384
	public boolean isTextSelectionEmpty() {
1373 1385
		return browser.evaluate(EMPTYSELECTIONTEST).equals(true);
1374 1386
	}
1375
	
1387

  
1376 1388
	public String getTextSelection() {
1377
		
1389

  
1378 1390
		// System.out.println("DOM="+getTextSelectionDOM());
1379 1391
		String dom = getTextSelectionDOM();
1380 1392
		if (dom == null) return "";
1381
		
1393

  
1382 1394
		String rez = dom.replaceAll("<[^>]+>", ""); //$NON-NLS-1$ //$NON-NLS-2$
1383 1395
		// System.out.println("STR="+rez);
1384 1396
		return rez;
1385 1397
	}
1386
	
1398

  
1387 1399
	@Override
1388 1400
	public void addSelectionChangedListener(ISelectionChangedListener listener) {}
1389
	
1401

  
1390 1402
	@Override
1391 1403
	public ISelection getSelection() {
1392
		
1404

  
1393 1405
		return new SynopticTextSelection(this);
1394 1406
	}
1395
	
1407

  
1396 1408
	@Override
1397 1409
	public void removeSelectionChangedListener(
1398 1410
			ISelectionChangedListener listener) {}
1399
	
1411

  
1400 1412
	@Override
1401 1413
	public void setSelection(ISelection selection) {}
1402
	
1414

  
1403 1415
	static public class SynopticTextSelection implements ISelection {
1404
		
1416

  
1405 1417
		String str;
1406
		
1418

  
1407 1419
		public SynopticTextSelection(EditionPanel panel) {
1408
			
1420

  
1409 1421
			this.str = panel.getTextSelection();
1410 1422
		}
1411
		
1423

  
1412 1424
		@Override
1413 1425
		public boolean isEmpty() {
1414
			
1426

  
1415 1427
			return str != null && str.length() > 0;
1416 1428
		}
1417
		
1429

  
1418 1430
		public String getTextSelection() {
1419
			
1431

  
1420 1432
			return str;
1421 1433
		}
1422 1434
	}
1423
	
1435

  
1424 1436
	public Edition getEdition() {
1425
		
1437

  
1426 1438
		return currentEdition;
1427 1439
	}
1428
	
1440

  
1429 1441
	public MenuManager getMenuManager() {
1430
		
1442

  
1431 1443
		return menuManager;
1432 1444
	}
1433
	
1445

  
1434 1446
	public void initMenu() {
1435
		
1447

  
1436 1448
		// create a new menu
1437 1449
		menuManager = new MenuManager();
1438
		
1450

  
1439 1451
		Menu menu = menuManager.createContextMenu(this.getBrowser());
1440
		
1452

  
1441 1453
		menu.addMenuListener(new MenuListener() {
1442
			
1454

  
1443 1455
			@Override
1444 1456
			public void menuShown(MenuEvent e) {
1445
				
1457

  
1446 1458
				Menu menu = menuManager.getMenu();
1447 1459
				if (menu == null) return;
1448 1460
				new MenuItem(menu, SWT.SEPARATOR);
1449
				
1461

  
1450 1462
				MenuItem searchItem = new MenuItem(menu, SWT.NONE);
1451 1463
				searchItem.setText("Search...");
1452 1464
				searchItem.addSelectionListener(new SelectionListener() {
1453
					
1465

  
1454 1466
					@Override
1455 1467
					public void widgetSelected(SelectionEvent e) {
1456
						
1468

  
1457 1469
						String text = EditionPanel.this.getTextSelection();
1458 1470
						synopticEditionEditor.getSearchEditionToolbar().openSearch(text);
1459 1471
					}
1460
					
1472

  
1461 1473
					@Override
1462 1474
					public void widgetDefaultSelected(SelectionEvent e) {}
1463 1475
				});
1464
				
1476

  
1465 1477
				MenuItem copyItem = new MenuItem(menu, SWT.NONE);
1466 1478
				copyItem.setText(EditionUIMessages.copyTextSelection);
1467 1479
				copyItem.addSelectionListener(new SelectionListener() {
1468
					
1480

  
1469 1481
					@Override
1470 1482
					public void widgetSelected(SelectionEvent e) {
1471
						
1483

  
1472 1484
						String text = EditionPanel.this.getTextSelection();
1473 1485
						if (text != null && text.length() > 0) {
1474 1486
							IOClipboard.write(text);
1475 1487
						}
1476 1488
					}
1477
					
1489

  
1478 1490
					@Override
1479 1491
					public void widgetDefaultSelected(SelectionEvent e) {}
1480 1492
				});
1481 1493
				String text = EditionPanel.this.getTextSelection();
1482 1494
				copyItem.setEnabled(text != null && text.length() > 0);
1483
				
1495

  
1484 1496
				MenuItem zoomInItem = new MenuItem(menu, SWT.NONE);
1485 1497
				zoomInItem.setText("Zoom avant");
1486 1498
				zoomInItem.addSelectionListener(new SelectionListener() {
1487
					
1499

  
1488 1500
					@Override
1489 1501
					public void widgetSelected(SelectionEvent e) {
1490 1502
						TXMBrowserEditor.zoomIn(browser);
1491 1503
					}
1492
					
1504

  
1493 1505
					@Override
1494 1506
					public void widgetDefaultSelected(SelectionEvent e) {}
1495 1507
				});
1496
				
1508

  
1497 1509
				MenuItem zoomOutItem = new MenuItem(menu, SWT.NONE);
1498 1510
				zoomOutItem.setText("Zoom arrière");
1499 1511
				zoomOutItem.addSelectionListener(new SelectionListener() {
1500
					
1512

  
1501 1513
					@Override
1502 1514
					public void widgetSelected(SelectionEvent e) {
1503
						
1515

  
1504 1516
						TXMBrowserEditor.zoomOut(browser);
1505 1517
					}
1506
					
1518

  
1507 1519
					@Override
1508 1520
					public void widgetDefaultSelected(SelectionEvent e) {}
1509 1521
				});
1510
				
1522

  
1511 1523
				MenuItem zoomResetItem = new MenuItem(menu, SWT.NONE);
1512 1524
				zoomResetItem.setText("Zoom initial");
1513 1525
				zoomResetItem.addSelectionListener(new SelectionListener() {
1514
					
1526

  
1515 1527
					@Override
1516 1528
					public void widgetSelected(SelectionEvent e) {
1517
						
1529

  
1518 1530
						TXMBrowserEditor.zoomReset(browser);
1519 1531
					}
1520
					
1532

  
1521 1533
					@Override
1522 1534
					public void widgetDefaultSelected(SelectionEvent e) {}
1523 1535
				});
1524
				
1536

  
1525 1537
				MenuItem reloadItem = new MenuItem(menu, SWT.NONE);
1526 1538
				reloadItem.setText(EditionUIMessages.reload);
1527 1539
				reloadItem.addSelectionListener(new SelectionListener() {
1528
					
1540

  
1529 1541
					@Override
1530 1542
					public void widgetSelected(SelectionEvent e) {
1531
						
1543

  
1532 1544
						EditionPanel.this.getBrowser().refresh();
1533 1545
					}
1534
					
1546

  
1535 1547
					@Override
1536 1548
					public void widgetDefaultSelected(SelectionEvent e) {}
1537 1549
				});
1538 1550
				MenuItem backItem = new MenuItem(menu, SWT.NONE);
1539 1551
				backItem.setText(EditionUIMessages.back);
1540 1552
				backItem.addSelectionListener(new SelectionListener() {
1541
					
1553

  
1542 1554
					@Override
1543 1555
					public void widgetSelected(SelectionEvent e) {
1544
						
1556

  
1545 1557
						EditionPanel.this.getBrowser().back();
1546 1558
					}
1547
					
1559

  
1548 1560
					@Override
1549 1561
					public void widgetDefaultSelected(SelectionEvent e) {}
1550 1562
				});
1551 1563
				MenuItem forwardItem = new MenuItem(menu, SWT.NONE);
1552 1564
				forwardItem.setText(EditionUIMessages.forward);
1553 1565
				forwardItem.addSelectionListener(new SelectionListener() {
1554
					
1566

  
1555 1567
					@Override
1556 1568
					public void widgetSelected(SelectionEvent e) {
1557
						
1569

  
1558 1570
						EditionPanel.this.getBrowser().forward();
1559 1571
					}
1560
					
1572

  
1561 1573
					@Override
1562 1574
					public void widgetDefaultSelected(SelectionEvent e) {}
1563 1575
				});
1564
				
1576

  
1565 1577
				MenuItem propertiesItem = new PagePropertiesMenu(getBrowser(), menu, SWT.NONE);
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff