Revision 940

tmp/org.txm.queryindex.rcp/src/queryindexrcp/adapters/AdapterFactory.java (revision 940)
5 5
import org.eclipse.jface.resource.ImageDescriptor;
6 6
import org.eclipse.ui.model.IWorkbenchAdapter;
7 7
import org.eclipse.ui.plugin.AbstractUIPlugin;
8
import org.txm.functions.queryindex.QueryIndex;
8
import org.txm.queryindex.core.functions.QueryIndex;
9 9
import org.txm.rcp.Application;
10 10
import org.txm.rcp.IImageKeys;
11 11

  
tmp/org.txm.queryindex.rcp/src/org/txm/queryindex/rcp/commands/link/QueryIndexToLexicalTable.java (revision 940)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate:$
25
// $LastChangedRevision:$
26
// $LastChangedBy:$ 
27
//
28
package org.txm.queryindex.rcp.commands.link;
29

  
30
import java.util.ArrayList;
31

  
32
import org.apache.batik.util.gui.CSSMediaPanel.Dialog;
33
import org.eclipse.core.commands.AbstractHandler;
34
import org.eclipse.core.commands.ExecutionEvent;
35
import org.eclipse.core.commands.ExecutionException;
36
import org.eclipse.jface.viewers.ArrayContentProvider;
37
import org.eclipse.jface.viewers.IStructuredSelection;
38
import org.eclipse.jface.viewers.LabelProvider;
39
import org.eclipse.swt.widgets.Shell;
40
import org.eclipse.ui.IWorkbenchWindow;
41
import org.eclipse.ui.dialogs.ListSelectionDialog;
42
import org.eclipse.ui.handlers.HandlerUtil;
43
import org.txm.lexicaltable.core.functions.LexicalTable;
44
import org.txm.lexicaltable.rcp.messages.LexicalTableUIMessages;
45
import org.txm.queryindex.core.functions.QueryIndex;
46
import org.txm.rcp.StatusLine;
47
import org.txm.rcp.messages.TXMUIMessages;
48
import org.txm.searchengine.cqp.corpus.Partition;
49
import org.txm.searchengine.cqp.corpus.Property;
50
import org.txm.utils.logger.Log;
51
// TODO: Auto-generated Javadoc
52
/**
53
 * The Class IndexToLexicalTable.
54
 */
55
public class QueryIndexToLexicalTable extends AbstractHandler {
56

  
57
	/** The window. */
58
	private IWorkbenchWindow window;
59
	
60
	/** The selection. */
61
	private IStructuredSelection selection;
62
	private static Shell shell;
63
	/* (non-Javadoc)
64
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
65
	 */
66
	@Override
67
	public Object execute(ExecutionEvent event) throws ExecutionException {
68
		// TODO Auto-generated method stub
69
		window = HandlerUtil.getActiveWorkbenchWindow(event);
70
		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
71
		shell = HandlerUtil.getActiveWorkbenchWindowChecked(event)
72
		.getShell();
73
		return null;
74
	}
75

  
76
	/**
77
	 * Builds the lexical table.
78
	 *
79
	 * @param qindex the voc
80
	 * @param from the from
81
	 * @param to the to
82
	 * @return true, if successful
83
	 */
84
	public boolean buildLexicalTable(QueryIndex qindex, int from, int to) {
85
		LexicalTable table;
86
		Partition partition;
87
		Property property;
88

  
89
		if (!qindex.isComputedWithPartition()) {
90
			
91
			System.out.println(TXMUIMessages.IndexToLexicalTable_0);
92
			StatusLine.setMessage(TXMUIMessages.IndexToLexicalTable_0);
93
			return false;
94
		}
95

  
96
		Log.info(LexicalTableUIMessages.ComputeLexicalTable_3);
97
		ArrayList<String> choices = new ArrayList<String>();
98
		choices.add(LexicalTableUIMessages.ComputeLexicalTable_16);
99
		choices.add(LexicalTableUIMessages.ComputeLexicalTable_12);
100
		ListSelectionDialog dialog = new ListSelectionDialog(shell, 
101
				choices, new ArrayContentProvider(), new LabelProvider(), 
102
				LexicalTableUIMessages.ComputeLexicalTable_13);
103
		
104
		int ret = dialog.open();
105
		//System.out.println("ret= "+ret);
106
		if (ret != Dialog.OK_OPTION) {
107
			return false;
108
		}
109
		
110
		// TODO: fix line 119
111
//		try {
112
//			table = LexicalTableImpl.createLexicalTableImpl(voc, QuantitativeDataStructureImpl
113
//					.createSymbole(LexicalTableImpl.class));
114
//			partition = voc.getPartition();
115
//			property = voc.getCorpus().getProperties().get(0);
116
//		} catch (Exception e) {
117
//			org.txm.rcp.utils.Logger.printStackTrace(e);
118
//			return false;
119
//		}
120
//
121
//		try {
122
//			IWorkbenchWindow window = PlatformUI.getWorkbench()
123
//					.getActiveWorkbenchWindow();
124
//			IWorkbenchPage page = window.getActivePage();
125
//			LexicalTableEditorInput editorInput = new LexicalTableEditorInput(
126
//					table, partition, property);
127
//			StatusLine.setMessage(RCPMessages.ComputeLexicalTable_10);
128
//			page
129
//					.openEditor(editorInput,
130
//							"org.txm.rcp.editors.lexicaltable.LexicalTableEditor"); //$NON-NLS-1$
131
//		} catch (PartInitException e) {
132
//			org.txm.rcp.utils.Logger.printStackTrace(e);
133
//		} 
134

  
135
		return false;
136
	}
137

  
138
}
0 139

  
tmp/org.txm.queryindex.rcp/src/org/txm/queryindex/rcp/commands/link/package.html (revision 940)
1
<html>
2
<body>
3
	<p>Commands which create link between 2 textometry function</p>
