Révision 491
| tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditorInput.java (revision 491) | ||
|---|---|---|
| 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.concordance.rcp.editors; |
|
| 29 |
|
|
| 30 |
import org.txm.concordance.core.functions.Concordance; |
|
| 31 |
import org.txm.rcp.editors.TXMResultEditorInput; |
|
| 32 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 33 |
|
|
| 34 |
/** |
|
| 35 |
* Concordance result editor input. |
|
| 36 |
* @author sjacquot |
|
| 37 |
* |
|
| 38 |
*/ |
|
| 39 |
public class ConcordanceEditorInput extends TXMResultEditorInput {
|
|
| 40 |
|
|
| 41 |
/** The corpus. */ |
|
| 42 |
private Corpus corpus; |
|
| 43 |
|
|
| 44 |
/** |
|
| 45 |
* Instantiates a new concordances editor input. |
|
| 46 |
* |
|
| 47 |
* @param corpus the corpus |
|
| 48 |
* @param concordance the concordance |
|
| 49 |
*/ |
|
| 50 |
public ConcordanceEditorInput(Corpus corpus, Concordance concordance) {
|
|
| 51 |
super(concordance); |
|
| 52 |
if (concordance != null) {
|
|
| 53 |
this.corpus = concordance.getCorpus(); |
|
| 54 |
} |
|
| 55 |
else {
|
|
| 56 |
this.corpus = corpus; |
|
| 57 |
} |
|
| 58 |
} |
|
| 59 |
|
|
| 60 |
/** |
|
| 61 |
* |
|
| 62 |
* @param corpus |
|
| 63 |
*/ |
|
| 64 |
public ConcordanceEditorInput(Corpus corpus) {
|
|
| 65 |
this(corpus, null); |
|
| 66 |
} |
|
| 67 |
|
|
| 68 |
/** |
|
| 69 |
* Gets the corpus. |
|
| 70 |
* |
|
| 71 |
* @return the corpus |
|
| 72 |
*/ |
|
| 73 |
public Corpus getCorpus() {
|
|
| 74 |
return corpus; |
|
| 75 |
} |
|
| 76 |
|
|
| 77 |
/** |
|
| 78 |
* Gets the concordance. |
|
| 79 |
* |
|
| 80 |
* @return the concordance |
|
| 81 |
*/ |
|
| 82 |
public Concordance getConcordance() {
|
|
| 83 |
return (Concordance) this.result; |
|
| 84 |
} |
|
| 85 |
|
|
| 86 |
/** |
|
| 87 |
* |
|
| 88 |
* @param newCorpus |
|
| 89 |
*/ |
|
| 90 |
public void setCorpus(Corpus newCorpus) {
|
|
| 91 |
this.corpus = newCorpus; |
|
| 92 |
} |
|
| 93 |
|
|
| 94 |
@Deprecated |
|
| 95 |
public void setConcordance(Concordance conc) {
|
|
| 96 |
this.result = conc; |
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
@Override |
|
| 100 |
public boolean equals(Object obj) {
|
|
| 101 |
if(obj instanceof ConcordanceEditorInput) {
|
|
| 102 |
return this.result == ((ConcordanceEditorInput) obj).getConcordance() |
|
| 103 |
&& (this.result != null && ((ConcordanceEditorInput) obj).getConcordance() != null && this.getConcordance().getQuery() == ((ConcordanceEditorInput) obj).getConcordance().getQuery()); |
|
| 104 |
} |
|
| 105 |
return false; |
|
| 106 |
} |
|
| 107 |
} |
|
| tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 491) | ||
|---|---|---|
| 70 | 70 |
import org.eclipse.swt.graphics.Font; |
| 71 | 71 |
import org.eclipse.swt.graphics.FontData; |
| 72 | 72 |
import org.eclipse.swt.graphics.GC; |
| 73 |
import org.eclipse.swt.graphics.Image; |
|
| 74 | 73 |
import org.eclipse.swt.graphics.Point; |
| 75 | 74 |
import org.eclipse.swt.graphics.Rectangle; |
| 76 | 75 |
import org.eclipse.swt.layout.FormAttachment; |
| ... | ... | |
| 96 | 95 |
import org.eclipse.ui.IWorkbenchWindow; |
| 97 | 96 |
import org.eclipse.ui.PartInitException; |
| 98 | 97 |
import org.eclipse.ui.dialogs.ListDialog; |
| 99 |
import org.eclipse.ui.part.EditorPart; |
|
| 100 |
import org.txm.Toolbox; |
|
| 101 | 98 |
import org.txm.annotation.Annotation; |
| 102 | 99 |
import org.txm.annotation.AnnotationManager; |
| 103 | 100 |
import org.txm.annotation.KRAnnotationEngine; |
| ... | ... | |
| 130 | 127 |
import org.txm.cooccurrence.rcp.messages.CooccurrenceUIMessages; |
| 131 | 128 |
import org.txm.core.messages.TXMCoreMessages; |
| 132 | 129 |
import org.txm.core.preferences.TXMPreferences; |
| 130 |
import org.txm.core.results.TXMResult; |
|
| 131 |
import org.txm.functions.internal.InternalView; |
|
| 133 | 132 |
import org.txm.objects.Page; |
| 134 | 133 |
import org.txm.rcp.IImageKeys; |
| 135 | 134 |
import org.txm.rcp.JobsTimer; |
| ... | ... | |
| 139 | 138 |
import org.txm.rcp.commands.OpenBrowser; |
| 140 | 139 |
import org.txm.rcp.commands.annotation.InitializeKnowledgeRepository; |
| 141 | 140 |
import org.txm.rcp.commands.annotation.SaveAnnotations; |
| 142 |
import org.txm.rcp.commands.editor.CustomizableEditor; |
|
| 143 | 141 |
import org.txm.rcp.commands.krview.OpenKRView; |
| 144 | 142 |
import org.txm.rcp.editors.TXMBrowser; |
| 143 |
import org.txm.rcp.editors.TXMEditorPart; |
|
| 144 |
import org.txm.rcp.editors.TXMResultEditorInput; |
|
| 145 | 145 |
import org.txm.rcp.editors.TableKeyListener; |
| 146 |
import org.txm.rcp.editors.input.InternalViewEditorInput; |
|
| 147 | 146 |
import org.txm.rcp.editors.internal.InternalViewEditor; |
| 148 | 147 |
import org.txm.rcp.preferences.RCPPreferences; |
| 149 | 148 |
import org.txm.rcp.swt.dialog.ConfirmDialog; |
| ... | ... | |
| 161 | 160 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 162 | 161 |
import org.txm.searchengine.cqp.corpus.Corpus; |
| 163 | 162 |
import org.txm.searchengine.cqp.corpus.Property; |
| 163 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
|
| 164 | 164 |
import org.txm.searchengine.cqp.corpus.query.Match; |
| 165 | 165 |
import org.txm.searchengine.cqp.corpus.query.Query; |
| 166 | 166 |
import org.txm.utils.AsciiUtils; |
| 167 | 167 |
import org.txm.utils.logger.Log; |
| 168 |
// TODO: Auto-generated Javadoc |
|
| 168 |
|
|
| 169 | 169 |
/** |
| 170 | 170 |
* display the concordances parameters and results in the same editor |
| 171 | 171 |
* |
| 172 | 172 |
* @author mdecorde. |
| 173 | 173 |
*/ |
| 174 |
public class ConcordanceEditor extends EditorPart implements CustomizableEditor {
|
|
| 174 |
public class ConcordanceEditor extends TXMEditorPart {
|
|
| 175 | 175 |
|
| 176 |
public static final String ID = ConcordanceEditor.class.getName(); |
|
| 177 |
|
|
| 176 | 178 |
/** |
| 177 | 179 |
* the limit number of annotation when a confirm dialog box is shown |
| 178 | 180 |
*/ |
| 179 | 181 |
private static final int NALERTAFFECTANNOTATIONS = 100; |
| 180 | 182 |
|
| 181 | 183 |
String locale = TXMPreferences.getString(RCPPreferences.UI_LOCALE, RCPPreferences.PREFERENCES_NODE); |
| 182 |
|
|
| 184 |
|
|
| 183 | 185 |
/** The lineids. */ |
| 184 | 186 |
List<String> lineids; |
| 185 | 187 |
|
| ... | ... | |
| 226 | 228 |
|
| 227 | 229 |
/** The annotation service */ |
| 228 | 230 |
private AnnotationManager annotManager; |
| 229 |
|
|
| 231 |
|
|
| 230 | 232 |
//boolean annotation_expert_mode = TxmPreferences.getBoolean(AnnotationPreferencePage.MODE, false); |
| 231 | 233 |
|
| 232 | 234 |
/** The standard comparator class name. */ |
| ... | ... | |
| 326 | 328 |
|
| 327 | 329 |
/** The is setup shown. */ |
| 328 | 330 |
private boolean isSetupShown = true; |
| 329 |
|
|
| 330 | 331 |
|
| 332 |
|
|
| 331 | 333 |
/** The hide btn. */ |
| 332 | 334 |
private Button hideBtn; |
| 333 | 335 |
private Button deleteLineButton; |
| 334 | 336 |
|
| 335 | 337 |
/** The query size. */ |
| 336 | 338 |
protected Point querySize; |
| 337 |
|
|
| 339 |
|
|
| 338 | 340 |
protected Point annotationSize; |
| 339 |
|
|
| 341 |
|
|
| 340 | 342 |
/** The annot btn. */ |
| 341 | 343 |
private Button annotationButton; |
| 342 | 344 |
|
| ... | ... | |
| 426 | 428 |
initializeEditor(); |
| 427 | 429 |
} |
| 428 | 430 |
|
| 429 |
private void initializeEditor() {
|
|
| 430 |
this.corpus = ((ConcordanceEditorInput) getEditorInput()).getCorpus(); |
|
| 431 |
private void initializeEditor() throws PartInitException {
|
|
| 432 |
|
|
| 433 |
TXMResultEditorInput input = getEditorInput(); |
|
| 434 |
TXMResult result = input.getResult(); |
|
| 435 |
if (!(result instanceof Concordance)) {
|
|
| 436 |
throw new PartInitException("Cannot open ConcordanceEditor with "+result);
|
|
| 437 |
} |
|
| 438 |
this.concordance = (Concordance)result; |
|
| 439 |
this.corpus = concordance.getCorpus(); |
|
| 431 | 440 |
this.annotManager = KRAnnotationEngine.getAnnotationManager(corpus); |
| 432 | 441 |
|
| 433 | 442 |
this.standardComparators = new ArrayList<LineComparator>(); |
| ... | ... | |
| 457 | 466 |
org.txm.rcp.utils.Logger.printStackTrace(e1); |
| 458 | 467 |
Log.severe("Error while computing concordance: "+e.getLocalizedMessage());
|
| 459 | 468 |
} |
| 460 |
|
|
| 469 |
|
|
| 461 | 470 |
return; |
| 462 | 471 |
} |
| 463 | 472 |
|
| 464 |
this.concordance = ((ConcordanceEditorInput) getEditorInput()).getConcordance();
|
|
| 473 |
initializeFields();
|
|
| 465 | 474 |
|
| 466 |
if (this.concordance == null) {
|
|
| 467 |
leftContextSize = TXMPreferences.getInt(ConcordancePreferences.LEFT_CONTEXT_SIZE, ConcordancePreferences.PREFERENCES_NODE); |
|
| 468 |
rightContextSize = TXMPreferences.getInt(ConcordancePreferences.RIGHT_CONTEXT_SIZE, ConcordancePreferences.PREFERENCES_NODE); |
|
| 469 |
|
|
| 470 |
selectedLeftViewProperties = new ArrayList<Property>(); |
|
| 471 |
selectedRightViewProperties = new ArrayList<Property>(); |
|
| 472 |
selectedKeywordViewProperties = new ArrayList<Property>(); |
|
| 473 |
|
|
| 474 |
//set default view property |
|
| 475 |
Property defaultViewProperty = availableKeywordViewProperties.get(0); |
|
| 476 |
if(!defaultViewProperty.getName().equals("word")) //$NON-NLS-1$
|
|
| 477 |
for(int i = 0 ; i < availableKeywordViewProperties.size() ; i++ ) |
|
| 478 |
if (availableKeywordViewProperties.get(i).getName().equals("word")) //$NON-NLS-1$
|
|
| 479 |
{
|
|
| 480 |
defaultViewProperty = availableKeywordViewProperties.get(i); |
|
| 481 |
break; |
|
| 482 |
} |
|
| 483 |
|
|
| 484 |
availableKeywordViewProperties.remove(defaultViewProperty); |
|
| 485 |
availableLeftViewProperties.remove(defaultViewProperty); |
|
| 486 |
availableRightViewProperties.remove(defaultViewProperty); |
|
| 487 |
selectedLeftViewProperties.add(defaultViewProperty); |
|
| 488 |
selectedRightViewProperties.add(defaultViewProperty); |
|
| 489 |
selectedKeywordViewProperties.add(defaultViewProperty); |
|
| 490 |
|
|
| 491 |
//set default sort property |
|
| 492 |
selectedLeftSortProperties = new ArrayList<Property>(); |
|
| 493 |
selectedRightSortProperties = new ArrayList<Property>(); |
|
| 494 |
selectedKeywordSortProperties = new ArrayList<Property>(); |
|
| 495 |
|
|
| 496 |
Property defaultSortProperty = availableKeywordSortProperties.get(0); |
|
| 497 |
if(!defaultSortProperty.getName().equals("word")) //$NON-NLS-1$
|
|
| 498 |
for(int i = 0 ; i < availableKeywordSortProperties.size() ; i++ ) |
|
| 499 |
if (availableKeywordSortProperties.get(i).getName().equals("word")) //$NON-NLS-1$
|
|
| 500 |
{
|
|
| 501 |
defaultSortProperty = availableKeywordSortProperties.get(i); |
|
| 502 |
break; |
|
| 503 |
} |
|
| 504 |
|
|
| 505 |
availableKeywordSortProperties.remove(defaultSortProperty); |
|
| 506 |
availableLeftSortProperties.remove(defaultSortProperty); |
|
| 507 |
availableRightSortProperties.remove(defaultSortProperty); |
|
| 508 |
selectedLeftSortProperties.add(defaultSortProperty); |
|
| 509 |
selectedRightSortProperties.add(defaultSortProperty); |
|
| 510 |
selectedKeywordSortProperties.add(defaultSortProperty); |
|
| 511 |
|
|
| 512 |
this.refViewPattern = new ReferencePattern(); |
|
| 513 |
this.refSortPattern = new ReferencePattern(); |
|
| 514 |
try { // set the default reference is there is one
|
|
| 515 |
if (corpus.getProperty("ref") != null) //$NON-NLS-1$
|
|
| 516 |
{
|
|
| 517 |
refViewPattern.addProperty(corpus.getProperty("ref")); //$NON-NLS-1$
|
|
| 518 |
refSortPattern.addProperty(corpus.getProperty("ref")); //$NON-NLS-1$
|
|
| 519 |
} else {
|
|
| 520 |
if (corpus.getStructuralUnit("text") != null) //$NON-NLS-1$
|
|
| 521 |
if (corpus.getStructuralUnit("text").getProperty("id") != null) //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 522 |
{
|
|
| 523 |
refViewPattern.addProperty(corpus.getStructuralUnit("text").getProperty("id")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 524 |
refSortPattern.addProperty(corpus.getStructuralUnit("text").getProperty("id")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 525 |
} |
|
| 526 |
} |
|
| 527 |
} catch (CqiClientException e) {
|
|
| 528 |
System.out.println(NLS.bind(Messages.ConcordancesEditor_43, corpus.getName(), e)); |
|
| 529 |
} |
|
| 530 |
} else {
|
|
| 531 |
leftContextSize = concordance.getLeftContextSize(); |
|
| 532 |
rightContextSize = concordance.getRightContextSize(); |
|
| 533 |
|
|
| 534 |
selectedLeftViewProperties = concordance.getLeftViewProperties(); |
|
| 535 |
selectedRightViewProperties = concordance.getRightViewProperties(); |
|
| 536 |
selectedKeywordViewProperties = concordance.getKeywordViewProperties(); |
|
| 537 |
availableKeywordViewProperties.remove(selectedKeywordViewProperties); |
|
| 538 |
availableLeftViewProperties.remove(selectedLeftViewProperties); |
|
| 539 |
availableRightViewProperties.remove(selectedRightViewProperties); |
|
| 540 |
|
|
| 541 |
selectedLeftSortProperties = concordance.getLeftAnalysisProperties(); |
|
| 542 |
selectedRightSortProperties = concordance.getRightAnalysisProperties(); |
|
| 543 |
selectedKeywordSortProperties = concordance.getKeywordAnalysisProperties(); |
|
| 544 |
availableKeywordSortProperties.remove(selectedKeywordSortProperties); |
|
| 545 |
availableLeftSortProperties.remove(selectedLeftSortProperties); |
|
| 546 |
availableRightSortProperties.remove(selectedRightSortProperties); |
|
| 547 |
|
|
| 548 |
this.refViewPattern = concordance.getRefViewPattern(); |
|
| 549 |
this.refSortPattern = concordance.getRefAnalysePattern(); |
|
| 550 |
} |
|
| 551 |
|
|
| 552 |
|
|
| 553 |
|
|
| 554 | 475 |
if (concordance != null) |
| 555 | 476 |
setPartName(concordance.getName()); |
| 556 | 477 |
else |
| ... | ... | |
| 631 | 552 |
} |
| 632 | 553 |
}); |
| 633 | 554 |
|
| 634 |
//TODO: to enable line deletion, Concordance code must updated |
|
| 555 |
//TODO: to enable line deletion, Concordance code must updated -> replace with key binding
|
|
| 635 | 556 |
viewer.getTable().addKeyListener(new KeyListener() {
|
| 636 | 557 |
|
| 637 | 558 |
@Override |
| ... | ... | |
| 639 | 560 |
|
| 640 | 561 |
@Override |
| 641 | 562 |
public void keyPressed(KeyEvent e) {
|
| 642 |
if (e.keyCode != SWT.DEL ) { // CTRL + C
|
|
| 643 |
return; |
|
| 644 |
} |
|
| 563 |
if (e.keyCode != SWT.DEL ) { return; }
|
|
| 645 | 564 |
|
| 646 | 565 |
DeleteLines.deleteConcordanceLines(ConcordanceEditor.this); |
| 647 | 566 |
} |
| ... | ... | |
| 901 | 820 |
concordance.setLeftAnalysisProperties(selectedLeftSortProperties); |
| 902 | 821 |
concordance.setKeywordAnalysisProperties(selectedKeywordSortProperties); |
| 903 | 822 |
concordance.setRightAnalysisProperties(selectedRightSortProperties); |
| 904 |
|
|
| 823 |
|
|
| 905 | 824 |
try {
|
| 906 | 825 |
Log.info(NLS.bind(CooccurrenceUIMessages.CooccurrencesEditor_0, currentComparator.getName())); |
| 907 | 826 |
if (currentComparator instanceof CompositeComparator) |
| ... | ... | |
| 957 | 876 |
public void fillDisplayArea(int from, int to) {
|
| 958 | 877 |
if (viewer == null) |
| 959 | 878 |
return; |
| 960 |
|
|
| 879 |
|
|
| 961 | 880 |
viewer.getControl().setRedraw(false); |
| 962 |
|
|
| 881 |
|
|
| 963 | 882 |
from = Math.max(from, 0); |
| 964 | 883 |
to = Math.min(to, concordance.getNLines() - 1); |
| 965 | 884 |
List<Line> lines = null; |
| ... | ... | |
| 995 | 914 |
navigationArea.getParent().layout(); |
| 996 | 915 |
|
| 997 | 916 |
refreshReferenceColumnTitle(); |
| 998 |
|
|
| 917 |
|
|
| 999 | 918 |
viewer.getControl().setRedraw(true); |
| 1000 | 919 |
} |
| 1001 | 920 |
|
| ... | ... | |
| 1014 | 933 |
|
| 1015 | 934 |
private Label equalLabel; |
| 1016 | 935 |
Boolean advanced_annotation_mode = false; |
| 1017 |
|
|
| 936 |
|
|
| 1018 | 937 |
private void composeAnnotationArea(final Composite parent){
|
| 1019 | 938 |
advanced_annotation_mode = "advanced".equals(TXMPreferences.getString(RCPPreferences.ANNOTATION_MODE, RCPPreferences.PREFERENCES_NODE)); |
| 1020 |
|
|
| 939 |
|
|
| 1021 | 940 |
List<KnowledgeRepository> krs = InitializeKnowledgeRepository.get(corpus.getMainCorpus()); |
| 1022 | 941 |
typesList.clear(); |
| 1023 | 942 |
Log.warning("Corpus KRs: "+krs); //$NON-NLS-1$
|
| 1024 | 943 |
|
| 1025 | 944 |
for (KnowledgeRepository kr : krs) {
|
| 1026 | 945 |
if (kr == null) continue; |
| 1027 |
|
|
| 946 |
|
|
| 1028 | 947 |
currentKnowledgeRepository = kr; |
| 1029 | 948 |
Log.warning(" KR: "+kr); //$NON-NLS-1$
|
| 1030 | 949 |
List<AnnotationType> krtypes = kr.getAllAnnotationTypes(); |
| ... | ... | |
| 1048 | 967 |
Log.warning("Available annotation types: "+typesList);
|
| 1049 | 968 |
break; |
| 1050 | 969 |
} |
| 1051 |
|
|
| 970 |
|
|
| 1052 | 971 |
if (currentKnowledgeRepository == null) {
|
| 1053 | 972 |
System.out.println("Error: no suitable KnowledgeRepository found");
|
| 1054 | 973 |
return; |
| ... | ... | |
| 1100 | 1019 |
GridData gdata = new GridData(SWT.CENTER, SWT.CENTER, false, true); |
| 1101 | 1020 |
gdata.widthHint = 90; |
| 1102 | 1021 |
addRemoveCombo.setLayoutData(gdata); |
| 1103 |
|
|
| 1022 |
|
|
| 1104 | 1023 |
withLabel = new Label(annotationArea, SWT.NONE); |
| 1105 | 1024 |
String withLabelText = currentKnowledgeRepository.getString(locale, "ConcordancesEditor_83"); |
| 1106 | 1025 |
if (withLabelText == null) withLabelText= Messages.ConcordancesEditor_83; |
| ... | ... | |
| 1239 | 1158 |
}else {
|
| 1240 | 1159 |
if (typesList.size() > 1){
|
| 1241 | 1160 |
if (annotationTypesCombo != null) annotationTypesCombo.getCombo().select(typesList.size()-1); |
| 1242 |
|
|
| 1161 |
|
|
| 1243 | 1162 |
} |
| 1244 |
|
|
| 1163 |
|
|
| 1245 | 1164 |
} |
| 1246 | 1165 |
KRView.refresh(); |
| 1247 | 1166 |
updateAnnotationWidgetStates(); |
| ... | ... | |
| 1390 | 1309 |
@Override |
| 1391 | 1310 |
public void widgetSelected(SelectionEvent e) {
|
| 1392 | 1311 |
//@TODO Closing the annotation tool bar |
| 1393 |
//System.out.println("must hide");
|
|
| 1394 |
annotationSize = annotationArea.getSize();
|
|
| 1395 |
annotationArea.dispose();
|
|
| 1396 |
annotationArea = null;
|
|
| 1397 |
parent.layout(true);
|
|
| 1398 |
parent.layout();
|
|
| 1399 |
annotationButton.setToolTipText(Messages.ConcordancesEditor_75);
|
|
| 1400 |
annotationButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL));
|
|
| 1401 |
annotationColumn.setWidth(0);
|
|
| 1402 |
annotationColumn.setResizable(false);
|
|
| 1312 |
//System.out.println("must hide");
|
|
| 1313 |
annotationSize = annotationArea.getSize(); |
|
| 1314 |
annotationArea.dispose(); |
|
| 1315 |
annotationArea = null; |
|
| 1316 |
parent.layout(true); |
|
| 1317 |
parent.layout(); |
|
| 1318 |
annotationButton.setToolTipText(Messages.ConcordancesEditor_75); |
|
| 1319 |
annotationButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL)); |
|
| 1320 |
annotationColumn.setWidth(0); |
|
| 1321 |
annotationColumn.setResizable(false); |
|
| 1403 | 1322 |
} |
| 1404 | 1323 |
|
| 1405 | 1324 |
@Override |
| 1406 | 1325 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
| 1407 | 1326 |
}); |
| 1408 |
|
|
| 1409 |
|
|
| 1327 |
|
|
| 1328 |
|
|
| 1410 | 1329 |
updateAnnotationWidgetStates(); |
| 1411 | 1330 |
|
| 1412 | 1331 |
parent.layout(); |
| ... | ... | |
| 1455 | 1374 |
System.out.println("Annotation canceled by user.");
|
| 1456 | 1375 |
return Status.CANCEL_STATUS; |
| 1457 | 1376 |
} |
| 1458 |
|
|
| 1377 |
|
|
| 1459 | 1378 |
return Status.OK_STATUS; |
| 1460 | 1379 |
} |
| 1461 | 1380 |
}; |
| ... | ... | |
| 1611 | 1530 |
// finally we can 'try' to create the annotations \o/ |
| 1612 | 1531 |
try {
|
| 1613 | 1532 |
HashMap<Match, List<Annotation>> existingAnnots = annotManager.createAnnotations(type, value_to_add, matches, job); |
| 1614 |
|
|
| 1533 |
|
|
| 1615 | 1534 |
// did we had problems ? |
| 1616 | 1535 |
if (existingAnnots!=null && existingAnnots.size() > 0) {
|
| 1617 | 1536 |
String message = Messages.ConcordancesEditor_61+value_to_add.getStandardName()+ |
| ... | ... | |
| 1853 | 1772 |
}); |
| 1854 | 1773 |
} |
| 1855 | 1774 |
// Navigation Area: infoLine and buttons |
| 1856 |
navigationArea = new NavigationWidget(navigationPanel, SWT.NONE);
|
|
| 1857 |
navigationArea.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false, 4, 1));
|
|
| 1775 |
navigationArea = new NavigationWidget(navigationPanel, SWT.NONE); |
|
| 1776 |
navigationArea.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false, 4, 1)); |
|
| 1858 | 1777 |
|
| 1859 |
// | [|<] [<] infos [>] [>|] |
|
|
| 1860 |
// [|<]
|
|
| 1861 |
navigationArea.addFirstListener(new SelectionListener() {
|
|
| 1862 |
@Override
|
|
| 1863 |
public void widgetDefaultSelected(SelectionEvent arg0) {
|
|
| 1864 |
}
|
|
| 1778 |
// | [|<] [<] infos [>] [>|] | |
|
| 1779 |
// [|<] |
|
| 1780 |
navigationArea.addFirstListener(new SelectionListener() {
|
|
| 1781 |
@Override |
|
| 1782 |
public void widgetDefaultSelected(SelectionEvent arg0) {
|
|
| 1783 |
} |
|
| 1865 | 1784 |
|
| 1866 |
@Override
|
|
| 1867 |
public void widgetSelected(SelectionEvent arg0) {
|
|
| 1868 |
fillDisplayArea(0, nLinePerPage - 1);
|
|
| 1869 |
}
|
|
| 1870 |
});
|
|
| 1785 |
@Override |
|
| 1786 |
public void widgetSelected(SelectionEvent arg0) {
|
|
| 1787 |
fillDisplayArea(0, nLinePerPage - 1); |
|
| 1788 |
} |
|
| 1789 |
}); |
|
| 1871 | 1790 |
|
| 1872 |
// [<]
|
|
| 1873 |
navigationArea.addPreviousListener(new SelectionListener() {
|
|
| 1874 |
@Override
|
|
| 1875 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
| 1876 |
}
|
|
| 1791 |
// [<] |
|
| 1792 |
navigationArea.addPreviousListener(new SelectionListener() {
|
|
| 1793 |
@Override |
|
| 1794 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
| 1795 |
} |
|
| 1877 | 1796 |
|
| 1878 |
@Override
|
|
| 1879 |
public void widgetSelected(SelectionEvent e) {
|
|
| 1880 |
int top = topLine - nLinePerPage;
|
|
| 1881 |
if (top < 0)
|
|
| 1882 |
top = 0;
|
|
| 1883 |
int bottom = top + nLinePerPage -1 ;
|
|
| 1884 |
fillDisplayArea(top, bottom);
|
|
| 1885 |
}
|
|
| 1886 |
});
|
|
| 1797 |
@Override |
|
| 1798 |
public void widgetSelected(SelectionEvent e) {
|
|
| 1799 |
int top = topLine - nLinePerPage; |
|
| 1800 |
if (top < 0) |
|
| 1801 |
top = 0; |
|
| 1802 |
int bottom = top + nLinePerPage -1 ; |
|
| 1803 |
fillDisplayArea(top, bottom); |
|
| 1804 |
} |
|
| 1805 |
}); |
|
| 1887 | 1806 |
|
| 1888 |
// [>]
|
|
| 1889 |
navigationArea.addNextListener(new SelectionListener() {
|
|
| 1890 |
@Override
|
|
| 1891 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
| 1892 |
}
|
|
| 1807 |
// [>] |
|
| 1808 |
navigationArea.addNextListener(new SelectionListener() {
|
|
| 1809 |
@Override |
|
| 1810 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
| 1811 |
} |
|
| 1893 | 1812 |
|
| 1894 |
@Override
|
|
| 1895 |
public void widgetSelected(SelectionEvent e) {
|
|
| 1896 |
fillDisplayArea(bottomLine + 1, bottomLine + nLinePerPage);
|
|
| 1897 |
}
|
|
| 1898 |
});
|
|
| 1813 |
@Override |
|
| 1814 |
public void widgetSelected(SelectionEvent e) {
|
|
| 1815 |
fillDisplayArea(bottomLine + 1, bottomLine + nLinePerPage); |
|
| 1816 |
} |
|
| 1817 |
}); |
|
| 1899 | 1818 |
|
| 1900 |
// [>|]
|
|
| 1901 |
navigationArea.addLastListener(new SelectionListener() {
|
|
| 1902 |
@Override
|
|
| 1903 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
| 1904 |
}
|
|
| 1819 |
// [>|] |
|
| 1820 |
navigationArea.addLastListener(new SelectionListener() {
|
|
| 1821 |
@Override |
|
| 1822 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
| 1823 |
} |
|
| 1905 | 1824 |
|
| 1906 |
@Override
|
|
| 1907 |
public void widgetSelected(SelectionEvent e) {
|
|
| 1908 |
int top = (concordance.getNLines()/nLinePerPage)*nLinePerPage;
|
|
| 1909 |
int bottom = top + nLinePerPage -1 ;
|
|
| 1910 |
fillDisplayArea(top, bottom);
|
|
| 1911 |
//fillDisplayArea(concordance.getNLines() - 1 - nLinePerPage,concordance.getNLines() - 1);
|
|
| 1912 |
}
|
|
| 1913 |
});
|
|
| 1825 |
@Override |
|
| 1826 |
public void widgetSelected(SelectionEvent e) {
|
|
| 1827 |
int top = (concordance.getNLines()/nLinePerPage)*nLinePerPage; |
|
| 1828 |
int bottom = top + nLinePerPage -1 ; |
|
| 1829 |
fillDisplayArea(top, bottom); |
|
| 1830 |
//fillDisplayArea(concordance.getNLines() - 1 - nLinePerPage,concordance.getNLines() - 1); |
|
| 1831 |
} |
|
| 1832 |
}); |
|
| 1914 | 1833 |
hideBtn = new Button(navigationPanel, SWT.PUSH); |
| 1915 | 1834 |
hideBtn.setText(Messages.ConcordancesEditor_38); |
| 1916 | 1835 |
hideBtn.addSelectionListener(new SelectionListener() {
|
| ... | ... | |
| 1984 | 1903 |
JobsTimer.start(); |
| 1985 | 1904 |
Concordance oldConcordance = concordance; |
| 1986 | 1905 |
System.out.println(NLS.bind(Messages.ConcordancesEditor_5, query.getQueryString(), corpus.getName())); |
| 1987 |
concordance = new Concordance(corpus, query, |
|
| 1906 |
concordance = new Concordance(corpus); |
|
| 1907 |
concordance.setParameters(query, |
|
| 1988 | 1908 |
selectedLeftSortProperties, |
| 1989 | 1909 |
selectedRightSortProperties, |
| 1990 | 1910 |
selectedKeywordSortProperties, |
| ... | ... | |
| 1994 | 1914 |
getViewReferencePattern(), |
| 1995 | 1915 |
getSortReferencePattern(), |
| 1996 | 1916 |
leftContextSize, rightContextSize); |
| 1997 |
|
|
| 1998 | 1917 |
concordance.setCQLSeparator(cql_limit); |
| 1999 | 1918 |
|
| 2000 | 1919 |
if (annotationArea != null) {
|
| ... | ... | |
| 2021 | 1940 |
CorporaView.refresh(); |
| 2022 | 1941 |
CorporaView.expand(corpus); |
| 2023 | 1942 |
QueriesView.refresh(); |
| 2024 |
//FIXME: the call below doesn't work |
|
| 2025 |
//RVariablesView.refresh(); |
|
| 2026 |
|
|
| 1943 |
|
|
| 2027 | 1944 |
if (fillDisplay) {
|
| 2028 | 1945 |
fillDisplayArea(top, bottom); |
| 2029 | 1946 |
} |
| ... | ... | |
| 2034 | 1951 |
resetColumnWidths(); |
| 2035 | 1952 |
|
| 2036 | 1953 |
updateAnnotationWidgetStates(); |
| 2037 |
JobsTimer.stopAndPrint(); |
|
| 2038 | 1954 |
|
| 2039 |
|
|
| 2040 |
((ConcordanceEditorInput)this.getEditorInput()).setResult(concordance); |
|
| 2041 |
|
|
| 2042 | 1955 |
JobsTimer.stopAndPrint(); |
| 2043 | 1956 |
|
| 2044 | 1957 |
} catch (Exception e1) {
|
| ... | ... | |
| 2053 | 1966 |
org.txm.rcp.utils.Logger.printStackTrace(e1); |
| 2054 | 1967 |
Log.severe(Log.toString(e1)); |
| 2055 | 1968 |
} |
| 2056 |
|
|
| 2057 | 1969 |
} |
| 2058 | 1970 |
} |
| 2059 | 1971 |
|
| 2060 |
|
|
| 2061 | 1972 |
/** |
| 2062 | 1973 |
* Computes the concordance and fills the display area with lines range corresponding to the first page. |
| 2063 | 1974 |
*/ |
| ... | ... | |
| 2803 | 2714 |
} |
| 2804 | 2715 |
*/ |
| 2805 | 2716 |
|
| 2806 |
/* (non-Javadoc) |
|
| 2807 |
* @see org.txm.rcp.commands.editor.CustomizableEditor#setName(java.lang.String) |
|
| 2808 |
*/ |
|
| 2809 |
@Override |
|
| 2810 |
public void setName(String name) {
|
|
| 2811 |
this.setPartName(name); |
|
| 2812 |
} |
|
| 2813 |
|
|
| 2814 |
/* (non-Javadoc) |
|
| 2815 |
* @see org.txm.rcp.commands.editor.CustomizableEditor#setIcon(org.eclipse.swt.graphics.Image) |
|
| 2816 |
*/ |
|
| 2817 |
@Override |
|
| 2818 |
public void setIcon(Image image) {
|
|
| 2819 |
this.setTitleImage(image); |
|
| 2820 |
} |
|
| 2821 |
|
|
| 2822 |
/* (non-Javadoc) |
|
| 2823 |
* @see org.txm.rcp.commands.editor.CustomizableEditor#setSource(java.lang.Object) |
|
| 2824 |
*/ |
|
| 2825 |
@Override |
|
| 2826 |
public void setSource(Object source) |
|
| 2827 |
{
|
|
| 2828 |
//this.source = source; |
|
| 2829 |
} |
|
| 2830 |
|
|
| 2831 |
/* (non-Javadoc) |
|
| 2832 |
* @see org.txm.rcp.commands.editor.CustomizableEditor#getSource() |
|
| 2833 |
*/ |
|
| 2834 |
@Override |
|
| 2835 |
public Object getSource() {
|
|
| 2836 |
return concordance; |
|
| 2837 |
} |
|
| 2838 |
|
|
| 2839 | 2717 |
/** |
| 2840 | 2718 |
* Gets the current comparator used for sorting lines. |
| 2841 | 2719 |
* @return the currentComparator |
| ... | ... | |
| 2852 | 2730 |
return (int) Math.ceil(((double)this.concordance.getNLines() / this.nLinePerPage)); |
| 2853 | 2731 |
} |
| 2854 | 2732 |
|
| 2855 |
|
|
| 2856 |
@Override |
|
| 2857 |
public Object toConcordance() { return null;}
|
|
| 2858 |
@Override |
|
| 2859 |
public Object toIndex() { return null;}
|
|
| 2860 |
@Override |
|
| 2861 |
public Object toProgression() { return null;}
|
|
| 2862 |
|
|
| 2863 | 2733 |
public void setQuery(String query) {
|
| 2864 | 2734 |
queryWidget.setText(query); |
| 2865 | 2735 |
} |
| ... | ... | |
| 2891 | 2761 |
} |
| 2892 | 2762 |
|
| 2893 | 2763 |
// Last resort edition |
| 2894 |
InternalViewEditorInput editorInput = new InternalViewEditorInput(corpus, null); |
|
| 2895 |
|
|
| 2896 |
IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage(); |
|
| 2897 | 2764 |
try {
|
| 2765 |
InternalView iview = new InternalView(corpus); |
|
| 2766 |
iview.setParameters(concordance.getKeywordAnalysisProperties(), |
|
| 2767 |
concordance.getCorpus().getStructuralUnit("text"),
|
|
| 2768 |
new ArrayList<StructuralUnitProperty>(), null); |
|
| 2769 |
|
|
| 2770 |
TXMResultEditorInput editorInput = new TXMResultEditorInput(iview); |
|
| 2771 |
|
|
| 2772 |
IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage(); |
|
| 2773 |
|
|
| 2898 | 2774 |
StatusLine.setMessage(Messages.ComputeReferencer_0); |
| 2899 |
InternalViewEditor editor = (InternalViewEditor)page.openEditor(editorInput,"org.txm.rcp.editors.internal.InternalViewEditor"); //$NON-NLS-1$
|
|
| 2775 |
InternalViewEditor editor = (InternalViewEditor)page.openEditor(editorInput,InternalViewEditor.class.getName()); //$NON-NLS-1$
|
|
| 2900 | 2776 |
editor.backToText(line); |
| 2901 | 2777 |
SWTEditorsUtils.addEditor(this, editor, EModelService.ABOVE); |
| 2902 |
} catch (PartInitException e) {
|
|
| 2903 |
System.err.println(Messages.CorporaView_6+ e); |
|
| 2778 |
} catch (Exception e) {
|
|
| 2779 |
System.err.println("Error: could not open InternalView editor: "+ e);
|
|
| 2780 |
Log.printStackTrace(e); |
|
| 2904 | 2781 |
} |
| 2905 | 2782 |
|
| 2906 | 2783 |
return false; |
| ... | ... | |
| 2946 | 2823 |
} |
| 2947 | 2824 |
|
| 2948 | 2825 |
@Override |
| 2949 |
public boolean usingCorpus(Corpus corpus) {
|
|
| 2950 |
return this.corpus.getName().equals(corpus.getName());
|
|
| 2826 |
public boolean isResultUsingParent(TXMResult parent) {
|
|
| 2827 |
return this.concordance.getParent().getName().equals(parent.getName());
|
|
| 2951 | 2828 |
} |
| 2952 | 2829 |
|
| 2953 | 2830 |
@Override |
| 2954 |
public boolean updateCorpus(Corpus corpus) {
|
|
| 2955 |
ConcordanceEditorInput input = (ConcordanceEditorInput) this.getEditorInput(); |
|
| 2956 |
input.setCorpus(corpus); |
|
| 2957 |
input.setResult(null); |
|
| 2958 |
initializeEditor(); |
|
| 2959 |
return true; |
|
| 2831 |
public void computeResult() {
|
|
| 2832 |
// TODO Auto-generated method stub |
|
| 2833 |
|
|
| 2960 | 2834 |
} |
| 2835 |
|
|
| 2836 |
@Override |
|
| 2837 |
protected void initializeFields() {
|
|
| 2838 |
if (this.concordance == null) {
|
|
| 2839 |
leftContextSize = TXMPreferences.getInt(ConcordancePreferences.LEFT_CONTEXT_SIZE, ConcordancePreferences.PREFERENCES_NODE); |
|
| 2840 |
rightContextSize = TXMPreferences.getInt(ConcordancePreferences.RIGHT_CONTEXT_SIZE, ConcordancePreferences.PREFERENCES_NODE); |
|
| 2841 |
|
|
| 2842 |
selectedLeftViewProperties = new ArrayList<Property>(); |
|
| 2843 |
selectedRightViewProperties = new ArrayList<Property>(); |
|
| 2844 |
selectedKeywordViewProperties = new ArrayList<Property>(); |
|
| 2845 |
|
|
| 2846 |
//set default view property |
|
| 2847 |
Property defaultViewProperty = availableKeywordViewProperties.get(0); |
|
| 2848 |
if(!defaultViewProperty.getName().equals("word")) //$NON-NLS-1$
|
|
| 2849 |
for(int i = 0 ; i < availableKeywordViewProperties.size() ; i++ ) |
|
| 2850 |
if (availableKeywordViewProperties.get(i).getName().equals("word")) //$NON-NLS-1$
|
|
| 2851 |
{
|
|
| 2852 |
defaultViewProperty = availableKeywordViewProperties.get(i); |
|
| 2853 |
break; |
|
| 2854 |
} |
|
| 2855 |
|
|
| 2856 |
availableKeywordViewProperties.remove(defaultViewProperty); |
|
| 2857 |
availableLeftViewProperties.remove(defaultViewProperty); |
|
| 2858 |
availableRightViewProperties.remove(defaultViewProperty); |
|
| 2859 |
selectedLeftViewProperties.add(defaultViewProperty); |
|
| 2860 |
selectedRightViewProperties.add(defaultViewProperty); |
|
| 2861 |
selectedKeywordViewProperties.add(defaultViewProperty); |
|
| 2862 |
|
|
| 2863 |
//set default sort property |
|
| 2864 |
selectedLeftSortProperties = new ArrayList<Property>(); |
|
| 2865 |
selectedRightSortProperties = new ArrayList<Property>(); |
|
| 2866 |
selectedKeywordSortProperties = new ArrayList<Property>(); |
|
| 2867 |
|
|
| 2868 |
Property defaultSortProperty = availableKeywordSortProperties.get(0); |
|
| 2869 |
if(!defaultSortProperty.getName().equals("word")) //$NON-NLS-1$
|
|
| 2870 |
for(int i = 0 ; i < availableKeywordSortProperties.size() ; i++ ) |
|
| 2871 |
if (availableKeywordSortProperties.get(i).getName().equals("word")) //$NON-NLS-1$
|
|
| 2872 |
{
|
|
| 2873 |
defaultSortProperty = availableKeywordSortProperties.get(i); |
|
| 2874 |
break; |
|
| 2875 |
} |
|
| 2876 |
|
|
| 2877 |
availableKeywordSortProperties.remove(defaultSortProperty); |
|
| 2878 |
availableLeftSortProperties.remove(defaultSortProperty); |
|
| 2879 |
availableRightSortProperties.remove(defaultSortProperty); |
|
| 2880 |
selectedLeftSortProperties.add(defaultSortProperty); |
|
| 2881 |
selectedRightSortProperties.add(defaultSortProperty); |
|
| 2882 |
selectedKeywordSortProperties.add(defaultSortProperty); |
|
| 2883 |
|
|
| 2884 |
this.refViewPattern = new ReferencePattern(); |
|
| 2885 |
this.refSortPattern = new ReferencePattern(); |
|
| 2886 |
try { // set the default reference is there is one
|
|
| 2887 |
if (corpus.getProperty("ref") != null) //$NON-NLS-1$
|
|
| 2888 |
{
|
|
| 2889 |
refViewPattern.addProperty(corpus.getProperty("ref")); //$NON-NLS-1$
|
|
| 2890 |
refSortPattern.addProperty(corpus.getProperty("ref")); //$NON-NLS-1$
|
|
| 2891 |
} else {
|
|
| 2892 |
if (corpus.getStructuralUnit("text") != null) //$NON-NLS-1$
|
|
| 2893 |
if (corpus.getStructuralUnit("text").getProperty("id") != null) //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 2894 |
{
|
|
| 2895 |
refViewPattern.addProperty(corpus.getStructuralUnit("text").getProperty("id")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 2896 |
refSortPattern.addProperty(corpus.getStructuralUnit("text").getProperty("id")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 2897 |
} |
|
| 2898 |
} |
|
| 2899 |
} catch (CqiClientException e) {
|
|
| 2900 |
System.out.println(NLS.bind(Messages.ConcordancesEditor_43, corpus.getName(), e)); |
|
| 2901 |
} |
|
| 2902 |
} else {
|
|
| 2903 |
leftContextSize = concordance.getLeftContextSize(); |
|
| 2904 |
rightContextSize = concordance.getRightContextSize(); |
|
| 2905 |
|
|
| 2906 |
selectedLeftViewProperties = concordance.getLeftViewProperties(); |
|
| 2907 |
selectedRightViewProperties = concordance.getRightViewProperties(); |
|
| 2908 |
selectedKeywordViewProperties = concordance.getKeywordViewProperties(); |
|
| 2909 |
availableKeywordViewProperties.remove(selectedKeywordViewProperties); |
|
| 2910 |
availableLeftViewProperties.remove(selectedLeftViewProperties); |
|
| 2911 |
availableRightViewProperties.remove(selectedRightViewProperties); |
|
| 2912 |
|
|
| 2913 |
selectedLeftSortProperties = concordance.getLeftAnalysisProperties(); |
|
| 2914 |
selectedRightSortProperties = concordance.getRightAnalysisProperties(); |
|
| 2915 |
selectedKeywordSortProperties = concordance.getKeywordAnalysisProperties(); |
|
| 2916 |
availableKeywordSortProperties.remove(selectedKeywordSortProperties); |
|
| 2917 |
availableLeftSortProperties.remove(selectedLeftSortProperties); |
|
| 2918 |
availableRightSortProperties.remove(selectedRightSortProperties); |
|
| 2919 |
|
|
| 2920 |
this.refViewPattern = concordance.getRefViewPattern(); |
|
| 2921 |
this.refSortPattern = concordance.getRefAnalysePattern(); |
|
| 2922 |
} |
|
| 2923 |
|
|
| 2924 |
} |
|
| 2961 | 2925 |
} |
| tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/handlers/ComputeConcordance.java (revision 491) | ||
|---|---|---|
| 35 | 35 |
import org.eclipse.ui.IEditorPart; |
| 36 | 36 |
import org.eclipse.ui.PartInitException; |
| 37 | 37 |
import org.txm.concordance.core.functions.Concordance; |
| 38 |
import org.txm.concordance.rcp.editors.ConcordanceEditorInput;
|
|
| 38 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
|
| 39 | 39 |
import org.txm.rcp.Messages; |
| 40 | 40 |
import org.txm.rcp.StatusLine; |
| 41 | 41 |
import org.txm.rcp.TXMWindows; |
| 42 |
import org.txm.rcp.editors.TXMResultEditorInput; |
|
| 42 | 43 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
| 43 | 44 |
import org.txm.rcp.views.corpora.CorporaView; |
| 44 | 45 |
import org.txm.searchengine.cqp.CQPEngine; |
| ... | ... | |
| 52 | 53 |
*/ |
| 53 | 54 |
public class ComputeConcordance extends BaseAbstractHandler {
|
| 54 | 55 |
|
| 55 |
|
|
| 56 |
|
|
| 57 | 56 |
// adds a double click listener to the Corpus View |
| 58 | 57 |
static {
|
| 59 | 58 |
CorporaView.addDoubleClickListener(Concordance.class, ComputeConcordance.class); |
| 60 | 59 |
} |
| 61 | 60 |
|
| 62 |
|
|
| 63 |
|
|
| 64 | 61 |
@Override |
| 65 | 62 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
| 66 | 63 |
|
| 67 | 64 |
Object selection = this.getSelection(); |
| 68 |
if (!(selection instanceof Corpus)) |
|
| 69 |
return null; |
|
| 70 |
Corpus corpus = (Corpus) selection; |
|
| 71 |
if (openEditor(corpus)) {
|
|
| 72 |
|
|
| 73 |
} else {
|
|
| 65 |
if (!openEditor(selection)) {
|
|
| 74 | 66 |
System.out.println(Messages.ComputeConcordance_1); |
| 75 | 67 |
} |
| 76 | 68 |
|
| ... | ... | |
| 78 | 70 |
} |
| 79 | 71 |
|
| 80 | 72 |
@Inject |
| 81 |
public static boolean openEditor(Corpus corpus) {
|
|
| 73 |
public static boolean openEditor(Object o) {
|
|
| 74 |
|
|
| 82 | 75 |
if (!CQPEngine.isInitialized()) {
|
| 83 | 76 |
System.out.println("SearchEngine is not ready. Aborting.");
|
| 84 | 77 |
return false; |
| 85 | 78 |
} |
| 86 | 79 |
|
| 87 |
ConcordanceEditorInput editorInput = new ConcordanceEditorInput(corpus, null); |
|
| 88 |
|
|
| 89 |
// FIXME: MD: test of manipulating the editor's position in the UI |
|
| 90 |
/* |
|
| 91 |
Workbench wb = (Workbench) PlatformUI.getWorkbench(); |
|
| 92 |
|
|
| 93 |
System.out.println("Workbench: " + wb);
|
|
| 94 |
for (IWorkbenchWindow iwindow : wb.getWorkbenchWindows()) {
|
|
| 95 |
WorkbenchWindow window = (WorkbenchWindow) iwindow; |
|
| 96 |
|
|
| 97 |
System.out.println(" Window: "+window);
|
|
| 98 |
for (IWorkbenchPage ipage :window.getPages()) {
|
|
| 99 |
WorkbenchPage page = (WorkbenchPage)ipage; |
|
| 100 |
System.out.println(" Page: "+page);
|
|
| 101 |
|
|
| 102 |
for (IEditorReference ieditor : page.getInternalEditorReferences()) {
|
|
| 103 |
EditorReference editor = (EditorReference)ieditor; |
|
| 104 |
System.out.println(" Editor: "+editor+" "+editor.getId());
|
|
| 105 |
System.out.println(" part: "+ieditor.getPart(false));
|
|
| 106 |
} |
|
| 107 |
for (IEditorPart dirtyEditor : page.getDirtyEditors()) {
|
|
| 108 |
System.out.println(" IEditorPart: "+dirtyEditor);
|
|
| 109 |
} |
|
| 110 |
|
|
| 111 |
for (ISaveablePart dirtyPart : page.getDirtyParts()) {
|
|
| 112 |
System.out.println(" ISaveablePart: "+dirtyPart);
|
|
| 113 |
} |
|
| 114 |
|
|
| 115 |
for (EditorReference editorref : page.getInternalEditorReferences()) {
|
|
| 116 |
System.out.println(" EditorReference: "+editorref+" "+editorref.getId());
|
|
| 117 |
} |
|
| 118 |
// for (IViewReference viewref : page.getViewReferences()) {
|
|
| 119 |
// System.out.println(" IViewReference: "+viewref+" "+viewref.getId());
|
|
| 120 |
// } |
|
| 121 |
for (IWorkingSet iworkingset : page.getWorkingSets()) {
|
|
| 122 |
WorkingSet workingset = (WorkingSet)iworkingset; |
|
| 123 |
System.out.println(" WorkingSet: "+workingset+" "+workingset.getId());
|
|
| 124 |
for (IAdaptable a : workingset.getElements()) {
|
|
| 125 |
System.out.println(" IAdaptable: "+a);
|
|
| 126 |
} |
|
| 127 |
} |
|
| 128 |
|
|
| 129 |
MWindow modelwindow = window.getModel(); |
|
| 130 |
|
|
| 131 |
System.out.println("MWindow: "+modelwindow);
|
|
| 132 |
for (MWindowElement elem : modelwindow.getChildren()) {
|
|
| 133 |
if (elem instanceof PartSashContainerImpl) {
|
|
| 134 |
printChildren(elem, " "); |
|
| 135 |
// PartSashContainerImpl psc = (PartSashContainerImpl)elem; |
|
| 136 |
// System.out.println(" PartSashContainerImpl: "+psc);
|
|
| 137 |
// for (MPartSashContainerElement elem2 : psc.getChildren()) {
|
|
| 138 |
// |
|
| 139 |
// if (elem2 instanceof PerspectiveStackImpl) {
|
|
| 140 |
// PerspectiveStackImpl psi = (PerspectiveStackImpl)elem2; |
|
| 141 |
// System.out.println(" PerspectiveStackImpl: "+psi);
|
|
| 142 |
// for (MPerspective p : psi.getChildren()) {
|
|
| 143 |
// System.out.println(" MPerspective: "+p);
|
|
| 144 |
// for (MPartSashContainerElement elem3 : p.getChildren()) {
|
|
| 145 |
// if (elem3 instanceof PartSashContainerImpl) {
|
|
| 146 |
// PartSashContainerImpl psci = (PartSashContainerImpl)elem3; |
|
| 147 |
// printChildren(psci, " "); |
|
| 148 |
// } else {
|
|
| 149 |
// System.out.println(" MPartSashContainerElement: "+elem3);
|
|
| 150 |
// } |
|
| 151 |
// } |
|
| 152 |
// } |
|
| 153 |
// } else if (elem2 instanceof PartStackImpl) {
|
|
| 154 |
// PartStackImpl psi = (PartStackImpl)elem2; |
|
| 155 |
// System.out.println(" PartStackImpl: "+psi);
|
|
| 156 |
// for (MStackElement e : psi.getChildren()) {
|
|
| 157 |
// System.out.println(" MStackElement: "+e);
|
|
| 158 |
// } |
|
| 159 |
// } else {
|
|
| 160 |
// System.out.println(" MPartSashContainerElement: "+elem2+" id="+elem2.getElementId());
|
|
| 161 |
// } |
|
| 162 |
// } |
|
| 163 |
} else {
|
|
| 164 |
System.out.println(" MWindowElement: "+elem);
|
|
| 165 |
} |
|
| 166 |
} |
|
| 167 |
} |
|
| 80 |
Concordance concordance = null; |
|
| 81 |
if (o instanceof Corpus) {
|
|
| 82 |
Corpus corpus = (Corpus) o; |
|
| 83 |
concordance = new Concordance(corpus); |
|
| 84 |
} else if (o instanceof Concordance) {
|
|
| 85 |
concordance = (Concordance)o; |
|
| 86 |
} else {
|
|
| 87 |
System.out.println("Could not call ComputeConcordance with: "+o);
|
|
| 88 |
return false; |
|
| 168 | 89 |
} |
| 169 |
*/ |
|
| 90 |
|
|
| 91 |
TXMResultEditorInput editorInput = new TXMResultEditorInput(concordance); |
|
| 92 |
|
|
| 170 | 93 |
try {
|
| 171 | 94 |
StatusLine.setMessage(Messages.ComputeConcordance_0); |
| 172 |
IEditorPart editor = TXMWindows.getActiveWindow().getActivePage().openEditor(editorInput, "ConcordanceEditor"); //$NON-NLS-1$ |
|
| 173 |
|
|
| 174 |
// WorkbenchWindow window = (WorkbenchWindow)TXMWindows.getActiveWindow(); |
|
| 175 |
// MWindow model = window.getModel(); |
|
| 176 |
// EModelService modelService = model.getContext().get(EModelService.class); |
|
| 177 |
// EPartService partService = model.getContext().get(EPartService.class); |
|
| 178 |
// modelService.find("org.eclipse.ui.editorss", model); // find org.eclipse.ui.editorss?
|
|
| 179 |
// MPart part = partService.createPart("org.txm.rcp.editors.ConcordancesEditor");
|
|
| 180 |
//// NEXT STEPS : find partStack, add the part, show the part http://stackoverflow.com/questions/26912078/open-an-editing-partas-an-editor-in-previous-eclipse-versions-in-eclipse-rcp-4 |
|
| 181 |
// ? direct access to PlaceholderImpl : elementId=org.eclipse.ui.editorss |
|
| 182 |
if (editor == null) return false; |
|
| 183 |
|
|
| 95 |
IEditorPart editor = TXMWindows.getActiveWindow().getActivePage().openEditor(editorInput, ConcordanceEditor.class.getName()); //$NON-NLS-1$ |
|
| 96 |
if (editor == null) return false; |
|
| 184 | 97 |
} catch (PartInitException e) {
|
| 185 | 98 |
System.err.println(NLS.bind(Messages.GetConcordances_4, e)); |
| 186 | 99 |
e.printStackTrace(); |
| 187 | 100 |
} |
| 188 | 101 |
return true; |
| 189 | 102 |
} |
| 190 |
|
|
| 191 |
// FIXME: tests |
|
| 192 |
// private static void printChildren(Object o, String space) {
|
|
| 193 |
// |
|
| 194 |
// System.out.println(space+o.getClass().getSimpleName()+": "+o); |
|
| 195 |
// |
|
| 196 |
// if (o instanceof PlaceholderImpl) {
|
|
| 197 |
// PlaceholderImpl phi = (PlaceholderImpl)o; |
|
| 198 |
// System.out.println("phi: "+phi);
|
|
| 199 |
// } else if (o instanceof PartSashContainerImpl) {
|
|
| 200 |
// PartSashContainerImpl psci = (PartSashContainerImpl)o; |
|
| 201 |
// for (MPartSashContainerElement e :psci.getChildren()) {
|
|
| 202 |
// printChildren(e, space+" "); |
|
| 203 |
// } |
|
| 204 |
// } else if (o instanceof PerspectiveStackImpl) {
|
|
| 205 |
// PerspectiveStackImpl psi = (PerspectiveStackImpl)o; |
|
| 206 |
// for (MPerspective p : psi.getChildren()) {
|
|
| 207 |
// printChildren(p,space+" "); |
|
| 208 |
// } |
|
| 209 |
// } else if (o instanceof MPerspective) {
|
|
| 210 |
// MPerspective p = (MPerspective)o; |
|
| 211 |
// for (MPartSashContainerElement e : p.getChildren()) {
|
|
| 212 |
// printChildren(e, space+" "); |
|
| 213 |
// } |
|
| 214 |
// } else if (o instanceof PartStackImpl) {
|
|
| 215 |
// PartStackImpl psi = (PartStackImpl)o; |
|
| 216 |
// for (MStackElement e : psi.getChildren()) {
|
|
| 217 |
// printChildren(e, space+" "); |
|
| 218 |
// } |
|
| 219 |
// } |
|
| 220 |
// } |
|
| 221 | 103 |
} |
| tmp/org.txm.concordance.rcp/plugin.xml (revision 491) | ||
|---|---|---|
| 35 | 35 |
allPopups="false" |
| 36 | 36 |
locationURI="popup:org.txm.rcp.views.CorporaView"> |
| 37 | 37 |
<command |
| 38 |
commandId="ComputeConcordance" |
|
| 38 |
commandId="org.txm.concordance.rcp.handlers.ComputeConcordance"
|
|
| 39 | 39 |
icon="icons/concordance.png" |
| 40 | 40 |
style="push"> |
| 41 | 41 |
<visibleWhen |
| ... | ... | |
| 51 | 51 |
<menuContribution |
| 52 | 52 |
locationURI="menu:menu.tools"> |
| 53 | 53 |
<command |
| 54 |
commandId="ComputeConcordance" |
|
| 54 |
commandId="org.txm.concordance.rcp.handlers.ComputeConcordance"
|
|
| 55 | 55 |
icon="icons/concordance.png" |
| 56 | 56 |
style="push"> |
| 57 | 57 |
<visibleWhen |
| ... | ... | |
| 68 | 68 |
allPopups="false" |
| 69 | 69 |
locationURI="toolbar:org.txm.rcp.toolbartools"> |
| 70 | 70 |
<command |
| 71 |
commandId="ComputeConcordance" |
|
| 71 |
commandId="org.txm.concordance.rcp.handlers.ComputeConcordance"
|
|
| 72 | 72 |
icon="icons/concordance.png" |
| 73 | 73 |
style="push" |
| 74 | 74 |
tooltip="%command.tooltip"> |
| ... | ... | |
| 85 | 85 |
<menuContribution |
| 86 | 86 |
locationURI="popup:org.txm.rcp.editors.ConcordancesEditor"> |
| 87 | 87 |
<command |
| 88 |
commandId="DeleteConcordanceLines" |
|
| 88 |
commandId="org.txm.concordance.rcp.handlers.DeleteLines" |
|
| 89 |
icon="platform:/plugin/org.txm.rcp/icons/cross.png" |
|
| 89 | 90 |
style="push"> |
| 90 | 91 |
</command> |
| 91 | 92 |
</menuContribution> |
| ... | ... | |
| 95 | 96 |
<command |
| 96 | 97 |
categoryId="org.txm.rcp.category.txm" |
| 97 | 98 |
defaultHandler="org.txm.concordance.rcp.handlers.ComputeConcordance" |
| 98 |
id="ComputeConcordance" |
|
| 99 |
id="org.txm.concordance.rcp.handlers.ComputeConcordance"
|
|
| 99 | 100 |
name="%command.name"> |
| 100 | 101 |
</command> |
| 101 | 102 |
<command |
| 102 | 103 |
defaultHandler="org.txm.concordance.rcp.handlers.DeleteLines" |
| 103 |
id="DeleteConcordanceLines"
|
|
| 104 |
id="org.txm.concordance.rcp.handlers.DeleteLines"
|
|
| 104 | 105 |
name="%command.name.37"> |
| 105 | 106 |
</command> |
| 106 | 107 |
</extension> |
| tmp/org.txm.ca.rcp/plugin.xml (revision 491) | ||
|---|---|---|
| 14 | 14 |
allPopups="false" |
| 15 | 15 |
locationURI="toolbar:org.txm.rcp.toolbartools"> |
| 16 | 16 |
<command |
| 17 |
commandId="ComputeCA" |
|
| 17 |
commandId="org.txm.ca.rcp.handlers.ComputeCA"
|
|
| 18 | 18 |
icon="icons/ca.png" |
| 19 | 19 |
style="push"> |
| 20 | 20 |
<visibleWhen |
| ... | ... | |
| 37 | 37 |
allPopups="false" |
| 38 | 38 |
locationURI="popup:org.txm.rcp.views.CorporaView"> |
| 39 | 39 |
<command |
| 40 |
commandId="ComputeCA" |
|
| 40 |
commandId="org.txm.ca.rcp.handlers.ComputeCA"
|
|
| 41 | 41 |
icon="icons/ca.png" |
| 42 | 42 |
style="push"> |
| 43 | 43 |
<visibleWhen |
| ... | ... | |
| 59 | 59 |
<menuContribution |
| 60 | 60 |
locationURI="menu:menu.tools"> |
| 61 | 61 |
<command |
| 62 |
commandId="ComputeCA" |
|
| 62 |
commandId="org.txm.ca.rcp.handlers.ComputeCA"
|
|
| 63 | 63 |
icon="icons/ca.png" |
| 64 | 64 |
style="push"> |
| 65 | 65 |
<visibleWhen |
| ... | ... | |
| 84 | 84 |
<command |
| 85 | 85 |
categoryId="org.txm.rcp.category.txm" |
| 86 | 86 |
defaultHandler="org.txm.ca.rcp.handlers.ComputeCA" |
| 87 |
id="ComputeCA" |
|
| 87 |
id="org.txm.ca.rcp.handlers.ComputeCA"
|
|
| 88 | 88 |
name="%command.name"> |
| 89 | 89 |
</command> |
| 90 | 90 |
</extension> |
| tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/handlers/ComputeCA.java (revision 491) | ||
|---|---|---|
| 40 | 40 |
import org.eclipse.ui.handlers.HandlerUtil; |
| 41 | 41 |
import org.txm.ca.core.functions.CA; |
| 42 | 42 |
import org.txm.ca.core.functions.ICAComputable; |
| 43 |
import org.txm.ca.rcp.editors.CAEditor; |
|
| 43 | 44 |
import org.txm.ca.rcp.messages.CAUIMessages; |
| 44 | 45 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
| 46 |
import org.txm.lexicaltable.core.functions.LexicalTableFactory; |
|
| 45 | 47 |
import org.txm.lexicaltable.rcp.editors.LexicalTableDialog; |
| 46 | 48 |
import org.txm.rcp.editors.TXMResultEditorInput; |
| 47 | 49 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
| ... | ... | |
| 52 | 54 |
import org.txm.rcp.views.corpora.CorporaView; |
| 53 | 55 |
import org.txm.searchengine.cqp.corpus.Partition; |
| 54 | 56 |
import org.txm.searchengine.cqp.corpus.Property; |
| 57 |
import org.txm.utils.logger.Log; |
|
| 55 | 58 |
import org.txm.utils.logger.MessageBox; |
| 56 | 59 |
|
| 57 | 60 |
/** |
| ... | ... | |
| 82 | 85 |
/** The Lexical Table. */ |
| 83 | 86 |
private LexicalTable lexicaltable; |
| 84 | 87 |
|
| 85 |
|
|
| 86 |
|
|
| 88 |
|
|
| 89 |
|
|
| 87 | 90 |
// adds a double click listener to the Corpus View |
| 88 | 91 |
static {
|
| 89 | 92 |
CorporaView.addDoubleClickListener(CA.class, ComputeCA.class); |
| 90 | 93 |
} |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 94 | 97 |
/* (non-Javadoc) |
| 95 | 98 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
| 96 | 99 |
*/ |
| 97 | 100 |
@Override |
| 98 | 101 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
| 99 |
|
|
| 100 |
ca = null; |
|
| 101 |
|
|
| 102 |
|
|
| 102 | 103 |
if (!this.checkStatsEngine()) {
|
| 103 | 104 |
return null; |
| 104 | 105 |
} |
| 105 |
|
|
| 106 |
|
|
| 106 | 107 |
final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); |
| 107 | 108 |
final Object selection = this.getSelection(); |
| 108 |
|
|
| 109 |
int code = 0; |
|
| 110 |
// Create CA from partition |
|
| 111 |
if (selection instanceof Partition) {
|
|
| 112 |
partition = (Partition) selection; |
|
| 113 |
//warning to few parts |
|
| 114 |
if (partition.getNPart() < 4) {
|
|
| 115 |
MessageDialog d = new MessageDialog( |
|
| 116 |
window.getShell(), |
|
| 117 |
CAUIMessages.ComputeCorrespondanceAnalysis_3, |
|
| 118 |
null, |
|
| 119 |
NLS.bind(CAUIMessages.ComputeCorrespondanceAnalysis_4, partition.getNPart()), |
|
| 120 |
0, |
|
| 121 |
new String[] { CAUIMessages.ComputeCorrespondanceAnalysis_6 },
|
|
| 122 |
0); |
|
| 123 |
d.open(); |
|
| 124 |
return null; |
|
| 125 |
} |
|
| 126 |
//ask property and Fmins and Vmax |
|
| 127 |
String title = Messages.bind(CAUIMessages.ComputeCorrespondanceAnalysisDialog_0, partition.getName()); |
|
| 128 |
LexicalTableDialog d = new LexicalTableDialog( |
|
| 129 |
window.getShell(), partition.getCorpus(), title); |
|
| 130 |
code = d.open(); |
|
| 131 |
if (code == Window.OK) {
|
|
| 132 |
property = d.getProperty(); |
|
| 133 |
fmin = d.getFmin(); |
|
| 134 |
vmax = d.getMaxLines(); |
|
| 135 |
} |
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
// final Property property = d.getProperty(); |
|
| 115 |
String statusmessage; |
|
| 116 |
if (partition != null) {
|
|
| 117 |
statusmessage = NLS.bind(CAUIMessages.ComputeCorrespondanceAnalysis_0, partition.getName(), property); |
|
| 136 | 118 |
} |
| 137 |
// Create CA from Lexical Table |
|
| 138 |
else if (selection instanceof LexicalTable) {
|
|
| 139 |
lexicaltable = (LexicalTable) selection; |
|
| 140 |
property = lexicaltable.getProperty(); |
|
| 141 |
partition = lexicaltable.getPartition(); |
|
| 142 |
if (lexicaltable.getNColumns() < 4) {
|
|
| 143 |
MessageBox.error(CAUIMessages.ComputeCorrespondanceAnalysis_13); |
|
| 144 |
return null; |
|
| 145 |
} |
|
| 146 |
if (lexicaltable.getNRows() < 4) {
|
|
| 147 |
MessageBox.error(CAUIMessages.ComputeCorrespondanceAnalysis_1); |
|
| 148 |
return null; |
|
| 149 |
} |
|
| 150 |
code = Window.OK; |
|
| 119 |
else {
|
|
| 120 |
statusmessage = NLS.bind(CAUIMessages.ComputeCorrespondanceAnalysis_0, selection, "<none>"); //$NON-NLS-1$ |
|
| 151 | 121 |
} |
| 152 |
// Reopens an existing editor |
|
| 153 |
else if (selection instanceof CA) {
|
|
| 154 |
ca = (CA) selection; |
|
| 155 |
partition = ca.getPartition(); |
|
| 156 |
} |
|
| 157 |
// From others |
|
| 158 |
else if (selection instanceof ICAComputable) {
|
|
| 159 |
partition = ((ICAComputable) selection).getPartition(); |
|
| 160 |
} |
|
| 161 | 122 |
|
| 162 |
if (code == Window.OK) {
|
|
| 163 |
// final Property property = d.getProperty(); |
|
| 164 |
String statusmessage; |
|
| 165 |
if (partition != null) {
|
|
| 166 |
statusmessage = NLS.bind(CAUIMessages.ComputeCorrespondanceAnalysis_0, partition.getName(), property); |
|
| 167 |
} |
|
| 168 |
else {
|
|
| 169 |
statusmessage = NLS.bind(CAUIMessages.ComputeCorrespondanceAnalysis_0, selection, "<none>"); //$NON-NLS-1$ |
|
| 170 |
} |
|
| 171 |
|
|
| 172 |
System.out.println(statusmessage); |
|
| 173 |
JobHandler jobhandler = new JobHandler(statusmessage) {
|
|
| 174 |
@Override |
|
| 175 |
protected IStatus run(IProgressMonitor monitor) {
|
|
| 176 |
this.runInit(monitor); |
|
| 177 |
try {
|
|
| 178 |
JobsTimer.start(); |
|
| 179 |
monitor.beginTask("", 100); //$NON-NLS-1$
|
|
| 180 |
monitor.subTask(CAUIMessages.ComputeCorrespondanceAnalysis_15); |
|
| 123 |
System.out.println(statusmessage); |
|
| 124 |
JobHandler jobhandler = new JobHandler(statusmessage) {
|
|
| 125 |
@Override |
|
| 126 |
protected IStatus run(IProgressMonitor monitor) {
|
|
| 127 |
this.runInit(monitor); |
|
| 128 |
try {
|
|
| 129 |
JobsTimer.start(); |
|
| 181 | 130 |
|
| 182 |
if (ca == null) {
|
|
| 183 |
if (selection instanceof Partition) {
|
|
| 184 |
ca = new CA(partition, property, fmin, vmax); |
|
| 185 |
} |
|
| 186 |
else if (selection instanceof LexicalTable) {
|
|
| 187 |
ca = new CA(lexicaltable); |
|
| 188 |
} |
|
| 189 |
else if (selection instanceof ICAComputable) {
|
|
| 190 |
ca = ((ICAComputable) selection).toCA(); |
|
| 191 |
} |
|
| 192 |
|
|
| 193 |
if (selection instanceof Partition) {
|
|
| 194 |
if (monitor.isCanceled()) return Status.CANCEL_STATUS; |
|
| 195 |
monitor.subTask(CAUIMessages.ComputeCorrespondanceAnalysis_16); |
|
| 196 |
|
|
| 197 |
this.acquireSemaphore(); |
|
| 198 |
ca.stepLexicalTable(); |
|
| 199 |
this.releaseSemaphore(); |
|
| 200 |
|
|
| 201 |
this.acquireSemaphore(); |
|
| 202 |
ca.stepSortTableLexical(); |
|
| 203 |
this.releaseSemaphore(); |
|
| 204 |
} |
|
| 205 |
|
|
| 206 |
monitor.worked(20); |
|
| 131 |
monitor.beginTask("", 100); //$NON-NLS-1$
|
|
| 132 |
monitor.subTask(CAUIMessages.ComputeCorrespondanceAnalysis_15); |
|
| 133 |
CA ca = null; |
|
| 207 | 134 |
|
| 208 |
if (monitor.isCanceled()) return Status.CANCEL_STATUS; |
|
| 135 |
if (selection instanceof Partition) { // Create CA from partition -> need a LexicalTable
|
|
| 136 |
partition = (Partition) selection; |
|
| 137 |
//warning to few parts |
|
| 138 |
if (partition.getNPart() < 4) {
|
|
| 139 |
MessageDialog d = new MessageDialog( |
|
| 140 |
window.getShell(), |
|
| 141 |
CAUIMessages.ComputeCorrespondanceAnalysis_3, |
|
| 142 |
null, |
|
| 143 |
NLS.bind(CAUIMessages.ComputeCorrespondanceAnalysis_4, partition.getNPart()), |
|
| 144 |
0, |
|
| 145 |
new String[] { CAUIMessages.ComputeCorrespondanceAnalysis_6 },
|
|
| 146 |
0); |
|
| 147 |
d.open(); |
|
| 148 |
return null; |
|
| 149 |
} |
|
| 150 |
//ask property and Fmins and Vmax |
|
| 151 |
String title = Messages.bind(CAUIMessages.ComputeCorrespondanceAnalysisDialog_0, partition.getName()); |
|
| 152 |
LexicalTableDialog d = new LexicalTableDialog( |
|
| 153 |
window.getShell(), partition.getCorpus(), title); |
|
| 154 |
if (d.open() == LexicalTableDialog.OK) {
|
|
| 155 |
property = d.getProperty(); |
|
| 156 |
fmin = d.getFmin(); |
|
| 157 |
vmax = d.getMaxLines(); |
|
| 209 | 158 |
|
| 210 |
monitor.subTask(CAUIMessages.ComputeCorrespondanceAnalysis_17); |
|
| 211 |
this.acquireSemaphore(); |
|
| 212 |
ca.stepCompute(); |
|
| 213 |
this.releaseSemaphore(); |
|
| 214 |
|
|
| 215 |
ca.getLexicalTable().addResult(ca); |
|
| 159 |
try {
|
|
| 160 |
LexicalTable table = LexicalTableFactory.getLexicalTable(partition, property, fmin); |
|
| 161 |
} catch (Exception e) {
|
|
| 162 |
System.out.println("Error: cannot create the lexical table: "+e);
|
|
| 163 |
Log.printStackTrace(e); |
|
| 164 |
} |
|
| 165 |
} |
|
| 166 |
} else if (selection instanceof LexicalTable) { // Create CA from Lexical Table
|
|
| 167 |
lexicaltable = (LexicalTable) selection; |
|
| 168 |
property = lexicaltable.getProperty(); |
|
| 169 |
partition = lexicaltable.getPartition(); |
|
| 216 | 170 |
|
| 171 |
if (lexicaltable.getNColumns() < 4) {
|
|
| 172 |
MessageBox.error(CAUIMessages.ComputeCorrespondanceAnalysis_13); |
|
| 173 |
return null; |
|
| 217 | 174 |
} |
| 218 |
|
|
| 219 |
if (ca == null) {
|
|
| 220 |
return Status.CANCEL_STATUS;
|
|
| 175 |
if (lexicaltable.getNRows() < 4) {
|
|
| 176 |
MessageBox.error(CAUIMessages.ComputeCorrespondanceAnalysis_1);
|
|
| 177 |
return null;
|
|
| 221 | 178 |
} |
| 222 | 179 |
|
| 223 |
|
|
| 224 |
monitor.worked(20); |
|
| 225 |
monitor.subTask(CAUIMessages.ComputeCorrespondanceAnalysis_8); |
|
| 180 |
ca = new CA(lexicaltable); |
|
| 181 |
} else if (selection instanceof CA) { // Reopens an existing editor
|
|
| 182 |
ca = (CA) selection; |
|
| 183 |
} else {
|
|
| 184 |
System.out.println("Error: cannot compute a CA with current selection: "+selection);
|
|
| 185 |
} |
|
| 226 | 186 |
|
| 227 |
syncExec(new Runnable() {
|
|
| 228 |
@Override |
|
| 229 |
public void run() {
|
|
| 230 |
try {
|
|
| 231 |
IWorkbenchPage page = window.getActivePage(); |
|
| 232 |
TXMResultEditorInput editorInput = new TXMResultEditorInput(ca); |
|
| 233 |
StatusLine.setMessage(CAUIMessages.ComputeCorrespondanceAnalysis_14); |
|
| 234 |
page.openEditor(editorInput, "CAEditor"); //$NON-NLS-1$ |
|
| 235 |
StatusLine.setMessage(CAUIMessages.ComputeCorrespondanceAnalysis_14); |
|
| 236 |
} catch (Exception e) {
|
|
| 237 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 238 |
} |
|
| 187 |
if (ca == null) {
|
|
| 188 |
System.out.println("Error: ca is null");
|
|
| 189 |
return Status.CANCEL_STATUS; |
|
| 190 |
} |
|
| 239 | 191 |
|
| 240 |
} |
|
| 241 |
}); |
|
| 242 |
monitor.worked(50); |
|
| 192 |
monitor.worked(20); |
|
| 243 | 193 |
|
| 244 |
monitor.subTask(Messages.RefreshingCorporaView);
|
|
| 194 |
if (monitor.isCanceled()) return Status.CANCEL_STATUS;
|
|
| 245 | 195 |
|
| 246 |
//FIXME: doesn't work, why? |
|
| 247 |
//CorporaView.refreshObject(ca); |
|
| 248 |
|
|
| 249 |
// syncExec(new Runnable() {
|
|
| 250 |
// @Override |
|
| 251 |
// public void run() {
|
|
| 252 |
// CorporaView.refresh(); |
|
| 253 |
// CorporaView.expand(ca.getParent()); |
|
| 254 |
// } |
|
| 255 |
// }); |
|
| 196 |
// monitor.subTask(CAUIMessages.ComputeCorrespondanceAnalysis_17); |
|
| 197 |
// this.acquireSemaphore(); |
|
| 198 |
// ca.stepCompute(); |
|
| 199 |
// this.releaseSemaphore(); |
|
| 200 |
// |
|
| 201 |
// ca.getLexicalTable().addResult(ca); |
|
| 256 | 202 |
|
| 257 |
monitor.worked(100); |
|
| 258 |
} catch (ThreadDeath td) {
|
|
| 259 |
return Status.CANCEL_STATUS; |
|
| 260 |
} catch (Exception e) {
|
|
| 261 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 262 |
} finally {
|
|
| 263 |
monitor.done(); |
|
| 264 |
JobsTimer.stopAndPrint(); |
|
| 265 |
} |
|
| 266 |
return Status.OK_STATUS; |
|
| 203 |
monitor.worked(20); |
|
| 204 |
monitor.subTask(CAUIMessages.ComputeCorrespondanceAnalysis_8); |
|
| 205 |
|
|
| 206 |
final TXMResultEditorInput editorInput = new TXMResultEditorInput(ca); |
|
| 207 |
syncExec(new Runnable() {
|
|
| 208 |
@Override |
|
| 209 |
public void run() {
|
|
| 210 |
try {
|
|
| 211 |
IWorkbenchPage page = window.getActivePage(); |
|
| 212 |
StatusLine.setMessage(CAUIMessages.ComputeCorrespondanceAnalysis_14); |
|
| 213 |
page.openEditor(editorInput, CAEditor.class.getName()); //$NON-NLS-1$ |
|
| 214 |
|
|
| 215 |
CorporaView.refresh(); |
|
| 216 |
} catch (Exception e) {
|
|
| 217 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 218 |
} |
|
| 219 |
} |
|
| 220 |
}); |
|
| 221 |
monitor.worked(60); |
|
| 222 |
|
|
| 223 |
} catch (ThreadDeath td) {
|
|
| 224 |
return Status.CANCEL_STATUS; |
|
| 225 |
} catch (Exception e) {
|
|
| 226 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 227 |
} finally {
|
|
| 228 |
monitor.done(); |
|
| 229 |
JobsTimer.stopAndPrint(); |
|
| 267 | 230 |
} |
| 268 |
}; |
|
| 269 |
jobhandler.startJob(); |
|
| 270 |
} |
|
| 231 |
return Status.OK_STATUS; |
|
| 232 |
} |
|
| 233 |
}; |
|
| 234 |
jobhandler.startJob(); |
|
| 271 | 235 |
return null; |
| 272 | 236 |
} |
| 273 | 237 |
} |
| tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAEditor.java (revision 491) | ||
|---|---|---|
| 62 | 62 |
import org.eclipse.ui.part.EditorPart; |
| 63 | 63 |
import org.txm.ca.core.chartsengine.base.Utils; |
| 64 | 64 |
import org.txm.ca.core.functions.CA; |
Formats disponibles : Unified diff