Révision 3081

tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/OpenEdition.java (revision 3081)
45 45
import org.txm.edition.rcp.messages.EditionUIMessages;
46 46
import org.txm.objects.Project;
47 47
import org.txm.objects.Text;
48
import org.txm.rcp.editors.TXMEditor;
48 49
import org.txm.searchengine.cqp.corpus.CQPCorpus;
49 50
import org.txm.searchengine.cqp.corpus.MainCorpus;
50 51
import org.txm.searchengine.cqp.corpus.Property;
......
148 149
	 * @return the object
149 150
	 */
150 151
	public static SynopticEditionEditor openEdition(CQPCorpus corpus, List<String> editions) {
151
		String textid = null;
152 152
		
153 153
		Log.fine("Opening edition of " + corpus); //$NON-NLS-1$
154 154
		try {
155
			corpus.compute(false);
156
			
155 157
			String[] availables = corpus.getCorpusTextIdsList();
156 158
			if (availables.length == 0) {
157
				Log.warning(NLS.bind("Error: No text in the {0} corpus", corpus));
159
				Log.warning(NLS.bind("Error: No text available in the {0} corpus", corpus));
158 160
				return null;
159 161
			}
160 162
			Text text = corpus.getProject().getText(availables[0]);
......
167 169
			// Property text_id = text_su.getProperty("id"); //$NON-NLS-1$
168 170
			
169 171
			// if (result.getNMatch() > 0) textid = result.getMatches(0, 1).get(0).getValueForProperty(text_id);
170
			MainCorpus maincorpus = corpus.getMainCorpus();
172
			// MainCorpus maincorpus = corpus.getMainCorpus();
171 173
			
172 174
			// if (textid != null) text = maincorpus.getText(textid);
173 175
			
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SearchEditionToolbar.java (revision 3081)
18 18
import org.txm.searchengine.core.IQuery;
19 19
import org.txm.searchengine.core.Selection;
20 20
import org.txm.searchengine.cqp.CQPSearchEngine;
21
import org.txm.searchengine.cqp.corpus.CQPCorpus;
21 22
import org.txm.searchengine.cqp.corpus.MainCorpus;
22 23
import org.txm.searchengine.cqp.corpus.QueryResult;
23 24
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
......
30 31
	
31 32
	private GridData searchGdata2;
32 33
	
33
	private GridData searchGdata3;
34
	
35 34
	private AssistedChoiceQueryWidget searchText;
36 35
	
37 36
	/**
......
44 43
	 */
45 44
	protected int searchIndex;
46 45
	
47
	private NewNavigationWidget searchNagigation;
46
	private NewNavigationWidget searchNavigation;
48 47
	
49 48
	
50 49
	
51 50
	Composite lowerControlsArea;
52 51
	
53
	MainCorpus mcorpus;
52
	CQPCorpus mcorpus;
54 53
	
55 54
	SynopticEditionEditor editor;
56 55
	
......
58 57
	
59 58
	private Button searchButton;
60 59
	
61
	public void init(Composite lowerControlsArea, MainCorpus mcorpus, SynopticEditionEditor editor) {
60
	private Button endSearchButton;
61
	
62
	private GridData searchButtonGdata;
63
	
64
	public void init(Composite lowerControlsArea, CQPCorpus mcorpus, SynopticEditionEditor editor) {
62 65
		
63 66
		this.lowerControlsArea = lowerControlsArea;
64 67
		this.mcorpus = mcorpus;
65 68
		this.editor = editor;
66 69
		
67
		Button endSearchButton = new Button(lowerControlsArea, SWT.PUSH);
68
		endSearchButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_DELETE));
70
		endSearchButton = new Button(lowerControlsArea, SWT.PUSH);
71
		endSearchButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_SEARCH));
69 72
		endSearchButton.addSelectionListener(new SelectionListener() {
70 73
			
71 74
			@Override
72 75
			public void widgetSelected(SelectionEvent e) {
73 76
				if (searchGdata.widthHint > 0) {
74
					searchGdata.minimumWidth = searchGdata.widthHint = 0;
75
					searchGdata2.minimumWidth = searchGdata2.widthHint = 0;
76
					searchGdata3.minimumWidth = searchGdata3.widthHint = 0;
77
					lowerControlsArea.layout();
78
					searchButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_SEARCH));
77
					closeSearch();
79 78
				}
79
				else {
80
					openSearch(editor.getTextSelection());
81
				}
80 82
			}
