Révision 3713

TXM/trunk/bundles/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSSelection.java (revision 3713)
1 1
package org.txm.annotation.urs.search;
2 2

  
3 3
import java.util.ArrayList;
4
import java.util.List;
5 4

  
6
import org.txm.objects.Match;
7 5
import org.txm.searchengine.core.IQuery;
8
import org.txm.searchengine.core.Selection;
6
import org.txm.searchengine.core.SimpleSelection;
9 7

  
10
public class URSSelection extends Selection {
8
public class URSSelection extends SimpleSelection<URSMatch> {
11 9

  
12
	ArrayList<URSMatch> matches;
13
	IQuery query;
14
	
15 10
	public URSSelection(IQuery query, ArrayList<URSMatch> matches2) {
16
		this.query = query;
17
		matches = matches2;
11
		super(query, matches2);
18 12
	}
19
	
20
	@Override
21
	public List<? extends Match> getMatches() throws Exception {
22
		return matches;
23
	}
24 13

  
25
	@Override
26
	public List<? extends Match> getMatches(int from, int to) throws Exception {
27
		if (to > matches.size()) to = matches.size();
28
		return matches.subList(from, to + 1); // +1 because Match.getMatches is start-end inclusive and List.subList is start inclusif and end exclusif
29
	}
30

  
31
	@Override
32
	public int getNMatch() throws Exception {
33
		return matches.size();
34
	}
35

  
36
	@Override
37
	public IQuery getQuery() {
38
		return query;
39
	}
40

  
41
	@Override
42
	public boolean isTargetUsed() throws Exception {
43
		return false;
44
	}
45

  
46
	@Override
47
	public void drop() throws Exception {
48
		// TODO Auto-generated method stub
49
	}
50

  
51
	@Override
52
	public boolean delete(int iMatch) {
53
		if (iMatch < 0) return false;
54
		if (iMatch >= matches.size()) return false;
55
		return matches.remove(iMatch) != null;
56
	}
57

  
58
	@Override
59
	public boolean delete(Match match) {
60
		return matches.remove(match);
61
	}
62

  
63
	@Override
64
	public boolean delete(ArrayList<Match> matchesToRemove) {
65
		return matches.removeAll(matchesToRemove);
66
	}
67 14
}
TXM/trunk/bundles/org.txm.searchengine.core/src/org/txm/searchengine/core/SimpleSelection.java (revision 3713)
1
package org.txm.searchengine.core;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5

  
6
import org.txm.objects.Match;
7

  
8
public class SimpleSelection<T extends Match> extends Selection {
9
	
10
	ArrayList<T> matches;
11
	IQuery query;
12
	
13
	public SimpleSelection(IQuery q, ArrayList<T> matcheList) {
14
		query = q;
15
		matches= matcheList;
16
	}
17

  
18
	@Override
19
	public List<T> getMatches() throws Exception {
20
		return matches;
21
	}
22

  
23
	@Override
24
	public List<T> getMatches(int from, int to) throws Exception {
25
		if (to > matches.size()) to = matches.size();
26
		return matches.subList(from, to + 1); // +1 because Match.getMatches is start-end inclusive and List.subList is start inclusif and end exclusif
27
	}
28

  
29
	@Override
30
	public int getNMatch() throws Exception {
31
		return matches.size();
32
	}
33

  
34
	@Override
35
	public IQuery getQuery() {
36
		return query;
37
	}
38

  
39
	@Override
40
	public boolean isTargetUsed() throws Exception {
41
		return false;
42
	}
43

  
44
	@Override
45
	public void drop() throws Exception {
46
		// TODO Auto-generated method stub
47
	}
48

  
49
	@Override
50
	public boolean delete(int iMatch) {
51
		if (iMatch < 0) return false;
52
		if (iMatch >= matches.size()) return false;
53
		return matches.remove(iMatch) != null;
54
	}
55

  
56
	@Override
57
	public boolean delete(Match match) {
58
		return matches.remove(match);
59
	}
60

  
61
	@Override
62
	public boolean delete(ArrayList<Match> matchesToRemove) {
63
		return matches.removeAll(matchesToRemove);
64
	}
65
}
0 66

  
TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/NewNavigationWidget.java (revision 3713)
239 239
		prev.setImage(IImageKeys.getImage(IImageKeys.CTRLREVERSE));
240 240
		next.setImage(IImageKeys.getImage(IImageKeys.CTRLPLAY));
241 241
		last.setImage(IImageKeys.getImage(IImageKeys.CTRLEND));
242
		
243 242
	}
244 243
	