4
</body>
5
</html>
0 6

  
tmp/org.txm.queryindex.rcp/src/org/txm/queryindex/rcp/commands/function/ComputeQueryIndex.java (revision 940)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate:$
25
// $LastChangedRevision:$
26
// $LastChangedBy:$ 
27
//
28
package org.txm.queryindex.rcp.commands.function;
29

  
30
import org.eclipse.core.commands.AbstractHandler;
31
import org.eclipse.core.commands.ExecutionEvent;
32
import org.eclipse.core.commands.ExecutionException;
33
import org.eclipse.jface.viewers.IStructuredSelection;
34
import org.eclipse.ui.IWorkbenchPage;
35
import org.eclipse.ui.handlers.HandlerUtil;
36
import org.txm.index.rcp.messages.IndexUIMessages;
37
import org.txm.queryindex.rcp.editors.input.QueryIndexEditorInput;
38
import org.txm.queryindex.rcp.editors.queryindex.QueryIndexEditor;
39
import org.txm.rcp.StatusLine;
40
import org.txm.rcp.TXMWindows;
41
import org.txm.searchengine.cqp.corpus.Corpus;
42
import org.txm.searchengine.cqp.corpus.Partition;
43
import org.txm.utils.logger.Log;
44
// TODO: Auto-generated Javadoc
45
/**
46
 * open the Index Editor 
47
 * @author mdecorde.
48
 */
49
public class ComputeQueryIndex extends AbstractHandler {
50

  
51
	/** The ID. */
52
	public static String ID = "org.txm.rcp.commands.function.ComputeQueryIndex"; //$NON-NLS-1$
53

  
54
	/** The selection. */
55
	private IStructuredSelection selection;
56
	
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
59
	 */
60
	@Override
61
	public Object execute(ExecutionEvent event) throws ExecutionException {
62
		Log.info("Compute QueryIndex: start");
63
		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
64

  
65
		Object s = selection.getFirstElement();
66
		if (s instanceof Corpus) {
67
			final Corpus corpus = (Corpus) s;
68
			openEditor(corpus);
69
		} else if (s instanceof Partition) {
70
			final Partition partition = (Partition) s;
71
			openEditor(partition);
72
		} else {
73
			Log.severe("Can not compute QueryIndex with: "+s);
74
		}
75

  
76
		return null;
77
	}
78
	
79
	public static void openEditor(Corpus corpus) {
80
		IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage();
81
		QueryIndexEditorInput editorInput = new QueryIndexEditorInput(corpus);
82
		try {
83
			StatusLine.setMessage(IndexUIMessages.ComputeIndex_0);
84
			QueryIndexEditor voceditor = (QueryIndexEditor) page
85
					.openEditor(editorInput,QueryIndexEditor.ID);
86
			voceditor.initializeFields();
87
		} catch (Exception e) {
88
			Log.printStackTrace(e);
89
		}
90
	}
91
	
92
	public static void openEditor(Partition partition) {
93
		IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage();
94
		QueryIndexEditorInput editorInput = new QueryIndexEditorInput(partition);
95
		try {
96
			StatusLine.setMessage(IndexUIMessages.ComputeIndex_0);
97
			QueryIndexEditor voceditor = (QueryIndexEditor) page
98
					.openEditor(editorInput, QueryIndexEditor.ID);
99
			voceditor.initializeFields();
100
		} catch (Exception e) {
101
			Log.printStackTrace(e);
102
		}
103
	}
104
}
0 105

  
tmp/org.txm.queryindex.rcp/src/org/txm/queryindex/rcp/editors/queryindex/LineLabelProvider.java (revision 940)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate:$
25
// $LastChangedRevision:$
26
// $LastChangedBy:$ 
27
//
28
package org.txm.queryindex.rcp.editors.queryindex;
29

  
30
import org.eclipse.jface.viewers.ILabelProviderListener;
31
import org.eclipse.jface.viewers.ITableLabelProvider;
32
import org.eclipse.swt.graphics.Image;
33
import org.txm.queryindex.core.functions.QueryIndexLine;
34

  
35
// TODO: Auto-generated Javadoc
36
/**
37
 * The Class LineLabelProvider.
38
 */
