|
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.cooccurrence.rcp.editors;
|
|
29 |
|
|
30 |
import java.lang.reflect.InvocationTargetException;
|
|
31 |
import java.util.ArrayList;
|
|
32 |
import java.util.List;
|
|
33 |
|
|
34 |
import org.eclipse.core.runtime.IProgressMonitor;
|
|
35 |
import org.eclipse.core.runtime.IStatus;
|
|
36 |
import org.eclipse.core.runtime.Status;
|
|
37 |
import org.eclipse.jface.action.MenuManager;
|
|
38 |
import org.eclipse.jface.operation.IRunnableWithProgress;
|
|
39 |
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
40 |
import org.eclipse.jface.viewers.TableViewer;
|
|
41 |
import org.eclipse.osgi.util.NLS;
|
|
42 |
import org.eclipse.swt.SWT;
|
|
43 |
import org.eclipse.swt.custom.ScrolledComposite;
|
|
44 |
import org.eclipse.swt.events.ControlAdapter;
|
|
45 |
import org.eclipse.swt.events.ControlEvent;
|
|
46 |
import org.eclipse.swt.events.KeyEvent;
|
|
47 |
import org.eclipse.swt.events.KeyListener;
|
|
48 |
import org.eclipse.swt.events.MouseAdapter;
|
|
49 |
import org.eclipse.swt.events.MouseEvent;
|
|
50 |
import org.eclipse.swt.events.SelectionEvent;
|
|
51 |
import org.eclipse.swt.events.SelectionListener;
|
|
52 |
import org.eclipse.swt.graphics.Font;
|
|
53 |
import org.eclipse.swt.graphics.FontData;
|
|
54 |
import org.eclipse.swt.graphics.Image;
|
|
55 |
import org.eclipse.swt.graphics.Point;
|
|
56 |
import org.eclipse.swt.graphics.Rectangle;
|
|
57 |
import org.eclipse.swt.layout.FormAttachment;
|
|
58 |
import org.eclipse.swt.layout.FormData;
|
|
59 |
import org.eclipse.swt.layout.FormLayout;
|
|
60 |
import org.eclipse.swt.layout.GridData;
|
|
61 |
import org.eclipse.swt.layout.GridLayout;
|
|
62 |
import org.eclipse.swt.layout.RowLayout;
|
|
63 |
import org.eclipse.swt.widgets.Button;
|
|
64 |
import org.eclipse.swt.widgets.Composite;
|
|
65 |
import org.eclipse.swt.widgets.Display;
|
|
66 |
import org.eclipse.swt.widgets.Event;
|
|
67 |
import org.eclipse.swt.widgets.Label;
|
|
68 |
import org.eclipse.swt.widgets.Listener;
|
|
69 |
import org.eclipse.swt.widgets.Menu;
|
|
70 |
import org.eclipse.swt.widgets.Spinner;
|
|
71 |
import org.eclipse.swt.widgets.TableColumn;
|
|
72 |
import org.eclipse.swt.widgets.Text;
|
|
73 |
import org.eclipse.ui.IEditorInput;
|
|
74 |
import org.eclipse.ui.IEditorSite;
|
|
75 |
import org.eclipse.ui.PartInitException;
|
|
76 |
import org.eclipse.ui.PlatformUI;
|
|
77 |
import org.eclipse.ui.part.EditorPart;
|
|
78 |
import org.txm.Toolbox;
|
|
79 |
import org.txm.cooccurrence.core.preferences.CooccurrencePreferences;
|
|
80 |
import org.txm.core.preferences.TXMPreferences;
|
|
81 |
import org.txm.functions.cooccurrence.Cooccurrence;
|
|
82 |
import org.txm.functions.cooccurrence.comparators.CLineComparator;
|
|
83 |
import org.txm.functions.cooccurrence.comparators.DistComparator;
|
|
84 |
import org.txm.functions.cooccurrence.comparators.FreqComparator;
|
|
85 |
import org.txm.functions.cooccurrence.comparators.NbOccComparator;
|
|
86 |
import org.txm.functions.cooccurrence.comparators.OccComparator;
|
|
87 |
import org.txm.functions.cooccurrence.comparators.ReverseComparator;
|
|
88 |
import org.txm.functions.cooccurrence.comparators.ScoreComparator;
|
|
89 |
import org.txm.rcpapplication.JobsTimer;
|
|
90 |
import org.txm.rcpapplication.Messages;
|
|
91 |
import org.txm.rcpapplication.StatusLine;
|
|
92 |
import org.txm.rcpapplication.TxmPreferences;
|
|
93 |
import org.txm.rcpapplication.commands.editor.CustomizableEditor;
|
|
94 |
import org.txm.rcpapplication.commands.link.CooccurrencesToConcordances;
|
|
95 |
import org.txm.rcpapplication.editors.TableKeyListener;
|
|
96 |
import org.txm.rcpapplication.preferences.UserPreferencePage;
|
|
97 |
import org.txm.rcpapplication.swt.widget.AssistedQueryWidget;
|
|
98 |
import org.txm.rcpapplication.swt.widget.EmpantWidget;
|
|
99 |
import org.txm.rcpapplication.swt.widget.PropertiesSelector;
|
|
100 |
import org.txm.rcpapplication.utils.JobHandler;
|
|
101 |
import org.txm.rcpapplication.utils.Logger;
|
|
102 |
import org.txm.rcpapplication.views.CorporaView;
|
|
103 |
import org.txm.rcpapplication.views.QueriesView;
|
|
104 |
import org.txm.rcpapplication.views.RVariablesView;
|
|
105 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
|
|
106 |
import org.txm.searchengine.cqp.corpus.Corpus;
|
|
107 |
import org.txm.searchengine.cqp.corpus.Property;
|
|
108 |
import org.txm.searchengine.cqp.corpus.StructuralUnit;
|
|
109 |
import org.txm.searchengine.cqp.corpus.query.Query;
|
|
110 |
import org.txm.utils.logger.Log;
|
|
111 |
|
|
112 |
// TODO: Auto-generated Javadoc
|
|
113 |
/**
|
|
114 |
* display the cooc parameters and result @ author mdecorde.
|
|
115 |
*/
|
|
116 |
public class CooccurrencesEditor extends EditorPart implements CustomizableEditor{
|
|
117 |
|
|
118 |
/** The Constant ID. */
|
|
119 |
public static final String ID = "CooccurrencesEditor"; //$NON-NLS-1$
|
|
120 |
|
|
121 |
/** The cooc. */
|
|
122 |
Cooccurrence cooc;
|
|
123 |
|
|
124 |
/** The self. */
|
|
125 |
CooccurrencesEditor self;
|
|
126 |
// params
|
|
127 |
/** The query widget. */
|
|
128 |
AssistedQueryWidget queryWidget;
|
|
129 |
|
|
130 |
/** The props area. */
|
|
131 |
PropertiesSelector propsArea;
|
|
132 |
|
|
133 |
/** The empant panel. */
|
|
134 |
EmpantWidget empantPanel;
|
|
135 |
|
|
136 |
/** The T score. */
|
|
137 |
Text TScore;
|
|
138 |
|
|
139 |
/** The T count. */
|
|
140 |
Spinner TCount;
|
|
141 |
|
|
142 |
/** The T freq. */
|
|
143 |
Spinner TFreq;
|
|
144 |
|
|
145 |
/** The line table viewer. */
|
|
146 |
TableViewer viewer;
|
|
147 |
|
|
148 |
/** The n column. */
|
|
149 |
TableColumn nColumn;
|
|
150 |
|
|
151 |
/** The occ column. */
|
|
152 |
TableColumn occColumn;
|
|
153 |
|
|
154 |
/** The freq column. */
|
|
155 |
TableColumn freqColumn;
|
|
156 |
|
|
157 |
/** The nbocc column. */
|
|
158 |
TableColumn nboccColumn;
|
|
159 |
|
|
160 |
/** The score column. */
|
|
161 |
TableColumn scoreColumn;
|
|
162 |
|
|
163 |
/** The dist column. */
|
|
164 |
TableColumn distColumn;
|
|
165 |
|
|
166 |
/** The current comparator. */
|
|
167 |
CLineComparator currentComparator;
|
|
168 |
|
|
169 |
/** The corpus. */
|
|
170 |
private Corpus corpus;
|
|
171 |
|
|
172 |
/** The query. */
|
|
173 |
private Query query;
|
|
174 |
|
|
175 |
/** The properties. */
|
|
176 |
private List<Property> properties;
|
|
177 |
|
|
178 |
/** The structure. */
|
|
179 |
private StructuralUnit structure;
|
|
180 |
|
|
181 |
/** The leftmin. */
|
|
182 |
private int leftmin;
|
|
183 |
|
|
184 |
/** The leftmax. */
|
|
185 |
private int leftmax;
|
|
186 |
|
|
187 |
/** The rightmin. */
|
|
188 |
private int rightmin;
|
|
189 |
|
|
190 |
/** The rightmax. */
|
|
191 |
private int rightmax;
|
|
192 |
|
|
193 |
/** The minfreq. */
|
|
194 |
private int minfreq;
|
|
195 |
|
|
196 |
/** The mincount. */
|
|
197 |
private int mincount;
|
|
198 |
|
|
199 |
/** The minscore. */
|
|
200 |
private double minscore;
|
|
201 |
|
|
202 |
/** The scroll composite. */
|
|
203 |
private ScrolledComposite scrollComposite;
|
|
204 |
|
|
205 |
/** The include xpivot. */
|
|
206 |
private boolean includeXpivot;
|
|
207 |
|
|
208 |
private boolean buildLexicalTableWithCooccurrents;
|
|
209 |
|
|
210 |
/** The source. */
|
|
211 |
private Object source;
|
|
212 |
|
|
213 |
/**
|
|
214 |
* Instantiates a new cooccurrences editor.
|
|
215 |
*/
|
|
216 |
public CooccurrencesEditor() {
|
|
217 |
super();
|
|
218 |
self = this;
|
|
219 |
}
|
|
220 |
|
|
221 |
/**
|
|
222 |
* Do save.
|
|
223 |
*
|
|
224 |
* @param arg0 the arg0
|
|
225 |
* @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
|
|
226 |
*/
|
|
227 |
@Override
|
|
228 |
public void doSave(IProgressMonitor arg0) {
|
|
229 |
|
|
230 |
}
|
|
231 |
|
|
232 |
/**
|
|
233 |
* Do save as.
|
|
234 |
*
|
|
235 |
* @see org.eclipse.lyon gournd zeroui.part.EditorPart#doSaveAs()
|
|
236 |
*/
|
|
237 |
@Override
|
|
238 |
public void doSaveAs() {
|
|
239 |
|
|
240 |
}
|
|
241 |
|
|
242 |
/**
|
|
243 |
* Inits the.
|
|
244 |
*
|
|
245 |
* @param site the site
|
|
246 |
* @param input the input
|
|
247 |
* @throws PartInitException the part init exception
|
|
248 |
* @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
|
|
249 |
* org.eclipse.ui.IEditorInput)
|
|
250 |
*/
|
|
251 |
@Override
|
|
252 |
public void init(IEditorSite site, IEditorInput input)
|
|
253 |
throws PartInitException {
|
|
254 |
setSite(site);
|
|
255 |
setInput(input);
|
|
256 |
|
|
257 |
this.cooc = ((CooccurrenceEditorInput) input).getCooc();
|
|
258 |
if (cooc != null)
|
|
259 |
{
|
|
260 |
this.corpus = cooc.getCorpus();
|
|
261 |
setPartName(cooc.getCorpus().getName()+": "+cooc.getName()); //$NON-NLS-1$
|
|
262 |
}
|
|
263 |
else
|
|
264 |
this.corpus = ((CooccurrenceEditorInput) input).getCorpus();
|
|
265 |
}
|
|
266 |
|
|
267 |
/**
|
|
268 |
* Checks if is dirty.
|
|
269 |
*
|
|
270 |
* @return true, if is dirty
|
|
271 |
* @see org.eclipse.ui.part.EditorPart#isDirty()
|
|
272 |
*/
|
|
273 |
@Override
|
|
274 |
public boolean isDirty() {
|
|
275 |
return false;
|
|
276 |
}
|
|
277 |
|
|
278 |
/**
|
|
279 |
* Checks if is save as allowed.
|
|
280 |
*
|
|
281 |
* @return true, if is save as allowed
|
|
282 |
* @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
|
|
283 |
*/
|
|
284 |
@Override
|
|
285 |
public boolean isSaveAsAllowed() {
|
|
286 |
return false;
|
|
287 |
}
|
|
288 |
|
|
289 |
/**
|
|
290 |
* Sort.
|
|
291 |
*/
|
|
292 |
public void sort() {
|
|
293 |
if (cooc != null && currentComparator != null) {
|
|
294 |
|
|
295 |
try {
|
|
296 |
Log.info(NLS.bind(Messages.CooccurrencesEditor_0, currentComparator.getName()));
|
|
297 |
|
|
298 |
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(
|
|
299 |
new IRunnableWithProgress() {
|
|
300 |
@Override
|
|
301 |
public void run(IProgressMonitor monitor)
|
|
302 |
throws InvocationTargetException,
|
|
303 |
InterruptedException {
|
|
304 |
try {
|
|
305 |
cooc.sort(currentComparator);
|
|
306 |
} catch (CqiClientException e) {
|
|
307 |
System.err.println(NLS.bind(
|
|
308 |
Messages.ERROR_WHILE_LOADING_CONCORDANCE_LINE, e));
|
|
309 |
}
|
|
310 |
}
|
|
311 |
});
|
|
312 |
} catch (Exception e) {
|
|
313 |
System.err.println(NLS.bind(
|
|
314 |
Messages.ERROR_WHILE_LOADING_CONCORDANCE_LINE, e));
|
|
315 |
org.txm.rcpapplication.utils.Logger.printStackTrace(e);
|
|
316 |
}
|
|
317 |
viewer.refresh();
|
|
318 |
}
|
|
319 |
}
|
|
320 |
|
|
321 |
/**
|
|
322 |
* Creates the part control.
|
|
323 |
*
|
|
324 |
* @param parent the parent
|
|
325 |
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
|
|
326 |
*/
|
|
327 |
@Override
|
|
328 |
public void createPartControl(final Composite parent) {
|
|
329 |
FormLayout parentLayout = new FormLayout();
|
|
330 |
parent.setLayout(parentLayout);
|
|
331 |
|
|
332 |
scrollComposite = new ScrolledComposite(parent, SWT.H_SCROLL
|
|
333 |
| SWT.BORDER);
|
|
334 |
FormData paramLayoutData = new FormData();
|
|
335 |
paramLayoutData.top = new FormAttachment(0);
|
|
336 |
paramLayoutData.left = new FormAttachment(0);
|
|
337 |
paramLayoutData.right = new FormAttachment(100);
|
|
338 |
scrollComposite.setLayoutData(paramLayoutData);
|
|
339 |
|
|
340 |
final Composite paramArea = new Composite(scrollComposite, SWT.NONE);
|
|
341 |
FormLayout paramLayout = new FormLayout();
|
|
342 |
paramArea.setLayout(paramLayout);
|
|
343 |
|
|
344 |
scrollComposite.setContent(paramArea);
|
|
345 |
scrollComposite.setExpandVertical(true);
|
|
346 |
scrollComposite.setExpandHorizontal(true);
|
|
347 |
scrollComposite.addControlListener(new ControlAdapter() {
|
|
348 |
@Override
|
|
349 |
public void controlResized(ControlEvent e) {
|
|
350 |
Rectangle r = scrollComposite.getClientArea();
|
|
351 |
scrollComposite.setMinSize(paramArea.computeSize(SWT.DEFAULT,
|
|
352 |
SWT.DEFAULT));
|
|
353 |
}
|
|
354 |
});
|
|
355 |
|
|
356 |
// Label infos = new Label(paramArea, SWT.NONE);
|
|
357 |
// infos.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
|
|
358 |
// true));
|
|
359 |
|
|
360 |
Composite queryArea = new Composite(paramArea, SWT.NONE);
|
|
361 |
|
|
362 |
FormData queryLayoutData = new FormData();
|
|
363 |
queryLayoutData.top = new FormAttachment(0);
|
|
364 |
queryLayoutData.left = new FormAttachment(0);
|
|
365 |
queryLayoutData.right = new FormAttachment(100);
|
|
366 |
queryArea.setLayoutData(queryLayoutData);
|
|
367 |
|
|
368 |
queryArea.setLayout(new GridLayout(3, false));
|
|
369 |
|
|
370 |
Label queryLabel = new Label(queryArea, SWT.NONE);
|
|
371 |
queryLabel.setText(Messages.IndexEditor_3);
|
|
372 |
queryLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
|
|
373 |
true));
|
|
374 |
|
|
375 |
// [ (v)]
|
|
376 |
queryWidget = new AssistedQueryWidget(queryArea, SWT.DROP_DOWN,
|
|
377 |
this.corpus);
|
|
378 |
GridData layoutData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
|
|
379 |
layoutData.horizontalAlignment = GridData.FILL;
|
|
380 |
layoutData.grabExcessHorizontalSpace = true;
|
|
381 |
queryWidget.setLayoutData(layoutData);
|
|
382 |
queryWidget.addKeyListener(new KeyListener() {
|
|
383 |
@Override
|
|
384 |
public void keyPressed(KeyEvent e) {
|
|
385 |
// System.out.println("key pressed : "+e.keyCode);
|
|
386 |
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
|
|
387 |
compute();
|
|
388 |
}
|
|
389 |
}
|
|
390 |
|
|
391 |
@Override
|
|
392 |
public void keyReleased(KeyEvent e) {
|
|
393 |
}
|
|
394 |
|
|
395 |
});
|
|
396 |
|
|
397 |
final Button go = new Button(queryArea, SWT.BOLD);
|
|
398 |
go.setText(Messages.CooccurrencesEditor_2);
|
|
399 |
|
|
400 |
Font f = go.getFont();
|
|
401 |
FontData defaultFont = f.getFontData()[0];
|
|
402 |
defaultFont.setStyle(SWT.BOLD);
|
|
403 |
Font newf = new Font(go.getDisplay(), defaultFont);
|
|
404 |
go.setFont(newf);
|
|
405 |
|
|
406 |
layoutData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
|
|
407 |
layoutData.horizontalAlignment = GridData.FILL;
|
|
408 |
layoutData.grabExcessHorizontalSpace = false;
|
|
409 |
go.setLayoutData(layoutData);
|
|
410 |
|
|
411 |
go.addSelectionListener(new SelectionListener() {
|
|
412 |
@Override
|
|
413 |
public void widgetSelected(SelectionEvent e) {
|
|
414 |
compute();
|
|
415 |
}
|
|
416 |
|
|
417 |
@Override
|
|
418 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
419 |
}
|
|
420 |
});
|
|
421 |
|
|
422 |
// Filters
|
|
423 |
Composite filtercontrols = new Composite(paramArea, SWT.NONE);
|
|
424 |
FormData filtersLayoutData = new FormData();
|
|
425 |
filtersLayoutData.top = new FormAttachment(queryArea, 0);
|
|
426 |
// filtersLayoutData.bottom = new FormAttachment (100);
|
|
427 |
filtersLayoutData.left = new FormAttachment(0);
|
|
428 |
filtersLayoutData.right = new FormAttachment(100);
|
|
429 |
filtercontrols.setLayoutData(filtersLayoutData);
|
|
430 |
RowLayout layout = new RowLayout();
|
|
431 |
layout.wrap = true;
|
|
432 |
layout.center = true;
|
|
433 |
filtercontrols.setLayout(layout);
|
|
434 |
|
|
435 |
// | Properties: word_pos [Edit] |
|
|
436 |
propsArea = new PropertiesSelector(filtercontrols, SWT.NONE);
|
|
437 |
propsArea.setLayout(new GridLayout(4, false));
|
|
438 |
propsArea.setCorpus(this.getCorpus());
|
|
439 |
propsArea.setText(Messages.CooccurrencesEditor_3);
|
|
440 |
propsArea.addValueChangeListener(new Listener() {
|
|
441 |
@Override
|
|
442 |
public void handleEvent(Event event) {
|
|
443 |
if (TxmPreferences.getBoolean(UserPreferencePage.AUTO_UPDATE_EDITOR))
|
|
444 |
compute();
|
|
445 |
}
|
|
446 |
});
|
|
447 |
/*
|
|
448 |
* FormData propsLayoutData = new FormData(); propsLayoutData.top = new
|
|
449 |
* FormAttachment (queryArea, 0); propsLayoutData.left = new
|
|
450 |
* FormAttachment (0); propsLayoutData.right = new FormAttachment (100);
|
|
451 |
* propsArea.setLayoutData(propsLayoutData);
|
|
452 |
*/
|
|
453 |
|
|
454 |
/*
|
|
455 |
* GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 9;
|
|
456 |
* gridLayout.makeColumnsEqualWidth = false;
|
|
457 |
* filtercontrols.setLayout(gridLayout);
|
|
458 |
*/
|
|
459 |
|
|
460 |
Label seuilLabel = new Label(filtercontrols, SWT.NONE);
|
|
461 |
seuilLabel.setText(Messages.CooccurrencesEditor_4);
|
|
462 |
|
|
463 |
TFreq = new Spinner(filtercontrols, SWT.BORDER);
|
|
464 |
TFreq.setMinimum(1);
|
|
465 |
TFreq.setMaximum(99999);
|
|
466 |
TFreq.setIncrement(1);
|
|
467 |
TFreq.setPageIncrement(100);
|
|
468 |
int defaultFmin = TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_FREQ);
|
|
469 |
TFreq.setSelection(defaultFmin);
|
|
470 |
|
|
471 |
seuilLabel = new Label(filtercontrols, SWT.NONE);
|
|
472 |
seuilLabel.setText(Messages.CooccurrencesEditor_5);
|
|
473 |
TCount = new Spinner(filtercontrols, SWT.BORDER);
|
|
474 |
TCount.setMinimum(1);
|
|
475 |
TCount.setMaximum(99999);
|
|
476 |
TCount.setIncrement(1);
|
|
477 |
TCount.setPageIncrement(100);
|
|
478 |
int defaultCountmin = TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_COUNT);
|
|
479 |
TCount.setSelection(defaultCountmin);
|
|
480 |
|
|
481 |
seuilLabel = new Label(filtercontrols, SWT.NONE);
|
|
482 |
seuilLabel.setText(Messages.CooccurrencesEditor_6);
|
|
483 |
TScore = new Text(filtercontrols, SWT.BORDER);
|
|
484 |
TScore.setText("0.0"); //$NON-NLS-1$
|
|
485 |
String defaultScoremin = TXMPreferences.getString(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_SCORE);
|
|
486 |
TScore.setText(defaultScoremin);
|
|
487 |
|
|
488 |
// empant
|
|
489 |
empantPanel = new EmpantWidget(paramArea, SWT.NONE, this.getCorpus());
|
|
490 |
|
|
491 |
FormData empantLayoutData = new FormData();
|
|
492 |
empantLayoutData.top = new FormAttachment(filtercontrols, 0);
|
|
493 |
empantLayoutData.bottom = new FormAttachment(100);
|
|
494 |
empantLayoutData.left = new FormAttachment(0);
|
|
495 |
empantLayoutData.right = new FormAttachment(100);
|
|
496 |
empantPanel.setLayoutData(empantLayoutData);
|
|
497 |
empantPanel.setMinLeft(TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_LEFT));
|
|
498 |
empantPanel.setMaxLeft(TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MAX_LEFT));
|
|
499 |
empantPanel.setMinRight(TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_RIGHT));
|
|
500 |
empantPanel.setMaxRight(TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MAX_RIGHT));
|
|
501 |
|
|
502 |
// result
|
|
503 |
Composite resultArea = new Composite(parent, SWT.NONE);
|
|
504 |
FormData resultLayoutData = new FormData();
|
|
505 |
resultLayoutData.top = new FormAttachment(scrollComposite, 0);
|
|
506 |
resultLayoutData.left = new FormAttachment(0);
|
|
507 |
resultLayoutData.right = new FormAttachment(100);
|
|
508 |
resultLayoutData.bottom = new FormAttachment(100);
|
|
509 |
resultArea.setLayoutData(resultLayoutData);
|
|
510 |
|
|
511 |
FormLayout resultLayout = new FormLayout();
|
|
512 |
resultArea.setLayout(resultLayout);
|
|
513 |
|
|
514 |
viewer = new TableViewer(resultArea, SWT.MULTI
|
|
515 |
| SWT.FULL_SELECTION | SWT.BORDER);
|
|
516 |
viewer.getTable().addKeyListener(new TableKeyListener(viewer));
|
|
517 |
viewer.getTable().setLinesVisible(true);
|
|
518 |
viewer.getTable().setHeaderVisible(true);
|
|
519 |
|
|
520 |
if (corpus != null && corpus.getFont() != null && corpus.getFont().length() > 0) {
|
|
521 |
Font old = viewer.getTable().getFont();
|
|
522 |
FontData fD = old.getFontData()[0];
|
|
523 |
//Font f = new Font(old.getDevice(), corpus.getFont(), fD.getHeight(), fD.getStyle());
|
|
524 |
Font font = new Font(Display.getCurrent(), corpus.getFont(), fD.getHeight(), fD.getStyle());
|
|
525 |
viewer.getTable().setFont(font);
|
|
526 |
}
|
|
527 |
|
|
528 |
viewer.getTable().addMouseListener(new MouseAdapter() {
|
|
529 |
@Override
|
|
530 |
public void mouseDoubleClick(MouseEvent e) {
|
|
531 |
Point mouseposition = new Point(e.x
|
|
532 |
+ viewer.getTable().getHorizontalBar()
|
|
533 |
.getSelection(), e.y);
|
|
534 |
int col = getPointedColumn(mouseposition);
|
|
535 |
//System.out.println("col "+col);
|
|
536 |
switch(col)
|
|
537 |
{
|
|
538 |
default:
|
|
539 |
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
|
|
540 |
CooccurrencesToConcordances.link(CooccurrencesEditor.this, selection);
|
|
541 |
}
|
|
542 |
}
|
|
543 |
});
|
|
544 |
|
|
545 |
FormData tableLayoutData = new FormData();
|
|
546 |
tableLayoutData.top = new FormAttachment(0);
|
|
547 |
tableLayoutData.bottom = new FormAttachment(100);
|
|
548 |
tableLayoutData.left = new FormAttachment(0);
|
|
549 |
tableLayoutData.right = new FormAttachment(100);
|
|
550 |
viewer.getTable().setLayoutData(tableLayoutData);
|
|
551 |
|
|
552 |
viewer.setLabelProvider(new LineLabelProvider());
|
|
553 |
viewer.setContentProvider(new LineContentProvider());
|
|
554 |
if (cooc != null)
|
|
555 |
viewer.setInput(cooc.getLines());
|
|
556 |
|
|
557 |
nColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
|
|
558 |
nColumn.setText(" "); //$NON-NLS-1$
|
|
559 |
nColumn.pack();
|
|
560 |
|
|
561 |
occColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
|
|
562 |
occColumn.setText(Messages.CooccurrencesEditor_8);
|
|
563 |
occColumn.setToolTipText(Messages.CooccurrencesEditor_8);
|
|
564 |
occColumn.setWidth(200);
|
|
565 |
occColumn.addSelectionListener(new SelectionListener() {
|
|
566 |
@Override
|
|
567 |
public void widgetSelected(SelectionEvent e) {
|
|
568 |
setColComparator(new OccComparator(), occColumn);
|
|
569 |
sort();
|
|
570 |
}
|
|
571 |
|
|
572 |
@Override
|
|
573 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
574 |
}
|
|
575 |
});
|
|
576 |
|
|
577 |
freqColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
|
|
578 |
freqColumn.setText(Messages.FrequencyListEditorInput_4);
|
|
579 |
freqColumn.setToolTipText(Messages.FrequencyListEditorInput_4);
|
|
580 |
freqColumn.setWidth(100);
|
|
581 |
freqColumn.addSelectionListener(new SelectionListener() {
|
|
582 |
@Override
|
|
583 |
public void widgetSelected(SelectionEvent e) {
|
|
584 |
setColComparator(new FreqComparator(), freqColumn);
|
|
585 |
sort();
|
|
586 |
}
|
|
587 |
|
|
588 |
@Override
|
|
589 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
590 |
}
|
|
591 |
});
|
|
592 |
|
|
593 |
nboccColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
|
|
594 |
nboccColumn.setText(Messages.CooccurrencesEditor_10);
|
|
595 |
nboccColumn.setToolTipText(Messages.CooccurrencesEditor_10);
|
|
596 |
nboccColumn.setWidth(130);
|
|
597 |
nboccColumn.addSelectionListener(new SelectionListener() {
|
|
598 |
@Override
|
|
599 |
public void widgetSelected(SelectionEvent e) {
|
|
600 |
setColComparator(new NbOccComparator(), nboccColumn);
|
|
601 |
sort();
|
|
602 |
}
|
|
603 |
|
|
604 |
@Override
|
|
605 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
606 |
}
|
|
607 |
});
|
|
608 |
|
|
609 |
scoreColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
|
|
610 |
scoreColumn.setText(Messages.CooccurrencesEditor_17);
|
|
611 |
scoreColumn.setToolTipText(Messages.CooccurrencesEditor_17);
|
|
612 |
scoreColumn.setWidth(100);
|
|
613 |
scoreColumn.addSelectionListener(new SelectionListener() {
|
|
614 |
@Override
|
|
615 |
public void widgetSelected(SelectionEvent e) {
|
|
616 |
setColComparator(new ScoreComparator(), scoreColumn);
|
|
617 |
sort();
|
|
618 |
}
|
|
619 |
|
|
620 |
@Override
|
|
621 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
622 |
}
|
|
623 |
});
|
|
624 |
|
|
625 |
distColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
|
|
626 |
distColumn.setText(Messages.CooccurrencesEditor_9);
|
|
627 |
distColumn.setToolTipText(Messages.CooccurrencesEditor_9);
|
|
628 |
distColumn.setWidth(130);
|
|
629 |
distColumn.addSelectionListener(new SelectionListener() {
|
|
630 |
@Override
|
|
631 |
public void widgetSelected(SelectionEvent e) {
|
|
632 |
setColComparator(new DistComparator(), distColumn);
|
|
633 |
sort();
|
|
634 |
}
|
|
635 |
|
|
636 |
@Override
|
|
637 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
638 |
}
|
|
639 |
});
|
|
640 |
|
|
641 |
TableColumn n2Column = new TableColumn(viewer.getTable(),
|
|
642 |
SWT.RIGHT);
|
|
643 |
n2Column.setText(""); //$NON-NLS-1$
|
|
644 |
n2Column.pack();
|
|
645 |
|
|
646 |
viewer.refresh();
|
|
647 |
currentComparator = new ScoreComparator();
|
|
648 |
setColComparator(new ScoreComparator(), scoreColumn);
|
|
649 |
sort();
|
|
650 |
setColComparator(new ScoreComparator(), scoreColumn);
|
|
651 |
sort();
|
|
652 |
createContextMenu(viewer);
|
|
653 |
setParametersFromCooc();
|
|
654 |
|
|
655 |
for (TableColumn col : viewer.getTable().getColumns())
|
|
656 |
col.pack();
|
|
657 |
}
|
|
658 |
|
|
659 |
/**
|
|
660 |
* Gets the pointed column.
|
|
661 |
*
|
|
662 |
* @param mouseposition the mouseposition
|
|
663 |
* @return the pointed column
|
|
664 |
*/
|
|
665 |
public int getPointedColumn(Point mouseposition) {
|
|
666 |
int x = mouseposition.x; // + lineTableViewer.getTable().get;
|
|
667 |
int sumWidthColumn = this.nColumn.getWidth();
|
|
668 |
if (x < sumWidthColumn)
|
|
669 |
return 0;
|
|
670 |
|
|
671 |
sumWidthColumn += this.occColumn.getWidth();
|
|
672 |
if (x < sumWidthColumn)
|
|
673 |
return 1;
|
|
674 |
|
|
675 |
sumWidthColumn += this.freqColumn.getWidth();
|
|
676 |
if (x < sumWidthColumn)
|
|
677 |
return 2;
|
|
678 |
|
|
679 |
sumWidthColumn += this.nboccColumn.getWidth();
|
|
680 |
if (x < sumWidthColumn)
|
|
681 |
return 3;
|
|
682 |
|
|
683 |
sumWidthColumn += this.scoreColumn.getWidth();
|
|
684 |
if (x < sumWidthColumn)
|
|
685 |
return 4;
|
|
686 |
|
|
687 |
sumWidthColumn += this.distColumn.getWidth();
|
|
688 |
if (x < sumWidthColumn)
|
|
689 |
return 5;
|
|
690 |
|
|
691 |
return 5;
|
|
692 |
}
|
|
693 |
|
|
694 |
/**
|
|
695 |
* Compute.
|
|
696 |
*/
|
|
697 |
public void compute() {
|
|
698 |
StatusLine.setMessage(Messages.CooccurrencesEditor_33);
|
|
699 |
if (this.queryWidget.getQueryString().trim().length() == 0
|
|
700 |
|| this.queryWidget.getQueryString().trim().equals("\"\"")) //$NON-NLS-1$
|
|
701 |
return;
|
|
702 |
this.query = new Query(this.queryWidget.getQueryString());
|
|
703 |
queryWidget.memorize();
|
|
704 |
|
|
705 |
if (this.empantPanel.getMinLeft() == -1 && this.empantPanel.getMinRight() == -1)
|
|
706 |
{
|
|
707 |
if (this.empantPanel.getStruct() == null) {
|
|
708 |
System.out.println(Messages.CooccurrencesEditor_16);
|
|
709 |
return;
|
|
710 |
} else if (!this.empantPanel.getXPivot()) {
|
|
711 |
System.out.println(Messages.CooccurrencesEditor_16);
|
|
712 |
return;
|
|
713 |
}
|
|
714 |
}
|
|
715 |
this.properties = this.propsArea.getProperties();
|
|
716 |
this.structure = this.empantPanel.getStruct();
|
|
717 |
this.leftmin = this.empantPanel.getMinLeft() + 1;
|
|
718 |
this.leftmax = this.empantPanel.getMaxLeft() + 1;
|
|
719 |
this.rightmin = this.empantPanel.getMinRight() + 1;
|
|
720 |
this.rightmax = this.empantPanel.getMaxRight() + 1;
|
|
721 |
this.minfreq = this.TFreq.getSelection();
|
|
722 |
this.mincount = this.TCount.getSelection();
|
|
723 |
this.includeXpivot = this.empantPanel.getXPivot();
|
|
724 |
/*if (!this.empantPanel.getXPivot() && this.structure != null) {
|
|
725 |
if (this.leftmin == 1) {
|
|
726 |
this.leftmin = 2;
|
|
727 |
if (this.leftmax == 1)
|
|
728 |
this.leftmax = 2;
|
|
729 |
}
|
|
730 |
if (this.rightmin == 1) {
|
|
731 |
this.rightmin = 2;
|
|
732 |
if (this.rightmax == 1)
|
|
733 |
this.rightmax = 2;
|
|
734 |
}
|
|
735 |
}*/
|
|
736 |
|
|
737 |
try {
|
|
738 |
Double d = Double.parseDouble(TScore.getText());
|
|
739 |
this.minscore = d;
|
|
740 |
} catch (Exception e) {
|
|
741 |
System.out.println(NLS.bind(Messages.CooccurrencesEditor_18, TScore.getText()));
|
|
742 |
this.minscore = 0.0;
|
|
743 |
}
|
|
744 |
|
|
745 |
buildLexicalTableWithCooccurrents = TXMPreferences.getBoolean(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.PARTIAL_LEXICAL_TABLE);
|
|
746 |
|
|
747 |
JobHandler jobhandler = new JobHandler(NLS.bind(Messages.CooccurrencesEditor_12, corpus)) {
|
|
748 |
@Override
|
|
749 |
protected IStatus run(IProgressMonitor monitor) {
|
|
750 |
this.runInit(monitor);
|
|
751 |
JobsTimer.start();
|
|
752 |
monitor.beginTask(Messages.CooccurrencesEditor_13, 100);
|
|
753 |
try {
|
|
754 |
System.out.println(NLS.bind(Messages.CooccurrencesEditor_20, query.getQueryString(), corpus.getName()));
|
|
755 |
cooc = new Cooccurrence(corpus, query, properties,
|
|
756 |
structure, leftmax, leftmin, rightmin, rightmax,
|
|
757 |
minfreq, mincount, minscore, includeXpivot, buildLexicalTableWithCooccurrents);
|
|
758 |
//System.out.println("cooc: "+corpus+" "+query+" "+properties+" "+structure+" "+leftmax+" "+leftmin+" "+rightmin+" "+rightmax+" "+minfreq+" "+mincount+" "+minscore+" "+includeXpivot);
|
|
759 |
monitor.worked(5);
|
|
760 |
|
|
761 |
monitor.subTask(Messages.CooccurrencesEditor_27);
|
|
762 |
if (!cooc.stepQueryLimits()) {
|
|
763 |
return Status.CANCEL_STATUS;
|
|
764 |
}
|
|
765 |
|
|
766 |
monitor.subTask(Messages.CooccurrencesEditor_28);
|
|
767 |
if (!cooc.stepGetMatches()) {
|
|
768 |
return Status.CANCEL_STATUS;
|
|
769 |
}
|
|
770 |
monitor.worked(10);
|
|
771 |
|
|
772 |
monitor.subTask(Messages.CooccurrencesEditor_29);
|
|
773 |
if (!cooc.stepBuildSignatures())
|
|
774 |
return Status.CANCEL_STATUS;
|
|
775 |
monitor.worked(10);
|
|
776 |
|
|
777 |
monitor.subTask(Messages.CooccurrencesEditor_30);
|
|
778 |
if (!cooc.stepCount())
|
|
779 |
return Status.CANCEL_STATUS;
|
|
780 |
monitor.worked(10);
|
|
781 |
|
|
782 |
monitor.subTask(Messages.CooccurrencesEditor_31);
|
|
783 |
this.acquireSemaphore();
|
|
784 |
if (!cooc.stepBuildLexicalTable())
|
|
785 |
return Status.CANCEL_STATUS;
|
|
786 |
monitor.worked(10);
|
|
787 |
this.releaseSemaphore();
|
|
788 |
|
|
789 |
monitor.subTask(Messages.CooccurrencesEditor_32);
|
|
790 |
this.acquireSemaphore();
|
|
791 |
if (!cooc.stepGetScores())
|
|
792 |
return Status.CANCEL_STATUS;
|
|
793 |
monitor.worked(10);
|
|
794 |
this.releaseSemaphore();
|
|
795 |
|
|
796 |
if (cooc != null) cooc.clearMemory();
|
|
797 |
|
|
798 |
|
|
799 |
|
|
800 |
final String message;
|
|
801 |
if (cooc.getLines().size() == 0) {
|
|
802 |
message = (Messages.CooccurrencesEditor_23);
|
|
803 |
} else if (cooc.getLines().size() == 1) {
|
|
804 |
message = (Messages.CooccurrencesEditor_24);
|
|
805 |
} else {
|
|
806 |
message = (Messages.bind(Messages.CooccurrencesEditor_34, cooc.getNumberOfKeyword(), cooc.getNumberOfDifferentCooccurrents()));
|
|
807 |
}
|
|
808 |
|
|
809 |
System.out.println(message);
|
|
810 |
this.syncExec(new Runnable() {
|
|
811 |
@Override
|
|
812 |
public void run() {
|
|
813 |
String txt = "tp "+cooc.getNumberOfKeyword()+", vc "+cooc.getNumberOfDifferentCooccurrents()+", tc "+cooc.getNumberOfCooccurrents(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
814 |
try { txt += ", T "+cooc.getCorpus().getSize();} //$NON-NLS-1$
|
|
815 |
catch(Exception e) {System.out.println(Messages.CooccurrencesEditor_25);}
|
|
816 |
String tooltip = "- " + txt.replaceAll(", ", "\n- "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
817 |
|
|
818 |
empantPanel.setInfo(txt, tooltip);
|
|
819 |
StatusLine.setMessage(message);
|
|
820 |
}
|
|
821 |
});
|
|
822 |
|
|
823 |
corpus.storeResult(cooc);
|
|
824 |
} catch(ThreadDeath e) {
|
|
825 |
if (cooc != null) cooc.clearMemory();
|
|
826 |
return Status.CANCEL_STATUS;
|
|
827 |
} catch (Exception e) {
|
|
828 |
if (cooc != null) cooc.clearMemory();
|
|
829 |
Logger.severe(Messages.CooccurrencesEditor_1
|
|
830 |
+ " " + Logger.toString(e)); //$NON-NLS-1$
|
|
831 |
|
|
832 |
try {
|
|
833 |
Logger.info(Messages.LastCQPError+Toolbox.getCqiClient().getLastCQPError());
|
|
834 |
} catch (Exception e2) {
|
|
835 |
Logger.severe(Messages.ConcordancesEditor_7+e2);
|
|
836 |
org.txm.rcpapplication.utils.Logger.printStackTrace(e);
|
|
837 |
}
|
|
838 |
|
|
839 |
return Status.CANCEL_STATUS;
|
|
840 |
}
|
|
841 |
if (cooc != null) cooc.clearMemory();
|
|
842 |
monitor.worked(5);
|
|
843 |
// System.out.println(cooc.toInfos());
|
|
844 |
|
|
845 |
monitor.subTask(Messages.CooccurrencesEditor_14);
|
|
846 |
|
|
847 |
if (monitor.isCanceled())
|
|
848 |
return Status.CANCEL_STATUS;
|
|
849 |
|
|
850 |
monitor.subTask(Messages.CooccurrencesEditor_15);
|
|
851 |
syncExec(new Runnable() {
|
|
852 |
@Override
|
|
853 |
public void run() {
|
|
854 |
viewer.setInput(cooc.getLines());
|
|
855 |
sort();
|
|
856 |
viewer.refresh();
|
|
857 |
for (TableColumn col : viewer.getTable().getColumns())
|
|
858 |
col.pack();
|
|
859 |
setTitleToolTip(cooc.toInfos());
|
|
860 |
CorporaView.refresh();
|
|
861 |
CorporaView.expand(corpus);
|
|
862 |
QueriesView.refresh();
|
|
863 |
RVariablesView.refresh();
|
|
864 |
|
|
865 |
viewer.getTable().setFocus();
|
|
866 |
setPartName(cooc.getCorpus().getName()+": "+cooc.getName()); //$NON-NLS-1$
|
|
867 |
}
|
|
868 |
});
|
|
869 |
|
|
870 |
monitor.worked(35);
|
|
871 |
monitor.done();
|
|
872 |
JobsTimer.stopAndPrint();
|
|
873 |
return Status.OK_STATUS;
|
|
874 |
}
|
|
875 |
};
|
|
876 |
jobhandler.startJob();
|
|
877 |
}
|
|
878 |
|
|
879 |
/**
|
|
880 |
* Sets the parameters from cooc.
|
|
881 |
*/
|
|
882 |
private void setParametersFromCooc() {
|
|
883 |
if (this.cooc != null) {
|
|
884 |
this.queryWidget.setText(cooc.getQuery().getQueryString());
|
|
885 |
List<Property> available;
|
|
886 |
try {
|
|
887 |
available = new ArrayList<Property>(this.cooc.getCorpus().getProperties());
|
|
888 |
available.removeAll(cooc.getProperties());
|
|
889 |
this.propsArea.setProperties(available, cooc.getProperties());
|
|
890 |
} catch (CqiClientException e) {
|
|
891 |
// TODO Auto-generated catch block
|
|
892 |
org.txm.rcpapplication.utils.Logger.printStackTrace(e);
|
|
893 |
}
|
|
894 |
this.empantPanel.setStructure(cooc.getStructure());
|
|
895 |
this.empantPanel.setMinLeft(cooc.getMinLeft()-1);
|
|
896 |
this.empantPanel.setMaxLeft(cooc.getMaxLeft()-1);
|
|
897 |
this.empantPanel.setMinRight(cooc.getMinRight()-1);
|
|
898 |
this.empantPanel.setMaxRight(cooc.getMaxRight()-1);
|
|
899 |
|
|
900 |
}
|
|
901 |
}
|
|
902 |
|
|
903 |
/**
|
|
904 |
* Sets the col comparator.
|
|
905 |
*
|
|
906 |
* @param comp the comp
|
|
907 |
* @param col the col
|
|
908 |
*/
|
|
909 |
private void setColComparator(CLineComparator comp, TableColumn col) {
|
|
910 |
currentComparator = comp;
|
|
911 |
if (viewer.getTable().getSortColumn() != col) {
|
|
912 |
viewer.getTable().setSortColumn(col);
|
|
913 |
viewer.getTable().setSortDirection(SWT.UP);
|
|
914 |
} else if (viewer.getTable().getSortDirection() == SWT.UP) {
|
|
915 |
viewer.getTable().setSortDirection(SWT.DOWN);
|
|
916 |
currentComparator = new ReverseComparator(currentComparator);
|
|
917 |
} else {
|
|
918 |
viewer.getTable().setSortDirection(SWT.UP);
|
|
919 |
}
|
|
920 |
if (cooc != null)
|
|
921 |
currentComparator.initialize(cooc.getCorpus());
|
|
922 |
}
|
|
923 |
|
|
924 |
/**
|
|
925 |
* Creates the context menu.
|
|
926 |
*
|
|
927 |
* @param tableViewer the table viewer
|
|
928 |
*/
|
|
929 |
private void createContextMenu(TableViewer tableViewer) {
|
|
930 |
|
|
931 |
MenuManager menuManager = new MenuManager();
|
|
932 |
Menu menu = menuManager.createContextMenu(tableViewer.getTable());
|
|
933 |
|
|
934 |
// Set the MenuManager
|
|
935 |
tableViewer.getTable().setMenu(menu);
|
|
936 |
getSite().registerContextMenu(menuManager, tableViewer);
|
|
937 |
// Make the selection available
|
|
938 |
getSite().setSelectionProvider(tableViewer);
|
|
939 |
}
|
|
940 |
|
|
941 |
/* (non-Javadoc)
|
|
942 |
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
|
|
943 |
*/
|
|
944 |
@Override
|
|
945 |
public void setFocus() {
|
|
946 |
|
|
947 |
}
|
|
948 |
|
|
949 |
/**
|
|
950 |
* Gets the corpus.
|
|
951 |
*
|
|
952 |
* @return the corpus
|
|
953 |
*/
|
|
954 |
public Corpus getCorpus() {
|
|
955 |
return corpus;
|
|
956 |
}
|
|
957 |
|
|
958 |
/**
|
|
959 |
* Gets the cooc.
|
|
960 |
*
|
|
961 |
* @return the cooc
|
|
962 |
*/
|
|
963 |
public Cooccurrence getCooc() {
|
|
964 |
return this.cooc;
|
|
965 |
}
|
|
966 |
|
|
967 |
/* (non-Javadoc)
|
|
968 |
* @see org.txm.rcpapplication.commands.editor.CustomizableEditor#setName(java.lang.String)
|
|
969 |
*/
|
|
970 |
@Override
|
|
971 |
public void setName(String name) {
|
|
972 |
this.setPartName(name);
|
|
973 |
}
|
|
974 |
|
|
975 |
/* (non-Javadoc)
|
|
976 |
* @see org.txm.rcpapplication.commands.editor.CustomizableEditor#setIcon(org.eclipse.swt.graphics.Image)
|
|
977 |
*/
|
|
978 |
@Override
|
|
979 |
public void setIcon(Image image) {
|
|
980 |
this.setTitleImage(image);
|
|
981 |
}
|
|
982 |
|
|
983 |
/* (non-Javadoc)
|
|
984 |
* @see org.txm.rcpapplication.commands.editor.CustomizableEditor#setSource(java.lang.Object)
|
|
985 |
*/
|
|
986 |
@Override
|
|
987 |
public void setSource(Object source)
|
|
988 |
{
|
|
989 |
this.source = source;
|
|
990 |
}
|
|
991 |
|
|
992 |
/* (non-Javadoc)
|
|
993 |
* @see org.txm.rcpapplication.commands.editor.CustomizableEditor#getSource()
|
|
994 |
*/
|
|
995 |
@Override
|
|
996 |
public Object getSource() {
|
|
997 |
return cooc;
|
|
998 |
}
|
|
999 |
|
|
1000 |
public void setFocus(String query2) {
|
|
1001 |
this.queryWidget.setText(query2);
|
|
1002 |
}
|
|
1003 |
|
|
1004 |
@Override
|
|
1005 |
public Object toConcordance() { return null;}
|
|
1006 |
@Override
|
|
1007 |
public Object toIndex() { return null;}
|
|
1008 |
@Override
|
|
1009 |
public Object toProgression() { return null;}
|
|
1010 |
|
|
1011 |
@Override
|
|
1012 |
public boolean usingCorpus(Corpus corpus) {
|
|
1013 |
return this.corpus.getName().equals(corpus.getName());
|
|
1014 |
}
|
|
1015 |
|
|
1016 |
@Override
|
|
1017 |
public boolean updateCorpus(Corpus corpus) {
|
|
1018 |
// TODO Auto-generated method stub
|
|
1019 |
return false;
|
|
1020 |
}
|
|
1021 |
}
|
0 |
1022 |
|