245 244
	/**
......
250 249
		this(parent, SWT.NONE);
251 250
	}
252 251
	
253
	
254 252
	public void addGoToKeyListener(KeyListener keyListener) {
255 253
		currentPositionText.addKeyListener(keyListener);
256 254
		currentPositionText.setEditable(true);
......
258 256
		// currentPosition.setBackground(new Color(currentPosition.get));
259 257
	}
260 258
	
259
	public int getShift() {
260
		return shift;
261
	}
262
	
263
	public void setShift(int shift) {
264
		this.shift = shift;
265
	}
266
	
261 267
	/**
262 268
	 * Adds the first listener.
263 269
	 *
......
330 336
		prev.setEnabled(b);
331 337
	}
332 338
	
333
	
334
	
335 339
	protected int getCurrentPositionFromTextField() {
336 340
		int ret = -1;
337 341
		try {
......
344 348
		return ret;
345 349
	}
346 350
	
347
	
348
	
349 351
	/**
350 352
	 * @return the minPosition
351 353
	 */
......
353 355
		return minPosition;
354 356
	}
355 357
	
356
	
357 358
	/**
358 359
	 * @param minPosition the minPosition to set
359 360
	 */
......
361 362
		this.minPosition = minPosition;
362 363
	}
363 364
	
365
	/**
366
	 * @param maxPosition the maxPosition to set
367
	 */
368
	public void setMinimum(int minPosition) {
369
		this.minPosition = minPosition;
370
	}
364 371
	
365 372
	/**
366 373
	 * @return the maxPosition
......
369 376
		return maxPosition;
370 377
	}
371 378
	
372
	
373 379
	/**
374 380
	 * @param maxPosition the maxPosition to set
375 381
	 */
......
378 384
	}
379 385
	
380 386
	/**
387
	 * @param maxPosition the maxPosition to set
388
	 */
389
	public void setMaximum(int maxPosition) {
390
		this.maxPosition = maxPosition;
391
	}
392
	
393
	/**
381 394
	 * Refreshes the widgets.
382 395
	 */
383 396
	public void refresh() {
......
412 425
		this.infoLine.setText(s);
413 426
	}
414 427
	
415
	
416 428
	/**
417 429
	 * @param currentPosition the currentPosition to set
418 430
	 */
......
423 435
		this.currentPosition = newPosition + this.shift;
424 436
	}
425 437
	
438
	/**
439
	 * To be compatible with the swtCombo.getSelection() method
440
	 * @return
441
	 */
442
	public void setSelection(int newPosition) {
443
		setCurrentPosition(newPosition);
444
	}
426 445
	
446
	
427 447
	/**
428 448
	 * @return the currentPosition
429 449
	 */
......
431 451
		return this.currentPosition - this.shift;
432 452
	}
433 453
	
454
	/**
455
	 * To be compatible with the swtCombo.getSelection() method
456
	 * @return
457
	 */
458
	public int getSelection() {
459
		return getCurrentPosition();
460
	}
434 461
	