81 83
			
82 84
			@Override
83 85
			public void widgetDefaultSelected(SelectionEvent e) {}
84 86
		});
85
		searchGdata3 = new GridData(GridData.CENTER, GridData.CENTER, false, false);
86
		searchGdata3.minimumWidth = 0;
87
		searchGdata3.widthHint = 0;
87
		GridData searchGdata3 = new GridData(GridData.CENTER, GridData.CENTER, false, false);
88
		// searchGdata3.minimumWidth = searchGdata3.widthHint = 0;
88 89
		endSearchButton.setLayoutData(searchGdata3);
89 90
		
90 91
		searchText = new AssistedChoiceQueryWidget(lowerControlsArea, SWT.NONE, mcorpus);
91 92
		searchGdata = new GridData(GridData.CENTER, GridData.CENTER, false, false);
92
		searchGdata.minimumWidth = 0;
93
		searchGdata.widthHint = 0;
93
		searchGdata.minimumWidth = searchGdata.widthHint = 0;
94 94
		searchText.setLayoutData(searchGdata);
95 95
		searchText.addKeyListener(new KeyListener() {
96 96
			
......
108 108
		});
109 109
		
110 110
		searchButton = new Button(lowerControlsArea, SWT.PUSH);
111
		searchButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_SEARCH));
111
		searchButton.setImage(IImageKeys.getImage(IImageKeys.START));
112 112
		searchButton.addSelectionListener(new SelectionListener() {
113 113
			
114 114
			@Override
115 115
			public void widgetSelected(SelectionEvent e) {
116
				if (searchGdata.widthHint == 0) {
117
					openSearch(editor.getTextSelection());
118
				}
119
				else if (searchText.getQuery() != null) {
116
				if (searchText.getQuery() != null) {
120 117
					search();
121 118
				}
122 119
			}
......
124 121
			@Override
125 122
			public void widgetDefaultSelected(SelectionEvent e) {}
126 123
		});
124
		searchButtonGdata = new GridData(GridData.CENTER, GridData.CENTER, false, false);
125
		searchButtonGdata.minimumWidth = searchButtonGdata.widthHint = 0;
126
		searchButton.setLayoutData(searchButtonGdata);
127 127
		
128
		searchNagigation = new NewNavigationWidget(lowerControlsArea, SWT.NONE) {
128
		searchNavigation = new NewNavigationWidget(lowerControlsArea, SWT.NONE) {
129 129
			
130 130
			@Override
131 131
			public void refresh() {
132 132
				super.refresh();
133
				int s = this.getCurrentPosition();
134
				if (s == searchIndex) {
135
					return; // no need to update
136
				}
133 137
				searchIndex = this.getCurrentPosition();
134 138
				showCurrentSearchMatch();
135 139
				// Log.info("showing the " + index + " match.");
136 140
			}
137 141
		};
138 142
		searchGdata2 = new GridData(GridData.CENTER, GridData.CENTER, false, false);
139
		searchGdata2.minimumWidth = 0;
140
		searchGdata2.widthHint = 0;
141
		searchNagigation.setLayoutData(searchGdata2);
142
		searchNagigation.setEnabled(false);
143
		searchGdata2.minimumWidth = searchGdata2.widthHint = 0;
144
		searchNavigation.setLayoutData(searchGdata2);
145
		searchNavigation.setEnabled(false);
146
	}
147
	
148
	protected void closeSearch() {
143 149
		
150
		// disable highlights
151
		if (foundWordids != null) {
152
			editor.removeHighlightWordsById(BackToText.red, foundWordids);
153
			editor.setFocusedWordID(null);
154
			editor.updateWordStyles();
155
		}
156
		
157
		// hide controls
158
		searchGdata.minimumWidth = searchGdata.widthHint = 0;
159
		searchGdata2.minimumWidth = searchGdata2.widthHint = 0;
160
		searchButtonGdata.minimumWidth = searchButtonGdata.widthHint = 0;
161
		lowerControlsArea.layout();
162
		endSearchButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_SEARCH));
144 163
	}
145 164
	