39
public class LineLabelProvider implements ITableLabelProvider {
40

  
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
43
	 */
44
	@Override
45
	public Image getColumnImage(Object element, int columnIndex) {
46
		return null;
47
	}
48

  
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
51
	 */
52
	@Override
53
	public String getColumnText(Object element, int columnIndex) {
54
		QueryIndexLine line = (QueryIndexLine) element;
55
		switch (columnIndex) {
56
		case 0:
57
			return ""; //$NON-NLS-1$
58
		case 1:
59
			return line.getName();
60
		case 2:
61
			return "" + line.getFrequency(); //$NON-NLS-1$
62
		default:
63
			if (line.getFreqs().length > 1
64
					&& columnIndex - 3 < line.getFreqs().length)
65
				return "" + line.getFrequency(columnIndex - 3); //$NON-NLS-1$
66
			else
67
				return "";//$NON-NLS-1$
68
		}
69
	}
70

  
71
	/* (non-Javadoc)
72
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
73
	 */
74
	@Override
75
	public void addListener(ILabelProviderListener listener) {
76
		// TODO Auto-generated method stub
77
	}
78

  
79
	/* (non-Javadoc)
80
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
81
	 */
82
	@Override
83
	public void dispose() {
84
		// TODO Auto-generated method stub
85
	}
86

  
87
	/* (non-Javadoc)
88
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
89
	 */
90
	@Override
91
	public boolean isLabelProperty(Object element, String property) {
92
		// TODO Auto-generated method stub
93
		return false;
94
	}
95

  
96
	/* (non-Javadoc)
97
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
98
	 */
99
	@Override
100
	public void removeListener(ILabelProviderListener listener) {
101
		// TODO Auto-generated method stub
102
	}
103
}
0 104

  
tmp/org.txm.queryindex.rcp/src/org/txm/queryindex/rcp/editors/queryindex/QueryIndexEditor.java (revision 940)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate:$
25
// $LastChangedRevision:$
26
// $LastChangedBy:$ 
27
//
28
package org.txm.queryindex.rcp.editors.queryindex;
29

  
30
import java.io.File;
31
import java.io.IOException;
32
import java.util.ArrayList;
33
import java.util.List;
34

  
35
import org.eclipse.core.runtime.IProgressMonitor;
36
import org.eclipse.core.runtime.IStatus;
37
import org.eclipse.core.runtime.Status;
38
import org.eclipse.jface.action.MenuManager;
39
import org.eclipse.jface.viewers.ISelection;
40
import org.eclipse.jface.viewers.StructuredSelection;
41
import org.eclipse.jface.viewers.TableViewer;
42
import org.eclipse.swt.SWT;
43
import org.eclipse.swt.events.KeyEvent;
44
import org.eclipse.swt.events.KeyListener;
45
import org.eclipse.swt.events.MouseAdapter;
46
import org.eclipse.swt.events.MouseEvent;
47
import org.eclipse.swt.events.SelectionEvent;
48
import org.eclipse.swt.events.SelectionListener;
49
import org.eclipse.swt.graphics.Font;
50
import org.eclipse.swt.graphics.FontData;
51
import org.eclipse.swt.graphics.Point;
52
import org.eclipse.swt.layout.FormAttachment;
53
import org.eclipse.swt.layout.FormData;
54
import org.eclipse.swt.layout.FormLayout;
55
import org.eclipse.swt.layout.GridData;
56
import org.eclipse.swt.layout.GridLayout;
57
import org.eclipse.swt.widgets.Button;
58
import org.eclipse.swt.widgets.Composite;
59
import org.eclipse.swt.widgets.Display;
60
import org.eclipse.swt.widgets.FileDialog;
61
import org.eclipse.swt.widgets.Label;
62
import org.eclipse.swt.widgets.Menu;
63
import org.eclipse.swt.widgets.Spinner;
64
import org.eclipse.swt.widgets.TableColumn;
65
import org.eclipse.ui.IEditorInput;
66
import org.eclipse.ui.IEditorSite;
67
import org.eclipse.ui.PartInitException;
68
import org.txm.core.messages.TXMCoreMessages;
69
import org.txm.index.core.functions.LineComparator.SortMode;
70
import org.txm.index.rcp.messages.IndexUIMessages;
71
import org.txm.queryindex.core.functions.Messages;
72
import org.txm.queryindex.core.functions.QueryIndex;
73
import org.txm.queryindex.core.functions.QueryIndexLine;
74
import org.txm.queryindex.rcp.editors.input.QueryIndexEditorInput;
75
import org.txm.rcp.JobsTimer;
76
import org.txm.rcp.StatusLine;
77
import org.txm.rcp.editors.TXMEditor;
78
import org.txm.rcp.editors.TableKeyListener;
79
import org.txm.rcp.messages.TXMUIMessages;
80
import org.txm.rcp.swt.dialog.LastOpened;
81
import org.txm.rcp.swt.widget.NamedAssistedQueryWidget;
82
import org.txm.rcp.swt.widget.NavigationWidget;
83
import org.txm.rcp.utils.JobHandler;
84
import org.txm.rcp.views.QueriesView;
85
import org.txm.rcp.views.corpora.CorporaView;
86
import org.txm.searchengine.cqp.CQPSearchEngine;
87
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
88
import org.txm.searchengine.cqp.corpus.Corpus;
89
import org.txm.searchengine.cqp.corpus.Partition;
90
import org.txm.searchengine.cqp.corpus.Property;
91
import org.txm.searchengine.cqp.corpus.query.Query;
92
import org.txm.statsengine.r.rcp.views.RVariablesView;
93
import org.txm.utils.logger.Log;
94

  
95
/**
96
 * display the query index parameters and result.
97
 * 
98
 * @author mdecorde
99
 */