435 462
	/**
436 463
	 * @return the currentPositionText
TXM/trunk/bundles/org.txm.treesearch.core/src/org/txm/treesearch/function/TreeSearch.java (revision 3713)
92 92
		return "no query";
93 93
	}
94 94
	
95
	public abstract int getNSentences();
95
	public abstract int getNMatchingSentences();
96 96
	
97
	public abstract int getNSubGraph(int matchNo);
97
	public abstract int getNSubMatch();
98 98
	
99
	public abstract int getTotalSubMatch();
100
	
99 101
	public final List<String> getNT() {
100 102
		return NT;
101 103
	}
......
115 117
		return NLS.bind("Rendering {0} Syntactic Tree...", this.getSelector().getEngine());
116 118
	}
117 119
	
118
	public abstract int getSub(int matchNo);
119
	
120 120
	public final List<String> getT() {
121 121
		return T;
122 122
	}
TXM/trunk/bundles/org.txm.conllu.core/src/org/txm/conllu/core/function/UDTreeSearch.java (revision 3713)
5 5
import java.util.ArrayList;
6 6
import java.util.Arrays;
7 7
import java.util.HashMap;
8
import java.util.LinkedHashMap;
8 9
import java.util.List;
9 10

  
10 11
import org.apache.commons.lang.StringUtils;
......
14 15
import org.txm.core.results.TXMParameters;
15 16
import org.txm.libs.deptreeviz.UDDepTreeVizPrintTree;
16 17
import org.txm.searchengine.core.Selection;
18
import org.txm.searchengine.core.SimpleSelection;
17 19
import org.txm.searchengine.cqp.CQPSearchEngine;
18 20
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
19 21
import org.txm.searchengine.cqp.corpus.CQPCorpus;
......
34 36
	
35 37
	Subcorpus udSentences;
36 38

  
37
	private QueryResult matches;
39
	private QueryResult rawMatches;
38 40
	
41
	private LinkedHashMap<org.txm.objects.Match, List<Integer>> matchingSentencesToMatches;
42
	private ArrayList<org.txm.objects.Match> matchingSentencesKeys;
43

  
44
	private int nTotalMatches;
45
	
39 46
	public UDTreeSearch(CQPCorpus corpus) {
40 47
		this(null, corpus);
41 48
	}
......
53 60
	}
54 61
	
55 62
	public boolean isComputed() {
56
		return matches != null;
63
		return matchingSentencesToMatches != null;
57 64
	}
58 65
	
59 66
	public boolean isDrawn() {
60
		return matches != null;
67
		return matchingSentencesToMatches != null;
61 68
	}
62 69
	
63 70
	public Selection getSelection() {
64
		return matches;
71
		return new SimpleSelection<org.txm.objects.Match>(pQuery, matchingSentencesKeys);
65 72
	}
66 73
	
67 74
	@Override
......
69 76
		
70 77
		if (!isDrawn()) return false; // no result
71 78
		try {
72
			//File file = File.createTempFile("txm", ".svg", new File(Toolbox.getTxmHomePath(), "results"));
79

  
80
			org.txm.objects.Match matchingSentence = this.matchingSentencesKeys.get(sent);
81
			Match submatch = rawMatches.getMatch(this.matchingSentencesToMatches.get(matchingSentence).get(sub)); // use the set highlight in the Graph
73 82
			
74
			//String engine = UDTreePreferences.getInstance().getString(UDTreePreferences.ENGINE);
83
			int[] positions = new int[matchingSentence.size()];
84
			for (int i = 0 ; i < matchingSentence.size() ; i++) positions[i] = matchingSentence.getStart()+i;
75 85
			
76
			Match match = this.matches.getMatches().get(sent);
77
			org.txm.objects.Match sentence = null;
78
			for (org.txm.objects.Match s : udSentences.getMatches()) {
79
				if (s.getStart() <= match.getStart() && match.getEnd() <= s.getEnd()) {
80
					sentence = s;
81
					break;
82
				}
83
			}
84
			
85
			if (sentence == null) {
86
				Log.warning("Error: match positions not found in sentences positions");
87
				return false;
88
			}
89
			
90
			int[] positions = new int[sentence.size()];
91
			for (int i = 0 ; i < sentence.size() ; i++) positions[i] = sentence.getStart()+i;
92
			
93 86
			String prefix = UDPreferences.getInstance().getProjectPreferenceValue(corpus.getProject(), UDPreferences.UDPREFIX, UDPreferences.getInstance().getString(UDPreferences.UDPREFIX));
94 87
			
95 88
			String[] Tvalues = new String[positions.length];
......
140 133
			ArrayList<String> conll = new ArrayList<String>();
141 134
			
142 135
			for (int p = 0 ; p < positions.length ; p++) {
136
				
137
				boolean startOfSubMatch = submatch.getStart() == positions[p];
138
				boolean endOfSubMatch = submatch.getEnd() == positions[p];
139
				
143 140
				StringBuilder buffer = new StringBuilder();
144 141
				for (String prop : ImportCoNLLUAnnotations.UD_PROPERTY_NAMES) {
142
					
145 143
					if (buffer.length() > 0) buffer.append("\t");
144
					if (prop.equals("form") && startOfSubMatch) buffer.append("[");
146 145
					buffer.append(values.get(prefix+prop)[p]);
146
					if (prop.equals("form") && endOfSubMatch) buffer.append("]");
147 147
				}
148 148
				
149 149
				conll.add(buffer.toString());
......
215 215
		return ready;
216 216
	}
217 217
	
218
	public int getNSentences() {
219
		if (matches == null) return 0;
218
	public int getNMatchingSentences() {
220 219
		
221
			try {
222
				return matches.getMatches().size();
223
			}
224
			catch (CqiClientException e) {
225
				// TODO Auto-generated catch block
226
				e.printStackTrace();
227
				return 0;
228
			}//getNMatch();
220
		if (matchingSentencesToMatches == null) return 0;
221
		
222
		return matchingSentencesToMatches.size();
229 223
	}
230 224
	
231
	public int getNSubGraph(int matchNo) {
225
	public int getNSubMatch() {
232 226
		
233
		return 1;
227
		if (matchingSentencesKeys == null) return 0;
228
		
229
		org.txm.objects.Match currentSent = matchingSentencesKeys.get(pIndex);
230
		
231
		List<Integer> submatches = matchingSentencesToMatches.get(currentSent);
232
		
233
		return submatches.size();
234 234
	}
235 235
	
236
	public int getSub(int matchNo) {
236
	public int getSub(int matchingSent) {
237 237
		
238
		return 1;
238
		return pSubIndex;//matchingSentencesToMatches.get(matchingSentencesKeys.get(matchingSent)).size();
239 239
	}
240 240
	
241 241
	/**
......
307 307
		
308 308
		String prefix = UDPreferences.getInstance().getProjectPreferenceValue(corpus.getProject(), UDPreferences.UDPREFIX, UDPreferences.getInstance().getString(UDPreferences.UDPREFIX));
309 309
		
310
		
311 310
		if (pQuery == null || pQuery.getQueryString().length() == 0) {
312
			pQuery = new CQLQuery("["+prefix+"deprel=\"root\"]"); // [ud-deprel="root"]
311
			pQuery = new CQLQuery("["+prefix+"id=\"1\"]"); // MD or use [ud-deprel="root"] ? but don't work if the corpus is not parsed
313 312
		}
314 313
		
315 314
		udSentences = UDSearchEngine.getSentenceSubcorpus(corpus, prefix);
316

  
317
		matches = udSentences.query((CQLQuery)pQuery, "matches", false);
315
		rawMatches = udSentences.query((CQLQuery)pQuery, "matches", false);
316
		nTotalMatches = 0; // counted below
318 317
		
319
		return matches.getNMatch() > 0;
318
		matchingSentencesToMatches = new LinkedHashMap<org.txm.objects.Match, List<Integer>>();;
319
		int nSent = udSentences.getSize();
320
		int imatch = 0;
321
		int nMatch = rawMatches.getNMatch();
322
		List<? extends org.txm.objects.Match> sentMatches = udSentences.getMatches();
323
		for (int iSent = 0 ; iSent < nSent ; iSent++) {
324
			if (imatch >= nMatch) { // all matches processed
325
				break;
326
			}
327
			org.txm.objects.Match sentMatch = sentMatches.get(iSent);
328
			for (; imatch < nMatch ; imatch++) {
329
				Match currentMatch = rawMatches.getMatch(imatch);
330
				if (currentMatch.getStart() > sentMatch.getEnd()) { // the match is after the sentence, process the next sentence
331
					break;
332
				} else if (sentMatch.getStart() > currentMatch.getEnd()) { // the sentence is after the match -> should not happen
333
					Log.warning("Warning: should not happen: the sentence is after the match: iSent="+iSent+" "+sentMatch+" imatch="+imatch+" "+currentMatch);
334
				} else {
335
					if (!matchingSentencesToMatches.containsKey(sentMatch)) {
336
						matchingSentencesToMatches.put(sentMatch, new ArrayList<Integer>());
337
					}
338
					matchingSentencesToMatches.get(sentMatch).add(imatch);
339
					nTotalMatches++;
340
				}
341
			}
342
		}
343
		
344
		if (imatch < nMatch) {
345
			Log.warning("Warning: should not happen: the matches should all be in the 'ud-s' subcorpus");
346
		}
347
		
348
		matchingSentencesKeys = new ArrayList<org.txm.objects.Match>(matchingSentencesToMatches.keySet());
349
		
350
		pIndex = 0;
351
		pSubIndex = 0;
352
		
353
		return true;
320 354
	}
321 355
	
322 356
	@Override
......
332 366
	@Override
333 367
	public boolean hasSubMatchesStrategy() {
334 368
		
335
		return false;
369
		return true;
336 370
	}
337 371
	
338 372
	public static boolean hasUDProperties(CQPCorpus corpus) {
......
418 452
		
419 453
		return new String[] {UDTreePreferences.DEPTREEVIZ, UDTreePreferences.BRAT};
420 454
	}
455

  
456
	@Override
457
	public int getTotalSubMatch() {
458
		return nTotalMatches;
459
	}
421 460
}
TXM/trunk/bundles/org.txm.conllu.core/src/org/txm/conllu/core/search/UDSearchEngine.java (revision 3713)
120 120
	public static Subcorpus getSentenceSubcorpus(CQPCorpus corpus, String prefix) throws CqiClientException, InterruptedException {
121 121
		
122 122
		Subcorpus udSentences = corpus.getSubcorpusByName(corpus.getName()+TXMPreferences.PARENT_NAME_SEPARATOR+"ud-s");
123
		if (udSentences != null) udSentences.compute();
123
		if (udSentences != null) udSentences.compute(false);
124 124
		
125 125
		CQLQuery sentencesQuery = new CQLQuery("["+prefix+"id=\"1\"] ["+prefix+"id !=\"1\"]+ [:"+prefix+"id=\"1|__UNDEF__\":]");
126 126
		if (udSentences == null) { // no ud-s subcorpus, create it
TXM/trunk/bundles/org.txm.tigersearch.rcp/src/org/txm/function/tigersearch/TIGERSearch.java (revision 3713)
150 150
		return ready;
151 151
	}
152 152
	
153
	public int getNSentences() {
153
	public int getNMatchingSentences() {
154 154
		if (tsresult == null) return 0;
155 155
		return tsresult.getNumberOfMatch();
156 156
	}
157 157
	
158
	public int getNSubGraph(int matchNo) {
158
	public int getNSubMatch() {
159 159
		if (tsresult == null) return 0;
160
		if (tsresult.getMatch(matchNo) == null) return 0;
160
		if (tsresult.getMatch(pIndex) == null) return 0;
161 161
		
162
		return tsresult.getMatch(matchNo).getNumberOfSubGraph();
162
		return tsresult.getMatch(pIndex).getNumberOfSubGraph();
163 163
	}
164 164
	
165
	// public int getSent() {
166
	// if (tsresult == null) return 0;
167
	// return tsresult.getCurrentMatchNo();
168
	// }
165
//	// public int getSent() {
166
//	// if (tsresult == null) return 0;
167
//	// return tsresult.getCurrentMatchNo();
168
//	// }
169
//	
170
//	public int getSub(int matchNo) {
171
//		if (tsresult == null) return 0;
172
//		if (tsresult.getMatch(matchNo) == null) return 0;
173
//		
174
//		return tsresult.getMatch(matchNo).getCurrentSubMatchNo();
175
//	}
169 176
	
170
	public int getSub(int matchNo) {
171
		if (tsresult == null) return 0;
172
		if (tsresult.getMatch(matchNo) == null) return 0;
173
		
174
		return tsresult.getMatch(matchNo).getCurrentSubMatchNo();
175
	}
176
	
177 177
	/**
178 178
	 * @return the query or the generic one
179 179
	 */