146 165
	/**
......
150 169
		if (searchGdata.widthHint == 0) {
151 170
			searchGdata.minimumWidth = searchGdata.widthHint = 350; //
152 171
			searchGdata2.minimumWidth = searchGdata2.widthHint = SWT.DEFAULT; // several buttons
153
			searchGdata3.minimumWidth = searchGdata3.widthHint = SWT.DEFAULT; // button
172
			searchButtonGdata.minimumWidth = searchButtonGdata.widthHint = SWT.DEFAULT; // button
154 173
			lowerControlsArea.layout();
155
			searchButton.setImage(IImageKeys.getImage(IImageKeys.START));
174
			endSearchButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_DELETE));
156 175
		}
157 176
		searchText.setFocus();
158 177
		if (value != null && value.length() > 0) {
......
186 205
						}
187 206
					}
188 207
				}
189
				searchNagigation.setEnabled(true);
190
				searchNagigation.setCurrentPosition(searchIndex);
191
				searchNagigation.setMinPosition(1);
192
				searchNagigation.setMaxPosition(tmp.getNMatch());
193
				searchNagigation.refresh();
208
				searchNavigation.setEnabled(true);
209
				searchNavigation.setCurrentPosition(searchIndex);
210
				searchNavigation.setMinPosition(1);
211
				searchNavigation.setMaxPosition(tmp.getNMatch());
212
				searchNavigation.refresh();
194 213
				Log.info("" + searchResult.getNMatch() + " hits.");
195 214
			}
196 215
			else {
197 216
				searchIndex = 0;
198
				searchNagigation.setEnabled(false);
199
				searchNagigation.setCurrentPosition(0);
200
				searchNagigation.setMinPosition(0);
201
				searchNagigation.setMaxPosition(0);
202
				searchNagigation.refresh();
217
				searchNavigation.setEnabled(false);
218
				searchNavigation.setCurrentPosition(0);
219
				searchNavigation.setMinPosition(0);
220
				searchNavigation.setMaxPosition(0);
221
				searchNavigation.refresh();
203 222
				Log.info("No hit.");
204 223
			}
205 224
		}
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java (revision 3081)
143 143
			"} catch (e) { };"; //$NON-NLS-1$
144 144
	
145 145
	public String functions = ""// "alert(\"loading functions\");" //$NON-NLS-1$
146
			+ "\nfunction getNodeText(node) {" //$NON-NLS-1$
146
			+ "\ngetNodeText = function getNodeText(node) {" //$NON-NLS-1$
147 147
			+ "\n	if (typeof node == 'string') return node;" //$NON-NLS-1$
148 148
			+ "\n	else if (typeof  node.innerText != 'undefined') return node.innerText;" //$NON-NLS-1$
149 149
			+ "\n	else if (typeof  node.InnerText != 'undefined') return node.InnerText;" //$NON-NLS-1$
150 150
			+ "\n	else if (typeof  node.textContent != 'undefined') return node.textContent;" //$NON-NLS-1$
151 151
			+ "\n	else return null;" //$NON-NLS-1$
152 152
			+ "\n}" //$NON-NLS-1$
153
			+ "\nfunction txmGetParent(node) {" //$NON-NLS-1$
153
			+ "\ntxmGetParent = function txmGetParent(node) {" //$NON-NLS-1$
154 154
			+ "\n	if (typeof  node.parentNode != 'undefined') return node.parentNode;" //$NON-NLS-1$
155 155
			+ "\n	else return null;" //$NON-NLS-1$
156 156
			+ "\n}" //$NON-NLS-1$
157
			+ "\nfunction txmGetChildren(node) {" //$NON-NLS-1$
157
			+ "\ntxmGetChildren = function txmGetChildren(node) {" //$NON-NLS-1$
158 158
			+ "\n	if (typeof node == 'string') return 'STRING HTML';" //$NON-NLS-1$
159 159
			+ "\n	else if (typeof  node.children != 'undefined') return node.children;" //$NON-NLS-1$
160 160
			+ "\n	else if (typeof  node.ChildNodes != 'undefined') return node.ChildNodes;" //$NON-NLS-1$
161 161
			+ "\n	else if (typeof  node.childNodes != 'undefined') return node.childNodes;" //$NON-NLS-1$
162 162
			+ "\n	else return null;" //$NON-NLS-1$
163 163
			+ "\n}" //$NON-NLS-1$
164
			+ "\nfunction txmGetSelection() {" //$NON-NLS-1$
164
			+ "\ntxmGetSelection = function txmGetSelection() {" //$NON-NLS-1$
165 165
			+ "\n	if (typeof window.getSelection != 'undefined') {return window.getSelection();}" //$NON-NLS-1$
166 166
			+ "\n	else if (typeof document.selection != 'undefined') { return document.selection;}" //$NON-NLS-1$
167 167
			+ "\n	else return 'NO SELECTION';" //$NON-NLS-1$
168 168
			+ "\n}" //$NON-NLS-1$
169
			+ "\nfunction txmGetRangeSize(selection) {" //$NON-NLS-1$
169
			+ "\ntxmGetRangeSize = function txmGetRangeSize(selection) {" //$NON-NLS-1$
170 170
			+ "\n	if (typeof selection.rangeCount != 'undefined') {return selection.rangeCount;}" //$NON-NLS-1$
171 171
			+ "\n	else if (typeof selection.createRangeCollection != 'undefined') { return selection.createRangeCollection().length();} // IE5 has no multiple selection" //$NON-NLS-1$
172 172
			+ "\n}" //$NON-NLS-1$
173
			+ "\nfunction txmGetRange(selection, i) {" //$NON-NLS-1$
173
			+ "\ntxmGetRange = function txmGetRange(selection, i) {" //$NON-NLS-1$
174 174
			+ "\n	if (typeof selection.getRangeAt != 'undefined') {return selection.getRangeAt(i);}" //$NON-NLS-1$
175 175
			+ "\n	else if (typeof selection.createRangeCollection != 'undefined') {return selection.createRangeCollection().item(i);}" // IE > IE5 //$NON-NLS-1$
176 176
			+ "\n	else if (typeof selection.createRange != 'undefined') { return selection.createRange();} // IE5 has no multiple selection" //$NON-NLS-1$
177 177
			+ "\n	else return 'NO RANGE';" //$NON-NLS-1$
178 178
			+ "\n}" //$NON-NLS-1$
179
			+ "\nfunction txmGetParentElementRange(range) {" //$NON-NLS-1$
179
			+ "\ntxmGetParentElementRange = function txmGetParentElementRange(range) {" //$NON-NLS-1$
180 180
			+ "\n	if (typeof range.parentElement != 'undefined') {return range.parentElement();}" //$NON-NLS-1$
181 181
			+ "\n	else if (typeof range.startContainer != 'undefined') { return range.startContainer.parentNode;}" //$NON-NLS-1$
182 182
			+ "\n	else return 'NO PARENT';" //$NON-NLS-1$
183 183
			+ "\n}" //$NON-NLS-1$
184
			+ "\nfunction txmGetFragment(range) {" //$NON-NLS-1$
184
			+ "\ntxmGetFragment = function txmGetFragment(range) {" //$NON-NLS-1$
185 185
			+ "\n	if (typeof range.cloneContents != 'undefined') { return range.cloneContents();}" //$NON-NLS-1$
186 186
			+ "\n	else if (typeof range.htmlText != 'undefined') {var node = document.createElement('sel'); node.innerHTML = range.htmlText; 		return node;" //$NON-NLS-1$
187 187
			+ "\n	} else return 'NO FRAG';" //$NON-NLS-1$
188 188
			+ "\n}" //$NON-NLS-1$
189
			+ "\nfunction txmGetTagName(node) {" //$NON-NLS-1$
189
			+ "\ntxmGetTagName = function txmGetTagName(node) {" //$NON-NLS-1$
190 190
			+ "\n	if (typeof node.tagName != 'undefined') {return node.tagName;}" //$NON-NLS-1$
191 191
			+ "\n	else if (typeof node.nodeName != 'undefined') { return node.nodeName;}" //$NON-NLS-1$
192 192
			+ "\n	else if (typeof node.name != 'undefined') { return node.name;}" //$NON-NLS-1$
193 193
			+ "\n	else return 'NO TAGNAME';" //$NON-NLS-1$
194 194
			+ "\n}" //$NON-NLS-1$
195
			+ "\nfunction findSpans(children, all) {" //$NON-NLS-1$
195
			+ "\nfindSpans = function findSpans(children, all) {" //$NON-NLS-1$
196 196
			+ "\n    for (var i = 0 ; i < children.length ; i++) {" //$NON-NLS-1$
197 197
			+ "\n    	var node = children.item(i);" //$NON-NLS-1$
198 198
			+ "\n		if (node.nodeType == 1) {" //$NON-NLS-1$
......
205 205
			+ "\n		}" //$NON-NLS-1$
206 206
			+ "\n	}" //$NON-NLS-1$
207 207
			+ "\n}" //$NON-NLS-1$
208
			+ "\nfunction findIdsInString(str, all) {" //$NON-NLS-1$
208
			+ "\nfindIdsInString = function findIdsInString(str, all) {" //$NON-NLS-1$
209 209
			+ "\n    for (var i = 0 ; i < children.length ; i++) {" //$NON-NLS-1$
210 210
			+ "\n    	var node = children.item(i);" //$NON-NLS-1$
211 211
			+ "\n		if (node.nodeType == 1) {" //$NON-NLS-1$
......
218 218
			+ "\n		}" //$NON-NLS-1$
219 219
			+ "\n	}" //$NON-NLS-1$
220 220
			+ "\n}" //$NON-NLS-1$
221
			+ "\nfunction get_type(thing){if(thing===null)return \"[object Null]\";  return Object.prototype.toString.call(thing);}\n" //$NON-NLS-1$
222
			+ "\nfunction getDetailedObject(inputObject) { var detailedObject = {}; var properties; \n   do {        properties = Object.getOwnPropertyNames( inputObject );        for (var o in properties) {detailedObject[properties[o]] = inputObject[properties[o]];}} while ( inputObject = Object.getPrototypeOf(inputObject) );return detailedObject;}\n" //$NON-NLS-1$
221
			+ "\nget_type = function get_type(thing){if(thing===null)return \"[object Null]\";  return Object.prototype.toString.call(thing);}\n" //$NON-NLS-1$
222
			+ "\ngetDetailedObject = function getDetailedObject(inputObject) { var detailedObject = {}; var properties; \n   do {        properties = Object.getOwnPropertyNames( inputObject );        for (var o in properties) {detailedObject[properties[o]] = inputObject[properties[o]];}} while ( inputObject = Object.getPrototypeOf(inputObject) );return detailedObject;}\n" //$NON-NLS-1$
223 223
			+ "\nvar sheet = null;" //$NON-NLS-1$
224 224
			+ "\ntry{" //$NON-NLS-1$
225 225
			+ "\n	var style = document.createElement(\"style\");" //$NON-NLS-1$
......
309 309
			@Override
310 310
			public void completed(ProgressEvent event) {
311 311
				
312
				// System.out.println("EditionPanel "+currentEdition.getName()+" reload "+getCurrentPage().getName());
312
				Log.finest("EditionPanel " + currentEdition.getName() + " reload " + getCurrentPage().getName());
313 313
				Object rez = evaluate("return typeof sheet;"); //$NON-NLS-1$
314 314
				if ("undefined".equals(rez)) { //$NON-NLS-1$
315
					if (!execute(functions)) { // build the sheet if not present in the HTML DOM
315
					Object loadResult = execute(functions);
316
					Object testloadResult = evaluate("return typeof txmGetSelection;");
317
					if (loadResult == null || testloadResult == null) { // build the sheet if not present in the HTML DOM
316 318
						Log.fine("JS execution (init) error with=" + functions); //$NON-NLS-1$
317 319
					}
318 320
					else {
319
						
321
						Log.finer("JS functions loaded.");
320 322
					}
321 323
				}
322 324
				
......
557 559
			
558 560
			boolean dblClick = false;
559 561
			
560
			boolean debug = false;
562
			boolean debug = true;
561 563
			
562 564
			private int t, x, y;
563 565
			
564 566
			@Override
565 567
			public void mouseDoubleClick(MouseEvent e) {
566
				if (debug) System.out.println("DOUBLE CLICK"); //$NON-NLS-1$
568
				if (debug) Log.finest("DOUBLE CLICK"); //$NON-NLS-1$
567 569
				dblClick = true;
568 570
			}
569 571
			
570 572
			@Override
571 573
			public void mouseDown(MouseEvent e) {
572
				if (debug) System.out.println("MOUSE DOWN"); //$NON-NLS-1$
574
				if (debug) Log.finest("MOUSE DOWN"); //$NON-NLS-1$
573 575
				dblClick = false;
574 576
				t = e.time;
575 577
				x = e.x;
......
582 584
					dblClick = false;
583 585
					return; // stop right now ! :-o
584 586
				}
585
				if (debug) System.out.println("MOUSE UP"); //$NON-NLS-1$
587
				if (debug) Log.finest("MOUSE UP"); //$NON-NLS-1$
586 588
				EditionPanel panel = EditionPanel.this;
587 589
				
588 590
				// filter click that are not a left simple click (no drag)
589 591
				// 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)));
590 592
				if (e.count > 1) {
591
					if (debug) System.out.println(" DOUBLE CLICK"); //$NON-NLS-1$
593
					if (debug) Log.finest(" DOUBLE CLICK"); //$NON-NLS-1$
592 594
					// System.out.println("not a simple click");
593 595
					return;
594 596
				}
......
606 608
			}
607 609
		});
608 610
		
609
		getBrowser().addKeyListener(new KeyListener() {
611
		KeyListener kListener = new KeyListener() {
610 612
			
613
			boolean debug = true;
614
			
611 615
			@Override
612 616
			public void keyReleased(KeyEvent e) {
613
				
614
				if (e.keyCode == 102 && (e.stateMask & SWT.CTRL) != 0) {
617
				if (debug) Log.finest(" KEY RELEASED: " + e); //$NON-NLS-1$
618
			}
619
			
620
			@Override
621
			public void keyPressed(KeyEvent e) {
622
				if (debug) Log.finest(" KEY PRESSED: " + e); //$NON-NLS-1$
623
				if (e.keyCode == 'f' && (e.stateMask & SWT.CTRL) != 0) {
615 624
					synopticEditionEditor.getSearchEditionToolbar().openSearch(getTextSelection());
616 625
				}
617 626
			}
618
			
619
			@Override
620
			public void keyPressed(KeyEvent e) {}
621
		});
627
		};
628
		getBrowser().setCapture(true);
629
		getBrowser().addKeyListener(kListener);
622 630
		
623 631
		getBrowser().addProgressListener(progresslistener);
624 632
		new CommandLink(synopticEditionEditor, getBrowser());
......
1085 1093
			"return html"; //$NON-NLS-1$
1086 1094
	
1087 1095
	public String getTextSelectionDOM() {
1088
		return ((String) evaluate(SCRIPT01));
1096
		String t = ((String) evaluate(SCRIPT01));
1097
		Log.finest("HTML text selection=" + t);
1098
		return t;
1089 1099
	}
1090 1100
	
1091 1101
	/**
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java (revision 3081)
82 82
import org.txm.rcp.editors.TXMEditor;
83 83
import org.txm.rcp.swt.GLComposite;
84 84
import org.txm.searchengine.cqp.corpus.CQPCorpus;
85
import org.txm.searchengine.cqp.corpus.MainCorpus;
86 85
import org.txm.utils.logger.Log;
87 86

  
88 87
/**
......
109 108
	
110 109
	private CQPCorpus corpus;
111 110
	
112
	private MainCorpus mainCorpus;
113
	
114 111
	private Text text;
115 112
	
116 113
	private Button editionsChooser;
......
129 126
	
130 127
	private SearchEditionToolbar set;
131 128
	
129
	private Project project;
130
	
132 131
	// TODO finish editor conversion
133 132
	@Override
134 133
	public Text getResult() {
......
317 316
			String[] texts = corpus.getCorpusTextIdsList();
318 317
			for (String text_id : texts) {
319 318
				if (text_id.equals(id)) {
320
					Text text = mainCorpus.getProject().getText(text_id);
319
					Text text = project.getText(text_id);
321 320
					if (text != null) {
322 321
						setText(text, true);
323 322
						return;
......
415 414
		// supplementaryButtonToolbar = new TXMEditorToolBar(this, getTopToolbarContainer(), annotationWidgetsArea, SWT.NONE, "annotation urs");
416 415
		
417 416
		set = new SearchEditionToolbar();
418
		Project project = this.getResult().getProject();
419
		MainCorpus mcorpus = (MainCorpus) project.getCorpusBuild(project.getName().toUpperCase(), MainCorpus.class);
420
		set.init(lowerControlsArea, mcorpus, this);
421 417
		
418
		// MainCorpus mcorpus = (MainCorpus) project.getCorpusBuild(project.getName().toUpperCase(), MainCorpus.class);
419
		set.init(lowerControlsArea, corpus, this);
420
		
422 421
		// Edition names label
423 422
		
424 423
		
425
		if (mainCorpus.getProject().getBuiltEditionNames().size() > 1) {
424
		if (project.getBuiltEditionNames().size() > 1) {
426 425
			editionsChooser = new Button(lowerControlsArea, SWT.PUSH);
427 426
			editionsChooser.setText(StringUtils.join(editionNames, " | ")); //$NON-NLS-1$
428 427
			editionsChooser.addSelectionListener(new SelectionListener() {
......
430 429
				@Override
431 430
				public void widgetSelected(SelectionEvent e) {
432 431
					try {
433
						List<String> availableEditions = mainCorpus.getProject().getBuiltEditionNames();
432
						List<String> availableEditions = project.getBuiltEditionNames();
434 433
						if (availableEditions.size() == 0) return;
435 434
						if (availableEditions.size() == 1) return;
436 435
						
437 436
						
438 437
						Shell shell = e.display.getActiveShell();
439
						EditionSelectorDialog d = new EditionSelectorDialog(shell, mainCorpus, editionNames);
438
						EditionSelectorDialog d = new EditionSelectorDialog(shell, project, editionNames);
440 439
						
441 440
						if (d.open() == Window.OK) {
442 441
							Object[] rez = d.getResult();
......
724 723
		
725 724
		try {
726 725
			// ensure all texts have build their page indexes
727
			for (Text t : mainCorpus.getProject().getTexts()) {
726
			for (Text t : project.getTexts()) {
728 727
				t.compute();
729 728
			}
730 729
			if (openEditions(text, editionNames)) {
......
880 879
			// TODO Auto-generated catch block
881 880
			e.printStackTrace();
882 881
		}
883
		mainCorpus = corpus.getMainCorpus(); // get the main corpus of the corpus
882
		
883
		project = corpus.getProject();
884
		
884 885
		text = ((SynopticEditorInput) input).getText();
885 886
		editionNames = ((SynopticEditorInput) input).getEditions();
886 887
		
......
939 940
		return corpus;
940 941
	}
941 942
	
942
	public CQPCorpus getMainCorpus() {
943
		return mainCorpus;
944
	}
945
	
946 943
	public EditionPanel getEditionPanel(int i) {
947 944
		int n = 0;
948 945
		for (EditionPanel p : editionPanels.values()) {
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionSelectorDialog.java (revision 3081)
9 9
import org.eclipse.swt.widgets.Shell;
10 10
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
11 11
import org.txm.edition.rcp.messages.EditionUIMessages;
12
import org.txm.objects.CorpusBuild;
12
import org.txm.objects.Project;
13 13

  
14 14
public class EditionSelectorDialog extends ElementListSelectionDialog {
15 15
	
16
	public EditionSelectorDialog(Shell parent, CorpusBuild corpus, List<String> defaultSelection) {
16
	public EditionSelectorDialog(Shell parent, Project project, List<String> defaultSelection) {
17 17
		super(parent, new ILabelProvider() {
18 18
			
19 19
			@Override
......
46 46
		setMessage(EditionUIMessages.selectOneOrMoreEditions);
47 47
		setMultipleSelection(true);
48 48
		
49
		setElements(corpus.getProject().getBuiltEditionNames().toArray());
49
		setElements(project.getBuiltEditionNames().toArray());
50 50
		setFilter("*"); //$NON-NLS-1$
51 51
		
52 52
		if (defaultSelection == null) {
53
			defaultSelection = Arrays.asList(corpus.getProject().getDefaultEditionName());
53
			defaultSelection = Arrays.asList(project.getDefaultEditionName());
54 54
		}
55 55
		this.setInitialSelections(defaultSelection.toArray());
56 56
	}
tmp/org.txm.edition.rcp/res/js/functions.js (revision 3081)
1
function getNodeText(node) {
1
getNodeText = function getNodeText(node) {
2 2
	if (typeof node == 'string')
3 3
		return node;
4 4
	else if (typeof node.innerText != 'undefined')
......
10 10
	else
11 11
		return null;
12 12
}
13
function txmGetParent(node) {
13
txmGetParent = function txmGetParent(node) {
14 14
	if (typeof node.parentNode != 'undefined')
15 15
		return node.parentNode;
16 16
	else
17 17
		return null;
18 18
}
19
function txmGetChildren(node) {
19
txmGetChildren = function txmGetChildren(node) {
20 20
	if (typeof node == 'string')
21 21
		return 'STRING HTML';
22 22
	else if (typeof node.children != 'undefined')
......
28 28
	else
29 29
		return null;
30 30
}
31
function txmGetSelection() {
31
txmGetSelection = function txmGetSelection() {
32 32
	if (typeof window.getSelection != 'undefined') {
33 33
		return window.getSelection();
34 34
	} else if (typeof document.selection != 'undefined') {
......
36 36
	} else
37 37
		return 'NO SELECTION';
38 38
}
39
function txmGetRangeSize(selection) {
39
txmGetRangeSize = function txmGetRangeSize(selection) {
40 40
	if (typeof selection.rangeCount != 'undefined') {
41 41
		return selection.rangeCount;
42 42
	} else if (typeof selection.createRangeCollection != 'undefined') {
43 43
		return selection.createRangeCollection().length();
44 44
	} // IE5 has no multiple selection
45 45
}
46
function txmGetRange(selection, i) {
46
txmGetRange = function txmGetRange(selection, i) {
47 47
	if (typeof selection.getRangeAt != 'undefined') {
48 48
		return selection.getRangeAt(i);
49 49
	} else if (typeof selection.createRangeCollection != 'undefined') {
......
54 54
	else
55 55
		return 'NO RANGE';
56 56
}
57
function txmGetParentElementRange(range) {
57
txmGetParentElementRange = function txmGetParentElementRange(range) {
58 58
	if (typeof range.parentElement != 'undefined') {
59 59
		return range.parentElement();
60 60
	} else if (typeof range.startContainer != 'undefined') {
......
62 62
	} else
63 63
		return 'NO PARENT';
64 64
}
65
function txmGetFragment(range) {
65
txmGetFragment = function txmGetFragment(range) {
66 66
	if (typeof range.cloneContents != 'undefined') {
67 67
		return range.cloneContents();
68 68
	} else if (typeof range.htmlText != 'undefined') {
......
72 72
	} else
73 73
		return 'NO FRAG';
74 74
}
75
function txmGetTagName(node) {
75
txmGetTagName = function txmGetTagName(node) {
76 76
	if (typeof node.tagName != 'undefined') {
77 77
		return node.tagName;
78 78
	} else if (typeof node.nodeName != 'undefined') {
......
82 82
	} else
83 83
		return 'NO TAGNAME';
84 84
}
85
function findSpans(children, all) {
85
findSpans = function findSpans(children, all) {
86 86
	for (var i = 0; i < children.length; i++) {
87 87
		var node = children.item(i);
88 88
		if (node.nodeType == 1) {
......
97 97
		}
98 98
	}
99 99
}
100
function findIdsInString(str, all) {
100
findIdsInString = function findIdsInString(str, all) {
101 101
	for (var i = 0; i < children.length; i++) {
102 102
		var node = children.item(i);
103 103
		if (node.nodeType == 1) {
......
112 112
		}
113 113
	}
114 114
}
115
function get_type(thing) {
115
get_type = function get_type(thing) {
116 116
	if (thing === null)
117 117
		return "[object Null]";
118 118
	return Object.prototype.toString.call(thing);
119 119
}
120 120

  
121
function getDetailedObject(inputObject) {
121
getDetailedObject = function getDetailedObject(inputObject) {
122 122
	var detailedObject = {};
123 123
	var properties;
124 124
	do {
......
185 185
// Element.prototype.scrollIntoViewIfNeeded = Element.prototype.scrollIntoView
186 186
// }
187 187

  
188
function showElementIfNeeded(el) {
188
showElementIfNeeded = function showElementIfNeeded(el) {
189 189
	if (!Element.prototype.scrollIntoViewIfNeeded) {
190 190
		if (!isAnyPartOfElementInViewport(el))
191 191
			el.scrollIntoView(false);
......
194 194
	}
195 195
}
196 196

  
197
function isAnyPartOfElementInViewport(el) {
197
isAnyPartOfElementInViewport = function isAnyPartOfElementInViewport(el) {
198 198
	try {
199 199
		const rect = el.getBoundingClientRect();
200 200
		// DOMRect { x: 8, y: 8, width: 100, height: 100, top: 8, right: 108,
......
212 212
	} catch (e) {
213 213
		return false;
214 214
	}
215
}
215
}
216

  
217
return true

Formats disponibles : Unified diff