100
public class QueryIndexEditor extends TXMEditor<QueryIndex> {
101

  
102
	/** The Constant ID. */
103
	public static final String ID = "org.txm.rcp.editors.queryindex.QueryIndexEditor"; //$NON-NLS-1$
104

  
105
	/** The corpus. */
106
	protected Corpus corpus;
107
	protected Partition partition; // can be null
108

  
109
	/** The index. */
110
	protected QueryIndex queryindex;
111
	boolean stored = false; // start storing at first line added
112
	// protected boolean saveQueryIndex = true;
113

  
114
	// params
115
	/** The query label. */
116
	protected Label queryLabel;
117

  
118
	/** The query widget. */
119
	protected NamedAssistedQueryWidget queryWidget;
120

  
121
	/** The N ligne p page spinner. */
122
	protected Spinner NLignePPageSpinner;
123
	// infos
124
	/** The navigation area. */
125
	protected NavigationWidget navigationArea;
126

  
127
	/** The l fmin info. */
128
	protected Label lFminInfo;
129

  
130
	/** The l fmax info. */
131
	protected Label lFmaxInfo;
132

  
133
	/** The l v info. */
134
	protected Label lVInfo;
135

  
136
	/** The l t info. */
137
	protected Label lTInfo;
138
	// result
139
	/** The line table viewer. */
140
	protected TableViewer viewer;
141

  
142
	/** The n column. */
143
	protected TableColumn nColumn;
144

  
145
	/** The unit column. */
146
	protected TableColumn unitColumn;
147

  
148
	/** The freq column. */
149
	protected TableColumn freqColumn;
150

  
151
	/** The separator column. */
152
	protected TableColumn separatorColumn;
153

  
154
	/** The top line. */
155
	protected int topLine;
156

  
157
	/** The bottom line. */
158
	protected int bottomLine;
159

  
160
	/** The nblinesperpage. */
161
	protected int nblinesperpage;
162

  
163
	/** The nblinesmax. */
164
	protected int nblinesmax;
165

  
166
//	/** The scroll composite. */
167
//	private ScrolledComposite scrollComposite;
168
//
169
//	/** The head composite. */
170
//	private Composite headComposite;
171

  
172
	/** The title. */
173
	String title;
174

  
175
	/**
176
	 * Instantiates a new index editor.
177
	 */
178
	public QueryIndexEditor() {
179
		super();
180
	}
181

  
182
	/**
183
	 * Do save.
184
	 * 
185
	 * @param arg0
186
	 *            the arg0
187
	 * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
188
	 */
189
	@Override
190
	public void doSave(IProgressMonitor arg0) {
191
		// TODO Auto-generated method stub
192
	}
193

  
194
	/**
195
	 * Do save as.
196
	 * 
197
	 * @see org.eclipse.lyon gournd zeroui.part.EditorPart#doSaveAs()
198
	 */
199
	@Override
200
	public void doSaveAs() {
201
		// TODO Auto-generated method stub
202
	}
203

  
204
	/**
205
	 * Inits the.
206
	 * 
207
	 * @param site
208
	 *            the site
209
	 * @param input
210
	 *            the input
211
	 * @throws PartInitException
212
	 *             the part init exception
213
	 * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
214
	 *      org.eclipse.ui.IEditorInput)
215
	 */
216
	@Override
217
	public void init(IEditorSite site, IEditorInput input)
218
			throws PartInitException {
219
		setSite(site);
220
		setInput(input);
221

  
222
		this.corpus = ((QueryIndexEditorInput) input).getCorpus();
223
		this.partition = ((QueryIndexEditorInput) input).getPartition();
224
		this.queryindex = ((QueryIndexEditorInput) input).getQueryIndex();
225
	}
226

  
227
	/**
228
	 * Checks if is dirty.
229
	 * 
230
	 * @return true, if is dirty
231
	 * @see org.eclipse.ui.part.EditorPart#isDirty()
232
	 */
233
	@Override
234
	public boolean isDirty() {
235
		return false;
236
	}
237

  
238
	/**
239
	 * Checks if is save as allowed.
240
	 * 
241
	 * @return true, if is save as allowed
242
	 * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
243
	 */
244
	@Override
245
	public boolean isSaveAsAllowed() {
246
		return false;
247
	}
248

  
249
	private QueryIndex createQueryIndex() {
250
		if (queryindex == null) {
251
			if (partition != null) {
252
				queryindex = new QueryIndex(partition);
253
				title = Messages.QueryIndexEditor_0 + partition.getName();
254
			} else {
255
				queryindex = new QueryIndex(corpus);
256
				title = Messages.QueryIndexEditor_0 + corpus;
257
			}
258
		}
259
		return queryindex;
260
	}
261

  
262
	/**
263
	 * Compute index.
264
	 */
265
	public void compute() {
266

  
267
		createQueryIndex();
268

  
269
		StatusLine.setMessage(IndexUIMessages.IndexEditor_33);
270
		final Query query; // if the query is empty then we put "[]" instead
271
		if (!queryWidget.getQueryString().equals("\"\"")) {//$NON-NLS-1$
272
			query = new Query(queryWidget.getQueryString());
273
		} else {
274
			System.err.println(IndexUIMessages.IndexEditor_0);
275
			return;
276
		}
277

  
278
		final String name;
279
		if (queryWidget.getQueryName().length() == 0) {
280
			name = query.toString();
281
		} else {
282
			name = queryWidget.getQueryName();
283
		}
284

  
285
		try {
286
			JobHandler jobhandler = new JobHandler(title,
287
					queryWidget.getParent()) {
288
				@Override
289
				protected IStatus run(IProgressMonitor monitor) {
290
					this.runInit(monitor);
291
					JobsTimer.start();
292
					final QueryIndexLine line;
293
					try {
294
						try {
295
							if (queryindex.hasLine(name)) {
296
								System.out.println(Messages.QueryIndexEditor_1 + name);
297
								queryindex.removeLine(name);
298
							}
299
							line = queryindex.addLine(name, query);
300
						} catch (CqiClientException e2) {
301
							System.out
302
									.println(Messages.QueryIndexEditor_2
303
											+ query);
304
							Log.printStackTrace(e2);
305
							return Status.CANCEL_STATUS;
306
						}
307

  
308
						if (line == null) {
309
							System.out
310
									.println(Messages.QueryIndexEditor_2
311
											+ query);
312
							return Status.CANCEL_STATUS;
313
						}
314

  
315
						if (monitor.isCanceled())
316
							return Status.CANCEL_STATUS;
317

  
318
						queryindex.sortLines(SortMode.FREQUNIT, true);
319

  
320
						if (monitor.isCanceled())
321
							return Status.CANCEL_STATUS;
322

  
323
						this.acquireSemaphore();
324
						this.releaseSemaphore();
325

  
326
						final String message = Messages.QueryIndexEditor_3;
327

  
328
						if (monitor.isCanceled())
329
							return Status.CANCEL_STATUS;
330

  
331
						monitor.worked(95);
332
						// refresh ui
333
						syncExec(new Runnable() {
334
							@Override
335
							public void run() {
336

  
337
								System.out.println(message);
338
								StatusLine.setMessage(message);
339

  
340
								CorporaView.refresh();
341
								CorporaView.expand(queryindex.getParent());
342
								QueriesView.refresh();
343
								RVariablesView.refresh();
344

  
345
								setPartName(title);
346

  
347
								queryWidget.memorize();
348
								nblinesperpage = NLignePPageSpinner
349
										.getSelection();
350

  
351
								fillDisplayArea(0,
352
										NLignePPageSpinner.getSelection());
353

  
354
								if (line != null) {
355
									queryWidget.setText(""); //$NON-NLS-1$
356
									queryWidget.setName(""); //$NON-NLS-1$
357
									queryWidget.focus();
358
								}
359
							}
360
						});
361
					} catch (Exception e) {
362
						System.out.println(e.getLocalizedMessage());
363
						try {
364
							System.out.println(TXMUIMessages.LastCQPError
365
									+ CQPSearchEngine.getCqiClient().getLastCQPError());
366
						} catch (Exception e1) {
367
							System.out.println(IndexUIMessages.IndexEditor_10
368
									+ e1);
369
							Log.printStackTrace(e1);
370
						}
371
						Log.severe("Error while computing QueryIndex: "+e.getLocalizedMessage());
372
					} catch (ThreadDeath td) {
373
						return Status.CANCEL_STATUS;
374
					} finally {
375
						monitor.done();
376
						JobsTimer.stopAndPrint();
377
					}
378
					return Status.OK_STATUS;
379
				}
380
			};
381
			jobhandler.startJob();
382

  
383
		} catch (Exception e1) {
384
			Log.printStackTrace(e1);
385
		}
386
	}
387

  
388
	/**
389
	 * Creates the part control.
390
	 * 
391
	 * @param parent
392
	 *            the parent
393
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
394
	 */
395
	@Override
396
	public void _createPartControl() {
397

  
398
		// create scrollable area
399
//		scrollComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.NONE);
400
//		FormData headLayoutData = new FormData();
401
//		headLayoutData.top = new FormAttachment(0, 0);
402
//		headLayoutData.left = new FormAttachment(0);
403
//		headLayoutData.right = new FormAttachment(100);
404
//		scrollComposite.setLayoutData(headLayoutData);
405
//		scrollComposite.setLayout(new FormLayout());
406
//
407
//		headComposite = new Composite(scrollComposite, SWT.NONE);
408
//		headLayoutData = new FormData();
409
//		headLayoutData.top = new FormAttachment(0);
410
//		headLayoutData.bottom = new FormAttachment(100);
411
//		headLayoutData.left = new FormAttachment(0);
412
//		headLayoutData.right = new FormAttachment(100);
413
//		headComposite.setLayoutData(headLayoutData);
414
//		headComposite.setLayout(new FormLayout());
415
//
416
//		scrollComposite.setContent(headComposite);
417
//		scrollComposite.setExpandVertical(true);
418
//		scrollComposite.setExpandHorizontal(true);
419
//		scrollComposite.addControlListener(new ControlAdapter() {
420
//			@Override
421
//			public void controlResized(ControlEvent e) {
422
//				Rectangle r = scrollComposite.getClientArea();
423
//				scrollComposite.setMinSize(headComposite.computeSize(
424
//						SWT.DEFAULT, SWT.DEFAULT));
425
//			}
426
//		});
427

  
428
		final Composite paramArea = getExtendedParametersComposite();
429

  
430
		// info&navigation panel
431
		// final Composite infosArea = new Composite(headComposite, SWT.NONE);
432
		// FormData infosLayoutData = new FormData();
433
		// infosLayoutData.top = new FormAttachment(paramArea, 0);
434
		// infosLayoutData.left = new FormAttachment(0);
435
		// infosLayoutData.right = new FormAttachment(100);
436
		// infosArea.setLayoutData(infosLayoutData);
437

  
438
		Composite resultArea = getResultArea();
439

  
440
		// compose paramArea
441
		FormLayout paramLayout = new FormLayout();
442
		paramArea.setLayout(paramLayout);
443

  
444
		// on créé une Query, ici le pivot de la concordance est "[]"
445
		// Query Area: query itself + view properties
446
		Composite queryArea = new Composite(paramArea, SWT.NONE);
447

  
448
		FormData queryLayoutData = new FormData();
449
		queryLayoutData.top = new FormAttachment(0);
450
		queryLayoutData.left = new FormAttachment(0);
451
		queryLayoutData.right = new FormAttachment(100);
452
		queryArea.setLayoutData(queryLayoutData);
453

  
454
		queryArea.setLayout(new GridLayout(4, false));
455

  
456
		// | Query: [ (v)] [Search] |
457
		// Query:
458
		// queryLabel = new Label(queryArea, SWT.NONE);
459
		// queryLabel.setText(RCPMessages.IndexEditor_3);
460
		// queryLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
461
		// true));
462

  
463
		// [ (v)]
464
		queryWidget = new NamedAssistedQueryWidget(queryArea, SWT.DROP_DOWN,
465
				this.corpus);
466
		GridData layoutData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
467
		layoutData.horizontalAlignment = GridData.FILL;
468
		layoutData.grabExcessHorizontalSpace = true;
469
		queryWidget.setLayoutData(layoutData);
470
		queryWidget.addKeyListener(new KeyListener() {
471
			@Override
472
			public void keyPressed(KeyEvent e) {
473
				// System.out.println("key pressed : "+e.keyCode);
474
				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
475
					compute();
476
				}
477
			}
478

  
479
			@Override
480
			public void keyReleased(KeyEvent e) {
481
			}
482
		});
483

  
484
		Button loadFromFile = new Button(queryArea, SWT.BOLD);
485
		loadFromFile.setEnabled(true);
486
		loadFromFile.setText(Messages.QueryIndexEditor_4);
487
		loadFromFile
488
				.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));