......
256 256
			
257 257
			tsresult = tscorpus.query(pQuery.getQueryString());
258 258
			tsresult.getFirst();
259
			
260
			pIndex = 0;
261
			pSubIndex = 0;
259 262
//		} else {
260 263
//			
261 264
//		}
......
373 376
	@Override
374 377
	public String[] getAvailableVisualisations() {
375 378
		
376
		// TODO Auto-generated method stub
377
		return null;
379
		return null; // only one visualisation
378 380
	}
381

  
382
	@Override
383
	public int getTotalSubMatch() {
384
		return tsresult.getForest().getSubMatchesSum();
385
	}
379 386
}
TXM/trunk/bundles/org.txm.treesearch.rcp/src/org/txm/treesearch/editor/TreeSearchEditor.java (revision 3713)
44 44
import org.txm.rcp.messages.TXMUIMessages;
45 45
import org.txm.rcp.swt.GLComposite;
46 46
import org.txm.rcp.swt.widget.LargeQueryField;
47
import org.txm.rcp.swt.widget.NavigationWidget;
48
import org.txm.rcp.swt.widget.NewNavigationWidget;
47 49
import org.txm.rcp.utils.SWTEditorsUtils;
48 50
import org.txm.rcp.views.QueriesView;
49 51
import org.txm.rcp.views.corpora.CorporaView;
......
72 74
	Browser svgPanel;
