Révision 553
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 553) | ||
---|---|---|
1998 | 1998 |
} |
1999 | 1999 |
|
2000 | 2000 |
@Override |
2001 |
public boolean isResultUsingParent(TXMResult parent) { |
|
2002 |
return this.concordance.getParent().getName().equals(parent.getName()); |
|
2003 |
} |
|
2004 |
|
|
2005 |
@Override |
|
2006 | 2001 |
public Concordance getResultData() { |
2007 | 2002 |
return concordance; |
2008 | 2003 |
} |
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesEditor.java (revision 553) | ||
---|---|---|
401 | 401 |
this.fillDisplay(); |
402 | 402 |
super.refresh(update); |
403 | 403 |
} |
404 |
|
|
405 | 404 |
|
406 |
|
|
407 | 405 |
|
408 | 406 |
/** |
409 | 407 |
* Fills display. |
... | ... | |
471 | 469 |
|
472 | 470 |
|
473 | 471 |
|
474 |
@Override |
|
475 |
public boolean isResultUsingParent(TXMResult parent) { |
|
476 |
if (this.getResultData() == null) { |
|
477 |
return false; |
|
478 |
} |
|
479 |
if (this.getResultData().getCorpus() == null) { |
|
480 |
return false; |
|
481 |
} |
|
482 |
return this.getResultData().getCorpus().getName().equals(parent.getName()); |
|
483 |
} |
|
484 |
|
|
485 | 472 |
|
486 |
|
|
487 |
|
|
488 | 473 |
// FIXME: old method |
489 | 474 |
// @Override |
490 | 475 |
// public void computeResult() { |
tmp/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java (revision 553) | ||
---|---|---|
834 | 834 |
&& this.getLexicalTable().getNColumns() > 3 |
835 | 835 |
; |
836 | 836 |
} |
837 |
|
|
837 |
|
|
838 | 838 |
@Override |
839 | 839 |
public boolean saveParameters() { |
840 |
// TODO Auto-generated method stub |
|
841 |
System.err.println("CA.saveParameters(): not yet implemented."); |
|
840 | 842 |
return true; |
841 | 843 |
} |
844 |
|
|
845 |
@Override |
|
846 |
public boolean setParameters(TXMParameters parameters) { |
|
847 |
// TODO Auto-generated method stub |
|
848 |
System.err.println("CA.setParameters(): not yet implemented."); |
|
849 |
return true; |
|
850 |
} |
|
842 | 851 |
} |
tmp/org.txm.ca.core/src/org/txm/ca/core/functions/Eigenvalues.java (revision 553) | ||
---|---|---|
6 | 6 |
import java.io.File; |
7 | 7 |
|
8 | 8 |
import org.txm.chartsengine.core.results.ChartResult; |
9 |
import org.txm.core.results.TXMParameters; |
|
9 | 10 |
import org.txm.core.results.TXMResult; |
10 | 11 |
|
11 | 12 |
/** |
... | ... | |
73 | 74 |
public boolean canCompute() throws Exception { |
74 | 75 |
return this.parent != null; |
75 | 76 |
} |
77 |
|
|
78 |
@Override |
|
79 |
public boolean saveParameters() { |
|
80 |
// TODO Auto-generated method stub |
|
81 |
System.err.println("Eigenvalues.saveParameters(): not yet implemented."); |
|
82 |
return true; |
|
83 |
} |
|
76 | 84 |
|
85 |
@Override |
|
86 |
public boolean setParameters(TXMParameters parameters) { |
|
87 |
// TODO Auto-generated method stub |
|
88 |
System.err.println("Eigenvalues.setParameters(): not yet implemented."); |
|
89 |
return true; |
|
90 |
} |
|
91 |
|
|
92 |
|
|
93 |
|
|
77 | 94 |
/* (non-Javadoc) |
78 | 95 |
* @see org.txm.core.results.TXMResult#_compute(boolean) |
79 | 96 |
*/ |
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java (revision 553) | ||
---|---|---|
37 | 37 |
import java.util.Arrays; |
38 | 38 |
import java.util.List; |
39 | 39 |
|
40 |
import org.txm.core.results.TXMParameters; |
|
40 | 41 |
import org.txm.core.results.TXMResult; |
41 | 42 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
42 | 43 |
import org.txm.lexicon.core.corpusengine.cqp.Lexicon; |
... | ... | |
614 | 615 |
public void setMaxScore(int maxScore) { |
615 | 616 |
this.pMaxScore = maxScore; |
616 | 617 |
} |
618 |
|
|
619 |
|
|
620 |
@Override |
|
621 |
public boolean saveParameters() { |
|
622 |
// TODO Auto-generated method stub |
|
623 |
System.err.println("Specificities.saveParameters(): not yet implemented."); |
|
624 |
return true; |
|
625 |
} |
|
617 | 626 |
|
627 |
@Override |
|
628 |
public boolean setParameters(TXMParameters parameters) { |
|
629 |
// TODO Auto-generated method stub |
|
630 |
System.err.println("Specificities.setParameters(): not yet implemented."); |
|
631 |
return true; |
|
632 |
} |
|
633 |
|
|
634 |
|
|
635 |
|
|
636 |
|
|
637 |
|
|
618 | 638 |
} |
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/SpecificitiesSelection.java (revision 553) | ||
---|---|---|
6 | 6 |
import java.io.File; |
7 | 7 |
|
8 | 8 |
import org.txm.chartsengine.core.results.ChartResult; |
9 |
import org.txm.core.results.TXMParameters; |
|
9 | 10 |
|
10 | 11 |
/** |
11 | 12 |
* A selection from a Specificities result dedicated to export or chart creation. |
... | ... | |
138 | 139 |
*/ |
139 | 140 |
@Override |
140 | 141 |
protected boolean _compute(boolean update) throws Exception { |
142 |
// does nothing |
|
143 |
return true; |
|
144 |
} |
|
145 |
|
|
146 |
|
|
147 |
@Override |
|
148 |
public boolean saveParameters() { |
|
141 | 149 |
// TODO Auto-generated method stub |
150 |
System.err.println("SpecificitiesSelection.saveParameters(): not yet implemented."); |
|
142 | 151 |
return true; |
143 | 152 |
} |
144 | 153 |
|
154 |
@Override |
|
155 |
public boolean setParameters(TXMParameters parameters) { |
|
156 |
// TODO Auto-generated method stub |
|
157 |
System.err.println("SpecificitiesSelection.setParameters(): not yet implemented."); |
|
158 |
return true; |
|
159 |
} |
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
145 | 164 |
/* (non-Javadoc) |
146 | 165 |
* @see org.txm.core.results.TXMResult#toTxt(java.io.File, java.lang.String, java.lang.String, java.lang.String) |
147 | 166 |
*/ |
tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/Chi2.java (revision 553) | ||
---|---|---|
57 | 57 |
return itable != null; |
58 | 58 |
} |
59 | 59 |
|
60 |
@Override |
|
61 |
public boolean saveParameters() { |
|
62 |
// TODO Auto-generated method stub |
|
63 |
System.err.println("Chi2.saveParameters(): not yet implemented."); |
|
64 |
return true; |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public boolean setParameters(TXMParameters parameters) { |
|
69 |
// TODO Auto-generated method stub |
|
70 |
System.err.println("Chi2.setParameters(): not yet implemented."); |
|
71 |
return true; |
|
72 |
} |
|
73 |
|
|
60 | 74 |
} |
tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/Specificites2.java (revision 553) | ||
---|---|---|
53 | 53 |
public boolean canCompute() { |
54 | 54 |
return itable != null; |
55 | 55 |
} |
56 |
|
|
57 |
@Override |
|
58 |
public boolean saveParameters() { |
|
59 |
// TODO Auto-generated method stub |
|
60 |
System.err.println("Specificites2.saveParameters(): not yet implemented."); |
|
61 |
return true; |
|
62 |
} |
|
56 | 63 |
|
64 |
@Override |
|
65 |
public boolean setParameters(TXMParameters parameters) { |
|
66 |
// TODO Auto-generated method stub |
|
67 |
System.err.println("Specificites2.setParameters(): not yet implemented."); |
|
68 |
return true; |
|
69 |
} |
|
70 |
|
|
71 |
|
|
57 | 72 |
} |
tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/RelativeFrequency.java (revision 553) | ||
---|---|---|
1 | 1 |
package org.txm.functions.contrasts; |
2 | 2 |
|
3 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
4 | 3 |
import org.txm.core.messages.TXMCoreMessages; |
5 | 4 |
import org.txm.core.results.TXMParameters; |
6 | 5 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
7 | 6 |
import org.txm.lexicaltable.core.statsengine.data.ILexicalTable; |
8 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
9 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
10 |
import org.txm.searchengine.cqp.corpus.Partition; |
|
11 |
import org.txm.searchengine.cqp.corpus.Property; |
|
12 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
|
13 |
import org.txm.statsengine.core.StatException; |
|
14 | 7 |
import org.txm.statsengine.r.core.RWorkspace; |
15 | 8 |
|
16 | 9 |
public class RelativeFrequency extends Contrast { |
... | ... | |
63 | 56 |
return itable != null; |
64 | 57 |
} |
65 | 58 |
|
59 |
@Override |
|
60 |
public boolean saveParameters() { |
|
61 |
// TODO Auto-generated method stub |
|
62 |
System.err.println("RelativeFrequency.saveParameters(): not yet implemented."); |
|
63 |
return true; |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public boolean setParameters(TXMParameters parameters) { |
|
68 |
// TODO Auto-generated method stub |
|
69 |
System.err.println("RelativeFrequency.setParameters(): not yet implemented."); |
|
70 |
return true; |
|
71 |
} |
|
72 |
|
|
73 |
|
|
66 | 74 |
} |
tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/AbsoluteFrequency.java (revision 553) | ||
---|---|---|
16 | 16 |
super(table); |
17 | 17 |
} |
18 | 18 |
|
19 |
public boolean setParameters(TXMParameters parameters) { |
|
20 |
return false; |
|
21 |
} |
|
22 |
|
|
23 | 19 |
@Override |
24 | 20 |
protected boolean _compute(boolean update) throws StatException { |
25 | 21 |
itable = table.getData(); |
... | ... | |
58 | 54 |
return itable != null; |
59 | 55 |
} |
60 | 56 |
|
57 |
@Override |
|
58 |
public boolean saveParameters() { |
|
59 |
// TODO Auto-generated method stub |
|
60 |
System.err.println("AbsoluteFrequency.saveParameters(): not yet implemented."); |
|
61 |
return true; |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public boolean setParameters(TXMParameters parameters) { |
|
66 |
// TODO Auto-generated method stub |
|
67 |
System.err.println("AbsoluteFrequency.setParameters(): not yet implemented."); |
|
68 |
return true; |
|
69 |
} |
|
70 |
|
|
61 | 71 |
} |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/DeleteLines.java (revision 553) | ||
---|---|---|
36 | 36 |
import org.eclipse.swt.widgets.Shell; |
37 | 37 |
import org.eclipse.ui.IWorkbenchPart; |
38 | 38 |
import org.eclipse.ui.handlers.HandlerUtil; |
39 |
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor2;
|
|
39 |
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor; |
|
40 | 40 |
import org.txm.rcp.RCPMessages; |
41 | 41 |
/** |
42 | 42 |
* Allow the user to delete lines in a Lexical Table. |
... | ... | |
58 | 58 |
|
59 | 59 |
IWorkbenchPart editor = HandlerUtil.getActiveWorkbenchWindow(event) |
60 | 60 |
.getActivePage().getActivePart(); |
61 |
if (editor instanceof LexicalTableEditor2) {
|
|
62 |
LexicalTableEditor2 LTeditor = (LexicalTableEditor2) editor;
|
|
61 |
if (editor instanceof LexicalTableEditor) { |
|
62 |
LexicalTableEditor LTeditor = (LexicalTableEditor) editor;
|
|
63 | 63 |
deleteLexicalTableLines(LTeditor); |
64 | 64 |
} |
65 | 65 |
return null; |
66 | 66 |
} |
67 | 67 |
|
68 |
public static void deleteLexicalTableLines(LexicalTableEditor2 LTeditor) {
|
|
68 |
public static void deleteLexicalTableLines(LexicalTableEditor LTeditor) { |
|
69 | 69 |
int[] selection = LTeditor.getlineTableViewer().getTable() |
70 | 70 |
.getSelectionIndices(); |
71 | 71 |
if (selection.length == 0) |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/___MergeCols.java (revision 553) | ||
---|---|---|
40 | 40 |
import org.eclipse.ui.IWorkbenchPart; |
41 | 41 |
import org.eclipse.ui.handlers.HandlerUtil; |
42 | 42 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
43 |
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor2;
|
|
43 |
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor; |
|
44 | 44 |
import org.txm.rcp.RCPMessages; |
45 | 45 |
import org.txm.statsengine.core.StatException; |
46 | 46 |
/** |
... | ... | |
59 | 59 |
|
60 | 60 |
IWorkbenchPart editor = HandlerUtil.getActiveWorkbenchWindow(event) |
61 | 61 |
.getActivePage().getActivePart(); |
62 |
if (editor instanceof LexicalTableEditor2) {
|
|
63 |
LexicalTableEditor2 LTeditor = (LexicalTableEditor2) editor;
|
|
62 |
if (editor instanceof LexicalTableEditor) { |
|
63 |
LexicalTableEditor LTeditor = (LexicalTableEditor) editor;
|
|
64 | 64 |
int[] selection = LTeditor.getlineTableViewer().getTable() |
65 | 65 |
.getSelectionIndices(); |
66 | 66 |
if (selection.length == 0) |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/ImportTable.java (revision 553) | ||
---|---|---|
37 | 37 |
import org.eclipse.swt.widgets.Shell; |
38 | 38 |
import org.eclipse.ui.IWorkbenchPart; |
39 | 39 |
import org.eclipse.ui.handlers.HandlerUtil; |
40 |
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor2;
|
|
40 |
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor; |
|
41 | 41 |
import org.txm.rcp.swt.dialog.LastOpened; |
42 | 42 |
|
43 | 43 |
// TODO: Auto-generated Javadoc |
... | ... | |
54 | 54 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
55 | 55 |
IWorkbenchPart editor = HandlerUtil.getActiveWorkbenchWindow(event) |
56 | 56 |
.getActivePage().getActivePart(); |
57 |
if (editor instanceof LexicalTableEditor2) {
|
|
58 |
LexicalTableEditor2 LTeditor = (LexicalTableEditor2) editor;
|
|
57 |
if (editor instanceof LexicalTableEditor) { |
|
58 |
LexicalTableEditor LTeditor = (LexicalTableEditor) editor;
|
|
59 | 59 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event) |
60 | 60 |
.getShell(); |
61 | 61 |
FileDialog d = new FileDialog(shell, SWT.OPEN); |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/ComputeLexicalTable.java (revision 553) | ||
---|---|---|
41 | 41 |
import org.eclipse.jface.viewers.LabelProvider; |
42 | 42 |
import org.eclipse.jface.window.Window; |
43 | 43 |
import org.eclipse.osgi.util.NLS; |
44 |
import org.eclipse.swt.widgets.Display; |
|
44 | 45 |
import org.eclipse.ui.IWorkbenchPage; |
45 | 46 |
import org.eclipse.ui.IWorkbenchWindow; |
46 | 47 |
import org.eclipse.ui.PartInitException; |
... | ... | |
54 | 55 |
import org.txm.lexicaltable.core.preferences.LexicalTablePreferences; |
55 | 56 |
import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl; |
56 | 57 |
import org.txm.lexicaltable.rcp.editors.LexicalTableDialog; |
57 |
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor2;
|
|
58 |
import org.txm.lexicaltable.rcp.editors.LexicalTableEditorInput; |
|
58 |
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor; |
|
59 |
import org.txm.lexicaltable.rcp.editors.___LexicalTableEditorInput;
|
|
59 | 60 |
import org.txm.rcp.JobsTimer; |
60 | 61 |
import org.txm.rcp.RCPMessages; |
61 | 62 |
import org.txm.rcp.StatusLine; |
63 |
import org.txm.rcp.editors.TXMEditorPart; |
|
62 | 64 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
63 | 65 |
import org.txm.rcp.utils.JobHandler; |
64 | 66 |
import org.txm.rcp.views.QueriesView; |
65 | 67 |
import org.txm.rcp.views.corpora.CorporaView; |
66 | 68 |
import org.txm.searchengine.cqp.corpus.Partition; |
67 | 69 |
import org.txm.searchengine.cqp.corpus.Property; |
68 |
import org.txm.statsengine.r.core.data.QuantitativeDataStructureImpl; |
|
69 | 70 |
import org.txm.statsengine.r.rcp.views.RVariablesView; |
70 |
import org.txm.utils.logger.Log; |
|
71 | 71 |
// TODO: Auto-generated Javadoc |
72 | 72 |
/** |
73 | 73 |
* if the selection is a Partition : creates a lexical table already filled if |
... | ... | |
108 | 108 |
return null; |
109 | 109 |
} |
110 | 110 |
|
111 |
window = HandlerUtil.getActiveWorkbenchWindow(event); |
|
112 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
113 |
|
|
114 |
Object s = selection.getFirstElement(); |
|
115 |
|
|
116 |
if (s instanceof Index) { |
|
117 |
List<Index> vocabularies = selection.toList(); |
|
118 |
|
|
111 |
Object selection = this.getSelection(event); |
|
112 |
LexicalTable lexicalTable = null; |
|
113 |
|
|
114 |
// Creating from Index |
|
115 |
if (selection instanceof Index) { |
|
116 |
List<Index> vocabularies = ((IStructuredSelection) HandlerUtil.getCurrentSelection(event)).toList(); |
|
117 |
|
|
119 | 118 |
System.out.println(RCPMessages.ComputeLexicalTable_3); |
120 | 119 |
ArrayList<String> choices = new ArrayList<String>(); |
121 | 120 |
choices.add(RCPMessages.ComputeLexicalTable_16); |
... | ... | |
131 | 130 |
//System.out.println("ret= "+ret); |
132 | 131 |
if (ret == Dialog.OK_OPTION) { |
133 | 132 |
//System.out.println("ok"); |
134 |
if(dialog.getResult().length == 0) |
|
133 |
if(dialog.getResult().length == 0) {
|
|
135 | 134 |
return null; |
135 |
} |
|
136 | 136 |
String sel = (String) dialog.getResult()[0]; |
137 |
if(sel.equals(RCPMessages.ComputeLexicalTable_16)) |
|
137 |
if(sel.equals(RCPMessages.ComputeLexicalTable_16)) {
|
|
138 | 138 |
useAllOccurrences = true; |
139 |
} |
|
139 | 140 |
} else { |
140 | 141 |
//System.out.println("cancel"); |
141 | 142 |
return false; |
142 | 143 |
} |
143 | 144 |
|
144 |
computeWithVocabularies(vocabularies, useAllOccurrences); |
|
145 |
return null; |
|
145 |
//computeWithVocabularies(vocabularies, useAllOccurrences);
|
|
146 |
//return null;
|
|
146 | 147 |
// } else if (s instanceof QueryIndex) { |
147 | 148 |
// List<QueryIndex> qindexes = selection.toList(); |
148 | 149 |
// computeWithQueryIndexes(qindexes); |
149 | 150 |
// return null; |
150 |
} else if (s instanceof Partition) { |
|
151 |
computeWithPartition((Partition) s); |
|
152 |
return null; |
|
153 |
} else if (s instanceof LexicalTable) { |
|
154 |
computeWithLexicalTableAble((LexicalTable) s); |
|
155 |
return null; |
|
156 |
} else |
|
157 |
return null; |
|
158 |
} |
|
159 |
|
|
160 |
/** |
|
161 |
* Compute with partition. |
|
162 |
* |
|
163 |
* @param partition the partition |
|
164 |
*/ |
|
165 |
private void computeWithLexicalTableAble(final LexicalTable lexicalTableAble) { |
|
166 |
|
|
167 |
JobHandler jobhandler = new JobHandler( |
|
168 |
RCPMessages.ComputeLexicalTable_0) { |
|
169 |
@Override |
|
170 |
protected IStatus run(IProgressMonitor monitor) { |
|
171 |
this.runInit(monitor); |
|
172 |
try { |
|
173 |
JobsTimer.start(); |
|
174 |
monitor.beginTask(NLS.bind(RCPMessages.ComputeLexicalTable_1, lexicalTableAble.getName(), "none"), 100); |
|
175 |
|
|
176 |
this.acquireSemaphore(); |
|
177 |
//table = lexicalTableAble.toLexicalTable(); |
|
178 |
table = lexicalTableAble; |
|
179 |
this.releaseSemaphore(); |
|
180 |
|
|
181 |
monitor.worked(45); |
|
182 |
|
|
183 |
lexicalTableAble.getParent().addChild(table); |
|
184 |
|
|
185 |
monitor.worked(5); |
|
186 |
|
|
187 |
//monitor.subTask(Messages.ComputeSpecifities_10); |
|
188 |
syncExec(new Runnable() { |
|
189 |
@Override |
|
190 |
public void run() { |
|
191 |
IWorkbenchPage page = window.getActivePage(); |
|
192 |
LexicalTableEditorInput editorInput = new LexicalTableEditorInput(table); |
|
193 |
try { |
|
194 |
StatusLine.setMessage(RCPMessages.ComputeLexicalTable_10); |
|
195 |
page.openEditor(editorInput, LexicalTableEditor2.ID); |
|
196 |
} catch (PartInitException e) { |
|
197 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
198 |
} |
|
199 |
} |
|
200 |
}); |
|
201 |
|
|
202 |
monitor.worked(50); |
|
203 |
if (monitor.isCanceled()) |
|
204 |
return Status.CANCEL_STATUS; |
|
205 |
|
|
206 |
//monitor.subTask(Messages.ComputeSpecifities_2); |
|
207 |
syncExec(new Runnable() { |
|
208 |
@Override |
|
209 |
public void run() { |
|
210 |
CorporaView.refresh(); |
|
211 |
CorporaView.expand(table.getParent()); |
|
212 |
QueriesView.refresh(); |
|
213 |
RVariablesView.refresh(); |
|
214 |
} |
|
215 |
}); |
|
216 |
|
|
217 |
monitor.worked(100); |
|
218 |
} catch (ThreadDeath td) { |
|
219 |
return Status.CANCEL_STATUS; |
|
220 |
} catch (Exception e) { |
|
221 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
222 |
} finally { |
|
223 |
monitor.done(); |
|
224 |
JobsTimer.stopAndPrint(); |
|
225 |
} |
|
226 |
return Status.OK_STATUS; |
|
151 |
} |
|
152 |
// Creating from Partition |
|
153 |
else if (selection instanceof Partition) { |
|
154 |
final Property property; |
|
155 |
final int Fmin; |
|
156 |
final int vmax; |
|
157 |
|
|
158 |
final Partition partition = (Partition) selection; |
|
159 |
|
|
160 |
String title = RCPMessages.bind(RCPMessages.ComputeLexicalTable_0, partition.getName()); |
|
161 |
|
|
162 |
LexicalTableDialog d = new LexicalTableDialog(Display.getDefault().getActiveShell(), partition.getCorpus(), title); |
|
163 |
d.setFminAndVMax(TXMPreferences.getInt(LexicalTablePreferences.F_MIN, LexicalTablePreferences.PREFERENCES_NODE), |
|
164 |
TXMPreferences.getInt(LexicalTablePreferences.V_MAX, LexicalTablePreferences.PREFERENCES_NODE)); |
|
165 |
|
|
166 |
if (d.open() == Window.OK) { |
|
167 |
property = d.getProperty(); |
|
168 |
Fmin = d.getFmin(); |
|
169 |
vmax = d.getMaxLines(); |
|
170 |
|
|
171 |
lexicalTable = new LexicalTable(partition, property, Fmin); |
|
172 |
lexicalTable.setVMax(vmax); |
|
173 |
|
|
174 |
|
|
175 |
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(CorporaView.ID); |
|
176 |
// JobHandler jobhandler = new JobHandler(RCPMessages.bind(RCPMessages.ComputeLexicalTable_0, partition.getName())) { |
|
177 |
// @Override |
|
178 |
// protected IStatus run(IProgressMonitor monitor) { |
|
179 |
// this.runInit(monitor); |
|
180 |
// try { |
|
181 |
// JobsTimer.start(); |
|
182 |
// monitor.beginTask(NLS.bind(RCPMessages.ComputeLexicalTable_1, partition.getName(), property), 100); |
|
183 |
// |
|
184 |
// this.acquireSemaphore(); |
|
185 |
// table = LexicalTableFactory.getLexicalTable(partition, property, Fmin); |
|
186 |
// this.releaseSemaphore(); |
|
187 |
// |
|
188 |
// this.acquireSemaphore(); |
|
189 |
// table.getData().cut(vmax); |
|
190 |
// this.releaseSemaphore(); |
|
191 |
// |
|
192 |
// monitor.worked(45); |
|
193 |
// if (monitor.isCanceled() || table == null) { |
|
194 |
// return Status.CANCEL_STATUS; |
|
195 |
// } |
|
196 |
// |
|
197 |
// partition.addChild(table); |
|
198 |
// |
|
199 |
// monitor.worked(5); |
|
200 |
// |
|
201 |
// //monitor.subTask(Messages.ComputeSpecifities_10); |
|
202 |
// syncExec(new Runnable() { |
|
203 |
// @Override |
|
204 |
// public void run() { |
|
205 |
// IWorkbenchPage page = window.getActivePage(); |
|
206 |
// LexicalTableEditorInput editorInput = new LexicalTableEditorInput(table); |
|
207 |
// try { |
|
208 |
// StatusLine.setMessage(RCPMessages.ComputeLexicalTable_10); |
|
209 |
// page.openEditor(editorInput, LexicalTableEditor.ID); //$NON-NLS-1$ |
|
210 |
// } catch (PartInitException e) { |
|
211 |
// org.txm.rcp.utils.Logger.printStackTrace(e); |
|
212 |
// } |
|
213 |
// } |
|
214 |
// }); |
|
215 |
// |
|
216 |
// monitor.worked(50); |
|
217 |
// if (monitor.isCanceled()) |
|
218 |
// return Status.CANCEL_STATUS; |
|
219 |
// |
|
220 |
// //monitor.subTask(Messages.ComputeSpecifities_2); |
|
221 |
// syncExec(new Runnable() { |
|
222 |
// @Override |
|
223 |
// public void run() { |
|
224 |
// QueriesView.refresh(); |
|
225 |
// RVariablesView.refresh(); |
|
226 |
// } |
|
227 |
// }); |
|
228 |
// |
|
229 |
// monitor.worked(100); |
|
230 |
// } catch (ThreadDeath td) { |
|
231 |
// return Status.CANCEL_STATUS; |
|
232 |
// } catch (Exception e) { |
|
233 |
// org.txm.rcp.utils.Logger.printStackTrace(e); |
|
234 |
// } finally { |
|
235 |
// monitor.done(); |
|
236 |
// JobsTimer.stopAndPrint(); |
|
237 |
// } |
|
238 |
// return Status.OK_STATUS; |
|
239 |
// } |
|
240 |
// }; |
|
241 |
// jobhandler.startJob(); |
|
227 | 242 |
} |
228 |
}; |
|
229 |
jobhandler.startJob(); |
|
230 |
|
|
231 |
return; |
|
232 |
} |
|
233 |
|
|
234 |
/** |
|
235 |
* Compute with partition. |
|
236 |
* |
|
237 |
* @param partition the partition |
|
238 |
*/ |
|
239 |
private void computeWithPartition(final Partition partition) { |
|
240 |
|
|
241 |
final Property property; |
|
242 |
final int Fmin; |
|
243 |
final int vmax; |
|
243 |
} |
|
244 |
// Reopening from existing result |
|
245 |
else if (selection instanceof LexicalTable) { |
|
246 |
lexicalTable = (LexicalTable) selection; |
|
247 |
} |
|
244 | 248 |
|
245 |
String title = RCPMessages.bind(RCPMessages.ComputeLexicalTable_0, partition.getName()); |
|
246 |
LexicalTableDialog d = new LexicalTableDialog(window.getShell(), partition.getCorpus(), title); |
|
249 |
TXMEditorPart.openEditor(lexicalTable, LexicalTableEditor.ID); |
|
247 | 250 |
|
248 |
d.setFminAndVMax(TXMPreferences.getInt(LexicalTablePreferences.F_MIN, LexicalTablePreferences.PREFERENCES_NODE), |
|
249 |
TXMPreferences.getInt(LexicalTablePreferences.V_MAX, LexicalTablePreferences.PREFERENCES_NODE)); |
|
250 |
|
|
251 |
if (d.open() == Window.OK) { |
|
252 |
property = d.getProperty(); |
|
253 |
Fmin = d.getFmin(); |
|
254 |
vmax = d.getMaxLines(); |
|
255 |
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(CorporaView.ID); |
|
256 |
JobHandler jobhandler = new JobHandler( |
|
257 |
RCPMessages.bind(RCPMessages.ComputeLexicalTable_0, partition.getName())) { |
|
258 |
@Override |
|
259 |
protected IStatus run(IProgressMonitor monitor) { |
|
260 |
this.runInit(monitor); |
|
261 |
try { |
|
262 |
JobsTimer.start(); |
|
263 |
monitor.beginTask(NLS.bind(RCPMessages.ComputeLexicalTable_1, partition.getName(), property), 100); |
|
251 |
return true; |
|
252 |
} |
|
264 | 253 |
|
265 |
this.acquireSemaphore(); |
|
266 |
table = LexicalTableFactory.getLexicalTable(partition, property, Fmin); |
|
267 |
this.releaseSemaphore(); |
|
268 |
|
|
269 |
this.acquireSemaphore(); |
|
270 |
table.getData().cut(vmax); |
|
271 |
this.releaseSemaphore(); |
|
254 |
// /** |
|
255 |
// * Compute with partition. |
|
256 |
// * |
|
257 |
// * @param partition the partition |
|
258 |
// */ |
|
259 |
// private void computeWithLexicalTableAble(final LexicalTable lexicalTableAble) { |
|
260 |
// |
|
261 |
// JobHandler jobhandler = new JobHandler( |
|
262 |
// RCPMessages.ComputeLexicalTable_0) { |
|
263 |
// @Override |
|
264 |
// protected IStatus run(IProgressMonitor monitor) { |
|
265 |
// this.runInit(monitor); |
|
266 |
// try { |
|
267 |
// JobsTimer.start(); |
|
268 |
// monitor.beginTask(NLS.bind(RCPMessages.ComputeLexicalTable_1, lexicalTableAble.getName(), "none"), 100); |
|
269 |
// |
|
270 |
// this.acquireSemaphore(); |
|
271 |
// //table = lexicalTableAble.toLexicalTable(); |
|
272 |
// table = lexicalTableAble; |
|
273 |
// this.releaseSemaphore(); |
|
274 |
// |
|
275 |
// monitor.worked(45); |
|
276 |
// |
|
277 |
// lexicalTableAble.getParent().addChild(table); |
|
278 |
// |
|
279 |
// monitor.worked(5); |
|
280 |
// |
|
281 |
// //monitor.subTask(Messages.ComputeSpecifities_10); |
|
282 |
// syncExec(new Runnable() { |
|
283 |
// @Override |
|
284 |
// public void run() { |
|
285 |
// IWorkbenchPage page = window.getActivePage(); |
|
286 |
// LexicalTableEditorInput editorInput = new LexicalTableEditorInput(table); |
|
287 |
// try { |
|
288 |
// StatusLine.setMessage(RCPMessages.ComputeLexicalTable_10); |
|
289 |
// page.openEditor(editorInput, LexicalTableEditor.ID); |
|
290 |
// } catch (PartInitException e) { |
|
291 |
// org.txm.rcp.utils.Logger.printStackTrace(e); |
|
292 |
// } |
|
293 |
// } |
|
294 |
// }); |
|
295 |
// |
|
296 |
// monitor.worked(50); |
|
297 |
// if (monitor.isCanceled()) |
|
298 |
// return Status.CANCEL_STATUS; |
|
299 |
// |
|
300 |
// //monitor.subTask(Messages.ComputeSpecifities_2); |
|
301 |
// syncExec(new Runnable() { |
|
302 |
// @Override |
|
303 |
// public void run() { |
|
304 |
// CorporaView.refresh(); |
|
305 |
// CorporaView.expand(table.getParent()); |
|
306 |
// QueriesView.refresh(); |
|
307 |
// RVariablesView.refresh(); |
|
308 |
// } |
|
309 |
// }); |
|
310 |
// |
|
311 |
// monitor.worked(100); |
|
312 |
// } catch (ThreadDeath td) { |
|
313 |
// return Status.CANCEL_STATUS; |
|
314 |
// } catch (Exception e) { |
|
315 |
// org.txm.rcp.utils.Logger.printStackTrace(e); |
|
316 |
// } finally { |
|
317 |
// monitor.done(); |
|
318 |
// JobsTimer.stopAndPrint(); |
|
319 |
// } |
|
320 |
// return Status.OK_STATUS; |
|
321 |
// } |
|
322 |
// }; |
|
323 |
// jobhandler.startJob(); |
|
324 |
// |
|
325 |
// return; |
|
326 |
// } |
|
272 | 327 |
|
273 |
monitor.worked(45); |
|
274 |
if (monitor.isCanceled() || table == null) { |
|
275 |
return Status.CANCEL_STATUS; |
|
276 |
} |
|
277 | 328 |
|
278 |
partition.addChild(table); |
|
279 | 329 |
|
280 |
monitor.worked(5); |
|
281 |
|
|
282 |
//monitor.subTask(Messages.ComputeSpecifities_10); |
|
283 |
syncExec(new Runnable() { |
|
284 |
@Override |
|
285 |
public void run() { |
|
286 |
IWorkbenchPage page = window.getActivePage(); |
|
287 |
LexicalTableEditorInput editorInput = new LexicalTableEditorInput(table); |
|
288 |
try { |
|
289 |
StatusLine.setMessage(RCPMessages.ComputeLexicalTable_10); |
|
290 |
page.openEditor(editorInput, LexicalTableEditor2.ID); //$NON-NLS-1$ |
|
291 |
} catch (PartInitException e) { |
|
292 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
293 |
} |
|
294 |
} |
|
295 |
}); |
|
296 |
|
|
297 |
monitor.worked(50); |
|
298 |
if (monitor.isCanceled()) |
|
299 |
return Status.CANCEL_STATUS; |
|
300 |
|
|
301 |
//monitor.subTask(Messages.ComputeSpecifities_2); |
|
302 |
syncExec(new Runnable() { |
|
303 |
@Override |
|
304 |
public void run() { |
|
305 |
QueriesView.refresh(); |
|
306 |
RVariablesView.refresh(); |
|
307 |
} |
|
308 |
}); |
|
309 |
|
|
310 |
monitor.worked(100); |
|
311 |
} catch (ThreadDeath td) { |
|
312 |
return Status.CANCEL_STATUS; |
|
313 |
} catch (Exception e) { |
|
314 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
315 |
} finally { |
|
316 |
monitor.done(); |
|
317 |
JobsTimer.stopAndPrint(); |
|
318 |
} |
|
319 |
return Status.OK_STATUS; |
|
320 |
} |
|
321 |
}; |
|
322 |
jobhandler.startJob(); |
|
323 |
} |
|
324 |
return; |
|
325 |
} |
|
326 |
|
|
327 | 330 |
// /** |
328 | 331 |
// * Compute with query index. |
329 | 332 |
// * |
... | ... | |
421 | 424 |
// return true; |
422 | 425 |
// } |
423 | 426 |
|
424 |
/** |
|
425 |
* Compute with vocabularies. |
|
426 |
* |
|
427 |
* @param fullvocabularies the fullvocabularies |
|
428 |
* @return true, if successful |
|
429 |
*/ |
|
430 |
private boolean computeWithVocabularies(List<Index> fullvocabularies, final boolean useAllOccurrences) { |
|
431 |
if (fullvocabularies.size() == 0) { |
|
432 |
return false; |
|
433 |
} |
|
434 |
|
|
435 |
final List<Index> vocabularies = fullvocabularies.subList(0, 1); |
|
436 |
for (Index voc : vocabularies) { |
|
437 |
if (!voc.isComputedWithPartition()) { |
|
438 |
System.out.println(RCPMessages.ComputeLexicalTable_5); |
|
439 |
StatusLine.setMessage(RCPMessages.ComputeLexicalTable_5); |
|
440 |
return false; |
|
441 |
} |
|
442 |
} |
|
443 |
|
|
444 |
List<Property> properties = vocabularies.get(0).getProperties(); |
|
445 |
for (Index voc : vocabularies) { |
|
446 |
if (!properties.equals(voc.getProperties())) { |
|
447 |
Log.warning(NLS.bind(RCPMessages.ComputeLexicalTable_6, properties)); |
|
448 |
return false; |
|
449 |
} |
|
450 |
} |
|
451 |
|
|
452 |
final Index firstIndex = vocabularies.get(0); |
|
453 |
Partition firstPartition = firstIndex.getPartition(); |
|
454 |
for (Index voc : vocabularies) { |
|
455 |
if (!firstPartition.equals(voc.getPartition())) { |
|
456 |
Log.warning(NLS.bind(RCPMessages.ComputeLexicalTable_7, firstPartition)); |
|
457 |
return false; |
|
458 |
} |
|
459 |
} |
|
460 |
|
|
461 |
final Property property = properties.get(0); |
|
462 |
|
|
463 |
JobHandler jobhandler = new JobHandler(RCPMessages.bind(RCPMessages.ComputeLexicalTable_0, firstIndex.getName())) { |
|
464 |
@Override |
|
465 |
protected IStatus run(IProgressMonitor monitor) { |
|
466 |
this.runInit(monitor); |
|
467 |
try { |
|
468 |
monitor.beginTask("Computing Lexical table with Index: "+firstIndex+" property: "+property, 100); |
|
469 |
this.acquireSemaphore(); |
|
470 |
table = new LexicalTable(firstIndex); |
|
471 |
table.setParameters(null, null, null, useAllOccurrences); |
|
472 |
table.compute(true, monitor); |
|
473 |
monitor.worked(45); |
|
474 |
this.releaseSemaphore(); |
|
475 |
if (monitor.isCanceled() || table == null) |
|
476 |
return Status.CANCEL_STATUS; |
|
477 |
|
|
478 |
firstIndex.addChild(table); |
|
479 |
monitor.worked(5); |
|
480 |
|
|
481 |
monitor.subTask(RCPMessages.ComputeLexicalTable_10); |
|
482 |
syncExec(new Runnable() { |
|
483 |
@Override |
|
484 |
public void run() { |
|
485 |
IWorkbenchPage page = window.getActivePage(); |
|
486 |
LexicalTableEditorInput editorInput = new LexicalTableEditorInput(table); |
|
487 |
try { |
|
488 |
StatusLine.setMessage(RCPMessages.ComputeLexicalTable_10); |
|
489 |
page.openEditor(editorInput, |
|
490 |
"org.txm.rcp.editors.lexicaltable.LexicalTableEditor"); //$NON-NLS-1$ |
|
491 |
} catch (PartInitException e) { |
|
492 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
493 |
} |
|
494 |
} |
|
495 |
}); |
|
496 |
|
|
497 |
monitor.worked(50); |
|
498 |
if (monitor.isCanceled()) |
|
499 |
return Status.CANCEL_STATUS; |
|
500 |
|
|
501 |
monitor.subTask(RCPMessages.ComputeSpecifities_2); |
|
502 |
syncExec(new Runnable() { |
|
503 |
@Override |
|
504 |
public void run() { |
|
505 |
CorporaView.refresh(); |
|
506 |
CorporaView.expand(table.getParent()); |
|
507 |
QueriesView.refresh(); |
|
508 |
RVariablesView.refresh(); |
|
509 |
} |
|
510 |
}); |
|
511 |
|
|
512 |
monitor.worked(100); |
|
513 |
} catch (ThreadDeath td) { |
|
514 |
return Status.CANCEL_STATUS; |
|
515 |
} catch (Exception e) { |
|
516 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
517 |
} finally { |
|
518 |
monitor.done(); |
|
519 |
} |
|
520 |
return Status.OK_STATUS; |
|
521 |
} |
|
522 |
}; |
|
523 |
jobhandler.startJob(); |
|
524 |
|
|
525 |
return true; |
|
526 |
} |
|
427 |
// /** |
|
428 |
// * Compute with vocabularies. |
|
429 |
// * |
|
430 |
// * @param fullvocabularies the fullvocabularies |
|
431 |
// * @return true, if successful |
|
432 |
// */ |
|
433 |
// private boolean computeWithVocabularies(List<Index> fullvocabularies, final boolean useAllOccurrences) { |
|
434 |
// if (fullvocabularies.size() == 0) { |
|
435 |
// return false; |
|
436 |
// } |
|
437 |
// |
|
438 |
// final List<Index> vocabularies = fullvocabularies.subList(0, 1); |
|
439 |
// for (Index voc : vocabularies) { |
|
440 |
// if (!voc.isComputedWithPartition()) { |
|
441 |
// System.out.println(RCPMessages.ComputeLexicalTable_5); |
|
442 |
// StatusLine.setMessage(RCPMessages.ComputeLexicalTable_5); |
|
443 |
// return false; |
|
444 |
// } |
|
445 |
// } |
|
446 |
// |
|
447 |
// List<Property> properties = vocabularies.get(0).getProperties(); |
|
448 |
// for (Index voc : vocabularies) { |
|
449 |
// if (!properties.equals(voc.getProperties())) { |
|
450 |
// Log.warning(NLS.bind(RCPMessages.ComputeLexicalTable_6, properties)); |
|
451 |
// return false; |
|
452 |
// } |
|
453 |
// } |
|
454 |
// |
|
455 |
// final Index firstIndex = vocabularies.get(0); |
|
456 |
// Partition firstPartition = firstIndex.getPartition(); |
|
457 |
// for (Index voc : vocabularies) { |
|
458 |
// if (!firstPartition.equals(voc.getPartition())) { |
|
459 |
// Log.warning(NLS.bind(RCPMessages.ComputeLexicalTable_7, firstPartition)); |
|
460 |
// return false; |
|
461 |
// } |
|
462 |
// } |
|
463 |
// |
|
464 |
// final Property property = properties.get(0); |
|
465 |
// |
|
466 |
// JobHandler jobhandler = new JobHandler(RCPMessages.bind(RCPMessages.ComputeLexicalTable_0, firstIndex.getName())) { |
|
467 |
// @Override |
|
468 |
// protected IStatus run(IProgressMonitor monitor) { |
|
469 |
// this.runInit(monitor); |
|
470 |
// try { |
|
471 |
// monitor.beginTask("Computing Lexical table with Index: "+firstIndex+" property: "+property, 100); |
|
472 |
// this.acquireSemaphore(); |
|
473 |
// table = new LexicalTable(firstIndex); |
|
474 |
// table.setParameters(null, null, null, useAllOccurrences); |
|
475 |
// table.compute(true, monitor); |
|
476 |
// monitor.worked(45); |
|
477 |
// this.releaseSemaphore(); |
|
478 |
// if (monitor.isCanceled() || table == null) |
|
479 |
// return Status.CANCEL_STATUS; |
|
480 |
// |
|
481 |
// firstIndex.addChild(table); |
|
482 |
// monitor.worked(5); |
|
483 |
// |
|
484 |
// monitor.subTask(RCPMessages.ComputeLexicalTable_10); |
|
485 |
// syncExec(new Runnable() { |
|
486 |
// @Override |
|
487 |
// public void run() { |
|
488 |
// IWorkbenchPage page = window.getActivePage(); |
|
489 |
// LexicalTableEditorInput editorInput = new LexicalTableEditorInput(table); |
|
490 |
// try { |
|
491 |
// StatusLine.setMessage(RCPMessages.ComputeLexicalTable_10); |
|
492 |
// page.openEditor(editorInput, |
|
493 |
// "org.txm.rcp.editors.lexicaltable.LexicalTableEditor"); //$NON-NLS-1$ |
|
494 |
// } catch (PartInitException e) { |
|
495 |
// org.txm.rcp.utils.Logger.printStackTrace(e); |
|
496 |
// } |
|
497 |
// } |
|
498 |
// }); |
|
499 |
// |
|
500 |
// monitor.worked(50); |
|
501 |
// if (monitor.isCanceled()) |
|
502 |
// return Status.CANCEL_STATUS; |
|
503 |
// |
|
504 |
// monitor.subTask(RCPMessages.ComputeSpecifities_2); |
|
505 |
// syncExec(new Runnable() { |
|
506 |
// @Override |
|
507 |
// public void run() { |
|
508 |
// CorporaView.refresh(); |
|
509 |
// CorporaView.expand(table.getParent()); |
|
510 |
// QueriesView.refresh(); |
|
511 |
// RVariablesView.refresh(); |
|
512 |
// } |
|
513 |
// }); |
|
514 |
// |
|
515 |
// monitor.worked(100); |
|
516 |
// } catch (ThreadDeath td) { |
|
517 |
// return Status.CANCEL_STATUS; |
|
518 |
// } catch (Exception e) { |
|
519 |
// org.txm.rcp.utils.Logger.printStackTrace(e); |
|
520 |
// } finally { |
|
521 |
// monitor.done(); |
|
522 |
// } |
|
523 |
// return Status.OK_STATUS; |
|
524 |
// } |
|
525 |
// }; |
|
526 |
// jobhandler.startJob(); |
|
527 |
// |
|
528 |
// return true; |
|
529 |
// } |
|
530 |
|
|
531 |
|
|
532 |
|
|
533 |
|
|
527 | 534 |
} |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/MergeLines.java (revision 553) | ||
---|---|---|
39 | 39 |
import org.eclipse.ui.IWorkbenchPart; |
40 | 40 |
import org.eclipse.ui.handlers.HandlerUtil; |
41 | 41 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
42 |
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor2;
|
|
42 |
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor; |
|
43 | 43 |
import org.txm.lexicaltable.rcp.messages.LexicalTableUIMessages; |
44 | 44 |
import org.txm.rcp.RCPMessages; |
45 | 45 |
import org.txm.rcp.StatusLine; |
... | ... | |
60 | 60 |
|
61 | 61 |
IWorkbenchPart editor = HandlerUtil.getActiveWorkbenchWindow(event) |
62 | 62 |
.getActivePage().getActivePart(); |
63 |
if (editor instanceof LexicalTableEditor2) {
|
|
64 |
LexicalTableEditor2 LTeditor = (LexicalTableEditor2) editor;
|
|
63 |
if (editor instanceof LexicalTableEditor) { |
|
64 |
LexicalTableEditor LTeditor = (LexicalTableEditor) editor;
|
|
65 | 65 |
int[] selection = LTeditor.getlineTableViewer().getTable() |
66 | 66 |
.getSelectionIndices(); |
67 | 67 |
if (selection.length == 0) |
... | ... | |
90 | 90 |
* @param newname the newname |
91 | 91 |
* @param selection the selection |
92 | 92 |
*/ |
93 |
static public void mergeLines(LexicalTableEditor2 LTeditor, String newname,
|
|
93 |
static public void mergeLines(LexicalTableEditor LTeditor, String newname, |
|
94 | 94 |
int[] selection) { |
95 | 95 |
// sum the lines |
96 | 96 |
StatusLine.setMessage(LexicalTableUIMessages.LexicalTableEditor_18); |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/ExportLexicalTable.java (revision 553) | ||
---|---|---|
37 | 37 |
import org.eclipse.swt.widgets.Shell; |
38 | 38 |
import org.eclipse.ui.IWorkbenchPart; |
39 | 39 |
import org.eclipse.ui.handlers.HandlerUtil; |
40 |
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor2;
|
|
40 |
import org.txm.lexicaltable.rcp.editors.LexicalTableEditor; |
|
41 | 41 |
import org.txm.rcp.commands.EditFile; |
42 | 42 |
import org.txm.rcp.swt.dialog.LastOpened; |
43 | 43 |
|
... | ... | |
55 | 55 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
56 | 56 |
IWorkbenchPart editor = HandlerUtil.getActiveWorkbenchWindow(event) |
57 | 57 |
.getActivePage().getActivePart(); |
58 |
if (editor instanceof LexicalTableEditor2) {
|
|
59 |
LexicalTableEditor2 LTeditor = (LexicalTableEditor2) editor;
|
|
58 |
if (editor instanceof LexicalTableEditor) { |
|
59 |
LexicalTableEditor LTeditor = (LexicalTableEditor) editor;
|
|
60 | 60 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event) |
61 | 61 |
.getShell(); |
62 | 62 |
FileDialog dialog = new FileDialog(shell, SWT.SAVE); |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/editors/LexicalTableEditorInput.java (revision 553) | ||
---|---|---|
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.lexicaltable.rcp.editors; |
|
29 |
|
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
|
34 |
import org.eclipse.jface.viewers.ITableLabelProvider; |
|
35 |
import org.eclipse.jface.viewers.LabelProvider; |
|
36 |
import org.eclipse.jface.viewers.Viewer; |
|
37 |
import org.eclipse.osgi.util.NLS; |
|
38 |
import org.eclipse.swt.graphics.Image; |
|
39 |
import org.eclipse.ui.IEditorInput; |
|
40 |
import org.eclipse.ui.part.EditorPart; |
|
41 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
|
42 |
import org.txm.rcp.editors.TXMResultEditorInput; |
|
43 |
import org.txm.rcp.RCPMessages; |
|
44 |
import org.txm.rcp.editors.Tablable; |
|
45 |
import org.txm.rcp.editors.input.AbstractTablable; |
|
46 |
import org.txm.searchengine.cqp.corpus.Property; |
|
47 |
import org.txm.statsengine.core.StatException; |
|
48 |
// TODO: Auto-generated Javadoc |
|
49 |
/** |
|
50 |
* The Class LexicalTableEditorInput. |
|
51 |
* |
|
52 |
* @author sloiseau |
|
53 |
*/ |
|
54 |
public class LexicalTableEditorInput extends TXMResultEditorInput { |
|
55 |
|
|
56 |
/** The editors. */ |
|
57 |
private List<EditorPart> editors; |
|
58 |
|
|
59 |
/** The inputs. */ |
|
60 |
private List<IEditorInput> inputs; |
|
61 |
|
|
62 |
/** |
|
63 |
* Instantiates a new lexical table editor input. |
|
64 |
* |
|
65 |
* @param table the table |
|
66 |
* @param partition the partition |
|
67 |
* @param property the property |
|
68 |
*/ |
|
69 |
public LexicalTableEditorInput(final LexicalTable table) { |
|
70 |
super(table); |
|
71 |
|
|
72 |
editors = new ArrayList<EditorPart>(); |
|
73 |
editors.add(new TableEditor()); |
|
74 |
|
|
75 |
inputs = new ArrayList<IEditorInput>(); |
|
76 |
|
|
77 |
class LexicalTableLabelProvider extends LabelProvider implements |
|
78 |
ITableLabelProvider { |
|
79 |
|
|
80 |
@Override |
|
81 |
public Image getColumnImage(Object element, int columnIndex) { |
|
82 |
return null; |
|
83 |
} |
|
84 |
|
|
85 |
@Override |
|
86 |
public String getColumnText(Object element, int columnIndex) { |
|
87 |
int[] val = (int[]) element; |
|
88 |
return String.valueOf(val[columnIndex]); |
|
89 |
} |
|
90 |
|
|
91 |
} |
|
92 |
|
|
93 |
Tablable asTable = new AbstractTablable() { |
|
94 |
|
|
95 |
@Override |
|
96 |
public String[] getColumnTitles() { |
|
97 |
return new String[] { RCPMessages.FrequencyListEditorInput_3, |
|
98 |
RCPMessages.FrequencyListEditorInput_4 }; |
|
99 |
} |
|
100 |
|
|
101 |
@Override |
|
102 |
public String[] getColumnTypes() { |
|
103 |
return new String[] { RCPMessages.FrequencyListEditorInput_5, |
|
104 |
RCPMessages.FrequencyListEditorInput_6 }; |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
108 |
public IStructuredContentProvider getContentProvider() { |
|
109 |
return new IStructuredContentProvider() { |
|
110 |
@Override |
|
111 |
public Object[] getElements(Object inputElement) { |
|
112 |
LexicalTable res = (LexicalTable) inputElement; |
|
113 |
List<int[]> row = new ArrayList<int[]>(); |
|
114 |
for (int i = 0; i < res.getNRows(); i++) { |
|
115 |
int[] v = null; |
|
116 |
try { |
|
117 |
v = res.getRow(i).asIntArray(); |
|
118 |
} catch (StatException e) { |
|
119 |
System.err.println(NLS.bind( |
|
120 |
RCPMessages.GraphicalLogger_0, e)); |
|
121 |
} |
|
122 |
row.add(v); |
|
123 |
} |
|
124 |
return row.toArray(); |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public void dispose() { |
|
129 |
// TODO Auto-generated method stub |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public void inputChanged(Viewer viewer, Object oldInput, |
|
134 |
Object newInput) { |
|
135 |
// TODO Auto-generated method stub |
|
136 |
} |
|
137 |
|
|
138 |
}; |
|
139 |
} |
|
140 |
|
|
141 |
@Override |
|
142 |
public Object getInput() { |
|
143 |
return table; |
|
144 |
} |
|
145 |
|
|
146 |
@Override |
|
147 |
public LabelProvider getLabelProvider() { |
|
148 |
return new LexicalTableLabelProvider(); |
|
149 |
} |
|
150 |
|
|
151 |
}; |
|
152 |
inputs.add(asTable); |
|
153 |
|
|
154 |
} |
|
155 |
|
|
156 |
|
|
157 |
/** |
|
158 |
* Gets the lexical table. |
|
159 |
* |
|
160 |
* @return the lexicon |
|
161 |
*/ |
|
162 |
public LexicalTable getLexicalTable() { |
|
163 |
return (LexicalTable) this.result; |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* Gets the property. |
|
168 |
* |
|
169 |
* @return the property |
|
170 |
*/ |
|
171 |
public Property getProperty() { |
|
172 |
return this.getLexicalTable().getProperty(); |
|
173 |
} |
|
174 |
|
|
175 |
} |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/editors/LexicalTableEditor2.java (revision 553) | ||
---|---|---|
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.lexicaltable.rcp.editors; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.util.ArrayList; |
|
32 |
import java.util.Arrays; |
|
33 |
import java.util.Collections; |
|
34 |
import java.util.Comparator; |
|
35 |
import java.util.List; |
|
36 |
|
|
37 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
38 |
import org.eclipse.jface.action.MenuManager; |
|
39 |
import org.eclipse.jface.viewers.CellLabelProvider; |
|
40 |
import org.eclipse.jface.viewers.TableViewer; |
|
41 |
import org.eclipse.jface.viewers.TableViewerColumn; |
|
42 |
import org.eclipse.jface.viewers.ViewerCell; |
|
43 |
import org.eclipse.jface.window.Window; |
|
44 |
import org.eclipse.osgi.util.NLS; |
|
45 |
import org.eclipse.swt.SWT; |
|
46 |
import org.eclipse.swt.events.SelectionEvent; |
|
47 |
import org.eclipse.swt.events.SelectionListener; |
|
48 |
import org.eclipse.swt.layout.FormAttachment; |
|
49 |
import org.eclipse.swt.layout.FormData; |
|
50 |
import org.eclipse.swt.layout.FormLayout; |
|
51 |
import org.eclipse.swt.layout.GridData; |
|
52 |
import org.eclipse.swt.layout.GridLayout; |
|
53 |
import org.eclipse.swt.widgets.Button; |
|
54 |
import org.eclipse.swt.widgets.Composite; |
|
55 |
import org.eclipse.swt.widgets.Label; |
|
56 |
import org.eclipse.swt.widgets.Menu; |
|
57 |
import org.eclipse.swt.widgets.MessageBox; |
|
58 |
import org.eclipse.swt.widgets.Spinner; |
|
59 |
import org.eclipse.swt.widgets.TableColumn; |
|
60 |
import org.eclipse.ui.IEditorInput; |
|
61 |
import org.eclipse.ui.IEditorSite; |
|
62 |
import org.eclipse.ui.PartInitException; |
|
63 |
import org.txm.core.messages.TXMCoreMessages; |
|
64 |
import org.txm.core.results.TXMResult; |
|
65 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
|
66 |
import org.txm.lexicaltable.core.statsengine.data.ILexicalTable; |
|
67 |
import org.txm.lexicaltable.rcp.handlers.MergeLines; |
|
68 |
import org.txm.lexicaltable.rcp.messages.LexicalTableUIMessages; |
|
69 |
import org.txm.rcp.RCPMessages; |
|
70 |
import org.txm.rcp.StatusLine; |
|
71 |
import org.txm.rcp.editors.TXMEditorPart; |
|
72 |
import org.txm.rcp.editors.TableKeyListener; |
|
73 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
74 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
75 |
import org.txm.statsengine.core.StatException; |
|
76 |
import org.txm.statsengine.core.data.Vector; |
|
77 |
/** |
|
78 |
* display the lexical table tools to merge/delete lines or columns and display |
|
79 |
* the lexical table too |
|
80 |
* |
|
81 |
* @author mdecorde |
|
82 |
*/ |
|
83 |
public class LexicalTableEditor2 extends TXMEditorPart { |
|
84 |
|
|
85 |
|
|
86 |
public static final String ID = LexicalTableEditor2.class.getName(); |
|
87 |
|
|
88 |
/** The table. */ |
|
89 |
LexicalTable table; |
|
90 |
ILexicalTable itable; |
|
91 |
|
|
92 |
// params |
|
93 |
/** The line table viewer. */ |
|
94 |
TableViewer viewer; |
|
95 |
|
|
96 |
/** The form column. */ |
|
97 |
TableViewerColumn formColumn; |
|
98 |
|
|
99 |
/** The freq column. */ |
|
100 |
TableViewerColumn freqColumn; |
|
101 |
// org.eclipse.swt.widgets.List colCombo; |
|
102 |
|
|
103 |
/** The minfreqspinner. */ |
|
104 |
Spinner minfreqspinner; |
|
105 |
|
|
106 |
/** The top spinner. */ |
|
107 |
Spinner nLinesSpinner; |
|
108 |
|
|
109 |
/** The cols. */ |
|
110 |
private List<double[]> cols; |
|
111 |
|
|
112 |
/** The rows. */ |
|
113 |
private List<String> rows; |
|
114 |
|
|
115 |
/** The collist. */ |
|
116 |
List<Object> collist; |
|
117 |
|
|
118 |
/** The freqs. */ |
|
119 |
//private List<Integer> freqs; |
|
120 |
|
|
121 |
/** The previous sorted col. */ |
|
122 |
private int previousSortedCol; |
|
123 |
boolean DEFAULTREVERSE = false; |
|
124 |
boolean reverse = DEFAULTREVERSE; |
|
125 |
|
|
126 |
/** |
|
127 |
* Inits the. |
|
128 |
* |
|
129 |
* @param site the site |
|
130 |
* @param input the input |
|
131 |
* @throws PartInitException the part init exception |
|
132 |
* @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, |
|
133 |
* org.eclipse.ui.IEditorInput) |
|
134 |
*/ |
|
135 |
@Override |
|
136 |
public void init(IEditorSite site, IEditorInput input) throws PartInitException { |
|
137 |
super.init(site, input); |
|
138 |
|
|
139 |
table = ((LexicalTableEditorInput) input).getLexicalTable(); |
|
140 |
itable = table.getData(); |
|
141 |
} |
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
/** |
|
146 |
* Sort. |
|
147 |
* |
|
148 |
* @param col the col |
|
149 |
* @param index the index |
|
150 |
*/ |
|
151 |
public void sort(TableViewerColumn col, int index) { |
|
152 |
|
|
153 |
if (index == previousSortedCol) { |
|
154 |
reverse = !reverse; |
|
155 |
} else { |
|
156 |
reverse = DEFAULTREVERSE; |
|
157 |
} |
|
158 |
|
|
159 |
if (index == -2) {// rownames |
|
160 |
itable.sortRowNames(reverse); |
|
161 |
} else if (index == -1) { // freqs |
|
162 |
try { |
|
163 |
itable.sortByFreqs(reverse); |
|
164 |
StatusLine.setMessage(RCPMessages.SORT_DONE); |
|
165 |
} catch (Exception e2) { |
|
166 |
org.txm.rcp.utils.Logger.printStackTrace(e2); |
|
167 |
} |
|
168 |
} else if (index >= 0) { |
|
169 |
itable.sort(index, reverse); |
|
170 |
} |
|
171 |
|
|
172 |
previousSortedCol = index; |
|
173 |
refreshTable(); |
|
174 |
|
|
175 |
viewer.getTable().setSortColumn(col.getColumn()); |
|
176 |
if (reverse) |
|
177 |
viewer.getTable().setSortDirection(SWT.DOWN); |
|
178 |
else |
|
179 |
viewer.getTable().setSortDirection(SWT.UP); |
|
180 |
} |
|
181 |
|
|
182 |
/** |
|
183 |
* Creates the part control. |
|
184 |
* |
|
185 |
* @param parent the parent |
|
186 |
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) |
|
187 |
*/ |
|
188 |
@Override |
|
189 |
public void createPartControl(final Composite parent) { |
|
190 |
|
|
191 |
super.createPartControl(parent); |
|
192 |
|
|
193 |
Composite paramArea = new Composite(this.getCommandParametersGroup(), SWT.NONE); |
|
194 |
|
|
195 |
GridLayout paramLayout = new GridLayout(5, false); |
|
196 |
paramArea.setLayout(paramLayout); |
|
197 |
|
|
198 |
// Apply button |
|
199 |
Button keepTop = new Button(paramArea, SWT.PUSH); |
|
200 |
keepTop.setText(LexicalTableUIMessages.LexicalTableEditor_4); |
|
201 |
keepTop.addSelectionListener(new SelectionListener() { |
|
202 |
@Override |
|
203 |
public void widgetSelected(SelectionEvent e) { |
|
204 |
StatusLine.setMessage(LexicalTableUIMessages.LexicalTableEditor_16); |
|
205 |
System.out.println(NLS.bind(LexicalTableUIMessages.LexicalTableEditor_5, nLinesSpinner.getSelection(), minfreqspinner.getSelection())); |
|
206 |
|
|
207 |
MessageBox messageBox = new MessageBox(e.display.getActiveShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO); |
|
208 |
messageBox.setMessage(RCPMessages.DeleteLines_1); |
|
209 |
int response = messageBox.open(); |
|
210 |
if (response != SWT.YES) |
|
211 |
return; |
|
212 |
|
|
213 |
try { |
|
214 |
itable.filter(nLinesSpinner.getSelection(), minfreqspinner.getSelection()); |
|
215 |
refresh(); |
|
216 |
StatusLine.setMessage(""); //$NON-NLS-1$ |
|
217 |
} catch (Exception e1) { |
Formats disponibles : Unified diff