Révision 3019

tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java (revision 3019)
115 115
	private Button editionsChooser;
116 116
	
117 117
	// private Label editionsLabel;
118
	private GLComposite controlsArea;
118
	private GLComposite lowerControlsArea;
119 119
	
120 120
	// private GLComposite annotationWidgetsArea;
121 121
	// private TXMEditorToolBar supplementaryButtonToolbar;
......
374 374
	// }
375 375
	
376 376
	public Composite getLowerToolbarArea() {
377
		return controlsArea;
377
		return lowerControlsArea;
378 378
	}
379 379
	
380 380
	@Override
......
385 385
		
386 386
		editionsArea = getResultArea();
387 387
		
388
		controlsArea = getBottomToolbar().installGLComposite(EditionUIMessages.controls, 15, false);
389
		controlsArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
388
		lowerControlsArea = getBottomToolbar().installGLComposite(EditionUIMessages.controls, 15, false);
389
		lowerControlsArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
390 390
		// spacer
391
		new Label(controlsArea, SWT.NONE).setText("  "); //$NON-NLS-1$
391
		new Label(lowerControlsArea, SWT.NONE).setText("  "); //$NON-NLS-1$
392 392
		
393 393
		// annotationWidgetsArea = new GLComposite(getBetweenTopToolbarsAndResultComposite(), SWT.NONE, "Edition annotation area");
394 394
		// this.annotationWidgetsArea.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
......
396 396
		// supplementaryButtonToolbar = new TXMEditorToolBar(this, getTopToolbarContainer(), annotationWidgetsArea, SWT.NONE, "annotation urs");
397 397
		
398 398
		// Edition names label
399
		editionsChooser = new Button(controlsArea, SWT.PUSH);
399
		editionsChooser = new Button(lowerControlsArea, SWT.PUSH);
400 400
		editionsChooser.setText(StringUtils.join(editionNames, " | ")); //$NON-NLS-1$
401 401
		
402 402
		if (mainCorpus.getProject().getBuiltEditionNames().size() > 1) {
......
441 441
		}
442 442
		
443 443
		// Navigation buttons
444
		GLComposite pageNavigationComposite = new GLComposite(controlsArea, SWT.NONE, EditionUIMessages.pageButtons);
444
		GLComposite pageNavigationComposite = new GLComposite(lowerControlsArea, SWT.NONE, EditionUIMessages.pageButtons);
445 445
		pageNavigationComposite.getLayout().numColumns = 6;
446 446
		pageNavigationComposite.getLayout().horizontalSpacing = 1;
447 447
		Button first = new Button(pageNavigationComposite, SWT.FLAT | SWT.PUSH);
......
452 452
		Button last = new Button(pageNavigationComposite, SWT.FLAT | SWT.PUSH);
453 453
		pageNavigationComposite.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, true, false));
454 454
		
455
		GLComposite textNavigationComposite = new GLComposite(controlsArea, SWT.NONE, EditionUIMessages.textButtons);
455
		GLComposite textNavigationComposite = new GLComposite(lowerControlsArea, SWT.NONE, EditionUIMessages.textButtons);
456 456
		textNavigationComposite.getLayout().numColumns = 7;
457 457
		textNavigationComposite.getLayout().horizontalSpacing = 1;
458 458
		Button firstText = new Button(textNavigationComposite, SWT.FLAT);
......
754 754
			// e1.printStackTrace();
755 755
			// }
756 756
			
757
			controlsArea.layout();
757
			lowerControlsArea.layout();
758 758
			return;
759 759
		}
760 760
	}
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SearchEditionToolbar.java (revision 3019)
1
package org.txm.edition.rcp.editors;
2

  
3
import java.util.List;
4

  
5
import org.eclipse.swt.SWT;
6
import org.eclipse.swt.events.SelectionEvent;
7
import org.eclipse.swt.events.SelectionListener;
8
import org.eclipse.swt.layout.GridData;
9
import org.eclipse.swt.widgets.Button;
10
import org.eclipse.swt.widgets.Composite;
11
import org.txm.objects.Match;
12
import org.txm.rcp.IImageKeys;
13
import org.txm.rcp.swt.widget.AssistedChoiceQueryWidget;
14
import org.txm.rcp.swt.widget.NewNavigationWidget;
15
import org.txm.searchengine.core.IQuery;
16
import org.txm.searchengine.core.Selection;
17
import org.txm.searchengine.cqp.corpus.MainCorpus;
18
import org.txm.searchengine.cqp.corpus.QueryResult;
19
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
20
import org.txm.utils.logger.Log;
21

  
22
public class SearchEditionToolbar {
23
	
24
	private GridData searchGdata;
25
	
26
	private AssistedChoiceQueryWidget searchText;
27
	
28
	/**
29
	 * search result
30
	 */
31
	protected Selection searchResult;
32
	
33
	/**
34
	 * search result index
35
	 */
36
	protected int searchIndex;
37
	
38
	private NewNavigationWidget searchNagigation;
39
	
40
	private GridData searchGdata2;
41
	
42
	Composite lowerControlsArea;
43
	
44
	MainCorpus mcorpus;
45
	
46
	SynopticEditionEditor editor;
47
	
48
	public void init(Composite lowerControlsArea, MainCorpus mcorpus, SynopticEditionEditor editor) {
49
		
50
		this.lowerControlsArea = lowerControlsArea;
51
		this.mcorpus = mcorpus;
52
		this.editor = editor;
53
		
54
		Button searchButton = new Button(lowerControlsArea, SWT.PUSH);
55
		searchButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_SEARCH));