73 75
	
74 76
	@Parameter(key = TXMPreferences.INDEX)
75
	Spinner sentSpinner;
77
	NewNavigationWidget sentSpinner;
76 78
	
77 79
	@Parameter(key = TXMPreferences.SUB_INDEX)
78
	Spinner subSpinner;
80
	NewNavigationWidget subSpinner;
79 81
	
80 82
	Button okButton;
81 83
	
......
86 88
	@Parameter(key = TXMPreferences.QUERY)
87 89
	private LargeQueryField queryArea;
88 90
	
89
	private Label subCounterLabel;
91
//	private Label subCounterLabel;
92
//	
93
//	private Label sentCounterLabel;
90 94
	
91
	private Label sentCounterLabel;
92
	
93 95
	@Parameter(key = TreeSearchPreferences.NTFEATURE)
94 96
	private org.eclipse.swt.widgets.List NTCombo;
95 97
	
......
142 144
					
143 145
					queryArea.setQueryClass(currentSelector.getQueryClass());
144 146
					initializeFields();
147
					
145 148
					getEditorInput().setResult(tsPerRepresentation.get(currentSelector.getEngine()));
146 149
					representationLabel.setImage(IImageKeys.getImage(tsPerRepresentation.get(currentSelector.getEngine()).getIconPath()));
