Révision 603
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/preferences/LexicalTablePreferences.java (revision 603) | ||
---|---|---|
46 | 46 |
Preferences preferences = DefaultScope.INSTANCE.getNode(PREFERENCES_NODE); |
47 | 47 |
preferences.putInt(F_MIN, 2); |
48 | 48 |
preferences.putInt(V_MAX, 200); |
49 |
preferences.put(PROPERTY, "word"); |
|
49 |
preferences.put(PROPERTY, "word"); //$NON-NLS-1$
|
|
50 | 50 |
preferences.putBoolean(USE_ALL_OCCURRENCES, true); |
51 | 51 |
} |
52 | 52 |
|
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 603) | ||
---|---|---|
43 | 43 |
protected ILexicalTable statsData; |
44 | 44 |
|
45 | 45 |
|
46 |
|
|
47 |
|
|
46 | 48 |
/** |
47 | 49 |
* The property. |
48 | 50 |
*/ |
49 |
@Parameter |
|
51 |
@Parameter(key=LexicalTablePreferences.PROPERTY)
|
|
50 | 52 |
private Property pProperty; |
51 | 53 |
|
52 | 54 |
/** |
53 | 55 |
* Minimum frequency. |
54 | 56 |
*/ |
55 |
@Parameter |
|
57 |
@Parameter(key=LexicalTablePreferences.F_MIN)
|
|
56 | 58 |
private Integer pfMinFilter; |
57 | 59 |
|
58 | 60 |
/** |
59 | 61 |
* Maximum number of lines. |
60 | 62 |
*/ |
61 |
@Parameter |
|
63 |
@Parameter(key=LexicalTablePreferences.V_MAX)
|
|
62 | 64 |
private Integer pVMaxFilter; |
63 | 65 |
|
64 |
@Parameter |
|
66 |
@Parameter(key=LexicalTablePreferences.USE_ALL_OCCURRENCES)
|
|
65 | 67 |
protected Boolean pUseAllOccurrences; |
66 | 68 |
|
69 |
|
|
70 |
|
|
67 | 71 |
/** |
68 | 72 |
* |
69 | 73 |
* @param corpus |
... | ... | |
162 | 166 |
@Override |
163 | 167 |
public boolean loadParameters() { |
164 | 168 |
try { |
165 |
this.setParameters(this.getCorpus().getProperty(this.getStringParameterValue(LexicalTablePreferences.PROPERTY)), |
|
166 |
this.getIntParameterValue(LexicalTablePreferences.F_MIN), |
|
167 |
this.getIntParameterValue(LexicalTablePreferences.V_MAX), |
|
168 |
this.getBooleanParameterValue(LexicalTablePreferences.USE_ALL_OCCURRENCES) |
|
169 |
); |
|
169 |
this.pProperty = this.getCorpus().getProperty(this.getStringParameterValue(LexicalTablePreferences.PROPERTY)); |
|
170 | 170 |
} |
171 | 171 |
catch (CqiClientException e) { |
172 | 172 |
// TODO Auto-generated catch block |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorPart.java (revision 603) | ||
---|---|---|
386 | 386 |
// computing result |
387 | 387 |
monitor.beginTask("Computing", 100); |
388 | 388 |
|
389 |
editorInput.getResult().compute(update, monitor); // always open the editor
|
|
389 |
editorInput.getResult().compute(update, monitor); |
|
390 | 390 |
|
391 | 391 |
monitor.worked(50); |
392 | 392 |
|
... | ... | |
573 | 573 |
else if(object instanceof Text) { |
574 | 574 |
((Text)object).setText((String) value); |
575 | 575 |
} |
576 |
// FIXME: need to extend this list of managed Widgets |
|
576 | 577 |
} |
577 | 578 |
catch (IllegalArgumentException e) { |
578 | 579 |
// TODO Auto-generated catch block |
... | ... | |
617 | 618 |
else if(object instanceof Text) { |
618 | 619 |
value = ((Text)object).getText(); |
619 | 620 |
} |
621 |
// FIXME: need to extend this list of managed Widgets |
|
620 | 622 |
|
621 | 623 |
this.getResultData().setParameter(parameter.key(), value); |
622 | 624 |
} |
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 603) | ||
---|---|---|
590 | 590 |
} |
591 | 591 |
|
592 | 592 |
/** |
593 |
* Initialize the @Parameter class members objects using the default and persisted values in the Preference Store |
|
593 |
* Fills the result parameter fields declared by their @Parameter annotation from the persisted result node or default node of the preferences. |
|
594 |
* One have to implement loadParameters() to load parameters that are not of primitive types (e.g. Property, List, HashMap...) |
|
594 | 595 |
* |
595 |
* extends and call this method if you need to load parameter with not simple type (e.g. Property, List, HashMap...) |
|
596 |
* |
|
597 | 596 |
* @return |
598 | 597 |
* @throws Exception |
599 | 598 |
* @throws Exception |
600 | 599 |
*/ |
601 | 600 |
protected boolean loadGenericParameters(int parameterType) throws Exception { |
602 | 601 |
|
603 |
// // FIXME: debug |
|
604 |
// System.err.println("TXMResult.loadGenericParameters(): loading generic parameters into fields for " + this.getClass() + " and parameters type = " + parameterType); |
|
605 |
|
|
606 | 602 |
List<Field> fields = this.getAllFields(); |
607 | 603 |
|
608 | 604 |
for (Field f : fields) { |
... | ... | |
619 | 615 |
try { |
620 | 616 |
f.setAccessible(true); // set accessible to test the field values |
621 | 617 |
|
622 |
// only manage simple persisted types |
|
623 |
if(f.getType().isAssignableFrom(String.class)) { |
|
624 |
String persistedValue = this.getStringParameterValue(key); |
|
625 |
if (persistedValue != null) { |
|
626 |
f.set(this, persistedValue); |
|
627 |
} |
|
618 |
Object value = null; |
|
619 |
|
|
620 |
// only manage primitive types |
|
621 |
if (f.getType().isAssignableFrom(String.class)) { |
|
622 |
value = this.getStringParameterValue(key); |
|
628 | 623 |
} |
629 |
else if (f.getType().isAssignableFrom(int.class)) { |
|
630 |
Integer persistedValue = this.getIntParameterValue(key); |
|
631 |
if (persistedValue != null) { |
|
632 |
f.set(this, persistedValue); |
|
633 |
} |
|
624 |
else if (f.getType().isAssignableFrom(int.class) || f.getType().isAssignableFrom(Integer.class)) { |
|
625 |
value = this.getIntParameterValue(key); |
|
634 | 626 |
} |
635 |
else if (f.getType().isAssignableFrom(double.class)) { |
|
636 |
Double persistedValue = this.getDoubleParameterValue(key); |
|
637 |
if (persistedValue != null) { |
|
638 |
f.set(this, persistedValue); |
|
639 |
} |
|
627 |
else if (f.getType().isAssignableFrom(double.class) || f.getType().isAssignableFrom(Double.class)) { |
|
628 |
value = this.getDoubleParameterValue(key); |
|
640 | 629 |
} |
641 |
else if (f.getType().isAssignableFrom(float.class)) { |
|
642 |
Float persistedValue = this.getFloatParameterValue(key); |
|
643 |
if (persistedValue != null) { |
|
644 |
f.set(this, persistedValue); |
|
645 |
} |
|
630 |
else if (f.getType().isAssignableFrom(float.class) || f.getType().isAssignableFrom(Float.class)) { |
|
631 |
value = this.getFloatParameterValue(key); |
|
646 | 632 |
} |
647 |
// FIXME: doesn't work |
|
648 |
//else if (f.getClass().equals(Boolean.class)) { |
|
649 |
else if (f.getType().isAssignableFrom(boolean.class)) { |
|
650 |
|
|
651 |
Boolean persistedValue = this.getBooleanParameterValue(key); |
|
652 |
if (persistedValue != null) { |
|
653 |
f.set(this, persistedValue); |
|
654 |
} |
|
633 |
else if (f.getType().isAssignableFrom(boolean.class) || f.getType().isAssignableFrom(Boolean.class)) { |
|
634 |
value = this.getBooleanParameterValue(key); |
|
655 | 635 |
} |
636 |
f.set(this, value); |
|
637 |
|
|
638 |
// FIXME: Debug |
|
639 |
System.err.println("TXMResult.loadGenericParameters(): setting parameter " + key + " = " + value + " for " + this.getClass()); |
|
640 |
|
|
656 | 641 |
} catch (Exception e) { |
657 | 642 |
e.printStackTrace(); |
658 | 643 |
} |
... | ... | |
678 | 663 |
|
679 | 664 |
|
680 | 665 |
/** |
681 |
* Sets a parameters form its parameter annotation "key".
|
|
666 |
* Sets a parameters from its parameter annotation "key".
|
|
682 | 667 |
* @param key |
683 | 668 |
* @param value |
684 | 669 |
* @return |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/editors/LexicalTableEditor.java (revision 603) | ||
---|---|---|
120 | 120 |
|
121 | 121 |
/** The minfreqspinner. */ |
122 | 122 |
// @Parameter(key=LexicalTablePreferences.F_MIN) |
123 |
Spinner minFreqSpinner;
|
|
123 |
Spinner fMin;
|
|
124 | 124 |
|
125 | 125 |
/** The top spinner. */ |
126 | 126 |
// @Parameter(key=LexicalTablePreferences.V_MAX) |
127 |
Spinner nLinesSpinner;
|
|
127 |
Spinner vMax;
|
|
128 | 128 |
|
129 | 129 |
|
130 | 130 |
|
... | ... | |
160 | 160 |
@Override |
161 | 161 |
public void widgetSelected(SelectionEvent e) { |
162 | 162 |
StatusLine.setMessage(LexicalTableUIMessages.LexicalTableEditor_16); |
163 |
System.out.println(NLS.bind(LexicalTableUIMessages.LexicalTableEditor_5, nLinesSpinner.getSelection(), minFreqSpinner.getSelection()));
|
|
163 |
System.out.println(NLS.bind(LexicalTableUIMessages.LexicalTableEditor_5, vMax.getSelection(), fMin.getSelection()));
|
|
164 | 164 |
|
165 | 165 |
MessageBox messageBox = new MessageBox(e.display.getActiveShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO); |
166 | 166 |
messageBox.setMessage(RCPMessages.DeleteLines_1); |
... | ... | |
187 | 187 |
// Number of lines |
188 | 188 |
Label nLines = new Label(paramArea, SWT.NONE); |
189 | 189 |
nLines.setText(LexicalTableUIMessages.LexicalTableEditor_8); |
190 |
nLinesSpinner = new Spinner(paramArea, SWT.BORDER);
|
|
190 |
vMax = new Spinner(paramArea, SWT.BORDER);
|
|
191 | 191 |
|
192 | 192 |
// Fmin |
193 | 193 |
Label fmin = new Label(paramArea, SWT.NONE); |
194 | 194 |
fmin.setText(LexicalTableUIMessages.LexicalTableEditor_6); |
195 |
minFreqSpinner = new Spinner(paramArea, SWT.BORDER);
|
|
195 |
fMin = new Spinner(paramArea, SWT.BORDER);
|
|
196 | 196 |
|
197 | 197 |
// Merge or delete columns button |
198 | 198 |
Button fusionCol = new Button(paramArea, SWT.PUSH); |
... | ... | |
624 | 624 |
|
625 | 625 |
@Override |
626 | 626 |
public void updateEditorFromResult(boolean update) { |
627 |
nLinesSpinner.setMinimum(1);
|
|
628 |
nLinesSpinner.setMaximum(lexicalTable.getData().getNRows());
|
|
629 |
nLinesSpinner.setSelection(lexicalTable.getData().getNRows());
|
|
630 |
minFreqSpinner.setMinimum(lexicalTable.getData().getFMin());
|
|
631 |
minFreqSpinner.setMaximum(lexicalTable.getData().getFMax());
|
|
627 |
vMax.setMinimum(1);
|
|
628 |
vMax.setMaximum(lexicalTable.getData().getNRows());
|
|
629 |
vMax.setSelection(lexicalTable.getData().getNRows());
|
|
630 |
fMin.setMinimum(lexicalTable.getData().getFMin());
|
|
631 |
fMin.setMaximum(lexicalTable.getData().getFMax());
|
|
632 | 632 |
|
633 | 633 |
this.refreshTable(); |
634 | 634 |
this.refreshInfos(); |
... | ... | |
642 | 642 |
@Override |
643 | 643 |
public void updateResultFromEditor() { |
644 | 644 |
try { |
645 |
lexicalTable.getData().filter(nLinesSpinner.getSelection(), minFreqSpinner.getSelection());
|
|
645 |
lexicalTable.getData().filter(vMax.getSelection(), fMin.getSelection());
|
|
646 | 646 |
} |
647 | 647 |
catch (Exception e) { |
648 | 648 |
// TODO Auto-generated catch block |
tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/ComputeLexicalTable.java (revision 603) | ||
---|---|---|
145 | 145 |
// TODO Auto-generated catch block |
146 | 146 |
e.printStackTrace(); |
147 | 147 |
} |
148 |
|
|
149 |
|
|
150 |
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(CorporaView.ID); |
|
151 |
// JobHandler jobhandler = new JobHandler(RCPMessages.bind(RCPMessages.ComputeLexicalTable_0, partition.getName())) { |
|
152 |
// @Override |
|
153 |
// protected IStatus run(IProgressMonitor monitor) { |
|
154 |
// this.runInit(monitor); |
|
155 |
// try { |
|
156 |
// JobsTimer.start(); |
|
157 |
// monitor.beginTask(NLS.bind(RCPMessages.ComputeLexicalTable_1, partition.getName(), property), 100); |
|
158 |
// |
|
159 |
// this.acquireSemaphore(); |
|
160 |
// table = LexicalTableFactory.getLexicalTable(partition, property, Fmin); |
|
161 |
// this.releaseSemaphore(); |
|
162 |
// |
|
163 |
// this.acquireSemaphore(); |
|
164 |
// table.getData().cut(vmax); |
|
165 |
// this.releaseSemaphore(); |
|
166 |
// |
|
167 |
// monitor.worked(45); |
|
168 |
// if (monitor.isCanceled() || table == null) { |
|
169 |
// return Status.CANCEL_STATUS; |
|
170 |
// } |
|
171 |
// |
|
172 |
// partition.addChild(table); |
|
173 |
// |
|
174 |
// monitor.worked(5); |
|
175 |
// |
|
176 |
// //monitor.subTask(Messages.ComputeSpecifities_10); |
|
177 |
// syncExec(new Runnable() { |
|
178 |
// @Override |
|
179 |
// public void run() { |
|
180 |
// IWorkbenchPage page = window.getActivePage(); |
|
181 |
// LexicalTableEditorInput editorInput = new LexicalTableEditorInput(table); |
|
182 |
// try { |
|
183 |
// StatusLine.setMessage(RCPMessages.ComputeLexicalTable_10); |
|
184 |
// page.openEditor(editorInput, LexicalTableEditor.ID); //$NON-NLS-1$ |
|
185 |
// } catch (PartInitException e) { |
|
186 |
// org.txm.rcp.utils.Logger.printStackTrace(e); |
|
187 |
// } |
|
188 |
// } |
|
189 |
// }); |
|
190 |
// |
|
191 |
// monitor.worked(50); |
|
192 |
// if (monitor.isCanceled()) |
|
193 |
// return Status.CANCEL_STATUS; |
|
194 |
// |
|
195 |
// //monitor.subTask(Messages.ComputeSpecifities_2); |
|
196 |
// syncExec(new Runnable() { |
|
197 |
// @Override |
|
198 |
// public void run() { |
|
199 |
// QueriesView.refresh(); |
|
200 |
// RVariablesView.refresh(); |
|
201 |
// } |
|
202 |
// }); |
|
203 |
// |
|
204 |
// monitor.worked(100); |
|
205 |
// } catch (ThreadDeath td) { |
|
206 |
// return Status.CANCEL_STATUS; |
|
207 |
// } catch (Exception e) { |
|
208 |
// org.txm.rcp.utils.Logger.printStackTrace(e); |
|
209 |
// } finally { |
|
210 |
// monitor.done(); |
|
211 |
// JobsTimer.stopAndPrint(); |
|
212 |
// } |
|
213 |
// return Status.OK_STATUS; |
|
214 |
// } |
|
215 |
// }; |
|
216 |
// jobhandler.startJob(); |
|
217 | 148 |
} |
218 | 149 |
// Reopening from existing result |
219 | 150 |
else if (selection instanceof LexicalTable) { |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java (revision 603) | ||
---|---|---|
675 | 675 |
* @throws CqiClientException |
676 | 676 |
*/ |
677 | 677 |
public int[] getPartSizes() throws CqiClientException { |
678 |
if (partSizes != null) |
|
678 |
if (partSizes != null) {
|
|
679 | 679 |
return partSizes; |
680 |
} |
|
680 | 681 |
partSizes = new int[getParts().size()]; |
681 | 682 |
for (int i = 0 ; i < getParts().size() ; i++) { |
682 | 683 |
Part p = getParts().get(i); |
... | ... | |
733 | 734 |
@Override |
734 | 735 |
protected boolean _compute(boolean update) throws Exception { |
735 | 736 |
// TODO Auto-generated method stub |
736 |
return false;
|
|
737 |
return true;
|
|
737 | 738 |
} |
738 | 739 |
|
739 | 740 |
@Override |
Formats disponibles : Unified diff