489
		loadFromFile.addSelectionListener(new SelectionListener() {
490
			@Override
491
			public void widgetSelected(SelectionEvent e) {
492
				File propFile = null;
493
				if (LastOpened.getFile(ID) != null)
494
					propFile = new File(LastOpened.getFolder(ID));
495

  
496
				FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
497
				String[] exts = { "*.properties" }; //$NON-NLS
498
				dialog.setFilterExtensions(exts);
499
				if (propFile != null) {
500
					dialog.setFilterPath(propFile.getParent());
501
					dialog.setFileName(propFile.getName());
502
				}
503
				String path = dialog.open();
504
				if (path != null) {
505
					propFile = new File(path);
506
					// compute();
507
					// System.out.println("TODO: load from file "+propFile);
508
					createQueryIndex();
509
					try {
510
						queryindex.addLinesFromFile(propFile);
511
						queryindex.sortLines(SortMode.FREQUNIT, true);
512

  
513
						stored = true;
514

  
515
						fillDisplayArea(0, NLignePPageSpinner.getSelection());
516

  
517
						CorporaView.refresh();
518
						CorporaView.expand(queryindex.getParent());
519
						QueriesView.refresh();
520
						RVariablesView.refresh();
521

  
522
						setPartName(title);
523

  
524
						queryWidget.focus();
525
					} catch (CqiClientException e1) {
526
						// TODO Auto-generated catch block
527
						Log.printStackTrace(e1);
528
					} catch (IOException e1) {
529
						// TODO Auto-generated catch block
530
						System.out
531
								.println(Messages.QueryIndexEditor_6 + propFile);
532
						Log.printStackTrace(e1);
533
					}
534
				}
535
			}
536

  
537
			@Override
538
			public void widgetDefaultSelected(SelectionEvent e) {
539
			}
540
		});
541

  
542
		Button go = new Button(queryArea, SWT.BOLD);
543
		go.setText(IndexUIMessages.IndexEditor_4);
544

  
545
		Font f = go.getFont();
546
		FontData defaultFont = f.getFontData()[0];
547
		defaultFont.setStyle(SWT.BOLD);
548
		Font newf = new Font(go.getDisplay(), defaultFont);
549
		go.setFont(newf);
550

  
551
		layoutData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
552
		layoutData.horizontalAlignment = GridData.FILL;
553
		layoutData.grabExcessHorizontalSpace = false;
554
		go.setLayoutData(layoutData);
555

  
556
		go.addSelectionListener(new SelectionListener() {
557
			@Override
558
			public void widgetSelected(SelectionEvent e) {
559
				compute();
560
			}
561

  
562
			@Override
563
			public void widgetDefaultSelected(SelectionEvent e) {
564
			}
565
		});
566

  
567
		// Filters
568
		Composite filtercontrols = new Composite(paramArea, SWT.NONE);
569
		FormData filtersLayoutData = new FormData();
570
		filtersLayoutData.top = new FormAttachment(queryArea, 0);
571
		filtersLayoutData.bottom = new FormAttachment(100);
572
		filtersLayoutData.left = new FormAttachment(0);
573
		filtersLayoutData.right = new FormAttachment(100);
574
		filtercontrols.setLayoutData(filtersLayoutData);
575

  
576
		GridLayout gridLayout = new GridLayout();
577
		gridLayout.numColumns = 9;
578
		gridLayout.makeColumnsEqualWidth = false;
579
		filtercontrols.setLayout(gridLayout);