147 150
					
148 151
					// if (e.widget == sentSpinner && tsPerRepresentation.get(currentSelector.getEngine()).hasSubMatchesStrategy()) {
149
					
150
					subSpinner.setSelection(1);
151
					subSpinner.setMaximum(tsPerRepresentation.get(currentSelector.getEngine()).getNSubGraph(sentSpinner.getSelection() - 1));
152
					subCounterLabel.setText("/" + tsPerRepresentation.get(currentSelector.getEngine()).getNSubGraph(sentSpinner.getSelection() - 1)); //$NON-NLS-1$
153
					// }
152
					//subSpinner.setSelection(0);
154 153
				}
155 154
				
156 155
				
156
				//subSpinner.setMaximum(tsPerRepresentation.get(currentSelector.getEngine()).getNSubMatch());
157
//				subCounterLabel.setText("/" + tsPerRepresentation.get(currentSelector.getEngine()).getNSubGraph(sentSpinner.getSelection())); //$NON-NLS-1$
158
				// }
159
				
157 160
				TreeSearchEditor.this.compute(true);
158 161
				// reloadGraph();
159 162
			}
......
256 259
					queryAreaLayoutData.minimumHeight = 0;
257 260
					queryAreaLayoutData.grabExcessVerticalSpace = false;
258 261
					queryAreaLayoutData.grabExcessHorizontalSpace = false;
262
					queryAreaLayoutData.minimumWidth = 0;
259 263
				} else {
260 264
					search.setImage(IImageKeys.getImage(IImageKeys.ACTION_DELETE));
261 265
					queryArea.setVisible(true);
262 266
					queryAreaLabel.setVisible(true);
263
					queryAreaLayoutData.heightHint = 80;
264
					queryAreaLayoutData.minimumHeight = 80;
265 267
					queryAreaLayoutData.grabExcessVerticalSpace = true;
266 268
					queryAreaLayoutData.grabExcessHorizontalSpace = true;
269
					if (currentSelector.getEngine().equals("UD")) {
270
						queryAreaLayoutData.minimumHeight = 0;
271
						queryAreaLayoutData.heightHint = 00;
272
					} else {
273
						queryAreaLayoutData.minimumHeight = 80;
274
						queryAreaLayoutData.heightHint = 80;
275
					}
276
					queryAreaLayoutData.minimumWidth = 150;
267 277
				}
278
				queryArea.layout();
268 279
				navigationAreaComposite.getParent().getParent().layout();
269 280
			}
270 281
			
......
279 290
		queryArea = new LargeQueryField(navigationAreaComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, currentSelector.getQueryClass());
280 291
		GridData queryAreaLayoutData = new GridData(GridData.FILL, GridData.FILL, true, true);
281 292
		queryAreaLayoutData.horizontalSpan = 2;
282
		queryAreaLayoutData.heightHint = 80;
283
		queryAreaLayoutData.minimumHeight = 80;
293
		
284 294
		queryArea.setLayoutData(queryAreaLayoutData);
285 295
		queryArea.setVisible(false);
286 296
		
......
301 311
		search.setImage(IImageKeys.getImage(IImageKeys.ACTION_SEARCH));
302 312
		queryArea.setVisible(false);
303 313
		queryAreaLabel.setVisible(false);
304
		queryAreaLayoutData.heightHint = 0;
305
		queryAreaLayoutData.minimumHeight = 0;
306
		queryAreaLayoutData.grabExcessVerticalSpace = false;
307
		queryAreaLayoutData.grabExcessHorizontalSpace = false;
308 314
		
309 315
		// fill param Area
310 316
		Label l3 = new Label(navigationAreaComposite, SWT.NONE);
311
		l3.setText("Match "); //$NON-NLS-1$
317
		l3.setText("Sentence "); //$NON-NLS-1$
312 318
		gdata = new GridData(SWT.FILL, SWT.CENTER, false, false);
313 319
		l3.setLayoutData(gdata);
314 320
		
315
		sentSpinner = new Spinner(navigationAreaComposite, SWT.BORDER);
321
		sentSpinner = new NewNavigationWidget(navigationAreaComposite, SWT.NONE);
