87 |
87 |
import org.txm.cooccurrence.rcp.messages.CooccurrenceUIMessages;
|
88 |
88 |
import org.txm.core.messages.TXMCoreMessages;
|
89 |
89 |
import org.txm.core.preferences.TXMPreferences;
|
|
90 |
import org.txm.core.results.TXMParameters;
|
90 |
91 |
import org.txm.rcp.JobsTimer;
|
91 |
92 |
import org.txm.rcp.Messages;
|
92 |
93 |
import org.txm.rcp.StatusLine;
|
... | ... | |
102 |
103 |
import org.txm.rcp.utils.JobHandler;
|
103 |
104 |
import org.txm.rcp.utils.Logger;
|
104 |
105 |
import org.txm.rcp.views.QueriesView;
|
105 |
|
import org.txm.rcp.views.corpora.CorporaView;
|
106 |
106 |
import org.txm.searchengine.cqp.CQPEngine;
|
107 |
107 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
|
108 |
108 |
import org.txm.searchengine.cqp.corpus.Corpus;
|
109 |
109 |
import org.txm.searchengine.cqp.corpus.Property;
|
110 |
|
import org.txm.searchengine.cqp.corpus.StructuralUnit;
|
111 |
110 |
import org.txm.searchengine.cqp.corpus.query.Query;
|
112 |
111 |
import org.txm.statsengine.r.rcp.views.RVariablesView;
|
113 |
112 |
import org.txm.utils.logger.Log;
|
... | ... | |
177 |
176 |
private Query query;
|
178 |
177 |
|
179 |
178 |
/** The properties. */
|
180 |
|
private List<Property> properties;
|
181 |
|
|
182 |
|
/** The structure. */
|
183 |
|
private StructuralUnit structure;
|
184 |
|
|
185 |
|
/** The leftmin. */
|
186 |
|
private int leftmin;
|
187 |
|
|
188 |
|
/** The leftmax. */
|
189 |
|
private int leftmax;
|
190 |
|
|
191 |
|
/** The rightmin. */
|
192 |
|
private int rightmin;
|
193 |
|
|
194 |
|
/** The rightmax. */
|
195 |
|
private int rightmax;
|
196 |
|
|
197 |
|
/** The minfreq. */
|
198 |
|
private int minfreq;
|
199 |
|
|
200 |
|
/** The mincount. */
|
201 |
|
private int mincount;
|
202 |
|
|
203 |
|
/** The minscore. */
|
204 |
|
private double minscore;
|
|
179 |
// private List<Property> properties;
|
|
180 |
//
|
|
181 |
// /** The structure. */
|
|
182 |
// private StructuralUnit structure;
|
|
183 |
//
|
|
184 |
// /** The leftmin. */
|
|
185 |
// private int leftmin;
|
|
186 |
//
|
|
187 |
// /** The leftmax. */
|
|
188 |
// private int leftmax;
|
|
189 |
//
|
|
190 |
// /** The rightmin. */
|
|
191 |
// private int rightmin;
|
|
192 |
//
|
|
193 |
// /** The rightmax. */
|
|
194 |
// private int rightmax;
|
|
195 |
//
|
|
196 |
// /** The minfreq. */
|
|
197 |
// private int minfreq;
|
|
198 |
//
|
|
199 |
// /** The mincount. */
|
|
200 |
// private int mincount;
|
|
201 |
//
|
|
202 |
// /** The minscore. */
|
|
203 |
// private double minscore;
|
205 |
204 |
|
206 |
205 |
/** The scroll composite. */
|
207 |
206 |
private ScrolledComposite scrollComposite;
|
208 |
207 |
|
209 |
208 |
/** The include xpivot. */
|
210 |
|
private boolean includeXpivot;
|
|
209 |
// private boolean includeXpivot;
|
211 |
210 |
|
212 |
211 |
private boolean buildLexicalTableWithCooccurrents;
|
213 |
212 |
|
214 |
213 |
/** The source. */
|
215 |
|
private Object source;
|
|
214 |
// private Object source;
|
216 |
215 |
|
217 |
216 |
/**
|
218 |
217 |
* Instantiates a new cooccurrences editor.
|
... | ... | |
223 |
222 |
}
|
224 |
223 |
|
225 |
224 |
/**
|
226 |
|
* Do save.
|
227 |
|
*
|
228 |
|
* @param arg0 the arg0
|
229 |
|
* @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
|
230 |
|
*/
|
231 |
|
@Override
|
232 |
|
public void doSave(IProgressMonitor arg0) {
|
233 |
|
|
234 |
|
}
|
235 |
|
|
236 |
|
/**
|
237 |
|
* Do save as.
|
238 |
|
*
|
239 |
|
* @see org.eclipse.lyon gournd zeroui.part.EditorPart#doSaveAs()
|
240 |
|
*/
|
241 |
|
@Override
|
242 |
|
public void doSaveAs() {
|
243 |
|
|
244 |
|
}
|
245 |
|
|
246 |
|
/**
|
247 |
225 |
* Inits the.
|
248 |
226 |
*
|
249 |
227 |
* @param site the site
|
... | ... | |
255 |
233 |
@Override
|
256 |
234 |
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
|
257 |
235 |
super.init(site, input);
|
|
236 |
|
258 |
237 |
|
259 |
|
if (((TXMResultEditorInput) input).getResult() != null)
|
260 |
|
{
|
|
238 |
// if (((TXMResultEditorInput) input).getResult() != null)
|
|
239 |
// {
|
261 |
240 |
this.cooc = (Cooccurrence) ((TXMResultEditorInput) input).getResult();
|
262 |
241 |
this.corpus = cooc.getCorpus();
|
|
242 |
//this.query = cooc.getQuery();
|
263 |
243 |
//FIXME: deprecated
|
264 |
|
setPartName(cooc.getCorpus().getName()+": "+cooc.getName()); //$NON-NLS-1$
|
265 |
|
}
|
266 |
|
else
|
267 |
|
this.corpus = (Corpus) ((TXMResultEditorInput) input).getSource();
|
|
244 |
//setPartName(cooc.getCorpus().getName()+": "+cooc.getName()); //$NON-NLS-1$
|
|
245 |
// }
|
|
246 |
// else {
|
|
247 |
// this.corpus = (Corpus) ((TXMResultEditorInput) input).getSource();
|
|
248 |
// this.query = new Query("");
|
|
249 |
// }
|
|
250 |
|
268 |
251 |
}
|
269 |
252 |
|
270 |
253 |
/**
|
271 |
|
* Checks if is dirty.
|
272 |
|
*
|
273 |
|
* @return true, if is dirty
|
274 |
|
* @see org.eclipse.ui.part.EditorPart#isDirty()
|
275 |
|
*/
|
276 |
|
@Override
|
277 |
|
public boolean isDirty() {
|
278 |
|
return false;
|
279 |
|
}
|
280 |
|
|
281 |
|
/**
|
282 |
|
* Checks if is save as allowed.
|
283 |
|
*
|
284 |
|
* @return true, if is save as allowed
|
285 |
|
* @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
|
286 |
|
*/
|
287 |
|
@Override
|
288 |
|
public boolean isSaveAsAllowed() {
|
289 |
|
return false;
|
290 |
|
}
|
291 |
|
|
292 |
|
/**
|
293 |
|
* Sort.
|
294 |
|
*/
|
295 |
|
public void sort() {
|
296 |
|
if (cooc != null && currentComparator != null) {
|
297 |
|
|
298 |
|
try {
|
299 |
|
Log.info(NLS.bind(CooccurrenceUIMessages.CooccurrencesEditor_0, currentComparator.getName()));
|
300 |
|
|
301 |
|
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(
|
302 |
|
new IRunnableWithProgress() {
|
303 |
|
@Override
|
304 |
|
public void run(IProgressMonitor monitor)
|
305 |
|
throws InvocationTargetException,
|
306 |
|
InterruptedException {
|
307 |
|
try {
|
308 |
|
cooc.sort(currentComparator);
|
309 |
|
} catch (CqiClientException e) {
|
310 |
|
System.err.println(NLS.bind(
|
311 |
|
Messages.ERROR_WHILE_LOADING_CONCORDANCE_LINE, e));
|
312 |
|
}
|
313 |
|
}
|
314 |
|
});
|
315 |
|
} catch (Exception e) {
|
316 |
|
System.err.println(NLS.bind(
|
317 |
|
Messages.ERROR_WHILE_LOADING_CONCORDANCE_LINE, e));
|
318 |
|
org.txm.rcp.utils.Logger.printStackTrace(e);
|
319 |
|
}
|
320 |
|
viewer.refresh();
|
321 |
|
}
|
322 |
|
}
|
323 |
|
|
324 |
|
/**
|
325 |
254 |
* Creates the part control.
|
326 |
255 |
*
|
327 |
256 |
* @param parent the parent
|
... | ... | |
378 |
307 |
true));
|
379 |
308 |
|
380 |
309 |
// [ (v)]
|
381 |
|
queryWidget = new AssistedQueryWidget(queryArea, SWT.DROP_DOWN,
|
382 |
|
this.corpus);
|
|
310 |
queryWidget = new AssistedQueryWidget(queryArea, SWT.DROP_DOWN, this.corpus);
|
383 |
311 |
GridData layoutData = new GridData(GridData.VERTICAL_ALIGN_CENTER);
|
384 |
312 |
layoutData.horizontalAlignment = GridData.FILL;
|
385 |
313 |
layoutData.grabExcessHorizontalSpace = true;
|
... | ... | |
445 |
373 |
propsArea.addValueChangeListener(new Listener() {
|
446 |
374 |
@Override
|
447 |
375 |
public void handleEvent(Event event) {
|
448 |
|
if (TXMPreferences.getBoolean(RCPPreferences.PREFERENCES_NODE, RCPPreferences.AUTO_UPDATE_EDITOR)) {
|
|
376 |
if (TXMPreferences.getBoolean(RCPPreferences.AUTO_UPDATE_EDITOR, RCPPreferences.PREFERENCES_NODE)) {
|
449 |
377 |
computeResult(false);
|
450 |
378 |
}
|
451 |
379 |
}
|
... | ... | |
471 |
399 |
TFreq.setMaximum(99999);
|
472 |
400 |
TFreq.setIncrement(1);
|
473 |
401 |
TFreq.setPageIncrement(100);
|
474 |
|
int defaultFmin = TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_FREQ);
|
475 |
|
TFreq.setSelection(defaultFmin);
|
476 |
402 |
|
477 |
403 |
seuilLabel = new Label(filtercontrols, SWT.NONE);
|
478 |
404 |
seuilLabel.setText(CooccurrenceUIMessages.CooccurrencesEditor_5);
|
... | ... | |
481 |
407 |
TCount.setMaximum(99999);
|
482 |
408 |
TCount.setIncrement(1);
|
483 |
409 |
TCount.setPageIncrement(100);
|
484 |
|
int defaultCountmin = TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_COUNT);
|
485 |
|
TCount.setSelection(defaultCountmin);
|
486 |
|
|
|
410 |
|
487 |
411 |
seuilLabel = new Label(filtercontrols, SWT.NONE);
|
488 |
412 |
seuilLabel.setText(CooccurrenceUIMessages.CooccurrencesEditor_6);
|
489 |
413 |
TScore = new Text(filtercontrols, SWT.BORDER);
|
490 |
|
TScore.setText("0.0"); //$NON-NLS-1$
|
491 |
|
String defaultScoremin = TXMPreferences.getString(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_SCORE);
|
492 |
|
TScore.setText(defaultScoremin);
|
493 |
|
|
|
414 |
|
494 |
415 |
// empant
|
495 |
416 |
empantPanel = new EmpantWidget(paramArea, SWT.NONE, this.getCorpus());
|
496 |
417 |
|
... | ... | |
500 |
421 |
empantLayoutData.left = new FormAttachment(0);
|
501 |
422 |
empantLayoutData.right = new FormAttachment(100);
|
502 |
423 |
empantPanel.setLayoutData(empantLayoutData);
|
503 |
|
empantPanel.setMinLeft(TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_LEFT));
|
504 |
|
empantPanel.setMaxLeft(TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MAX_LEFT));
|
505 |
|
empantPanel.setMinRight(TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MIN_RIGHT));
|
506 |
|
empantPanel.setMaxRight(TXMPreferences.getInt(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.MAX_RIGHT));
|
507 |
424 |
|
508 |
425 |
// result
|
509 |
426 |
Composite resultArea = new Composite(parent, SWT.NONE);
|
... | ... | |
656 |
573 |
setColComparator(new ScoreComparator(), scoreColumn);
|
657 |
574 |
sort();
|
658 |
575 |
createContextMenu(viewer);
|
659 |
|
updateParameters();
|
|
576 |
fillCommandParametersArea();
|
660 |
577 |
|
661 |
578 |
for (TableColumn col : viewer.getTable().getColumns())
|
662 |
579 |
col.pack();
|
|
580 |
|
663 |
581 |
}
|
664 |
582 |
|
665 |
583 |
/**
|
... | ... | |
697 |
615 |
return 5;
|
698 |
616 |
}
|
699 |
617 |
|
700 |
|
|
|
618 |
/**
|
|
619 |
* Creates some parameters from the current widget values.
|
|
620 |
* @return
|
|
621 |
*/
|
|
622 |
public TXMParameters getWidgetsParameters() {
|
|
623 |
|
|
624 |
TXMParameters parameters = new TXMParameters();
|
|
625 |
parameters.put(CooccurrencePreferences.QUERY, this.queryWidget.getQueryString());
|
|
626 |
parameters.put("properties", this.propsArea.getProperties());
|
|
627 |
parameters.put("structure", this.empantPanel.getStruct());
|
|
628 |
parameters.put(CooccurrencePreferences.MIN_LEFT, this.empantPanel.getMinLeft() + 1);
|
|
629 |
parameters.put(CooccurrencePreferences.MAX_LEFT, this.empantPanel.getMaxLeft() + 1);
|
|
630 |
parameters.put(CooccurrencePreferences.MIN_RIGHT, this.empantPanel.getMinRight() + 1);
|
|
631 |
parameters.put(CooccurrencePreferences.MAX_RIGHT, this.empantPanel.getMaxRight() + 1);
|
|
632 |
parameters.put(CooccurrencePreferences.MIN_FREQ, this.TFreq.getSelection());
|
|
633 |
parameters.put(CooccurrencePreferences.MIN_COUNT, this.TCount.getSelection());
|
|
634 |
parameters.put(CooccurrencePreferences.INCLUDE_X_PIVOT, this.empantPanel.getXPivot());
|
|
635 |
parameters.put(CooccurrencePreferences.PARTIAL_LEXICAL_TABLE, TXMPreferences.getBoolean(CooccurrencePreferences.PARTIAL_LEXICAL_TABLE, CooccurrencePreferences.PREFERENCES_NODE));
|
|
636 |
|
|
637 |
|
|
638 |
Double minScore = 0.0;
|
|
639 |
try {
|
|
640 |
Double d = Double.parseDouble(this.TScore.getText());
|
|
641 |
minScore = d;
|
|
642 |
}
|
|
643 |
catch (Exception e) {
|
|
644 |
System.out.println(NLS.bind(CooccurrenceUIMessages.CooccurrencesEditor_18, this.TScore.getText()));
|
|
645 |
}
|
|
646 |
|
|
647 |
parameters.put(CooccurrencePreferences.MIN_SCORE, minScore);
|
|
648 |
|
|
649 |
return parameters;
|
|
650 |
}
|
701 |
651 |
|
702 |
|
|
703 |
652 |
@Override
|
704 |
653 |
public void computeResult(boolean update) {
|
705 |
654 |
StatusLine.setMessage(CooccurrenceUIMessages.CooccurrencesEditor_33);
|
706 |
|
if (this.queryWidget.getQueryString().trim().length() == 0
|
707 |
|
|| this.queryWidget.getQueryString().trim().equals("\"\"")) //$NON-NLS-1$
|
|
655 |
if (this.queryWidget.getQueryString().trim().length() == 0 || this.queryWidget.getQueryString().trim().equals("\"\"")) //$NON-NLS-1$
|
708 |
656 |
return;
|
709 |
|
this.query = new Query(this.queryWidget.getQueryString());
|
710 |
657 |
queryWidget.memorize();
|
711 |
658 |
|
712 |
659 |
if (this.empantPanel.getMinLeft() == -1 && this.empantPanel.getMinRight() == -1)
|
... | ... | |
719 |
666 |
return;
|
720 |
667 |
}
|
721 |
668 |
}
|
722 |
|
this.properties = this.propsArea.getProperties();
|
723 |
|
this.structure = this.empantPanel.getStruct();
|
724 |
|
this.leftmin = this.empantPanel.getMinLeft() + 1;
|
725 |
|
this.leftmax = this.empantPanel.getMaxLeft() + 1;
|
726 |
|
this.rightmin = this.empantPanel.getMinRight() + 1;
|
727 |
|
this.rightmax = this.empantPanel.getMaxRight() + 1;
|
728 |
|
this.minfreq = this.TFreq.getSelection();
|
729 |
|
this.mincount = this.TCount.getSelection();
|
730 |
|
this.includeXpivot = this.empantPanel.getXPivot();
|
731 |
|
/*if (!this.empantPanel.getXPivot() && this.structure != null) {
|
732 |
|
if (this.leftmin == 1) {
|
733 |
|
this.leftmin = 2;
|
734 |
|
if (this.leftmax == 1)
|
735 |
|
this.leftmax = 2;
|
736 |
|
}
|
737 |
|
if (this.rightmin == 1) {
|
738 |
|
this.rightmin = 2;
|
739 |
|
if (this.rightmax == 1)
|
740 |
|
this.rightmax = 2;
|
741 |
|
}
|
742 |
|
}*/
|
743 |
|
|
744 |
|
try {
|
745 |
|
Double d = Double.parseDouble(TScore.getText());
|
746 |
|
this.minscore = d;
|
747 |
|
} catch (Exception e) {
|
748 |
|
System.out.println(NLS.bind(CooccurrenceUIMessages.CooccurrencesEditor_18, TScore.getText()));
|
749 |
|
this.minscore = 0.0;
|
750 |
|
}
|
751 |
669 |
|
752 |
|
buildLexicalTableWithCooccurrents = TXMPreferences.getBoolean(CooccurrencePreferences.PREFERENCES_NODE, CooccurrencePreferences.PARTIAL_LEXICAL_TABLE);
|
753 |
|
|
754 |
670 |
JobHandler jobhandler = new JobHandler(NLS.bind(CooccurrenceUIMessages.CooccurrencesEditor_12, corpus)) {
|
755 |
671 |
@Override
|
756 |
672 |
protected IStatus run(IProgressMonitor monitor) {
|
... | ... | |
758 |
674 |
JobsTimer.start();
|
759 |
675 |
monitor.beginTask(CooccurrenceUIMessages.CooccurrencesEditor_13, 100);
|
760 |
676 |
try {
|
761 |
|
System.out.println(NLS.bind(CooccurrenceUIMessages.CooccurrencesEditor_20, query.getQueryString(), corpus.getName()));
|
762 |
|
cooc = new Cooccurrence(corpus, query, properties,
|
763 |
|
structure, leftmax, leftmin, rightmin, rightmax,
|
764 |
|
minfreq, mincount, minscore, includeXpivot, buildLexicalTableWithCooccurrents);
|
|
677 |
// System.out.println(NLS.bind(CooccurrenceUIMessages.CooccurrencesEditor_20,
|
|
678 |
// queryWidget.getQueryString(),
|
|
679 |
// corpus.getName()));
|
|
680 |
// cooc = new Cooccurrence(corpus, query, properties,
|
|
681 |
// structure, leftmax, leftmin, rightmin, rightmax,
|
|
682 |
// minfreq, mincount, minscore, includeXpivot, buildLexicalTableWithCooccurrents);
|
|
683 |
|
|
684 |
|
|
685 |
|
|
686 |
//cooc = new Cooccurrence(corpus);
|
|
687 |
|
|
688 |
//FIXME: Debug
|
765 |
689 |
//System.out.println("cooc: "+corpus+" "+query+" "+properties+" "+structure+" "+leftmax+" "+leftmin+" "+rightmin+" "+rightmax+" "+minfreq+" "+mincount+" "+minscore+" "+includeXpivot);
|
766 |
|
monitor.worked(5);
|
|
690 |
//monitor.worked(5);
|
767 |
691 |
|
768 |
|
monitor.subTask(CooccurrenceUIMessages.CooccurrencesEditor_27);
|
769 |
|
if (!cooc.stepQueryLimits()) {
|
770 |
|
return Status.CANCEL_STATUS;
|
771 |
|
}
|
|
692 |
// FIXME: method using TXMCommandParameters
|
|
693 |
//cooc.compute(this, getWidgetsParameters());
|
772 |
694 |
|
773 |
|
monitor.subTask(CooccurrenceUIMessages.CooccurrencesEditor_28);
|
774 |
|
if (!cooc.stepGetMatches()) {
|
775 |
|
return Status.CANCEL_STATUS;
|
|
695 |
|
|
696 |
// FIXME: method without using TXMCommandParameters
|
|
697 |
Double minScore = 0.0;
|
|
698 |
try {
|
|
699 |
Double d = Double.parseDouble(TScore.getText());
|
|
700 |
minScore = d;
|
776 |
701 |
}
|
777 |
|
monitor.worked(10);
|
|
702 |
catch (Exception e) {
|
|
703 |
System.out.println(NLS.bind(CooccurrenceUIMessages.CooccurrencesEditor_18, TScore.getText()));
|
|
704 |
}
|
|
705 |
cooc.compute(this,
|
|
706 |
new Query(
|
|
707 |
queryWidget.getQueryString()),
|
|
708 |
propsArea.getProperties(),
|
|
709 |
null,
|
|
710 |
empantPanel.getMinLeft() + 1,
|
|
711 |
empantPanel.getMaxLeft() + 1,
|
|
712 |
empantPanel.getMinRight() + 1,
|
|
713 |
empantPanel.getMaxRight() + 1,
|
|
714 |
TFreq.getSelection(),
|
|
715 |
minScore,
|
|
716 |
TCount.getSelection(),
|
|
717 |
empantPanel.getXPivot(),
|
|
718 |
TXMPreferences.getBoolean(CooccurrencePreferences.PARTIAL_LEXICAL_TABLE, CooccurrencePreferences.PREFERENCES_NODE)
|
|
719 |
);
|
778 |
720 |
|
779 |
|
monitor.subTask(CooccurrenceUIMessages.CooccurrencesEditor_29);
|
780 |
|
if (!cooc.stepBuildSignatures())
|
781 |
|
return Status.CANCEL_STATUS;
|
782 |
|
monitor.worked(10);
|
783 |
721 |
|
784 |
|
monitor.subTask(CooccurrenceUIMessages.CooccurrencesEditor_30);
|
785 |
|
if (!cooc.stepCount())
|
786 |
|
return Status.CANCEL_STATUS;
|
787 |
|
monitor.worked(10);
|
|
722 |
//FIXME: DEbug
|
|
723 |
// parameters.dump();
|
|
724 |
// TXMPreferences.dump(CooccurrencePreferences.PREFERENCES_NODE, cooc);
|
788 |
725 |
|
789 |
|
monitor.subTask(CooccurrenceUIMessages.CooccurrencesEditor_31);
|
790 |
|
this.acquireSemaphore();
|
791 |
|
if (!cooc.stepBuildLexicalTable())
|
792 |
|
return Status.CANCEL_STATUS;
|
793 |
|
monitor.worked(10);
|
794 |
|
this.releaseSemaphore();
|
|
726 |
//getEditorInput().setResult(cooc);
|
795 |
727 |
|
796 |
|
monitor.subTask(CooccurrenceUIMessages.CooccurrencesEditor_32);
|
797 |
|
this.acquireSemaphore();
|
798 |
|
if (!cooc.stepGetScores())
|
799 |
|
return Status.CANCEL_STATUS;
|
800 |
|
monitor.worked(10);
|
801 |
|
this.releaseSemaphore();
|
802 |
728 |
|
803 |
|
if (cooc != null) cooc.clearMemory();
|
804 |
729 |
|
805 |
|
getEditorInput().setResult(cooc);
|
806 |
|
|
|
730 |
// FIXME: this code should be move in Cooccurrence.getDetails() or getName(), etc?
|
807 |
731 |
final String message;
|
808 |
732 |
if (cooc.getLines().size() == 0) {
|
809 |
733 |
message = (CooccurrenceUIMessages.CooccurrencesEditor_23);
|
810 |
|
} else if (cooc.getLines().size() == 1) {
|
|
734 |
}
|
|
735 |
else if (cooc.getLines().size() == 1) {
|
811 |
736 |
message = (CooccurrenceUIMessages.CooccurrencesEditor_24);
|
812 |
|
} else {
|
|
737 |
}
|
|
738 |
else {
|
813 |
739 |
message = (CooccurrenceUIMessages.bind(CooccurrenceUIMessages.CooccurrencesEditor_34, cooc.getNumberOfKeyword(), cooc.getNumberOfDifferentCooccurrents()));
|
814 |
740 |
}
|
815 |
741 |
|
... | ... | |
826 |
752 |
StatusLine.setMessage(message);
|
827 |
753 |
}
|
828 |
754 |
});
|
|
755 |
// End of FIXME
|
829 |
756 |
|
830 |
|
} catch(ThreadDeath e) {
|
831 |
|
if (cooc != null) cooc.clearMemory();
|
|
757 |
|
|
758 |
|
|
759 |
}
|
|
760 |
// user canceling
|
|
761 |
catch(ThreadDeath e) {
|
|
762 |
close(true);
|
832 |
763 |
return Status.CANCEL_STATUS;
|
833 |
|
} catch (Exception e) {
|
834 |
|
if (cooc != null) cooc.clearMemory();
|
835 |
|
Logger.severe(CooccurrenceUIMessages.CooccurrencesEditor_1
|
836 |
|
+ " " + Logger.toString(e)); //$NON-NLS-1$
|
837 |
|
|
|
764 |
}
|
|
765 |
catch (Exception e) {
|
|
766 |
close(true);
|
|
767 |
Logger.severe(CooccurrenceUIMessages.CooccurrencesEditor_1 + " " + Logger.toString(e)); //$NON-NLS-1$
|
|
768 |
e.printStackTrace();
|
838 |
769 |
try {
|
839 |
770 |
Logger.info(Messages.LastCQPError+CQPEngine.getCqiClient().getLastCQPError());
|
840 |
|
} catch (Exception e2) {
|
|
771 |
}
|
|
772 |
catch (Exception e2) {
|
841 |
773 |
Logger.severe(Messages.ConcordancesEditor_7+e2);
|
842 |
774 |
org.txm.rcp.utils.Logger.printStackTrace(e);
|
843 |
775 |
}
|
844 |
776 |
|
845 |
777 |
return Status.CANCEL_STATUS;
|
846 |
778 |
}
|
847 |
|
if (cooc != null) cooc.clearMemory();
|
848 |
779 |
monitor.worked(5);
|
849 |
780 |
// System.out.println(cooc.toInfos());
|
850 |
781 |
|
... | ... | |
867 |
798 |
}
|
868 |
799 |
viewer.getControl().setRedraw(true);
|
869 |
800 |
|
870 |
|
|
871 |
|
setTitleToolTip(cooc.toInfos());
|
872 |
|
|
873 |
801 |
refresh();
|
874 |
802 |
|
875 |
|
CorporaView.refresh();
|
876 |
|
CorporaView.expand(corpus);
|
877 |
803 |
QueriesView.refresh();
|
878 |
804 |
RVariablesView.refresh();
|
879 |
805 |
|
880 |
806 |
viewer.getTable().setFocus();
|
881 |
|
setPartName(cooc.getCorpus().getName()+": "+cooc.getName()); //$NON-NLS-1$
|
882 |
807 |
}
|
883 |
808 |
});
|
884 |
809 |
|
... | ... | |
892 |
817 |
}
|
893 |
818 |
|
894 |
819 |
/**
|
895 |
|
* Sets the parameters from cooc.
|
|
820 |
* Updates the parameters area from values from parameters, local result node or preferences.
|
896 |
821 |
*/
|
897 |
|
private void updateParameters() {
|
|
822 |
private void fillCommandParametersArea() {
|
898 |
823 |
// from result
|
899 |
|
if (this.cooc != null) {
|
900 |
|
this.queryWidget.setText(cooc.getQuery().getQueryString());
|
|
824 |
//FIXME: to remove
|
|
825 |
// if (this.cooc != null) {
|
|
826 |
// this.queryWidget.setText(cooc.getQuery().getQueryString());
|
|
827 |
// List<Property> available;
|
|
828 |
// try {
|
|
829 |
// available = new ArrayList<Property>(this.cooc.getCorpus().getProperties());
|
|
830 |
// available.removeAll(cooc.getProperties());
|
|
831 |
// this.propsArea.setProperties(available, cooc.getProperties());
|
|
832 |
// } catch (CqiClientException e) {
|
|
833 |
// // TODO Auto-generated catch block
|
|
834 |
// org.txm.rcp.utils.Logger.printStackTrace(e);
|
|
835 |
// }
|
|
836 |
// this.empantPanel.setStructure(cooc.getStructure());
|
|
837 |
// this.empantPanel.setMinLeft(cooc.getMinLeft()-1);
|
|
838 |
// this.empantPanel.setMaxLeft(cooc.getMaxLeft()-1);
|
|
839 |
// this.empantPanel.setMinRight(cooc.getMinRight()-1);
|
|
840 |
// this.empantPanel.setMaxRight(cooc.getMaxRight()-1);
|
|
841 |
//
|
|
842 |
// }
|
|
843 |
//FIXME: look for parameters or preferences in following order: command parameters, local result node, default preferences, alternate preferences nodes
|
|
844 |
// else {
|
|
845 |
|
|
846 |
|
|
847 |
queryWidget.setText(this.getStringParameterValue(CooccurrencePreferences.QUERY));
|
|
848 |
|
|
849 |
if (this.cooc.getProperties() != null) {
|
901 |
850 |
List<Property> available;
|
902 |
851 |
try {
|
903 |
852 |
available = new ArrayList<Property>(this.cooc.getCorpus().getProperties());
|
904 |
853 |
available.removeAll(cooc.getProperties());
|
905 |
854 |
this.propsArea.setProperties(available, cooc.getProperties());
|
906 |
|
} catch (CqiClientException e) {
|
|
855 |
}
|
|
856 |
catch (Exception e) {
|
907 |
857 |
// TODO Auto-generated catch block
|
908 |
858 |
org.txm.rcp.utils.Logger.printStackTrace(e);
|
909 |
859 |
}
|
910 |
|
this.empantPanel.setStructure(cooc.getStructure());
|
911 |
|
this.empantPanel.setMinLeft(cooc.getMinLeft()-1);
|
912 |
|
this.empantPanel.setMaxLeft(cooc.getMaxLeft()-1);
|
913 |
|
this.empantPanel.setMinRight(cooc.getMinRight()-1);
|
914 |
|
this.empantPanel.setMaxRight(cooc.getMaxRight()-1);
|
|
860 |
}
|
915 |
861 |
|
916 |
|
}
|
917 |
|
// from params
|
918 |
|
else if(this.getEditorInput().getParams() != null) {
|
919 |
|
this.queryWidget.setText((String) this.getEditorInput().getParams().get("query"));
|
920 |
|
}
|
921 |
|
//FIXME: from default preferences
|
|
862 |
|
|
863 |
TFreq.setSelection(this.getIntParameterValue(CooccurrencePreferences.MIN_FREQ));
|
|
864 |
TCount.setSelection(this.getIntParameterValue(CooccurrencePreferences.MIN_COUNT));
|
|
865 |
|
|
866 |
TScore.setText(this.getStringParameterValue(CooccurrencePreferences.MIN_SCORE));
|
|
867 |
|
|
868 |
empantPanel.setMinLeft(this.getIntParameterValue(CooccurrencePreferences.MIN_LEFT));
|
|
869 |
empantPanel.setMaxLeft(this.getIntParameterValue(CooccurrencePreferences.MAX_LEFT));
|
|
870 |
empantPanel.setMinRight(this.getIntParameterValue(CooccurrencePreferences.MIN_RIGHT));
|
|
871 |
empantPanel.setMaxRight(this.getIntParameterValue(CooccurrencePreferences.MAX_RIGHT));
|
|
872 |
|
|
873 |
// }
|
922 |
874 |
}
|
923 |
875 |
|
|
876 |
|
|
877 |
|
|
878 |
|
924 |
879 |
/**
|
925 |
880 |
* Sets the col comparator.
|
926 |
881 |
*
|
... | ... | |
959 |
914 |
getSite().setSelectionProvider(tableViewer);
|
960 |
915 |
}
|
961 |
916 |
|
962 |
|
/* (non-Javadoc)
|
963 |
|
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
|
964 |
|
*/
|
965 |
|
@Override
|
966 |
|
public void setFocus() {
|
967 |
917 |
|
968 |
|
}
|
969 |
|
|
970 |
918 |
/**
|
971 |
919 |
* Gets the corpus.
|
972 |
920 |
*
|
... | ... | |
1007 |
955 |
@Override
|
1008 |
956 |
public void setSource(Object source)
|
1009 |
957 |
{
|
1010 |
|
this.source = source;
|
|
958 |
// this.source = source;
|
1011 |
959 |
}
|
1012 |
960 |
|
1013 |
961 |
/* (non-Javadoc)
|
... | ... | |
1040 |
988 |
return false;
|
1041 |
989 |
}
|
1042 |
990 |
|
|
991 |
|
|
992 |
/**
|
|
993 |
* Do save.
|
|
994 |
*
|
|
995 |
* @param arg0 the arg0
|
|
996 |
* @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
|
|
997 |
*/
|
|
998 |
@Override
|
|
999 |
public void doSave(IProgressMonitor arg0) {
|
|
1000 |
|
|
1001 |
}
|
|
1002 |
|
|
1003 |
/**
|
|
1004 |
* Do save as.
|
|
1005 |
*
|
|
1006 |
* @see org.eclipse.lyon gournd zeroui.part.EditorPart#doSaveAs()
|
|
1007 |
*/
|
|
1008 |
@Override
|
|
1009 |
public void doSaveAs() {
|
|
1010 |
|
|
1011 |
}
|
|
1012 |
|
|
1013 |
|
|
1014 |
|
|
1015 |
/**
|
|
1016 |
* Checks if is dirty.
|
|
1017 |
*
|
|
1018 |
* @return true, if is dirty
|
|
1019 |
* @see org.eclipse.ui.part.EditorPart#isDirty()
|
|
1020 |
*/
|
|
1021 |
@Override
|
|
1022 |
public boolean isDirty() {
|
|
1023 |
return false;
|
|
1024 |
}
|
|
1025 |
|
|
1026 |
/**
|
|
1027 |
* Checks if is save as allowed.
|
|
1028 |
*
|
|
1029 |
* @return true, if is save as allowed
|
|
1030 |
* @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
|
|
1031 |
*/
|
|
1032 |
@Override
|
|
1033 |
public boolean isSaveAsAllowed() {
|
|
1034 |
return false;
|
|
1035 |
}
|
|
1036 |
|
|
1037 |
/**
|
|
1038 |
* Sort.
|
|
1039 |
*/
|
|
1040 |
public void sort() {
|
|
1041 |
if (cooc != null && currentComparator != null) {
|
|
1042 |
|
|
1043 |
try {
|
|
1044 |
Log.info(NLS.bind(CooccurrenceUIMessages.CooccurrencesEditor_0, currentComparator.getName()));
|
|
1045 |
|
|
1046 |
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(
|
|
1047 |
new IRunnableWithProgress() {
|
|
1048 |
@Override
|
|
1049 |
public void run(IProgressMonitor monitor)
|
|
1050 |
throws InvocationTargetException,
|
|
1051 |
InterruptedException {
|
|
1052 |
try {
|
|
1053 |
cooc.sort(currentComparator);
|
|
1054 |
} catch (CqiClientException e) {
|
|
1055 |
System.err.println(NLS.bind(
|
|
1056 |
Messages.ERROR_WHILE_LOADING_CONCORDANCE_LINE, e));
|
|
1057 |
}
|
|
1058 |
}
|
|
1059 |
});
|
|
1060 |
} catch (Exception e) {
|
|
1061 |
System.err.println(NLS.bind(
|
|
1062 |
Messages.ERROR_WHILE_LOADING_CONCORDANCE_LINE, e));
|
|
1063 |
org.txm.rcp.utils.Logger.printStackTrace(e);
|
|
1064 |
}
|
|
1065 |
viewer.refresh();
|
|
1066 |
}
|
|
1067 |
}
|
|
1068 |
|
1043 |
1069 |
}
|