580

  
581
		Label lNLigneppage = new Label(filtercontrols, SWT.NONE);
582
		lNLigneppage.setText(IndexUIMessages.IndexEditor_8);
583
		lNLigneppage.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
584
				false));
585

  
586
		NLignePPageSpinner = new Spinner(filtercontrols, SWT.BORDER);
587
		NLignePPageSpinner.setMinimum(0);
588
		NLignePPageSpinner.setMaximum(99999);
589
		NLignePPageSpinner.setSelection(100);
590
		NLignePPageSpinner.setIncrement(1);
591
		NLignePPageSpinner.setPageIncrement(100);
592
		NLignePPageSpinner.setLayoutData(new GridData(
593
				GridData.VERTICAL_ALIGN_END));
594
		NLignePPageSpinner.addSelectionListener(new SelectionListener() {
595
			@Override
596
			public void widgetSelected(SelectionEvent e) {
597
			}
598

  
599
			@Override
600
			public void widgetDefaultSelected(SelectionEvent e) {
601
				fillDisplayArea(0, NLignePPageSpinner.getSelection());
602
				viewer.getTable().select(0);
603
				viewer.getTable().showSelection();
604
			}
605
		});
606

  
607
		// compose infosArea
608
		// infosArea.setLayout(new GridLayout(6, false));
609

  
610
		navigationArea = new NavigationWidget(filtercontrols, SWT.NONE);
611
		navigationArea.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true,
612
				false));
613

  
614
		navigationArea.addFirstListener(new SelectionListener() {
615
			@Override
616
			public void widgetDefaultSelected(SelectionEvent e) {
617
			}
618

  
619
			@Override
620
			public void widgetSelected(SelectionEvent e) {
621
				fillDisplayArea(0, NLignePPageSpinner.getSelection());
622
				viewer.getTable().select(0);
623
				viewer.getTable().showSelection();
624
			}
625
		});
626
		navigationArea.addLastListener(new SelectionListener() {
627
			@Override
628
			public void widgetDefaultSelected(SelectionEvent e) {
629
			}
630

  
631
			@Override
632
			public void widgetSelected(SelectionEvent e) {
633
				int top = (queryindex.getV() / NLignePPageSpinner
634
						.getSelection()) * NLignePPageSpinner.getSelection();
635
				int bottom = top + NLignePPageSpinner.getSelection();
636
				fillDisplayArea(top, bottom);
637
				viewer.getTable().select(0);
638
				viewer.getTable().showSelection();
639
			}
640
		});
641
		navigationArea.addNextListener(new SelectionListener() {
642
			@Override
643
			public void widgetDefaultSelected(SelectionEvent e) {
644
			}
645

  
646
			@Override
647
			public void widgetSelected(SelectionEvent e) {
648
				int top = topLine + NLignePPageSpinner.getSelection();
649
				int bottom = top + NLignePPageSpinner.getSelection();
650
				fillDisplayArea(top, bottom);
651
				viewer.getTable().select(0);
652
				viewer.getTable().showSelection();
653
			}
654
		});
655
		navigationArea.addPreviousListener(new SelectionListener() {
656
			@Override
657
			public void widgetDefaultSelected(SelectionEvent e) {
658
			}
659

  
660
			@Override
661
			public void widgetSelected(SelectionEvent e) {
662
				int top = topLine - NLignePPageSpinner.getSelection();
663
				if (top < 0)
664
					top = 0;
665
				int bottom = top + NLignePPageSpinner.getSelection();
666
				fillDisplayArea(top, bottom);
667
				viewer.getTable().select(0);
668
				viewer.getTable().showSelection();
669
			}
670
		});
671

  
672
		// Labels
673
		lTInfo = new Label(filtercontrols, SWT.NONE);
674
		lTInfo.setText(""); //$NON-NLS-1$
675
		lTInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
676

  
677
		lVInfo = new Label(filtercontrols, SWT.NONE);
678
		lVInfo.setText(""); //$NON-NLS-1$
679
		lVInfo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
680

  
681
		lFminInfo = new Label(filtercontrols, SWT.NONE);
682
		lFminInfo.setText(""); //$NON-NLS-1$
683
		lFminInfo
684
				.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
685

  
686
		lFmaxInfo = new Label(filtercontrols, SWT.NONE);
687
		lFmaxInfo.setText(""); //$NON-NLS-1$
688
		lFmaxInfo
689
				.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
690

  
691
		// results
692
		FormLayout resultLayout = new FormLayout();
693
		resultArea.setLayout(resultLayout);
694

  
695
		viewer = new TableViewer(resultArea, SWT.MULTI | SWT.FULL_SELECTION
696
				| SWT.BORDER);
697
		viewer.getTable().setLinesVisible(true);
698
		viewer.getTable().setHeaderVisible(true);
699
		viewer.getTable().addKeyListener(new TableKeyListener(viewer));
700

  
701
		if (corpus != null && corpus.getFont() != null
702
				&& corpus.getFont().length() > 0) {
703
			Font old = viewer.getTable().getFont();
704
			FontData fD = old.getFontData()[0];
705
			Font font = new Font(Display.getCurrent(), corpus.getFont(),
706
					fD.getHeight(), fD.getStyle());
707
			viewer.getTable().setFont(font);
708
		}
709

  
710
		FormData tableLayoutData = new FormData();
711
		tableLayoutData.top = new FormAttachment(0);
712
		tableLayoutData.bottom = new FormAttachment(100);
713
		tableLayoutData.left = new FormAttachment(0);
714
		tableLayoutData.right = new FormAttachment(100);
715
		viewer.getTable().setLayoutData(tableLayoutData);
716

  
717
		viewer.setLabelProvider(new LineLabelProvider());
718
		viewer.setContentProvider(new LineContentProvider());
719
		viewer.setInput(new ArrayList<Property>());
720

  
721
		viewer.getTable().addMouseListener(new MouseAdapter() {
722
			@Override
723
			public void mouseDoubleClick(MouseEvent e) {
724
				Point mouseposition = new Point(e.x
725
						+ viewer.getTable().getHorizontalBar().getSelection(),
726
						e.y);
727
				int col = getPointedColumn(mouseposition);
728
				if (col == 1) {
729
					// IndexToConcordance.link(self,
730
					// (IStructuredSelection) viewer
731
					// .getSelection());
732
					System.out.println(Messages.QueryIndexEditor_7);
733
				} else if (col == 2) {
734
					System.out.println(Messages.QueryIndexEditor_8);
735
				}
736
			}
737
		});