316 322
		sentSpinner.setMinimum(1);
317
		sentSpinner.setIncrement(1);
318 323
		sentSpinner.setMaximum(10000000);
319
		sentSpinner.setSelection(1);
324
		sentSpinner.setSelection(0);
325
		sentSpinner.refresh();
320 326
		
321 327
		gdata = new GridData(SWT.FILL, SWT.CENTER, false, false);
322 328
		sentSpinner.setLayoutData(gdata);
323
		sentSpinner.addSelectionListener(selChangedListener);
329
		sentSpinner.addFirstListener(selChangedListener);
330
		sentSpinner.addPreviousListener(selChangedListener);
331
		sentSpinner.addNextListener(selChangedListener);
332
		sentSpinner.addLastListener(selChangedListener);
324 333
		
325
		sentCounterLabel = new Label(navigationAreaComposite, SWT.NONE);
326
		gdata = new GridData(SWT.FILL, SWT.CENTER, false, false);
327
		gdata.minimumWidth = 100;
328
		sentCounterLabel.setLayoutData(gdata);
329 334
		
335
//		sentCounterLabel = new Label(navigationAreaComposite, SWT.NONE);
336
//		gdata = new GridData(SWT.FILL, SWT.CENTER, false, false);
337
//		gdata.minimumWidth = 100;
338
//		sentCounterLabel.setLayoutData(gdata);
339
		
330 340
		new Label(navigationAreaComposite, SWT.NONE);
331 341
		
332 342
		// if (tsPerRepresentation.get(currentSelector.getEngine()).hasSubMatchesStrategy()) {
333 343
		Label l4 = new Label(navigationAreaComposite, SWT.NONE);
334
		l4.setText("Sub-Match "); //$NON-NLS-1$
344
		l4.setText("Match "); //$NON-NLS-1$
335 345
		gdata = new GridData(SWT.FILL, SWT.CENTER, false, false);
336 346
		l4.setLayoutData(gdata);
337 347
		
338
		subSpinner = new Spinner(navigationAreaComposite, SWT.BORDER);
348
		subSpinner = new NewNavigationWidget(navigationAreaComposite, SWT.NONE);
339 349
		subSpinner.setMinimum(1);
340
		subSpinner.setIncrement(1);
341 350
		subSpinner.setMaximum(100000000);
342
		subSpinner.setSelection(1);
351
		subSpinner.setSelection(0);
343 352
		gdata = new GridData(SWT.FILL, SWT.CENTER, false, false);
344 353
		subSpinner.setLayoutData(gdata);
345
		subSpinner.addSelectionListener(selChangedListener);
354
		subSpinner.addFirstListener(selChangedListener);
355
		subSpinner.addPreviousListener(selChangedListener);
356
		subSpinner.addNextListener(selChangedListener);
357
		subSpinner.addLastListener(selChangedListener);
358
		subSpinner.refresh();
346 359
		
347
		subCounterLabel = new Label(navigationAreaComposite, SWT.NONE);
348
		gdata = new GridData(SWT.FILL, SWT.CENTER, false, false);
349
		subCounterLabel.setLayoutData(gdata);
360
//		subCounterLabel = new Label(navigationAreaComposite, SWT.NONE);
361
//		gdata = new GridData(SWT.FILL, SWT.CENTER, false, false);
362
//		subCounterLabel.setLayoutData(gdata);
350 363
		// }
351 364
		
352 365
		Composite mainPanel = this.getResultArea();
......
489 502
		
490 503
		if (ts.isComputed()) {
491 504
			queryArea.setText(ts.getQuery());
492
			sentCounterLabel.setText("/" + ts.getNSentences()); //$NON-NLS-1$
493
			if (ts.getNSentences() > 0) {
494
				subCounterLabel.setText("/" + ts.getNSubGraph(0)); //$NON-NLS-1$
495
			}
505
			
506
//			sentCounterLabel.setText("/" + ts.getNSentences()); //$NON-NLS-1$
507
//			if (ts.getNSentences() > 0) {
508
//				subCounterLabel.setText("/" + ts.getNSubGraph(0)); //$NON-NLS-1$
509
//			}
496 510
		}
497 511
		else {
498
			sentCounterLabel.setText(Messages.NoSentence);
499
			if (ts.hasSubMatchesStrategy()) subCounterLabel.setText(Messages.NoSubGraph);
512
//			sentCounterLabel.setText(Messages.NoSentence);
513
//			if (ts.hasSubMatchesStrategy()) subCounterLabel.setText(Messages.NoSubGraph);
500 514
		}
