Révision 2226

tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorpus.java (revision 2226)
211 211
					public void run() {
212 212

  
213 213
						if (newProject2 != null) {
214
							newProject2.compute();
214
							newProject2.compute(); // TODO calling compute now calls preferences.flush --> JOB LOCK
215 215
							RestartTXM.reloadViews();
216 216
							//System.out.println("Select newly loaded corpus: "+base2.getCorpora().values());
217 217
							CorporaView.select(newProject2.getChildren(MainCorpus.class));
tmp/org.txm.rcp/src/main/java/org/eclipse/jface/fieldassist/TXMContentProposalAdapter.java (revision 2226)
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2013 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Hannes Erven <hannes@erven.at> - Bug 293841 - [FieldAssist] NumLock keyDown event should not close the proposal popup [with patch]
11
 *******************************************************************************/
12
package org.eclipse.jface.fieldassist;
13

  
14
import java.util.ArrayList;
15

  
16
import org.eclipse.core.runtime.Assert;
17
import org.eclipse.core.runtime.ListenerList;
18
import org.eclipse.jface.bindings.keys.KeyStroke;
19
import org.eclipse.jface.dialogs.PopupDialog;
20
import org.eclipse.jface.preference.JFacePreferences;
21
import org.eclipse.jface.resource.JFaceResources;
22
import org.eclipse.jface.util.Util;
23
import org.eclipse.jface.viewers.ILabelProvider;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.events.DisposeEvent;
26
import org.eclipse.swt.events.DisposeListener;
27
import org.eclipse.swt.events.FocusAdapter;
28
import org.eclipse.swt.events.FocusEvent;
29
import org.eclipse.swt.events.SelectionEvent;
30
import org.eclipse.swt.events.SelectionListener;
31
import org.eclipse.swt.graphics.Color;
32
import org.eclipse.swt.graphics.Image;
33
import org.eclipse.swt.graphics.Point;
34
import org.eclipse.swt.graphics.Rectangle;
35
import org.eclipse.swt.layout.GridData;
36
import org.eclipse.swt.widgets.Combo;
37
import org.eclipse.swt.widgets.Composite;
38
import org.eclipse.swt.widgets.Control;
39
import org.eclipse.swt.widgets.Event;
40
import org.eclipse.swt.widgets.Listener;
41
import org.eclipse.swt.widgets.ScrollBar;
42
import org.eclipse.swt.widgets.Shell;
43
import org.eclipse.swt.widgets.Table;
44
import org.eclipse.swt.widgets.TableItem;
45
import org.eclipse.swt.widgets.Text;
46

  
47
/**
48
 * ContentProposalAdapter can be used to attach content proposal behavior to a
49
 * control. This behavior includes obtaining proposals, opening a popup dialog,
50
 * managing the content of the control relative to the selections in the popup,
51
 * and optionally opening up a secondary popup to further describe proposals.
52
 * <p>
53
 * A number of configurable options are provided to determine how the control
54
 * content is altered when a proposal is chosen, how the content proposal popup
55
 * is activated, and whether any filtering should be done on the proposals as
56
 * the user types characters.
57
 * <p>
58
 * This class provides some overridable methods to allow clients to manually
59
 * control the popup. However, most of the implementation remains private.
60
 * 
61
 * @since 3.2
62
 */
63
public class TXMContentProposalAdapter extends ContentProposalAdapter {
64
	public TXMContentProposalAdapter(Control control, IControlContentAdapter controlContentAdapter, IContentProposalProvider proposalProvider, KeyStroke keyStroke, char[] autoActivationCharacters) {
65
		super(control, controlContentAdapter, proposalProvider, keyStroke, autoActivationCharacters);
66
		// TODO Auto-generated constructor stub
67
	}
68
	
69
	public void open() {
70
		super.openProposalPopup();
71
	}
72
	
73
	public void close() {
74
		super.closeProposalPopup();
75
	}
76
}
0 77

  
tmp/org.txm.rcp/src/main/java/org/eclipse/jface/fieldassist/TXMSimpleContentProposalProvider.java (revision 2226)
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2013 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Amir Kouchekinia <amir@pyrus.us> - bug 200762
11
 *******************************************************************************/
12
package org.eclipse.jface.fieldassist;
13

  
14
import java.util.ArrayList;
15

  
16
/**
17
 * SimpleContentProposalProvider is a class designed to map a static list of
18
 * Strings to content proposals.
19
 * 
20
 * Modified to find values 
21
 * 
22
 * @see IContentProposalProvider
23
 * @since 3.2
24
 * 
25
 */
26
public class TXMSimpleContentProposalProvider implements IContentProposalProvider {
27

  
28
	/*
29
	 * The proposals provided.
30
	 */
31
	private String[] proposals;
32

  
33
	/*
34
	 * The proposals mapped to IContentProposal. Cached for speed in the case
35
	 * where filtering is not used.
36
	 */
37
	private IContentProposal[] contentProposals;
38

  
39
	/*
40
	 * Boolean that tracks whether filtering is used.
41
	 */
42
	private boolean filterProposals = false;
43

  
44
	/**
45
	 * Construct a SimpleContentProposalProvider whose content proposals are
46
	 * always the specified array of Objects.
47
	 * 
48
	 * @param proposals
49
	 *            the array of Strings to be returned whenever proposals are
50
	 *            requested.
51
	 */
52
	public TXMSimpleContentProposalProvider(String[] proposals) {
53
		super();
54
		this.proposals = proposals;
55
	}
56

  
57
	/**
58
	 * Return an array of Objects representing the valid content proposals for a
59
	 * field. 
60
	 * 
61
	 * @param contents
62
	 *            the current contents of the field (only consulted if filtering
63
	 *            is set to <code>true</code>)
64
	 * @param position
65
	 *            the current cursor position within the field (ignored)
66
	 * @return the array of Objects that represent valid proposals for the field
67
	 *         given its current content.
68
	 */
69
	@Override
70
	public IContentProposal[] getProposals(String contents, int position) {
71
		
72
		if (filterProposals) {
73
//			System.out.println("getProposals...");
74
			ArrayList<ContentProposal> list = new ArrayList<ContentProposal>();
75
			
76
			boolean prefixeSearch = true;
77
			if (prefixeSearch) {
78
				for (int i = 0; i < proposals.length; i++) {
79
					if (proposals[i].length() >= contents.length()
80
							&& proposals[i].substring(0, contents.length())
81
									.equalsIgnoreCase(contents)) {
82
						list.add(new ContentProposal(proposals[i]));
83
					}
84
				}
85
			} else {
86
				contents = contents.toLowerCase();
87
				for (int i = 0; i < proposals.length; i++) {
88
					if (proposals[i].toLowerCase().contains(contents)) {
89
						list.add(new ContentProposal(proposals[i]));
90
					}
91
				}
92
			}
93
			
94
			return list.toArray(new IContentProposal[list.size()]);
95
		}
96
		
97
		if (contentProposals == null) {
98
			contentProposals = new IContentProposal[proposals.length];
99
			for (int i = 0; i < proposals.length; i++) {
100
				contentProposals[i] = new ContentProposal(proposals[i]);
101
			}
102
		}
103
		return contentProposals;
104
	}
105

  
106
	/**
107
	 * Set the Strings to be used as content proposals.
108
	 * 
109
	 * @param items
110
	 *            the array of Strings to be used as proposals.
111
	 */
112
	public void setProposals(String[] items) {
113
		this.proposals = items;
114
		contentProposals = null;
115
	}
116

  
117
	/**
118
	 * Set the boolean that controls whether proposals are filtered according to
119
	 * the current field content.
120
	 * 
121
	 * @param filterProposals
122
	 *            <code>true</code> if the proposals should be filtered to
123
	 *            show only those that match the current contents of the field,
124
	 *            and <code>false</code> if the proposals should remain the
125
	 *            same, ignoring the field content.
126
	 * @since 3.3
127
	 */
128
	public void setFiltering(boolean filterProposals) {
129
		this.filterProposals = filterProposals;
130
		// Clear any cached proposals.
131
		contentProposals = null;
132
	}
133
}
0 134

  
tmp/org.txm.rcp/src/main/java/org/eclipse/jface/fieldassist/TXMAutoCompleteField.java (revision 2226)
1
package org.eclipse.jface.fieldassist;
2

  
3
import java.util.ArrayList;
4

  
5
import org.eclipse.jface.bindings.keys.KeyStroke;
6
import org.eclipse.swt.widgets.Control;
7

  
8
/**
9
 * AutoCompleteField is a class which attempts to auto-complete a user's
10
 * keystrokes by activating a popup that filters a list of proposals according
11
 * to the content typed by the user.
12
 * 
13
 * @see ContentProposalAdapter
14
 * @see SimpleContentProposalProvider
15
 * 
16
 * @since 3.3
17
 */
18
public class TXMAutoCompleteField {
19

  
20
	private TXMSimpleContentProposalProvider proposalProvider;
21
	private TXMContentProposalAdapter adapter;
22
	boolean open = false;
23

  
24
	public boolean isOpen() { return adapter.isProposalPopupOpen();};
25
	
26
	/**
27
	 * Construct an AutoComplete field on the specified control, whose
28
	 * completions are characterized by the specified array of Strings.
29
	 * 
30
	 * @param control
31
	 *            the control for which autocomplete is desired. May not be
32
	 *            <code>null</code>.
33
	 * @param controlContentAdapter
34
	 *            the <code>IControlContentAdapter</code> used to obtain and
35
	 *            update the control's contents. May not be <code>null</code>.
36
	 * @param proposals
37
	 *            the array of Strings representing valid content proposals for
38
	 *            the field.
39
	 */
40
	public TXMAutoCompleteField(Control control,
41
			IControlContentAdapter controlContentAdapter, String[] proposals, KeyStroke keyStroke) {
42
		this(control, controlContentAdapter, proposals, keyStroke, null);
43
	}
44
	
45
	/**
46
	 * Construct an AutoComplete field on the specified control, whose
47
	 * completions are characterized by the specified array of Strings.
48
	 * 
49
	 * @param control
50
	 *            the control for which autocomplete is desired. May not be
51
	 *            <code>null</code>.
52
	 * @param controlContentAdapter
53
	 *            the <code>IControlContentAdapter</code> used to obtain and
54
	 *            update the control's contents. May not be <code>null</code>.
55
	 * @param proposals
56
	 *            the array of Strings representing valid content proposals for
57
	 *            the field.
58
	 */
59
	public TXMAutoCompleteField(Control control,
60
			IControlContentAdapter controlContentAdapter, String[] proposals, KeyStroke keyStroke, char[] autoActivationCharacters) {
61
		proposalProvider = new TXMSimpleContentProposalProvider(proposals);
62
		proposalProvider.setFiltering(true);
63
		
64
		adapter = new TXMContentProposalAdapter(control, controlContentAdapter,
65
				proposalProvider, keyStroke, autoActivationCharacters);
66
		adapter.setPropagateKeys(true);
67
		adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
68
		adapter.addContentProposalListener(new IContentProposalListener2() {
69
			@Override
70
			public void proposalPopupOpened(ContentProposalAdapter adapter) {
71
				open = true;
72
			}
73
			
74
			@Override
75
			public void proposalPopupClosed(ContentProposalAdapter adapter) {
76
				open = false;
77
			}
78
		});
79
	}
80
	
81
	/**
82
	 * Construct an AutoComplete field on the specified control, whose
83
	 * completions are characterized by the specified array of Strings.
84
	 * 
85
	 * @param control
86
	 *            the control for which autocomplete is desired. May not be
87
	 *            <code>null</code>.
88
	 * @param controlContentAdapter
89
	 *            the <code>IControlContentAdapter</code> used to obtain and
90
	 *            update the control's contents. May not be <code>null</code>.
91
	 * @param proposals
92
	 *            the array of Strings representing valid content proposals for
93
	 *            the field.
94
	 */
95
	public TXMAutoCompleteField(Control control,
96
			IControlContentAdapter controlContentAdapter, String[] proposals) {
97
		this(control, controlContentAdapter, proposals, null, null);
98
	}
99

  
100
	/**
101
	 * Set the Strings to be used as content proposals.
102
	 * 
103
	 * @param proposals
104
	 *            the array of Strings to be used as proposals.
105
	 */
106
	public void setProposals(String[] proposals) {
107
		proposalProvider.setProposals(proposals);
108
	}
109

  
110
	public void open() {
111
		if (open) adapter.close();
112
		else adapter.open();
113
	}
114
}
0 115

  
tmp/org.txm.rcp/META-INF/MANIFEST.MF (revision 2226)
72 72
 org.apache.log4j.spi,
73 73
 org.apache.log4j.varia,
74 74
 org.apache.log4j.xml,
75
 org.eclipse.jface.fieldassist,
75 76
 org.hamcrest,
76 77
 org.hamcrest.core,
77 78
 org.hamcrest.internal,
......
116 117
 org.txm.rcp.handlers.scripts,
117 118
 org.txm.rcp.jface,
118 119
 org.txm.rcp.log,
120
 org.txm.rcp.menu,
119 121
 org.txm.rcp.messages,
120 122
 org.txm.rcp.p2.plugins,
121 123
 org.txm.rcp.perspective,
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/OpenEdition.java (revision 2226)
153 153
			Text text = null;
154 154
			if (corpus instanceof Subcorpus) {
155 155
				Subcorpus sub = (Subcorpus)corpus;
156
				sub.compute(false);
156 157
				List<Match> matches = sub.getMatches();
157 158
				if (matches.size() > 0) {
158 159
					StructuralUnit text_su = corpus.getStructuralUnit("text"); //$NON-NLS-1$
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java (revision 2226)
1 1
package org.txm.edition.rcp.editors;
2 2

  
3 3
import java.io.File;
4
import java.io.IOException;
4 5
import java.net.URL;
5 6
import java.util.ArrayList;
6 7
import java.util.Arrays;
......
39 40
import org.txm.objects.Text;
40 41
import org.txm.rcp.StatusLine;
41 42
import org.txm.rcp.utils.IOClipboard;
43
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
44
import org.txm.searchengine.cqp.serverException.CqiServerError;
42 45
import org.txm.utils.io.IOUtils;
43 46
import org.txm.utils.logger.Log;
44 47

  
......
690 693

  
691 694
	public void firstText() {
692 695
		//Text current = this.currentPage.getEdition().getText();
693
		Project corpus = currentText.getProject();
694
		Text firstText = corpus.getFirstText();
696
		Project project = currentText.getProject();
697
		String id;
698
		try {
699
			id = this.synopticEditionEditor.getCorpus().getCorpusTextIdsList()[0];
700
		} catch (Exception e) {
701
			// TODO Auto-generated catch block
702
			e.printStackTrace();
703
			return;
704
		}
705
		Text firstText = project.getText(id);
695 706

  
696 707
		if (firstText != null) {
697 708
			String editionName = currentEdition.getName();
......
716 727
	 */
717 728
	public void lastText() {
718 729
		//Text current = this.currentPage.getEdition().getText();
719
		Project b = currentText.getProject();
720
		Text lastText = b.getLastText();
730
		Project project = currentText.getProject();
731
		String id;
732
		try {
733
			String[] ids = this.synopticEditionEditor.getCorpus().getCorpusTextIdsList();
734
			id = ids[ids.length-1];
735
		} catch (Exception e) {
736
			// TODO Auto-generated catch block
737
			e.printStackTrace();
738
			return;
739
		}
740
		Text lastText = project.getText(id);
721 741

  
722 742
		if (lastText != null) {
723 743
			String editionName = currentEdition.getName();
......
747 767
	 */
748 768
	public void previousText(boolean fromNextText) {
749 769

  
750
		//Text current = this.currentPage.getEdition().getText();
751
		Project corpus = currentText.getProject();
752
		Text previousText = corpus.getPreviousText(currentText);
770
		Project project = currentText.getProject();
771
		String id;
772
		try {
773
			String[] ids = this.synopticEditionEditor.getCorpus().getCorpusTextIdsList();
774
			String current = currentText.getName();
775
			int idx = Arrays.binarySearch(ids, current);
776
			if (idx > 0) idx--;
777
			id = ids[idx];
778
		} catch (Exception e) {
779
			e.printStackTrace();
780
			return;
781
		}
782
		Text previousText = project.getText(id);
753 783

  
754 784
		if (previousText != null) {
755 785
			String editionName = currentEdition.getName();
......
780 810
	 */
781 811
	public void nextText() {
782 812
		//Text current = this.currentPage.getEdition().getText();
783
		Project b = currentText.getProject();
784
		Text nextText = b.getNextText(currentText);
813
		Project project = currentText.getProject();
814
		String id;
815
		try {
816
			String[] ids = this.synopticEditionEditor.getCorpus().getCorpusTextIdsList();
817
			String currentId = currentText.getName();
818
			int idx = Arrays.binarySearch(ids, currentId);
819
			if (idx < ids.length - 1) idx++;
820
			id = ids[idx];
821
		} catch (Exception e) {
822
			e.printStackTrace();
823
			return;
824
		}
825
		Text nextText = project.getText(id);
785 826

  
786 827
		if (nextText != null) {
787 828
			String editionName = currentEdition.getName();
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java (revision 2226)
27 27
//
28 28
package org.txm.edition.rcp.editors;
29 29

  
30
import java.io.IOException;
30 31
import java.util.ArrayList;
31 32
import java.util.Arrays;
32 33
import java.util.Collection;
......
41 42
import org.eclipse.core.commands.Parameterization;
42 43
import org.eclipse.core.commands.ParameterizedCommand;
43 44
import org.eclipse.core.commands.common.NotDefinedException;
44
import org.eclipse.core.runtime.IConfigurationElement;
45
import org.eclipse.core.runtime.IProgressMonitor;
46
import org.eclipse.core.runtime.Platform;
45
import org.eclipse.jface.bindings.keys.KeyStroke;
46
import org.eclipse.jface.fieldassist.TXMAutoCompleteField;
47
import org.eclipse.jface.fieldassist.TextContentAdapter;
47 48
import org.eclipse.jface.text.ITextSelection;
48 49
import org.eclipse.jface.viewers.ISelection;
49 50
import org.eclipse.jface.viewers.ISelectionChangedListener;
......
55 56
import org.eclipse.swt.events.KeyListener;
56 57
import org.eclipse.swt.events.SelectionEvent;
57 58
import org.eclipse.swt.events.SelectionListener;
59
import org.eclipse.swt.graphics.Cursor;
58 60
import org.eclipse.swt.layout.GridData;
59
import org.eclipse.swt.layout.GridLayout;
60 61
import org.eclipse.swt.widgets.Button;
61 62
import org.eclipse.swt.widgets.Composite;
62 63
import org.eclipse.swt.widgets.Label;
63 64
import org.eclipse.swt.widgets.Shell;
64
import org.eclipse.swt.widgets.ToolItem;
65 65
import org.eclipse.ui.IEditorInput;
66 66
import org.eclipse.ui.IEditorPart;
67 67
import org.eclipse.ui.IEditorSite;
68
import org.eclipse.ui.IPartListener2;
69
import org.eclipse.ui.IWorkbenchPartReference;
70 68
import org.eclipse.ui.IWorkbenchWindow;
71 69
import org.eclipse.ui.PartInitException;
72 70
import org.eclipse.ui.PlatformUI;
......
80 78
import org.txm.rcp.editors.IEditionEditor;
81 79
import org.txm.rcp.editors.TXMEditor;
82 80
import org.txm.rcp.swt.GLComposite;
81
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
83 82
import org.txm.searchengine.cqp.corpus.CQPCorpus;
83
import org.txm.searchengine.cqp.corpus.MainCorpus;
84
import org.txm.searchengine.cqp.serverException.CqiServerError;
84 85
import org.txm.utils.logger.Log;
85 86
/**
86 87
 * Call the internal browser of RCP to display the Edition Pages of a Text
......
100 101
	GLComposite editionsArea;
101 102
	private List<String> editionNames;
102 103
	private CQPCorpus corpus;
104
	private MainCorpus mainCorpus;
105
	
103 106
	private Text text;
104 107
	private Button editionsChooser;
105 108
	//private Label editionsLabel;
......
107 110
//	private GLComposite annotationWidgetsArea;
108 111
//	private TXMEditorToolBar supplementaryButtonToolbar;
109 112
	private ISelectionProvider selProvider;
113
	private org.eclipse.swt.widgets.Text text_text;
114
	private Label text_label;
110 115

  
111 116
	//TODO finish editor conversion
112 117
	public Text getResult() {
......
256 261
	}
257 262

  
258 263
	/**
259
	 * Next page.
264
	 * Direct access to a page with a name.
260 265
	 */
261 266
	public void goToPage(String name) {
262 267
		for(EditionPanel panel : editionPanels.values())
......
264 269
		updatePageLabel();
265 270

  
266 271
	}
272
	
273
	/**
274
	 * Direct access to a text with a name.
275
	 */
276
	public void goToText(String id) {
277
		try {
278
			String[] texts = corpus.getCorpusTextIdsList();
279
			for (String text_id : texts) {
280
				if (text_id.equals(id)) {
281
					Text text = mainCorpus.getProject().getText(text_id);
282
					if (text != null) {
283
						setText(text, true);
284
						return;
285
					}
286
				}
287
			}
288
		} catch (Exception e) {
289
			e.printStackTrace();
290
		}
291
		
292
		Log.info(NLS.bind("No {0} text found.", id));
293
	}
267 294

  
268 295
	/**
269 296
	 * Previous text.
......
335 362
		editionsChooser = new Button(controlsArea, SWT.PUSH);
336 363
		editionsChooser.setText(StringUtils.join(editionNames, " | ")); //$NON-NLS-1$
337 364

  
338
		if (corpus.getProject().getBuiltEditionNames().size() > 1) {			
365
		if (mainCorpus.getProject().getBuiltEditionNames().size() > 1) {			
339 366

  
340 367
			editionsChooser.addSelectionListener(new SelectionListener() {
341 368
				@Override
342 369
				public void widgetSelected(SelectionEvent e) {
343 370
					try {
344
						List<String> availableEditions = corpus.getProject().getBuiltEditionNames();
371
						List<String> availableEditions = mainCorpus.getProject().getBuiltEditionNames();
345 372
						if (availableEditions.size() == 0) return;
346 373
						if (availableEditions.size() == 1) return;
347 374
						
348 375
						
349 376
						Shell shell = e.display.getActiveShell();
350
						EditionSelectorDialog d = new EditionSelectorDialog(shell, corpus, editionNames);
377
						EditionSelectorDialog d = new EditionSelectorDialog(shell, mainCorpus, editionNames);
351 378

  
352 379
						if (d.open() == Window.OK) {
353 380
							Object[] rez = d.getResult();
......
355 382
							for(int i = 0 ; i < rez.length ; i++) editionNames.add(rez[i].toString());
356 383
							
357 384
							editionsChooser.setText(StringUtils.join(editionNames, " | ")); //$NON-NLS-1$
358
							openEditions(corpus, text, editionNames);
385
							openEditions(text, editionNames);
359 386
							firstPage();
360 387
						}
361 388
					} catch (Exception e2) {
......
383 410
		pageNavigationComposite.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, true, false));
384 411
		
385 412
		GLComposite textNavigationComposite = new GLComposite(controlsArea, SWT.NONE, EditionUIMessages.textButtons);
386
		textNavigationComposite.getLayout().numColumns = 6;
413
		textNavigationComposite.getLayout().numColumns = 7;
387 414
		Button firstText = new Button(textNavigationComposite, SWT.FLAT);
388 415
		Button previousText = new Button(textNavigationComposite, SWT.FLAT);
389
		new Label(textNavigationComposite, SWT.NONE).setText(EditionUIMessages.CommandLink_empty);
416
		text_text = new org.eclipse.swt.widgets.Text(textNavigationComposite, SWT.BORDER);
417
		KeyStroke keys = KeyStroke.getInstance(SWT.CONTROL, SWT.SPACE);
418
		try {
419
			String[] text_ids = corpus.getCorpusTextIdsList();
420
			GridData gdata = new GridData(GridData.CENTER, GridData.FILL, true, false);
421
			gdata.minimumWidth = 1;
422
			for (String text_id : text_ids) {
423
				double s = text_id.length()*7;
424
				if (s > gdata.minimumWidth) {
425
					gdata.minimumWidth = (int) s;
426
				}
427
			}
428
			text_text.setLayoutData(gdata);
429
			TXMAutoCompleteField identifiantComboAutoCompleteField = new TXMAutoCompleteField(text_text, new TextContentAdapter(), text_ids, keys);
430
		} catch (Exception e2) {
431
			e2.printStackTrace();
432
		}
433
		Cursor cursor = new Cursor(text_text.getDisplay(), SWT.CURSOR_SIZENS);
434
		text_text.setCursor(cursor);
435
		text_label = new Label(textNavigationComposite, SWT.NONE);
390 436
		Button nextText = new Button(textNavigationComposite, SWT.FLAT|SWT.PUSH);
391 437
		Button lastText = new Button(textNavigationComposite, SWT.FLAT|SWT.PUSH);
392 438
		textNavigationComposite.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false));
......
431 477

  
432 478
		// set labels
433 479
		page_label.setText(""); //$NON-NLS-1$
480
		text_label.setText(""); //$NON-NLS-1$
434 481
		firstText.setImage(IImageKeys.getImage(IImageKeys.CTRLREWINDSTART));
435 482
		firstText.setToolTipText(EditionUIMessages.firstTextOfTheCorpus); 
436 483
		previousText.setImage(IImageKeys.getImage(IImageKeys.CTRLREWIND));
......
460 507
			@Override
461 508
			public void keyPressed(KeyEvent e) {}
462 509
		});
510
		text_text.addKeyListener(new KeyListener() {
511

  
512
			@Override
513
			public void keyReleased(KeyEvent e) {
514
				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
515
					goToText(text_text.getText());
516
				}
517
			}
518

  
519
			@Override
520
			public void keyPressed(KeyEvent e) {}
521
		});
463 522
		// set listeners
464 523
		first.addSelectionListener(new SelectionListener() {
465 524
			@Override
......
554 613

  
555 614
		try {
556 615
			// ensure all texts have build their page indexes
557
			for (Text t : corpus.getProject().getTexts()) {
616
			for (Text t : mainCorpus.getProject().getTexts()) {
558 617
				t.compute();
559 618
			}
560
			if (openEditions(corpus, text, editionNames)) {
619
			if (openEditions(text, editionNames)) {
561 620
				firstPage();
562 621
			}
563 622
		} catch (Exception e1) {
......
566 625
		}
567 626
	}
568 627

  
569
	/**
570
	 * Opens the default corpus edition with the first Text
571
	 * 
572
	 * @param corpus
573
	 */
574
	public boolean openEditions(CQPCorpus corpus) {
575
		if (corpus == null) return false;
576
		return openEditions(corpus, corpus.getProject().getFirstText(), corpus.getProject().getDefaultEdition());
577
	}
628
//	/**
629
//	 * Opens the default corpus edition with the first Text
630
//	 * 
631
//	 * @param corpus
632
//	 */
633
//	public boolean openEditions(CQPCorpus corpus) {
634
//		if (corpus == null) return false;
635
//		return openEditions(corpus, corpus.getProject().getFirstText(), corpus.getProject().getDefaultEdition());
636
//	}
578 637

  
579 638
	/**
580 639
	 * update editor title using the first panel only 
......
590 649
			if (page_text.isDisposed()) continue;
591 650
			page_text.setText(cpage.getName());
592 651
			page_label.setText(" / "+e.getNumPages()); //$NON-NLS-1$
652
			
653
			text_text.setText(p.getCurrentText().getName());
654
			try {
655
				text_label.setText(" / "+corpus.getCorpusTextIdsList().length);
656
			} catch (Exception e1) {
657
				// TODO Auto-generated catch block
658
				e1.printStackTrace();
659
			}
660

  
593 661
			controlsArea.layout();
594 662
			return;
595 663
		}
596 664
	}
597 665

  
598
	public boolean openEditions(CQPCorpus corpus, String textID, String... editionNames) {
599
		Text text = corpus.getProject().getText(textID);
600
		if (text == null) return false;
601
		return openEditions(corpus, text, editionNames);
602
	}
666
//	public boolean openEditions(CQPCorpus corpus, String textID, String... editionNames) {
667
//		Text text = corpus.getProject().getText(textID);
668
//		if (text == null) return false;
669
//		return openEditions(corpus, text, editionNames);
670
//	}
603 671

  
604
	/**
605
	 * Opens a list of edition corpus
606
	 * @param corpus
607
	 * @param editionNames
608
	 */
609
	public boolean openEditions(CQPCorpus corpus, Text text, String... editionNames) {
610
		return openEditions(corpus, text, Arrays.asList(editionNames));
611
	}
672
//	/**
673
//	 * Opens a list of edition corpus
674
//	 * @param corpus
675
//	 * @param editionNames
676
//	 */
677
//	public boolean openEditions(CQPCorpus corpus, Text text, String... editionNames) {
678
//		return openEditions(corpus, text, Arrays.asList(editionNames));
679
//	}
612 680
	
613 681
	/**
614 682
	 * Opens a list of edition corpus
615 683
	 * @param corpus
616 684
	 * @param editionNames
617 685
	 */
618
	public boolean openEditions(CQPCorpus corpus, Text text, List<String> editionNames) {
686
	public boolean openEditions(Text text, List<String> editionNames) {
619 687

  
620 688
		try {
621 689
			text.compute();
......
654 722
		return true;
655 723
	}
656 724

  
657
	/**
658
	 * 
659
	 * //TODO: add getDefaultEditions to Corpus object
660
	 * 
661
	 * @param corpus
662
	 * @return a list of default editions
663
	 */
664
	public String[] getDefaultEditions(CQPCorpus corpus) {
665
		String defaultEdition = corpus.getProject().getDefaultEdition();
666
		if (defaultEdition.contains(",")) { //$NON-NLS-1$
667
			return defaultEdition.split(","); //$NON-NLS-1$
668
		} else {
669
			return new String[]{defaultEdition};
670
		}
671
	}
725
//	/**
726
//	 * 
727
//	 * //TODO: add getDefaultEditions to Corpus object
728
//	 * 
729
//	 * @param corpus
730
//	 * @return a list of default editions
731
//	 */
732
//	public String[] getDefaultEditions(CQPCorpus corpus) {
733
//		String defaultEdition = corpus.getProject().getDefaultEdition();
734
//		if (defaultEdition.contains(",")) { //$NON-NLS-1$
735
//			return defaultEdition.split(","); //$NON-NLS-1$
736
//		} else {
737
//			return new String[]{defaultEdition};
738
//		}
739
//	}
672 740

  
673 741
	@Override
674 742
	public void doSaveAs() {
......
679 747
	public void init(IEditorSite site, IEditorInput input)
680 748
			throws PartInitException {
681 749
		
682
		corpus = ((SynopticEditorInput) input).getCorpus();
683
		corpus = corpus.getMainCorpus(); // get the main corpus of the corpus
750
		corpus = ((SynopticEditorInput) input).getCorpus(); // corpus focused when opening the editions
751
		corpus.compute(false);
752
		mainCorpus = corpus.getMainCorpus(); // get the main corpus of the corpus
684 753
		text = ((SynopticEditorInput) input).getText();
685 754
		editionNames = ((SynopticEditorInput) input).getEditions();
686 755
		
......
737 806
	public CQPCorpus getCorpus() {
738 807
		return corpus;
739 808
	}
809
	
740 810

  
811
	public CQPCorpus getMainCorpus() {
812
		return mainCorpus;
813
	}
814

  
741 815
	public EditionPanel getEditionPanel(int i) {
742 816
		int n = 0;
743 817
		for (EditionPanel p : editionPanels.values()) {

Formats disponibles : Unified diff