738

  
739
		viewer.getTable().addKeyListener(new KeyListener() {
740
			@Override
741
			public void keyReleased(KeyEvent e) {
742
			}
743

  
744
			@Override
745
			public void keyPressed(KeyEvent e) {
746
				if (e.keyCode == SWT.DEL) {
747
					System.out.println(Messages.QueryIndexEditor_9);
748
					ISelection sel = viewer.getSelection();
749
					if (sel instanceof StructuredSelection) {
750
						List<?> lines = ((StructuredSelection) sel).toList();
751
						for (Object obj : lines) {
752
							if (obj instanceof QueryIndexLine) {
753
								QueryIndexLine line = (QueryIndexLine) obj;
754
								queryindex.removeLine(line.getName());
755
							}
756
						}
757
						fillDisplayArea(topLine, bottomLine);
758
					}
759
				}
760
			}
761
		});
762

  
763
		nColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
764
		nColumn.setText(" "); //$NON-NLS-1$
765
		nColumn.pack();
766

  
767
		unitColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
768
		unitColumn.setText(TXMCoreMessages.common_units);
769
		unitColumn.setToolTipText(TXMCoreMessages.common_units);
770
		unitColumn.setWidth(200);
771
		unitColumn.addSelectionListener(new SelectionListener() {
772
			@Override
773
			public void widgetSelected(SelectionEvent e) {
774
				StatusLine.setMessage(IndexUIMessages.IndexEditor_36);
775
				if (viewer.getTable().getSortColumn() != unitColumn) {
776
					viewer.getTable().setSortColumn(unitColumn);
777
					viewer.getTable().setSortDirection(SWT.UP);
778
					queryindex.sortLines(SortMode.UNITFREQ, false);
779
				} else {
780
					if (viewer.getTable().getSortDirection() == SWT.UP) {
781
						viewer.getTable().setSortDirection(SWT.DOWN);
782
						queryindex.sortLines(SortMode.UNITFREQ, true);
783
					} else {
784
						viewer.getTable().setSortDirection(SWT.UP);
785
						queryindex.sortLines(SortMode.UNITFREQ, false);
786
					}
787
				}
788

  
789
				StatusLine.setMessage(IndexUIMessages.IndexEditor_37);
790
				fillDisplayArea(topLine, bottomLine);
791
			}
792

  
793
			@Override
794
			public void widgetDefaultSelected(SelectionEvent e) {
795
			}
796
		});
797

  
798
		freqColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
799
		try {
800
			if (partition != null)
801
				freqColumn.setText(TXMCoreMessages.common_frequency
802
						+ " T=" + partition.getTotalSize()); //$NON-NLS-1$
803
			else
804
				freqColumn.setText(TXMCoreMessages.common_frequency
805
						+ " T=" + corpus.getSize()); //$NON-NLS-1$
806
		} catch (CqiClientException e2) {
807
			Log.printStackTrace(e2);
808
			return;
809
		}
810
		freqColumn.setToolTipText(TXMCoreMessages.common_frequency);
811
		freqColumn.setWidth(100);
812
		freqColumn.addSelectionListener(new SelectionListener() {
813
			@Override
814
			public void widgetSelected(SelectionEvent e) {
815
				if (viewer.getTable().getSortColumn() != freqColumn) {
816
					viewer.getTable().setSortColumn(freqColumn);
817
					viewer.getTable().setSortDirection(SWT.UP);
818
					queryindex.sortLines(SortMode.FREQUNIT, false);
819
				} else {
820
					if (viewer.getTable().getSortDirection() == SWT.UP) {
821
						viewer.getTable().setSortDirection(SWT.DOWN);
822
						queryindex.sortLines(SortMode.FREQUNIT, true);
823
					} else {
824
						viewer.getTable().setSortDirection(SWT.UP);
825
						queryindex.sortLines(SortMode.FREQUNIT, false);
826
					}
827
				}
828
				StatusLine.setMessage(IndexUIMessages.IndexEditor_37);
829
				fillDisplayArea(topLine, bottomLine);
830
			}
831

  
832
			@Override
833
			public void widgetDefaultSelected(SelectionEvent e) {
834
			}
835
		});
836

  
837
		// rmv/creates parts columns if needed
838
		if (this.partition != null) {
839
			List<String> partnames = this.partition.getPartNames();
840
			if (partnames.size() > 1)
841
				if (viewer.getTable().getColumnCount() < partnames.size() + 3) {
842
					for (int i = 0; i < partnames.size(); i++) {
843
						final TableColumn partColumn = new TableColumn(
844
								viewer.getTable(), SWT.RIGHT);
845
						try {
846
							partColumn
847
									.setText(partnames.get(i)
848
											+ " t=" + partition.getParts().get(i).getSize()); //$NON-NLS-1$
849
						} catch (CqiClientException e1) {
850
							Log.printStackTrace(e1);
851
							return;
852
						}
853
						partColumn.setToolTipText(partnames.get(i));
854
						partColumn.setWidth(100);
855
						partColumn
856
								.addSelectionListener(new SelectionListener() {
857
									@Override
858
									public void widgetSelected(SelectionEvent e) {
859
										if (viewer.getTable().getSortColumn() != partColumn) {
860
											viewer.getTable().setSortColumn(
861
													partColumn);
862
											viewer.getTable().setSortDirection(
863
													SWT.UP);
864
											queryindex.sortLines(
865
													SortMode.FREQUNIT, false);
866
										} else {
867
											if (viewer.getTable()
868
													.getSortDirection() == SWT.UP) {
869
												viewer.getTable()
870
														.setSortDirection(
871
																SWT.DOWN);
872
												queryindex
873
														.sortLines(
874
																SortMode.FREQUNIT,
875
																true);
876
											} else {
877
												viewer.getTable()
878
														.setSortDirection(
879
																SWT.UP);
880
												queryindex.sortLines(
881
														SortMode.FREQUNIT,
882
														false);
883
											}
884
										}
885
										fillDisplayArea(topLine, bottomLine);
886
									}
887

  
888
									@Override
889
									public void widgetDefaultSelected(
890
											SelectionEvent e) {
891
									}
892
								});
893
					}
894
				}
895
		}
896
		separatorColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
897
		separatorColumn.setText(""); //$NON-NLS-1$
898
		separatorColumn.pack();
899

  
900
		initializeFields();
901
		createContextMenu(viewer);