56
		searchButton.addSelectionListener(new SelectionListener() {
57
			
58
			@Override
59
			public void widgetSelected(SelectionEvent e) {
60
				if (searchGdata.widthHint == 0) {
61
					searchGdata.minimumWidth = searchGdata.widthHint = 250;
62
					searchGdata2.minimumWidth = searchGdata2.widthHint = 250;
63
					lowerControlsArea.layout();
64
				}
65
				else if (searchText.getQuery() != null) {
66
					Log.info("Searching " + searchText.getQuery());
67
					IQuery q = searchText.getQuery();
68
					try {
69
						Selection tmp = q.getSearchEngine().query(mcorpus, q, "SEARCH", false);
70
						if (tmp.getNMatch() > 0) {
71
							searchResult = tmp;
72
							
73
							searchIndex = 0;
74
							String wordid = editor.getEditionPanel(0).getCurrentPage().getWordId();
75
							String text = editor.getEditionPanel(0).getCurrentPage().getEdition().getText().getName();
76
							if (wordid != null && text != null) {
77
								QueryResult rez2 = mcorpus.query(new CQLQuery("[_.text_id=\"" + text + "\" & id=\"" + wordid + "\"]"), "SEARCHINIT", false);
78
								if (rez2.getNMatch() > 0) {
79
									int p = rez2.getMatch(0).getStart();
80
									List<? extends Match> matches = searchResult.getMatches();
81
									for (int i = 0; i < matches.size(); i++) {
82
										if (p < matches.get(i).getStart()) {
83
											searchIndex = i - 1; // previous index was the one
84
											break;
85
										}
86
									}
87
								}
88
							}
89
							searchNagigation.setEnabled(true);
90
							searchNagigation.setCurrentPosition(searchIndex);
91
							searchNagigation.setMinPosition(1);
92
							searchNagigation.setMaxPosition(tmp.getNMatch());
93
							searchNagigation.refresh();
94
							Log.info("" + searchResult.getNMatch() + " matches.");
95
						}
96
					}
97
					catch (Exception e1) {
98
						// TODO Auto-generated catch block
99
						e1.printStackTrace();
100
					}
101
				}
102
			}
103
			
104
			@Override
105
			public void widgetDefaultSelected(SelectionEvent e) {}
106
		});
107
		
108
		searchText = new AssistedChoiceQueryWidget(lowerControlsArea, SWT.NONE, mcorpus);
109
		searchGdata = new GridData(GridData.CENTER, GridData.FILL, false, false);
110
		searchGdata.minimumWidth = 0;
111
		searchGdata.widthHint = 0;
112
		searchText.setLayoutData(searchGdata);
113
		
114
		searchNagigation = new NewNavigationWidget(lowerControlsArea, SWT.NONE) {
115
			
116
			@Override
117
			public void refresh() {
118
				super.refresh();
119
				searchIndex = this.getCurrentPosition();
120
				showCurrentSearchMatch();
121
				// Log.info("showing the " + index + " match.");
122
			}
123
		};
124
		searchGdata2 = new GridData(GridData.CENTER, GridData.FILL, false, false);
125
		searchGdata2.minimumWidth = 0;
126
		searchGdata2.widthHint = 0;
127
		searchNagigation.setLayoutData(searchGdata2);
128
		searchNagigation.setEnabled(false);
129
	}
130
	
131
	protected void showCurrentSearchMatch() {
132
		if (searchResult != null && searchIndex >= 0) {
133
			String text = "";
134
			String wordid = "";
135
			editor.getEditionPanel(0).backToText(editor.getResult().getProject().getText(text), wordid);
136
		}
137
	}
138
}
0 139

  
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 3019)
1388 1388
	
1389 1389
	/**
1390 1390
	 * Deletes the object from its parent, also deletes the children. The <code>TXMResult.clean()</code> methods of this result and children results are applied before the deletion.
1391
	 * default behavior is not silent
1391 1392
	 * 
1392 1393
	 * @return
1393 1394
	 */
1394 1395
	public final boolean delete() {
1396
		return delete(false);
1397
	}
1398
	
1399
	/**
1400
	 * Deletes the object from its parent, also deletes the children. The <code>TXMResult.clean()</code> methods of this result and children results are applied before the deletion.
1401
	 * 
1402
	 * @param silent no info message if silent is true
1403
	 * @return
1404
	 */
1405
	public final boolean delete(boolean silent) {
1395 1406
		
1396 1407
		try {
1397 1408
			// FIXME: debug
......
1402 1413
			// remove children and clean resources
1403 1414
			while (this.children.size() > 0) {
1404 1415
				TXMResult c = this.children.get(0);
1405
				c.delete(); // should call parent.removeResult(child)
1416
				c.delete(silent); // should call parent.removeResult(child)
1406 1417
				this.children.remove(c); // but should be done already...
1407 1418
			}
1408 1419
			this.children.clear();
......
1414 1425
			// specific cleaning
1415 1426
			this.clean();
1416 1427
			
1417
			
1418 1428
			// log
1419
			if (this.isVisible() || Log.isLoggingFineLevel()) {
1429
			if ((this.isVisible()
1430
					&& !silent) || Log.isLoggingFineLevel()) {
1420 1431
				Log.info(TXMCoreMessages.bind(TXMCoreMessages.info_p0P1Deleted, this.getResultType(), this.getSimpleName()));
1421 1432
			}
1422 1433
			

Formats disponibles : Unified diff