501 515
		
502 516
		if (!ts.isDrawn()) {
503
			sentSpinner.setSelection(ts.getCurrentMatchIndex() + 1);
504
			sentSpinner.setMaximum(ts.getNSentences());
517
			sentSpinner.setSelection(ts.getCurrentMatchIndex());
518
			sentSpinner.setMaximum(ts.getNMatchingSentences());
505 519
			// if (ts.hasSubMatchesStrategy()) {
506
			subSpinner.setSelection(ts.getSub(0));
507
			subSpinner.setMaximum(ts.getNSubGraph(0));
520
			subSpinner.setSelection(ts.getCurrentSubMatchIndex());
521
			subSpinner.setMaximum(ts.getNSubMatch());
508 522
			// }
509 523
			
510 524
			try {
......
516 530
			}
517 531
		}
518 532
		else {
519
			sentSpinner.setSelection(1);
520
			if (ts.hasSubMatchesStrategy()) subSpinner.setSelection(1);
533
			sentSpinner.setSelection(0);
534
			if (ts.hasSubMatchesStrategy()) subSpinner.setSelection(0);
521 535
			if (ts.isComputed()) {
522
				sentSpinner.setMaximum(ts.getNSentences());
523
				if (ts.hasSubMatchesStrategy()) subSpinner.setMaximum(ts.getNSubGraph(0));
536
				sentSpinner.setMaximum(ts.getNMatchingSentences());
537
				if (ts.hasSubMatchesStrategy()) subSpinner.setMaximum(ts.getNSubMatch());
524 538
			}
525 539
			else {
526 540
				sentSpinner.setMaximum(1);
......
533 547
		// return;
534 548
		// }
535 549
		
536
		sentCounterLabel.getParent().layout();
550
//		sentCounterLabel.getParent().layout();
537 551
		getMainParametersComposite().getParent().layout();
538 552
		
539 553
	}
......
575 589
		// protected IStatus run(IProgressMonitor monitor) {
576 590
		try {
577 591
			TreeSearch ts = tsPerRepresentation.get(currentSelector.getEngine());
578
			if (ts.getNSentences() > 0) {
592
			if (ts.getNMatchingSentences() > 0) {
579 593
				
580
				sentCounterLabel.setText("/" + ts.getNSentences()); //$NON-NLS-1$
581
				if (ts.hasSubMatchesStrategy()) subCounterLabel.setText("/" + ts.getNSubGraph(0)); //$NON-NLS-1$
594
//				sentCounterLabel.setText("/" + ts.getNSentences()); //$NON-NLS-1$
595
//				if (ts.hasSubMatchesStrategy()) subCounterLabel.setText("/" + ts.getNSubGraph(0)); //$NON-NLS-1$
596
				sentSpinner.setEnabled(true);
597
				subSpinner.setEnabled(true);
582 598
				sentSpinner.setSelection(ts.getCurrentMatchIndex());
583
				sentSpinner.setMaximum(ts.getNSentences());
584
				
599
				sentSpinner.setMaximum(ts.getNMatchingSentences());
600
				sentSpinner.refresh();
585 601
				subSpinner.setSelection(ts.getCurrentSubMatchIndex());
586
				subSpinner.setMaximum(ts.getNSubGraph(0));
587
				
602
				subSpinner.setMaximum(ts.getNSubMatch());
603
				subSpinner.refresh();
588 604
				reloadGraph();
605
				Log.warning(""+ts.getNMatchingSentences()+" matching sentence(s) for "+ts.getTotalSubMatch()+" matches.");
606
			} else {
607
				Log.warning("No matching sentence.");
608
				svgPanel.setText("");
609
				sentSpinner.setEnabled(false);
610
				subSpinner.setEnabled(false);
589 611
			}
590 612
			
591 613
			CorporaView.refresh();
......
616 638
//		}
617 639
		List<String> T = Arrays.asList(TCombo.getSelection());
618 640
		List<String> NT = Arrays.asList(NTCombo.getSelection());
619
		int sent = sentSpinner.getSelection() - 1;
641
		int sent = sentSpinner.getSelection();
620 642
		int sub = 0;
621 643
		
622 644
		TreeSearch ts = tsPerRepresentation.get(currentSelector.getEngine());
623 645
		
624
		if (ts.hasSubMatchesStrategy()) sub = subSpinner.getSelection() - 1;
646
		if (ts.hasSubMatchesStrategy()) sub = subSpinner.getSelection();
625 647
		
626 648
		ts.setIndexAndSubIndex(sent, sub);
627 649
		

Formats disponibles : Unified diff