902
		viewer.getTable().pack();
903
	}
904

  
905
	/**
906
	 * Gets the pointed column.
907
	 * 
908
	 * @param mouseposition
909
	 *            the mouseposition
910
	 * @return the pointed column
911
	 */
912
	public int getPointedColumn(Point mouseposition) {
913
		int x = mouseposition.x; // + lineTableViewer.getTable().get;
914
		int sumWidthColumn = this.nColumn.getWidth();
915
		if (x < sumWidthColumn)
916
			return 0;
917

  
918
		sumWidthColumn += this.unitColumn.getWidth();
919
		if (x < sumWidthColumn)
920
			return 1;
921

  
922
		sumWidthColumn += this.freqColumn.getWidth();
923
		if (x < sumWidthColumn)
924
			return 2;
925

  
926
		return 2;
927
	}
928

  
929
	/**
930
	 * Creates the context menu.
931
	 * 
932
	 * @param tableViewer
933
	 *            the table viewer
934
	 */
935
	private void createContextMenu(TableViewer tableViewer) {
936
		MenuManager menuManager = new MenuManager();
937
		Menu menu = menuManager.createContextMenu(tableViewer.getTable());
938

  
939
		// Set the MenuManager
940
		tableViewer.getTable().setMenu(menu);
941
		getSite().registerContextMenu(menuManager, tableViewer);
942
		// Make the selection available
943
		getSite().setSelectionProvider(tableViewer);
944
	}
945

  
946
	/**
947
	 * Initialize fields.
948
	 */
949
	public void initializeFields() {
950
		if (this.queryindex != null) {
951

  
952
			if (queryindex.getPartition() != null)
953
				setPartName(queryindex.getPartition().getName()
954
						+ ": " + queryindex.getName()); //$NON-NLS-1$
955
			else
956
				setPartName(queryindex.getCorpus().getName()
957
						+ ": " + queryindex.getName()); //$NON-NLS-1$
958
			queryWidget.setFocus();
959

  
960
			queryindex.sortLines(SortMode.FREQUNIT, true);
961

  
962
			fillDisplayArea(0, NLignePPageSpinner.getSelection());
963
		} else if (this.corpus != null) {
964
			// no query
965
			queryWidget.setText(""); //$NON-NLS-1$
966

  
967
			if (partition != null) {
968
				setPartName(partition.getName());
969
			} else {
970
				setPartName(corpus.getName());
971
			}
972
			queryWidget.setFocus();
973
		} else {
974
			System.err.println(IndexUIMessages.IndexEditor_22);
975
		}
976
	}
977

  
978
	/**
979
	 * Fill display area.
980
	 * 
981
	 * @param from
982
	 *            the from
983
	 * @param to
984
	 *            the to
985
	 */
986
	public void fillDisplayArea(int from, int to) {
987
		// System.out.println("call fill from "+from+" to "+to);
988
		from = Math.max(from, 0);
989
		to = Math.min(to, queryindex.getV());
990
		ArrayList<QueryIndexLine> lines = null;
991
		if (queryindex.getV() > 0) {
992
			lines = queryindex.getLines(from, to);
993
		} else
994
			lines = new ArrayList<QueryIndexLine>();
995

  
996
		navigationArea.setInfoLineText("" + (from + 1), //$NON-NLS-1$
997
				"-" + (to) + " / " + queryindex.getV()); //$NON-NLS-1$ //$NON-NLS-2$
998
		navigationArea.setPreviousEnabled(from > 0);
999
		navigationArea.setFirstEnabled(from > 0);
1000
		navigationArea.setNextEnabled(to < queryindex.getV() - 1);
1001
		navigationArea.setLastEnabled(to < queryindex.getV() - 1);
1002

  
1003
		lFminInfo.setText(IndexUIMessages.IndexEditor_25 + queryindex.getFmin());
1004
		lFmaxInfo.setText(IndexUIMessages.IndexEditor_26 + queryindex.getFmax());
1005
		lTInfo.setText(IndexUIMessages.IndexEditor_27 + queryindex.getT());
1006
		lVInfo.setText(IndexUIMessages.IndexEditor_28 + queryindex.getV());
1007

  
1008
		lVInfo.getParent().layout();
1009

  
1010
		unitColumn.setText(Messages.QueryIndexEditor_10);
1011

  
1012
		viewer.setInput(lines);
1013
		viewer.refresh();
1014
		// System.out.println("table refreshed from "+from+" to "+to+" with : "+lines);
1015
		topLine = from;
1016
		bottomLine = to;
1017
		for (TableColumn col : viewer.getTable().getColumns()) {
1018
			col.pack();
1019
		}
1020
	}
1021

  
1022
	/*
1023
	 * (non-Javadoc)
1024
	 * 
1025
	 * @see org.eclipse.ui.part.EditorPart#getTitleToolTip()
1026
	 */
1027
	@Override
1028
	public String getTitleToolTip() {
1029
		if (queryindex != null) {
1030
			String str = Messages.QueryIndexEditor_11;
1031

  
1032
			return str;
1033
		}
1034
		return ""; //$NON-NLS-1$
1035
	}
1036

  
1037
	/**
1038
	 * Sets the focus.
1039
	 * 
1040
	 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
1041
	 */
1042
	@Override
1043
	public void setFocus() {
1044
		this.queryWidget.setFocus();
1045
		StatusLine.setMessage(IndexUIMessages.IndexEditor_29);
1046
	}
1047

  
1048
	/**
1049
	 * Gets the corpus.
1050
	 * 
1051
	 * @return the corpus
1052
	 */
1053
	public Corpus getCorpus() {
1054
		return this.corpus;
1055
	}
1056

  
1057
	/**
1058
	 * Gets the partition.
1059
	 * 
1060
	 * @return the partition
1061
	 */
1062
	public Partition getPartition() {
1063
		return this.partition;
1064
	}
1065

  
1066
	/**
1067
	 * Sets the focus.
1068
	 * 
1069
	 * @param query
1070
	 *            the new focus
1071
	 */
1072
	public void setFocus(String query) {
1073
		this.queryWidget.setText(query);
1074
	}
1075

  
1076
	/**
1077
	 * Gets the index.
1078
	 * 
1079
	 * @return the index
1080
	 */
1081
	public Object getIndex() {
1082
		return this.queryindex;
1083
	}
1084

  
1085
	@Override
1086
	public void updateResultFromEditor() {
1087
		// TODO Auto-generated method stub
1088
		
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff