Révision 1138
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1138) | ||
---|---|---|
76 | 76 |
protected boolean hasBeenComputedOnce = false; |
77 | 77 |
|
78 | 78 |
/** |
79 |
* Can be used to know if an object needs a full recomputing. |
|
80 |
*/ |
|
81 |
protected boolean needsFullRecomputing = false; |
|
82 |
|
|
83 |
/** |
|
79 | 84 |
* The weight, essentially used for sorting purpose. |
80 | 85 |
*/ |
81 | 86 |
protected int weight; |
... | ... | |
139 | 144 |
*/ |
140 | 145 |
protected HashMap<String, Object> lastParameters = new HashMap<String, Object>(); |
141 | 146 |
|
147 |
// FIXME: SJ: actually only used by the chart results. Purpose here is that the chart creators need to know if a computing parameter has changed to recreate or not some entity. |
|
148 |
// The problem is since the result is already computing, the parameters are already updated and the method hasParameterChanged() will always return false. Using this stack fix the problem. |
|
149 |
// But this stack is also the start for an UNDO command on TXMResult. |
|
150 |
protected ArrayList<HashMap<String, Object>> parametersHistory = new ArrayList<HashMap<String, Object>>(); |
|
151 |
|
|
142 | 152 |
|
143 | 153 |
/** |
144 | 154 |
* Internal persistable state. |
... | ... | |
282 | 292 |
if (this.parent == null) { |
283 | 293 |
Log.warning("Warning: the TXMResult of " + this.getClass() + " is attached to no parent. (uuid = " + this.getUUID() + ")"); |
284 | 294 |
} |
295 |
|
|
296 |
try { |
|
297 |
this.updateLastParameters(); |
|
298 |
} |
|
299 |
catch (Exception e) { |
|
300 |
// TODO Auto-generated catch block |
|
301 |
e.printStackTrace(); |
|
302 |
} |
|
285 | 303 |
} |
286 | 304 |
|
287 | 305 |
public void setUserName(String name) { |
... | ... | |
399 | 417 |
*/ |
400 | 418 |
protected void updateLastParameters(int parameterType) throws Exception { |
401 | 419 |
|
420 |
// FIXME: SJ store in the history stack |
|
421 |
HashMap<String, Object> lastParametersHistory = new HashMap<>(); |
|
422 |
|
|
402 | 423 |
List<Field> fields = this.getAllFields(); |
403 | 424 |
|
404 | 425 |
for (Field f : fields) { |
... | ... | |
417 | 438 |
|
418 | 439 |
f.setAccessible(true); |
419 | 440 |
this.lastParameters.put(name, f.get(this)); |
441 |
|
|
442 |
lastParametersHistory.put(name, f.get(this)); |
|
420 | 443 |
} |
444 |
|
|
445 |
this.parametersHistory.add(lastParametersHistory); |
|
421 | 446 |
} |
422 | 447 |
|
423 | 448 |
|
... | ... | |
764 | 789 |
return TXMPreferences.keyExists(this.parametersNodePath, key); |
765 | 790 |
} |
766 | 791 |
|
792 |
/** |
|
793 |
* Checks if a preference is empty (equals to "") in the command preference node. |
|
794 |
* An empty preference can be used to disable a functionality for a kind of result |
|
795 |
* (eg. A partition dimension bar chart does not have a legend so it can be used to not offer the hide/show legend button in UI). |
|
796 |
* @param key |
|
797 |
* @return |
|
798 |
*/ |
|
799 |
public boolean isEmptyPreference(String key) { |
|
800 |
return TXMPreferences.isEmpty(this.commandPreferencesNodePath, key); |
|
801 |
} |
|
767 | 802 |
|
803 |
|
|
804 |
|
|
768 | 805 |
/** |
769 | 806 |
* Stores the specified parameters pairs of key/value in a local node dedicated to the specified result. The node qualifier is generated by the <code>TXMResult.getUUID</code> method. |
770 | 807 |
* |
... | ... | |
964 | 1001 |
return setParameters(new TXMParameters(parameters)); |
965 | 1002 |
} |
966 | 1003 |
|
1004 |
/** |
|
1005 |
* Sets a parameters from its parameter annotation "key". |
|
1006 |
* @param key |
|
1007 |
* @param value |
|
1008 |
* @return |
|
1009 |
* @throws Exception |
|
1010 |
*/ |
|
967 | 1011 |
public boolean setParameter(String key, Object value) throws Exception { |
968 |
return setParameter(key, value, false);
|
|
1012 |
return setParameter(key, value, true);
|
|
969 | 1013 |
} |
970 | 1014 |
|
971 | 1015 |
/** |
... | ... | |
998 | 1042 |
targetField.setAccessible(true); |
999 | 1043 |
|
1000 | 1044 |
// FIXME: debug |
1001 |
// if(value != null) {
|
|
1002 |
// Log.info("TXMResult.setParameter(): setting parameter " + key + " = " + value + " for " + this.getClass() + " (" + value.getClass() + ")");
|
|
1003 |
// }
|
|
1045 |
//if(value != null) { |
|
1046 |
// Log.info("TXMResult.setParameter(): setting parameter " + key + " = " + value + " for " + this.getClass() + " (" + value.getClass() + ")"); |
|
1047 |
//} |
|
1004 | 1048 |
|
1005 | 1049 |
targetField.set(this, value); |
1006 |
} else if (bubble) { |
|
1007 |
getParent().setParameter(key, value); |
|
1008 | 1050 |
} |
1051 |
//else |
|
1052 |
if (this.parent != null && bubble) { |
|
1053 |
this.parent.setParameter(key, value); |
|
1054 |
} |
|
1009 | 1055 |
|
1010 | 1056 |
return true; |
1011 | 1057 |
} |
... | ... | |
1233 | 1279 |
} |
1234 | 1280 |
} |
1235 | 1281 |
|
1282 |
/** |
|
1283 |
* Deletes the children of the specified class. |
|
1284 |
* @param type |
|
1285 |
* @return |
|
1286 |
*/ |
|
1287 |
synchronized public void deleteChildren(Class type) { |
|
1288 |
ArrayList<TXMResult> children = (ArrayList<TXMResult>) this.getChildren(type); |
|
1289 |
for (int i = 0; i < children.size(); i++) { |
|
1290 |
children.get(i).delete(); |
|
1291 |
} |
|
1292 |
} |
|
1293 |
|
|
1236 | 1294 |
|
1237 | 1295 |
/** |
1238 | 1296 |
* Gets the first child. |
... | ... | |
1684 | 1742 |
|
1685 | 1743 |
|
1686 | 1744 |
/** |
1687 |
* |
|
1688 |
* @param monitor |
|
1689 |
* @param deepComputing |
|
1690 |
* @return |
|
1691 |
* @throws Exception |
|
1692 |
*/ |
|
1693 |
public boolean compute(IProgressMonitor monitor, boolean deepComputing) throws Exception { |
|
1694 |
return this.compute(monitor, deepComputing, true); |
|
1695 |
} |
|
1696 |
|
|
1697 |
/** |
|
1698 | 1745 |
* Computes the result if |
1699 | 1746 |
* it can be computed |
1700 | 1747 |
* it is dirty |
... | ... | |
1709 | 1756 |
* @throws CqiClientExceptio |
1710 | 1757 |
* @throws IOException |
1711 | 1758 |
*/ |
1712 |
protected boolean compute(IProgressMonitor monitor, boolean deepComputing, boolean updateLastParameters) throws Exception {
|
|
1759 |
public boolean compute(IProgressMonitor monitor, boolean deepComputing) throws Exception {
|
|
1713 | 1760 |
|
1714 | 1761 |
// FIXME: see if this skipComputing tests is still useful? is it possible to directly return instead? |
1715 | 1762 |
// en fait voir ChartResult.compute() if(super.compute(monitor, true, false)), je pense que le prob vient du fait que si on retourne false dans TXMResult.compute() alors renderChart() ne sera pas appelé |
... | ... | |
1717 | 1764 |
|
1718 | 1765 |
this.monitor = monitor; |
1719 | 1766 |
|
1720 |
if (!this.isDirtyFromHistory() && !this.isDirty()) { |
|
1767 |
if (!this.needsFullRecomputing && !this.isDirtyFromHistory() && !this.isDirty()) {
|
|
1721 | 1768 |
Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": result parameters have not changed since last computing, computing skipped."); |
1722 | 1769 |
skipComputing = true; |
1723 | 1770 |
} |
... | ... | |
1733 | 1780 |
// if (parent != null && !parent.getHasBeenComputedOnce()) { // parent must be computed at least one time |
1734 | 1781 |
// SJ: other way, test the object itself |
1735 | 1782 |
if (this.parent != null && !(this.parent instanceof Project)) { |
1736 |
if (!this.parent.compute(monitor, false, updateLastParameters)) {
|
|
1783 |
if (!this.parent.compute(monitor, true)) {
|
|
1737 | 1784 |
Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to compute parent result."); |
1738 | 1785 |
|
1739 | 1786 |
//return false; |
... | ... | |
1756 | 1803 |
// clear the lazy name, no more needed since the object has been computed and getSimpleName() can now work |
1757 | 1804 |
this.lazyName = null; |
1758 | 1805 |
|
1759 |
// store last used parameters |
|
1760 |
if (updateLastParameters) { |
|
1806 |
// // store last used parameters |
|
1807 |
// if (updateLastParameters) { |
|
1808 |
// this.updateLastParameters(); |
|
1809 |
// } |
|
1810 |
// |
|
1811 |
// if (!this.autoSaveParametersFromAnnotations()) { |
|
1812 |
// Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to save parameters from annotations for " + this.getName() + "."); |
|
1813 |
// } |
|
1814 |
// if (!this.saveParameters()) { |
|
1815 |
// Log.severe("TXMResult.compute():" + this.getClass().getSimpleName() + ": failed to save parameters for " + this.getName() + "."); |
|
1816 |
// } |
|
1817 |
// |
|
1818 |
// // file persistence flush |
|
1819 |
// // FIXME: to do only if !skipComputing? |
|
1820 |
// if (this.mustBePersisted()) { |
|
1821 |
// TXMPreferences.flush(this); |
|
1822 |
// } |
|
1823 |
|
|
1824 |
if(!skipComputing) { |
|
1825 |
|
|
1826 |
// store last used parameters |
|
1761 | 1827 |
this.updateLastParameters(); |
1762 |
} |
|
1763 | 1828 |
|
1764 |
if (!this.autoSaveParametersFromAnnotations()) { |
|
1765 |
Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to save parameters from annotations for " + this.getName() + "."); |
|
1766 |
} |
|
1767 |
if (!this.saveParameters()) { |
|
1768 |
Log.severe("TXMResult.compute():" + this.getClass().getSimpleName() + ": failed to save parameters for " + this.getName() + "."); |
|
1769 |
} |
|
1829 |
if (!this.autoSaveParametersFromAnnotations()) {
|
|
1830 |
Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to save parameters from annotations for " + this.getName() + ".");
|
|
1831 |
}
|
|
1832 |
if (!this.saveParameters()) {
|
|
1833 |
Log.severe("TXMResult.compute():" + this.getClass().getSimpleName() + ": failed to save parameters for " + this.getName() + ".");
|
|
1834 |
}
|
|
1770 | 1835 |
|
1771 |
// file persistence flush |
|
1772 |
if (this.mustBePersisted()) { |
|
1773 |
TXMPreferences.flush(this); |
|
1774 |
} |
|
1775 |
|
|
1776 |
if(!skipComputing) { |
|
1836 |
// file persistence flush
|
|
1837 |
if (this.mustBePersisted()) {
|
|
1838 |
TXMPreferences.flush(this);
|
|
1839 |
}
|
|
1840 |
|
|
1841 |
|
|
1777 | 1842 |
this.dirty = false; // the computing was successful, the result is no more dirty |
1778 | 1843 |
this.hasBeenComputedOnce = true; |
1844 |
this.needsFullRecomputing = false; |
|
1845 |
|
|
1779 | 1846 |
Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing of result type " + this.getClass() + " done."); |
1780 | 1847 |
|
1848 |
// set the children as dirty since the result has changed |
|
1781 | 1849 |
for (int i = 0; i < this.children.size(); i++) { |
1782 |
this.getChild(i).setDirty(); // force recomputing even if some parameters of the result itself have not changed
|
|
1850 |
this.getChild(i).setDirty(); |
|
1783 | 1851 |
} |
1784 | 1852 |
|
1785 | 1853 |
// Children cascade computing |
... | ... | |
1787 | 1855 |
|
1788 | 1856 |
Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": cascade computing of " + this.children.size() + " children."); |
1789 | 1857 |
|
1790 |
for (TXMResult child : getChildren()) { |
|
1858 |
for (TXMResult child : this.getChildren()) {
|
|
1791 | 1859 |
// FIXME: may be better to add a member needFullRecomputing in TXMResult? |
1792 | 1860 |
// this.getChild(i).setDirty(); // force recomputing even if some parameters of the result itself have not changed |
1793 |
//this.getChild(i).setHasBeenComputedOnce(false); // force recomputing even if some parameters of the result itself have not changed |
|
1861 |
child.setNeedsFullRecomputing(true); // force recomputing even if some parameters of the result itself have not changed |
|
1862 |
|
|
1863 |
// recompute only children that has been opened once |
|
1794 | 1864 |
//if (child.hasBeenComputedOnce()) { |
1795 |
child.compute(monitor, deepComputing, updateLastParameters);
|
|
1865 |
child.compute(monitor, deepComputing); |
|
1796 | 1866 |
//} |
1797 | 1867 |
} |
1798 | 1868 |
} |
... | ... | |
2092 | 2162 |
public String getParametersNodePath() { |
2093 | 2163 |
return parametersNodePath; |
2094 | 2164 |
} |
2165 |
|
|
2166 |
/** |
|
2167 |
* @return the needsFullRecomputing |
|
2168 |
*/ |
|
2169 |
public boolean needsFullRecomputing() { |
|
2170 |
return needsFullRecomputing; |
|
2171 |
} |
|
2172 |
|
|
2173 |
/** |
|
2174 |
* @param needsFullRecomputing the needsFullRecomputing to set |
|
2175 |
*/ |
|
2176 |
public void setNeedsFullRecomputing(boolean needsFullRecomputing) { |
|
2177 |
this.needsFullRecomputing = needsFullRecomputing; |
|
2178 |
} |
|
2179 |
|
|
2180 |
/** |
|
2181 |
* @return the parametersHistory |
|
2182 |
*/ |
|
2183 |
public ArrayList<HashMap<String, Object>> getParametersHistory() { |
|
2184 |
return parametersHistory; |
|
2185 |
} |
|
2095 | 2186 |
} |
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/results/ChartResult.java (revision 1138) | ||
---|---|---|
4 | 4 |
package org.txm.chartsengine.core.results; |
5 | 5 |
|
6 | 6 |
import java.lang.reflect.Field; |
7 |
import java.util.HashMap; |
|
7 | 8 |
import java.util.List; |
8 | 9 |
|
9 | 10 |
import org.eclipse.core.runtime.IProgressMonitor; |
... | ... | |
141 | 142 |
@Override |
142 | 143 |
public void setDirty() { |
143 | 144 |
super.setDirty(); |
144 |
// this.chart = null;
|
|
145 |
this.chart = null; |
|
145 | 146 |
this.setChartDirty(); |
146 | 147 |
} |
147 | 148 |
|
... | ... | |
154 | 155 |
|
155 | 156 |
|
156 | 157 |
@Override |
157 |
public void setHasBeenComputedOnce(boolean hasBeenComputedOnce) {
|
|
158 |
super.setHasBeenComputedOnce(hasBeenComputedOnce);
|
|
158 |
public void setNeedsFullRecomputing(boolean needsFullRecomputing) {
|
|
159 |
super.setNeedsFullRecomputing(needsFullRecomputing);
|
|
159 | 160 |
this.chart = null; |
160 | 161 |
} |
161 | 162 |
|
... | ... | |
165 | 166 |
Log.finest("ChartResult.compute(): computing result of type " + this.getClass() + "..."); |
166 | 167 |
|
167 | 168 |
// compute the result if needed |
168 |
if(super.compute(monitor, true, false)) {
|
|
169 |
if(super.compute(monitor, true)) { |
|
169 | 170 |
// compute the chart |
170 | 171 |
return renderChart(); |
171 | 172 |
} |
... | ... | |
175 | 176 |
|
176 | 177 |
} |
177 | 178 |
|
179 |
|
|
180 |
@Override |
|
181 |
public boolean hasParameterChanged(String key) { |
|
182 |
HashMap<String, Object> lastParameters = this.lastParameters; |
|
183 |
if(this.parametersHistory.size() > 1) { |
|
184 |
lastParameters = this.parametersHistory.get(this.parametersHistory.size() - 2); |
|
185 |
} |
|
186 |
|
|
187 |
return this.hasParameterChanged(key, lastParameters); |
|
188 |
} |
|
189 |
|
|
178 | 190 |
/** |
191 |
* Renders the chart using the right chart creator. |
|
192 |
* The chart is created if needed then it is updated. |
|
179 | 193 |
* |
180 | 194 |
* @return true if the chart has been rendered |
181 | 195 |
* @throws Exception |
... | ... | |
512 | 526 |
} |
513 | 527 |
|
514 | 528 |
|
515 |
/** |
|
516 |
* Checks if a preference is empty (equals to "") in the command preference node. |
|
517 |
* An empty preference can be used to disable a functionality for a kind of result |
|
518 |
* (eg. A partition dimension bar chart does not have a legend so it can be used to not offer the hide/show legend button in UI). |
|
519 |
* @param key |
|
520 |
* @return |
|
521 |
*/ |
|
522 |
public boolean isEmptyPreference(String key) { |
|
523 |
return TXMPreferences.isEmpty(this.commandPreferencesNodePath, key); |
|
524 |
} |
|
525 | 529 |
|
526 |
|
|
527 |
|
|
528 |
|
|
529 | 530 |
/** |
530 | 531 |
* @return the monoStyle |
531 | 532 |
*/ |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreatePartitionDialog.java (revision 1138) | ||
---|---|---|
632 | 632 |
return null; |
633 | 633 |
} |
634 | 634 |
|
635 |
if (p.getNPart() == 0) {
|
|
635 |
if (p.getPartsCount() == 0) {
|
|
636 | 636 |
Log.severe(TXMUIMessages.CreatePartitionDialog_10); |
637 | 637 |
return null; |
638 | 638 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/adapters/TXMResultAdapter.java (revision 1138) | ||
---|---|---|
67 | 67 |
Color color = display.getSystemColor(SWT.COLOR_DARK_GRAY); |
68 | 68 |
return color.getRGB(); |
69 | 69 |
} |
70 |
// FIXME: DEbug |
|
71 |
// else if(element instanceof TXMResult && ((TXMResult)element).isDirty()) { |
|
72 |
// Display display = Display.getCurrent(); |
|
73 |
// Color color = display.getSystemColor(SWT.COLOR_YELLOW); |
|
74 |
// return color.getRGB(); |
|
75 |
// } |
|
76 |
|
|
70 | 77 |
return null; |
71 | 78 |
} |
72 | 79 |
|
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 1138) | ||
---|---|---|
44 | 44 |
import org.eclipse.swt.widgets.ToolItem; |
45 | 45 |
import org.eclipse.ui.IEditorInput; |
46 | 46 |
import org.eclipse.ui.IEditorPart; |
47 |
import org.eclipse.ui.IEditorReference; |
|
47 | 48 |
import org.eclipse.ui.IEditorSite; |
48 | 49 |
import org.eclipse.ui.IPartListener; |
49 | 50 |
import org.eclipse.ui.IPartListener2; |
... | ... | |
626 | 627 |
public void run() { |
627 | 628 |
if(update) { |
628 | 629 |
// FIXME: DEbug |
629 |
System.err.println("TXMEditor.compute(): manually updating result from editor."); //$NON-NLS-1$
|
|
630 |
Log.finest("TXMEditor.compute(): " + TXMEditor.this.getClass().getSimpleName() + ": manually updating result from editor."); //$NON-NLS-1$
|
|
630 | 631 |
updateResultFromEditor(); // subclasses manual result updating from editor fields |
631 | 632 |
// FIXME: DEbug |
632 |
System.err.println("TXMEditor.compute(): auto updating result from editor."); //$NON-NLS-1$
|
|
633 |
Log.finest("TXMEditor.compute(): " + TXMEditor.this.getClass().getSimpleName() + ": auto updating result from editor."); //$NON-NLS-1$
|
|
633 | 634 |
autoUpdateResultFromEditorParameters(); // auto updating result from Parameter annotations in result <=> editor |
634 | 635 |
|
635 | 636 |
// Stores the last parameters before the computing to later auto-update the Widgets only if some parameters have changed |
... | ... | |
773 | 774 |
CorporaView.refreshObject(this); |
774 | 775 |
TXMResultDebugView.refreshView(); |
775 | 776 |
|
777 |
// FIXME: debug test to not draw while updating the widgets |
|
778 |
this.getContainer().setRedraw(true); |
|
779 |
|
|
780 |
|
|
776 | 781 |
// FIXME: update all open editors of the children result |
777 | 782 |
// FIXME: prob here is that updateEditorFromResult() doesn't enough because the compute() method does some other stuff |
778 | 783 |
// so the cascade computing may be done here rather than in TXMResult.compute() or we need to move some stuff from TXMEditor.compute() to |
779 | 784 |
// TXMEditor.updateEditorFromResult(), eg. the chart loading |
780 | 785 |
// WARNING: At This moment, with this code, TXMResult.compute() of the children is called twice |
781 |
// for (IEditorReference reference : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences()) { |
|
782 |
// IEditorPart editor = reference.getEditor(false); |
|
783 |
// if(editor != null && editor instanceof TXMEditor) { |
|
784 |
// TXMEditor txmEditor = ((TXMEditor)editor); |
|
785 |
// if(txmEditor.getResult().getParent() == this.getResult()) { |
|
786 |
// Log.finest("TXMEditor.refresh(): updating editor for result: " + txmEditor.getResult().getSimpleName()); |
|
787 |
// txmEditor.compute(true); |
|
788 |
// //txmEditor.updateEditorFromResult(false); |
|
789 |
// } |
|
790 |
// } |
|
791 |
// } |
|
786 |
// for (IEditorReference reference : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences()) { |
|
787 |
// IEditorPart editor = reference.getEditor(false); |
|
788 |
// if(editor != null && editor instanceof TXMEditor) { |
|
789 |
// TXMEditor txmEditor = ((TXMEditor)editor); |
|
790 |
// if(txmEditor.getResult().getParent() == this.getResult()) { |
|
791 |
// Log.finest("TXMEditor.refresh(): updating editor for result: " + txmEditor.getResult().getSimpleName()); |
|
792 |
// txmEditor.compute(false); |
|
793 |
// //txmEditor.updateEditorFromResult(false); |
|
794 |
// //txmEditor.refresh(false); |
|
795 |
// } |
|
796 |
// } |
|
797 |
// } |
|
792 | 798 |
|
793 | 799 |
|
794 |
// FIXME: debug test to not draw while updating the widgets |
|
795 |
this.getContainer().setRedraw(true); |
|
796 | 800 |
|
797 | 801 |
|
798 | 802 |
} |
tmp/org.txm.index.core/src/org/txm/index/core/functions/Lexicon.java (revision 1138) | ||
---|---|---|
135 | 135 |
@Override |
136 | 136 |
public boolean loadParameters() throws Exception { |
137 | 137 |
try { |
138 |
//this.persistable = false; // FIXME: remove that later |
|
139 | 138 |
String p = this.getStringParameterValue(TXMPreferences.UNIT_PROPERTY); |
140 | 139 |
if (p != null && p.length() > 0) { |
141 | 140 |
CQPCorpus parent = getParent(); |
tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/CreatePartition.java (revision 1138) | ||
---|---|---|
103 | 103 |
} |
104 | 104 |
monitor.worked(95); |
105 | 105 |
|
106 |
Log.info(NLS.bind(TXMUIMessages.CreatePartition_6, partition.getNPart()));
|
|
106 |
Log.info(NLS.bind(TXMUIMessages.CreatePartition_6, partition.getPartsCount()));
|
|
107 | 107 |
|
108 | 108 |
monitor.subTask(TXMUIMessages.RefreshingCorporaView); |
109 | 109 |
syncExec(new Runnable() { |
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesEditor.java (revision 1138) | ||
---|---|---|
148 | 148 |
|
149 | 149 |
|
150 | 150 |
// create 2nd column: Frequency |
151 |
this.typeFrequencyColumn = new TableColumn(viewer.getTable(), SWT.NONE);
|
|
151 |
this.typeFrequencyColumn = new TableColumn(specificitesTable, SWT.NONE);
|
|
152 | 152 |
this.typeFrequencyColumn.setAlignment(SWT.RIGHT); |
153 | 153 |
this.typeFrequencyColumn.setText(TXMCoreMessages.common_frequency); |
154 | 154 |
|
... | ... | |
203 | 203 |
return; |
204 | 204 |
} |
205 | 205 |
|
206 |
// remove part columns if exist |
|
207 |
// for (int firstPartColumnIndex = 3; firstPartColumnIndex < specificitesTable.getColumnCount(); firstPartColumnIndex++) { |
|
208 |
// specificitesTable.getColumn(firstPartColumnIndex).dispose(); |
|
209 |
// } |
|
210 |
|
|
206 | 211 |
// System.out.println("partnames: "+Arrays.toString(partNames)); |
207 |
for (int i = 0, columnIndex = 2; i < partNames.length ; i++) { // for each part |
|
212 |
// for each part |
|
213 |
for (int i = 0, firstPartColumnIndex = 2; i < partNames.length ; i++) { |
|
208 | 214 |
|
209 | 215 |
//FREQ COLUMN |
210 | 216 |
final TableColumn freqpartTableColumn = new TableColumn(specificitesTable, SWT.NONE); |
... | ... | |
214 | 220 |
freqpartTableColumn.setAlignment(SWT.RIGHT); |
215 | 221 |
freqpartTableColumn.pack(); |
216 | 222 |
|
217 |
viewerComparator.addSelectionAdapter(viewer, freqpartTableColumn, ++columnIndex);
|
|
223 |
viewerComparator.addSelectionAdapter(viewer, freqpartTableColumn, ++firstPartColumnIndex);
|
|
218 | 224 |
|
219 | 225 |
//SCORE COLUMN |
220 | 226 |
final TableColumn partTableColumn = new TableColumn(specificitesTable, SWT.NONE); |
... | ... | |
224 | 230 |
partTableColumn.setAlignment(SWT.RIGHT); |
225 | 231 |
partTableColumn.pack(); |
226 | 232 |
|
227 |
viewerComparator.addSelectionAdapter(viewer, partTableColumn, ++columnIndex);
|
|
233 |
viewerComparator.addSelectionAdapter(viewer, partTableColumn, ++firstPartColumnIndex);
|
|
228 | 234 |
|
229 | 235 |
} |
230 | 236 |
} |
... | ... | |
248 | 254 |
//final int[] sortedPartIndexes = specificitesResult.getSortedPartIndexes(); |
249 | 255 |
|
250 | 256 |
// Create an array of lines to fill the tables |
251 |
// System.out.println("len types: "+typeNames.length);
|
|
252 |
// System.out.println("len freq: "+typeFreq.length);
|
|
253 |
// System.out.println("len spec: "+specFreqs.length);
|
|
254 |
// System.out.println("len specidx: "+specIndex.length);
|
|
257 |
System.out.println("len types: "+typeNames.length); |
|
258 |
System.out.println("len freq: "+typeFreq.length); |
|
259 |
System.out.println("len specfreqs: "+specFreqs.length);
|
|
260 |
System.out.println("len specidx: "+specIndex.length); |
|
255 | 261 |
Object[] tableLines = new Object[typeNames.length]; |
256 | 262 |
for (int j = 0; j < tableLines.length; j++) { |
257 | 263 |
tableLines[j] = new Object[] { typeNames[j], new Integer(typeFreq[j]), specFreqs[j], specIndex[j] }; |
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/handlers/ComputeCA.java (revision 1138) | ||
---|---|---|
81 | 81 |
|
82 | 82 |
Partition partition = (Partition) selection; |
83 | 83 |
|
84 |
if (partition.getNPart() < 4) { // error to few parts
|
|
84 |
if (partition.getPartsCount() < 4) { // error to few parts
|
|
85 | 85 |
MessageDialog d = new MessageDialog(window.getShell(), "", null, //$NON-NLS-1$ |
86 |
NLS.bind(CAUIMessages.ComputeCorrespondanceAnalysis_4, partition.getNPart()), 0, new String[] { ""}, 0); //$NON-NLS-1$
|
|
86 |
NLS.bind(CAUIMessages.ComputeCorrespondanceAnalysis_4, partition.getPartsCount()), 0, new String[] { ""}, 0); //$NON-NLS-1$
|
|
87 | 87 |
d.open(); |
88 | 88 |
return null; |
89 | 89 |
} |
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java (revision 1138) | ||
---|---|---|
34 | 34 |
import java.io.IOException; |
35 | 35 |
import java.io.OutputStreamWriter; |
36 | 36 |
import java.io.UnsupportedEncodingException; |
37 |
import java.util.ArrayList; |
|
37 | 38 |
import java.util.Arrays; |
38 | 39 |
import java.util.List; |
39 | 40 |
|
... | ... | |
185 | 186 |
|
186 | 187 |
@Override |
187 | 188 |
protected boolean _compute() throws Exception { |
189 |
|
|
190 |
this.frequencies = null; |
|
191 |
|
|
188 | 192 |
|
189 | 193 |
// recompute the lexical table |
190 |
if(this.hasParameterChanged(TBXPreferences.UNIT_PROPERTY)) { |
|
191 |
this.lexicalTable.setUnitProperty(this.unitProperty); |
|
192 |
this.lexicalTable.compute(this, false); |
|
194 |
// if(this.hasParameterChanged(TBXPreferences.UNIT_PROPERTY)) { |
|
195 |
// this.lexicalTable.setUnitProperty(this.unitProperty); |
|
196 |
// this.lexicalTable.compute(this, false); |
|
197 |
// } |
|
198 |
|
|
199 |
// delete the specificities selection chart children since they can not be valid anymore |
|
200 |
if(this.needsFullRecomputing || this.hasParameterChanged(TBXPreferences.UNIT_PROPERTY)) { |
|
201 |
this.deleteChildren(SpecificitiesSelection.class); |
|
193 | 202 |
} |
203 |
|
|
194 | 204 |
|
195 | 205 |
// essentially for cascade computing from the parent lexical table |
196 | 206 |
this.unitProperty = this.lexicalTable.getProperty(); |
... | ... | |
206 | 216 |
init(rSpecificities.getSymbol(), specIndex, "TLNONAME: " + this.unitProperty.getName()); //$NON-NLS-1$ |
207 | 217 |
} |
208 | 218 |
} |
219 |
|
|
209 | 220 |
return true; |
210 | 221 |
} |
211 | 222 |
|
... | ... | |
452 | 463 |
//System.out.println("FROM TABLE"); |
453 | 464 |
frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(lexicalTable.getData().getSymbol()); |
454 | 465 |
|
455 |
} else {// if table == null : subcorpus specif |
|
466 |
} |
|
467 |
else {// if table == null : subcorpus specif |
|
456 | 468 |
//System.out.println("FROM LEXICON"); |
457 | 469 |
frequencies = new int[lexicon.getFreq().length][2]; // build a frequency table from lexicons |
458 | 470 |
String[] corpusforms = lexicon.getForms(); // all the forms |
... | ... | |
462 | 474 |
|
463 | 475 |
// System.out.println("len subforms: "+subcorpusforms.length); |
464 | 476 |
// System.out.println("len subfreqs: "+subcorpusfreq.length); |
465 |
for (int i = 0 ; i < corpusforms.length ; i++) //get all forms
|
|
466 |
{ |
|
477 |
//get all forms |
|
478 |
for (int i = 0 ; i < corpusforms.length ; i++) {
|
|
467 | 479 |
int j = 0; // find the index of the form in the subcorpus arrays |
468 | 480 |
for (j = 0; j < subcorpusforms.length; j++) { |
469 | 481 |
if (subcorpusforms[j].equals(corpusforms[i])) |
tmp/org.txm.progression.core/src/org/txm/progression/core/chartsengine/jfreechart/JFCProgressionCumulativeChartCreator.java (revision 1138) | ||
---|---|---|
19 | 19 |
import org.txm.chartsengine.jfreechart.core.renderers.MultipleItemsSelector; |
20 | 20 |
import org.txm.chartsengine.jfreechart.core.renderers.interfaces.IRendererWithItemSelection; |
21 | 21 |
import org.txm.chartsengine.jfreechart.core.themes.base.ExtendedNumberAxis; |
22 |
import org.txm.core.preferences.TXMPreferences; |
|
22 | 23 |
import org.txm.progression.core.chartsengine.base.ProgressionChartCreator; |
23 | 24 |
import org.txm.progression.core.chartsengine.base.Utils; |
24 | 25 |
import org.txm.progression.core.chartsengine.jfreechart.themes.highcharts.renderers.ProgressionItemSelectionRenderer; |
... | ... | |
119 | 120 |
|
120 | 121 |
|
121 | 122 |
// Fill the data set from the result |
122 |
if(progression.hasParameterChanged(ProgressionPreferences.QUERIES)) {
|
|
123 |
if(progression.hasParameterChanged(TXMPreferences.QUERIES)) {
|
|
123 | 124 |
XYSeriesCollection dataset = (XYSeriesCollection) chart.getXYPlot().getDataset(); |
124 | 125 |
dataset.removeAllSeries(); |
125 | 126 |
|
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Part.java (revision 1138) | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import java.io.File; |
31 | 31 |
|
32 |
import org.eclipse.osgi.util.NLS; |
|
33 |
import org.txm.core.messages.TXMCoreMessages; |
|
34 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
|
32 | 35 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
36 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
|
37 |
import org.txm.utils.logger.Log; |
|
33 | 38 |
|
34 | 39 |
/** |
35 | 40 |
* A Part is related to the {@link Partition} and is a CQP this. |
... | ... | |
45 | 50 |
* |
46 | 51 |
* @param partition |
47 | 52 |
*/ |
48 |
public Part(Partition partition) { |
|
53 |
public Part(Partition partition, String partName, String query) {
|
|
49 | 54 |
super(partition); |
50 | 55 |
|
56 |
this.userName = partName; |
|
57 |
this.pQuery = new CQLQuery(query); |
|
58 |
this.pID = CqpObject.partNamePrefix + CQPCorpus.getNextSubcorpusCounter(); |
|
59 |
|
|
51 | 60 |
this.setVisible(false); |
52 | 61 |
this.internalPersistable = true; |
53 | 62 |
this.userPersistable = false; |
... | ... | |
65 | 74 |
this.userPersistable = false; |
66 | 75 |
} |
67 | 76 |
|
68 |
public Partition getParent() { |
|
69 |
return (Partition)super.getParent(); |
|
77 |
@Override |
|
78 |
public boolean loadParameters() throws Exception { |
|
79 |
return super.loadParameters(); |
|
70 | 80 |
} |
81 |
|
|
82 |
@Override |
|
83 |
protected boolean _compute() throws Exception { |
|
71 | 84 |
|
85 |
Log.finest(NLS.bind(TXMCoreMessages.CREATING_PART, this.getName(), this.pQuery)); |
|
86 |
long start = System.currentTimeMillis(); |
|
87 |
try { |
|
88 |
super._compute(); |
|
89 |
|
|
90 |
} catch (Exception e) { |
|
91 |
try { |
|
92 |
throw new CqiClientException(TXMCoreMessages.Partition_9 + this.getParent().getName() + "_" + this.getName() + e + " last error: " + CQPSearchEngine.getCqiClient().getLastCQPError()); //$NON-NLS-1$ //$NON-NLS-2$ |
|
93 |
} catch (Exception e1) { |
|
94 |
Log.severe(TXMCoreMessages.Partition_18 + e1); |
|
95 |
org.txm.utils.logger.Log.printStackTrace(e1); |
|
96 |
return false; |
|
97 |
} |
|
98 |
} |
|
99 |
long end = System.currentTimeMillis(); |
|
100 |
Log.finest(NLS.bind(TXMCoreMessages.info_partCreatedInXMs, this.getParent().getName() + "_" + this.getName(), (end - start))); //$NON-NLS-1 |
|
101 |
|
|
102 |
return true; |
|
103 |
} |
|
104 |
|
|
105 |
|
|
106 |
// public Part createPart(String partitionName, String partName, String query) throws CqiClientException { |
|
107 |
// Part part; |
|
108 |
// String partCqpId = CqpObject.partNamePrefix + CQPCorpus.getNextSubcorpusCounter(); |
|
109 |
// Log.finest(NLS.bind(TXMCoreMessages.CREATING_PART, partName, query)); |
|
110 |
// long start = System.currentTimeMillis(); |
|
111 |
// try { |
|
112 |
// CorpusManager.getCorpusManager().getCqiClient().cqpQuery(this.getParent().getQualifiedCqpId(), partCqpId, query); |
|
113 |
// part = new Part(this); |
|
114 |
// part.setParameters(partCqpId, partName, new CQLQuery(query)); |
|
115 |
// part.compute(); |
|
116 |
// // FIXME: persistence tests: define the UUID as the concatenation of all part CQP id |
|
117 |
//// this.uniqueID += partCqpId; |
|
118 |
// |
|
119 |
// } catch (Exception e) { |
|
120 |
// try { |
|
121 |
// throw new CqiClientException(TXMCoreMessages.Partition_9 + partitionName + "_" + partName + e + " last error: " + CQPSearchEngine.getCqiClient().getLastCQPError()); //$NON-NLS-1$ //$NON-NLS-2$ |
|
122 |
// } catch (Exception e1) { |
|
123 |
// Log.severe(TXMCoreMessages.Partition_18 + e1); |
|
124 |
// org.txm.utils.logger.Log.printStackTrace(e1); |
|
125 |
// return null; |
|
126 |
// } |
|
127 |
// } |
|
128 |
// long end = System.currentTimeMillis(); |
|
129 |
// Log.finest(NLS.bind(TXMCoreMessages.info_partCreatedInXMs, partitionName + "_" + partName, (end - start))); //$NON-NLS-1 |
|
130 |
// |
|
131 |
// return part; |
|
132 |
// } |
|
133 |
// |
|
134 |
|
|
135 |
|
|
136 |
|
|
72 | 137 |
/** |
73 | 138 |
* Gets the number of texts in this part. |
74 | 139 |
* |
75 | 140 |
* @return the n texts |
76 | 141 |
* |
77 |
* @throws CqiClientException |
|
78 |
* the cqi client exception |
|
142 |
* @throws CqiClientException the cqi client exception |
|
79 | 143 |
*/ |
80 | 144 |
public int getNTexts() throws CqiClientException { |
81 | 145 |
if (nTexts < 0) { |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java (revision 1138) | ||
---|---|---|
82 | 82 |
protected StructuralUnitProperty pProperty; |
83 | 83 |
|
84 | 84 |
/** |
85 |
* the parts property values to use, may be null
|
|
85 |
* The parts property values to use, may be null.
|
|
86 | 86 |
*/ |
87 | 87 |
@Parameter(key=TXMPreferences.VALUES) |
88 | 88 |
protected List<String> pValues; |
89 | 89 |
|
90 | 90 |
/** |
91 |
* the parts queries
|
|
91 |
* The parts queries
|
|
92 | 92 |
*/ |
93 | 93 |
@Parameter(key=TXMPreferences.QUERIES) |
94 | 94 |
protected List<String> pQueries; |
95 | 95 |
|
96 | 96 |
/** |
97 |
* the parts names -> do the parts order
|
|
97 |
* The parts names -> do the parts order
|
|
98 | 98 |
*/ |
99 | 99 |
@Parameter(key=CQPPreferences.PART_NAMES) |
100 | 100 |
protected List<String> pPartNames; |
101 | 101 |
|
102 |
/** |
|
103 |
* the partition name to set |
|
104 |
*/ |
|
105 |
@Parameter(key=TXMPreferences.LAZY_NAME) |
|
106 |
protected String pName; |
|
107 | 102 |
|
108 |
// /** |
|
109 |
// * Create a partition with a set of raw queries. |
|
110 |
// * |
|
111 |
// * @param corpus the corpus |
|
112 |
// * @param name the name |
|
113 |
// * @param queries the queries |
|
114 |
// * @throws CqiClientException the cqi client exception |
|
115 |
// * @author Sylvain Loiseau |
|
116 |
// */ |
|
117 |
// protected Partition(Corpus corpus, String name, List<String> queries) throws CqiClientException { |
|
118 |
// this(corpus, name, queries, null); |
|
119 |
// } |
|
120 |
|
|
121 | 103 |
/** |
122 | 104 |
* |
123 | 105 |
* @param parent |
... | ... | |
146 | 128 |
*/ |
147 | 129 |
public boolean _compute_with_lists() throws Exception { |
148 | 130 |
|
149 |
if (pName == null || pName.length() == 0) {
|
|
150 |
pName = "no_name";
|
|
131 |
if (this.userName == null || this.userName.length() == 0) {
|
|
132 |
this.userName = "no_name";
|
|
151 | 133 |
} |
152 | 134 |
|
153 |
Log.info(NLS.bind(TXMCoreMessages.info_creatingNewPartition, this.getParent(), this.pName));
|
|
135 |
Log.info(NLS.bind(TXMCoreMessages.info_creatingNewPartition, this.getParent(), this.userName));
|
|
154 | 136 |
long start = System.currentTimeMillis(); |
155 | 137 |
for (int i = 0; i < pQueries.size(); i++) { |
156 | 138 |
String queryS = pQueries.get(i); |
... | ... | |
163 | 145 |
partName = "-"; //$NON-NLS-1$ |
164 | 146 |
} |
165 | 147 |
|
166 |
Part part = this.createPart(this.getName(), partName, queryS); // lazy
|
|
148 |
this.addChild(new Part(this, partName, queryS));
|
|
167 | 149 |
} |
168 | 150 |
long end = System.currentTimeMillis(); |
169 |
Log.info(NLS.bind(TXMCoreMessages.info_partitionCreatedInXMs, this.pName, (end - start)));
|
|
151 |
Log.info(NLS.bind(TXMCoreMessages.info_partitionCreatedInXMs, this.userName, (end - start)));
|
|
170 | 152 |
|
171 | 153 |
return pQueries.size() > 0; |
172 | 154 |
} |
... | ... | |
179 | 161 |
* part is composed by all the structure <code>structure</code> such as |
180 | 162 |
* <code>strucutre.getValue(property) == values.get(i)<code> |
181 | 163 |
* |
182 |
* @param corpus |
|
183 |
* the corpus |
|
184 |
* @param structure |
|
185 |
* the structure |
|
186 |
* @param property |
|
187 |
* the property |
|
188 |
* @param values |
|
189 |
* the values, raw values special chars will be backslashed |
|
164 |
* @param corpus the corpus |
|
165 |
* @param structure the structure |
|
166 |
* @param property the property |
|
167 |
* @param values the values, raw values special chars will be backslashed |
|
190 | 168 |
* @throws Exception |
191 | 169 |
*/ |
192 | 170 |
|
193 | 171 |
protected boolean _compute_with_property() throws Exception { |
194 | 172 |
|
195 |
CQPCorpus corpus = getParent(); |
|
196 |
if (pName == null || pName.length() == 0) {
|
|
197 |
pName = corpus.getName() + "_" + pProperty.getFullName(); //$NON-NLS-1$
|
|
173 |
CQPCorpus corpus = this.getParent();
|
|
174 |
if (this.userName == null || this.userName.length() == 0) {
|
|
175 |
this.userName = corpus.getName() + "_" + pProperty.getFullName(); //$NON-NLS-1$
|
|
198 | 176 |
} |
199 | 177 |
|
200 | 178 |
if (pValues == null) { |
... | ... | |
210 | 188 |
} |
211 | 189 |
if (type == null || type.trim().length() == 0 || type.equals("String")) { //$NON-NLS-1$ |
212 | 190 |
Collections.sort(pValues, Collator.getInstance(Locale.getDefault())); // alpha sort |
213 |
} else if (type.equals("Integer")) { //$NON-NLS-1$ |
|
191 |
} |
|
192 |
else if (type.equals("Integer")) { //$NON-NLS-1$ |
|
214 | 193 |
Collections.sort(pValues, new Comparator<String>() { |
215 | 194 |
@Override |
216 | 195 |
public int compare(String arg0, String arg1) { |
... | ... | |
219 | 198 |
return i0 - i1; |
220 | 199 |
} |
221 | 200 |
}); |
222 |
} else if (type.equals("Date")) { //$NON-NLS-1$ |
|
201 |
} |
|
202 |
else if (type.equals("Date")) { //$NON-NLS-1$ |
|
223 | 203 |
String format = infos.get("inputFormat"); //$NON-NLS-1$ |
224 | 204 |
final DateFormat formater = new SimpleDateFormat(format); |
225 | 205 |
Collections.sort(pValues, new Comparator<String>() { |
... | ... | |
234 | 214 |
} |
235 | 215 |
} |
236 | 216 |
}); |
237 |
} else if (type.contains("|")){ //$NON-NLS-1$ |
|
217 |
} |
|
218 |
else if (type.contains("|")){ //$NON-NLS-1$ |
|
238 | 219 |
final List<String> sortedValues = Arrays.asList(type.split("\\|")); //$NON-NLS-1$ |
239 | 220 |
Collections.sort(pValues, new Comparator<String>() { |
240 | 221 |
@Override |
... | ... | |
262 | 243 |
@Override |
263 | 244 |
protected boolean _compute() throws Exception { |
264 | 245 |
|
265 |
if (getParts().size() > 0) return true; // Parts already created |
|
246 |
// Parts already created |
|
247 |
if (this.getParts().size() > 0) { |
|
248 |
// //FIXME: temporary fix, compute all the children parts |
|
249 |
// List<Part> parts = (List<Part>)getChildren(Part.class); |
|
250 |
// for (int i = 0; i < parts.size(); i++) { |
|
251 |
// if(!parts.get(i).hasBeenComputedOnce()) { |
|
252 |
// parts.get(i).compute(this, true); |
|
253 |
// } |
|
254 |
// } |
|
255 |
return true; |
|
256 |
} |
|
266 | 257 |
|
267 |
Log.finest(NLS.bind(TXMCoreMessages.info_creatingNewPartition, this.getParent(), this.pName));
|
|
258 |
Log.finest(NLS.bind(TXMCoreMessages.info_creatingNewPartition, this.getParent(), this.userName));
|
|
268 | 259 |
|
269 |
if (pProperty != null) { |
|
260 |
if (this.pProperty != null) {
|
|
270 | 261 |
_compute_with_property(); |
271 |
} else { |
|
262 |
} |
|
263 |
else { |
|
272 | 264 |
_compute_with_lists(); |
273 | 265 |
} |
274 | 266 |
|
275 |
//FIXME: temporary fix, compute all the children parts |
|
276 |
// List<Part> parts = (List<Part>)getChildren(Part.class); |
|
277 |
// for (int i = 0; i < parts.size(); i++) { |
|
278 |
// parts.get(i).compute(this, true); |
|
279 |
// } |
|
280 | 267 |
|
281 | 268 |
return true; |
282 | 269 |
} |
... | ... | |
318 | 305 |
|
319 | 306 |
@Override |
320 | 307 |
public boolean canCompute() { |
321 |
return getParent() != null && (pProperty != null || (pQueries != null && pQueries.size() > 0));
|
|
308 |
return this.getParent() != null && (this.pProperty != null || (this.pQueries != null && this.pQueries.size() > 0));
|
|
322 | 309 |
} |
323 | 310 |
|
324 | 311 |
@Override |
... | ... | |
337 | 324 |
return output; |
338 | 325 |
} |
339 | 326 |
|
340 |
/** |
|
341 |
* TODO Part should be create lazily |
|
342 |
* |
|
343 |
* Create a part with a raw query. |
|
344 |
* |
|
345 |
* @param partitionName the partition name |
|
346 |
* @param partName the part name |
|
347 |
* @param query the query |
|
348 |
* @return the part |
|
349 |
* @throws CqiClientException the cqi client exception |
|
350 |
* |
|
351 |
* @author Sylvain Loiseau, mdecorde |
|
352 |
*/ |
|
353 |
public Part createPart(String partitionName, String partName, String query) throws CqiClientException { |
|
354 |
Part part; |
|
355 |
String partCqpId = CqpObject.partNamePrefix + CQPCorpus.getNextSubcorpusCounter(); |
|
356 |
Log.finest(NLS.bind(TXMCoreMessages.CREATING_PART, partName, query)); |
|
357 |
long start = System.currentTimeMillis(); |
|
358 |
try { |
|
359 |
CorpusManager.getCorpusManager().getCqiClient().cqpQuery(this.getParent().getQualifiedCqpId(), partCqpId, query); |
|
360 |
part = new Part(this); |
|
361 |
part.setParameters(partCqpId, partName, new CQLQuery(query)); |
|
362 |
part.compute(); |
|
363 |
// FIXME: persistence tests: define the UUID as the concatenation of all part CQP id |
|
364 |
// this.uniqueID += partCqpId; |
|
365 |
|
|
366 |
} catch (Exception e) { |
|
367 |
try { |
|
368 |
throw new CqiClientException(TXMCoreMessages.Partition_9 + partitionName + "_" + partName + e + " last error: " + CQPSearchEngine.getCqiClient().getLastCQPError()); //$NON-NLS-1$ //$NON-NLS-2$ |
|
369 |
} catch (Exception e1) { |
|
370 |
Log.severe(TXMCoreMessages.Partition_18 + e1); |
|
371 |
org.txm.utils.logger.Log.printStackTrace(e1); |
|
372 |
return null; |
|
373 |
} |
|
374 |
} |
|
375 |
long end = System.currentTimeMillis(); |
|
376 |
Log.finest(NLS.bind(TXMCoreMessages.info_partCreatedInXMs, partitionName + "_" + partName, (end - start))); //$NON-NLS-1 |
|
377 |
|
|
378 |
return part; |
|
379 |
} |
|
327 |
// /**
|
|
328 |
// * TODO Part should be create lazily
|
|
329 |
// *
|
|
330 |
// * Create a part with a raw query.
|
|
331 |
// *
|
|
332 |
// * @param partitionName the partition name
|
|
333 |
// * @param partName the part name
|
|
334 |
// * @param query the query
|
|
335 |
// * @return the part
|
|
336 |
// * @throws CqiClientException the cqi client exception
|
|
337 |
// *
|
|
338 |
// * @author Sylvain Loiseau, mdecorde
|
|
339 |
// */
|
|
340 |
// public Part createPart(String partitionName, String partName, String query) throws CqiClientException {
|
|
341 |
// Part part;
|
|
342 |
// String partCqpId = CqpObject.partNamePrefix + CQPCorpus.getNextSubcorpusCounter();
|
|
343 |
// Log.finest(NLS.bind(TXMCoreMessages.CREATING_PART, partName, query));
|
|
344 |
// long start = System.currentTimeMillis();
|
|
345 |
// try {
|
|
346 |
// CorpusManager.getCorpusManager().getCqiClient().cqpQuery(this.getParent().getQualifiedCqpId(), partCqpId, query);
|
|
347 |
// part = new Part(this);
|
|
348 |
// part.setParameters(partCqpId, partName, new CQLQuery(query));
|
|
349 |
// part.compute();
|
|
350 |
// // FIXME: persistence tests: define the UUID as the concatenation of all part CQP id
|
|
351 |
//// this.uniqueID += partCqpId;
|
|
352 |
// |
|
353 |
// } catch (Exception e) {
|
|
354 |
// try {
|
|
355 |
// throw new CqiClientException(TXMCoreMessages.Partition_9 + partitionName + "_" + partName + e + " last error: " + CQPSearchEngine.getCqiClient().getLastCQPError()); //$NON-NLS-1$ //$NON-NLS-2$
|
|
356 |
// } catch (Exception e1) {
|
|
357 |
// Log.severe(TXMCoreMessages.Partition_18 + e1);
|
|
358 |
// org.txm.utils.logger.Log.printStackTrace(e1);
|
|
359 |
// return null;
|
|
360 |
// }
|
|
361 |
// }
|
|
362 |
// long end = System.currentTimeMillis();
|
|
363 |
// Log.finest(NLS.bind(TXMCoreMessages.info_partCreatedInXMs, partitionName + "_" + partName, (end - start))); //$NON-NLS-1
|
|
364 |
// |
|
365 |
// return part;
|
|
366 |
// }
|
|
380 | 367 |
|
381 |
/** |
|
382 |
* Gets the dirty states. |
|
383 |
* |
|
384 |
* @return |
|
385 |
*/ |
|
386 |
public boolean isDirty() { |
|
387 |
return this.dirty; |
|
388 |
} |
|
389 | 368 |
|
390 | 369 |
@Override |
391 | 370 |
public String getDetails() { |
392 | 371 |
return getName(); |
393 | 372 |
} |
394 | 373 |
|
395 |
@Override |
|
396 |
public String getName() { |
|
397 |
return this.pName; |
|
398 |
} |
|
399 |
|
|
400 | 374 |
/** |
401 | 375 |
* Gets the number of parts. |
402 | 376 |
* |
403 | 377 |
* @return the the number of parts. |
404 | 378 |
*/ |
405 |
public int getNPart() {
|
|
379 |
public int getPartsCount() {
|
|
406 | 380 |
// FIXME: later should just return the direct children count |
407 | 381 |
try { |
408 | 382 |
if (!hasBeenComputedOnce()) { |
... | ... | |
480 | 454 |
|
481 | 455 |
@Override |
482 | 456 |
public String getSimpleName() { |
483 |
return this.pName;
|
|
457 |
return this.userName;
|
|
484 | 458 |
} |
485 | 459 |
|
486 | 460 |
/** |
... | ... | |
531 | 505 |
* the cqi client exception |
532 | 506 |
*/ |
533 | 507 |
public List<QueryResult> query(CQLQuery query, String name) throws CqiClientException { |
534 |
Log.finest(TXMCoreMessages.QUERYING_PARTITION + this.pName);
|
|
508 |
Log.finest(TXMCoreMessages.QUERYING_PARTITION + this.userName);
|
|
535 | 509 |
List<Part> parts = getParts(); |
536 | 510 |
List<QueryResult> results = new ArrayList<QueryResult>(parts.size()); |
537 | 511 |
for (Subcorpus part : parts) { |
... | ... | |
605 | 579 |
//p.dropSubcorpus(p.getSubCorpus()); |
606 | 580 |
} |
607 | 581 |
|
608 |
/** |
|
609 |
* Sets the name. |
|
610 |
* |
|
611 |
* @param name the new name |
|
612 |
*/ |
|
613 |
public void setName(String name) { |
|
614 |
this.pName = name; |
|
615 |
// if(this.getSelfElement() != null) |
|
616 |
// this.getSelfElement().setAttribute("name", name); //$NON-NLS-1$ |
|
617 |
} |
|
618 | 582 |
|
619 |
|
|
583 |
@Override |
|
620 | 584 |
public String toString() { |
621 |
if (pName != null) {
|
|
622 |
return pName;
|
|
585 |
if (this.userName != null) {
|
|
586 |
return this.userName;
|
|
623 | 587 |
} |
624 | 588 |
return super.toString(); |
625 | 589 |
} |
... | ... | |
634 | 598 |
public boolean setParameters(String name, StructuralUnitProperty property, List<String> values) { |
635 | 599 |
this.pProperty = property; |
636 | 600 |
this.pValues = values; |
637 |
this.pName = name;
|
|
601 |
this.userName = name;
|
|
638 | 602 |
this.pQueries = null; |
639 | 603 |
this.pPartNames = null; |
640 | 604 |
return true; |
... | ... | |
643 | 607 |
public boolean setParameters(String name, List<String> queries, List<String> names) { |
644 | 608 |
this.pProperty = null; |
645 | 609 |
this.pValues = null; |
646 |
this.pName = name;
|
|
610 |
this.userName = name;
|
|
647 | 611 |
this.pQueries = queries; |
648 | 612 |
this.pPartNames = names; |
649 | 613 |
return true; |
... | ... | |
651 | 615 |
|
652 | 616 |
@Override |
653 | 617 |
public boolean setParameters(TXMParameters parameters) { |
654 |
this.pName = parameters.getString(TXMPreferences.LAZY_NAME);
|
|
618 |
this.userName = parameters.getString(TXMPreferences.USER_NAME);
|
|
655 | 619 |
String tmp = parameters.getString(CQPPreferences.PART_NAMES); |
656 | 620 |
if (tmp != null) { |
657 | 621 |
this.pPartNames = Arrays.asList(tmp.split("\t")); |
... | ... | |
723 | 687 |
public boolean saveParameters() { |
724 | 688 |
|
725 | 689 |
if (this.pProperty != null) { |
726 |
this.saveParameter(TBXPreferences.STRUCTURAL_UNIT_PROPERTY, this.pProperty.getName());
|
|
690 |
this.saveParameter(TXMPreferences.STRUCTURAL_UNIT_PROPERTY, this.pProperty.getName());
|
|
727 | 691 |
} |
728 | 692 |
|
729 | 693 |
if (this.pPartNames != null) { |
... | ... | |
731 | 695 |
} |
732 | 696 |
|
733 | 697 |
if (this.pQueries != null) { |
734 |
this.saveParameter(TBXPreferences.QUERIES, StringUtils.join(pQueries, "\t"));
|
|
698 |
this.saveParameter(TXMPreferences.QUERIES, StringUtils.join(pQueries, "\t"));
|
|
735 | 699 |
} |
736 | 700 |
|
737 | 701 |
if (this.pValues != null) { |
... | ... | |
761 | 725 |
public String getResultype() { |
762 | 726 |
return "Partition"; |
763 | 727 |
} |
728 |
|
|
729 |
/** |
|
730 |
* Gets the parent Partition of the specified result if exists. |
|
731 |
* @param result |
|
732 |
* @return the parent Partition if exists otherwise null |
|
733 |
*/ |
|
764 | 734 |
synchronized public static Partition getFirstParentPartition(TXMResult result) { |
765 | 735 |
return (Partition) result.getFirstParent(Partition.class); |
766 | 736 |
} |
737 |
|
|
738 |
@Override |
|
739 |
public String getName() { |
|
740 |
return this.userName; |
|
741 |
} |
|
767 | 742 |
} |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/PartitionFocus.java (revision 1138) | ||
---|---|---|
105 | 105 |
*/ |
106 | 106 |
public List<Part> getFocusedParts() { |
107 | 107 |
List<Part> focused = new ArrayList<Part>(modality.size()); |
108 |
for (int i = 0; i < partition.getNPart(); i++) {
|
|
108 |
for (int i = 0; i < partition.getPartsCount(); i++) {
|
|
109 | 109 |
if (modality.contains(partition.getParts().get(i))) { |
110 | 110 |
focused.add(partition.getParts().get(i)); |
111 | 111 |
} |
... | ... | |
120 | 120 |
*/ |
121 | 121 |
public List<Part> getNotFocusedParts() { |
122 | 122 |
List<Part> notFocused = new ArrayList<Part>(modality.size()); |
123 |
for (int i = 0; i < partition.getNPart(); i++) {
|
|
123 |
for (int i = 0; i < partition.getPartsCount(); i++) {
|
|
124 | 124 |
if (!modality.contains(partition.getParts().get(i))) { |
125 | 125 |
notFocused.add(partition.getParts().get(i)); |
126 | 126 |
} |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Subcorpus.java (revision 1138) | ||
---|---|---|
35 | 35 |
import org.eclipse.osgi.util.NLS; |
36 | 36 |
import org.txm.core.messages.TXMCoreMessages; |
37 | 37 |
import org.txm.core.preferences.TBXPreferences; |
38 |
import org.txm.core.preferences.TXMPreferences; |
|
38 | 39 |
import org.txm.core.results.Parameter; |
39 | 40 |
import org.txm.core.results.TXMParameters; |
40 | 41 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
... | ... | |
57 | 58 |
*/ |
58 | 59 |
public class Subcorpus extends CQPCorpus { |
59 | 60 |
|
61 |
|
|
62 |
private SelectionResult selectionResult; |
|
63 |
protected QueryResult qresult; |
|
64 |
|
|
65 |
|
|
66 |
|
|
60 | 67 |
/** |
61 | 68 |
* Query used to build the corpus. |
62 | 69 |
*/ |
63 |
@Parameter(key=TBXPreferences.QUERY)
|
|
70 |
@Parameter(key=TXMPreferences.QUERY)
|
|
64 | 71 |
protected CQLQuery pQuery; |
65 | 72 |
|
66 |
private SelectionResult selectionResult; |
|
67 |
protected QueryResult qresult; |
|
68 |
|
|
69 | 73 |
|
70 | 74 |
/** |
71 | 75 |
* |
... | ... | |
122 | 126 |
* {@link CQPCorpus#createSubcorpus(CQLQuery, String)} |
123 | 127 |
*/ |
124 | 128 |
protected boolean _compute() throws Exception { |
125 |
if (pQuery != null) { |
|
129 |
if (this.pQuery != null) {
|
|
126 | 130 |
this.qresult = null; // reset |
127 | 131 |
|
128 |
CorpusManager.getCorpusManager().getCqiClient().cqpQuery( |
|
129 |
this.getCorpusParent().getQualifiedCqpId(), pID, |
|
130 |
pQuery.getQueryString()); |
|
132 |
CorpusManager.getCorpusManager().getCqiClient().cqpQuery(this.getCorpusParent().getQualifiedCqpId(), this.pID, this.pQuery.getQueryString()); |
|
131 | 133 |
|
132 |
this.qresult = new QueryResult(pID, pName, this.getCorpusParent(), pQuery); // getCorpusParent().query(pQuery, this.pID, true);
|
|
134 |
this.qresult = new QueryResult(this.pID, this.pName, this.getCorpusParent(), this.pQuery); // getCorpusParent().query(pQuery, this.pID, true);
|
|
133 | 135 |
} |
134 | 136 |
return qresult != null; |
135 | 137 |
} |
136 | 138 |
|
139 |
/** |
|
140 |
* Sets the query to use. |
|
141 |
* @param query |
|
142 |
*/ |
|
137 | 143 |
public void setQuery(CQLQuery query) { |
138 | 144 |
this.pQuery = query; |
139 | 145 |
} |
... | ... | |
525 | 531 |
|
526 | 532 |
@Override |
527 | 533 |
public boolean loadParameters() throws Exception { |
528 |
String q = this.getStringParameterValue(TBXPreferences.QUERY);
|
|
529 |
if (q != null) {
|
|
534 |
String q = this.getStringParameterValue(TXMPreferences.QUERY);
|
|
535 |
if (!q.isEmpty()) {
|
|
530 | 536 |
pQuery = new CQLQuery(q); |
531 | 537 |
} |
532 | 538 |
|
tmp/org.txm.ca.core/src/org/txm/ca/core/chartsengine/jfreechart/themes/highcharts/chartcreators/JFCCAChartCreator.java (revision 1138) | ||
---|---|---|
79 | 79 |
public void updateChart(ChartResult result) { |
80 | 80 |
|
81 | 81 |
CA ca = (CA) result; |
82 |
|
|
82 | 83 |
JFreeChart chart = (JFreeChart)result.getChart(); |
83 |
|
|
84 |
|
|
84 | 85 |
// freeze rendering while computing |
85 | 86 |
chart.setNotify(false); |
87 |
|
|
86 | 88 |
|
89 |
// recreate the dataset if the unit property has changed |
|
90 |
// if(ca.getLexicalTable().hasParameterChanged(TXMPreferences.UNIT_PROPERTY)) { |
|
91 |
// try { |
|
92 |
// chart.getXYPlot().setDataset(new CAXYDataset(ca)); |
|
93 |
// } |
|
94 |
// catch (Exception e) { |
|
95 |
// // TODO Auto-generated catch block |
|
96 |
// e.printStackTrace(); |
|
97 |
// } |
|
98 |
// } |
|
99 |
|
|
87 | 100 |
|
88 | 101 |
CAItemSelectionRenderer renderer = (CAItemSelectionRenderer) chart.getXYPlot().getRenderer(); |
89 | 102 |
// XYPlot plot = chart.getXYPlot(); |
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 1138) | ||
---|---|---|
200 | 200 |
|
201 | 201 |
// parts lexicons |
202 | 202 |
List<Lexicon> partsLexicons = new ArrayList<Lexicon>(); |
203 |
for (int i = 0; i < partition.getNPart(); i++) {
|
|
203 |
for (int i = 0; i < partition.getPartsCount(); i++) {
|
|
204 | 204 |
partsLexicons.add(Lexicon.getLexicon(partition.getParts().get(i), this.property, this.monitor, false)); |
205 | 205 |
} |
206 | 206 |
|
tmp/org.txm.queryindex.rcp/src/org/txm/functions/queryindex/QueryIndex.java (revision 1138) | ||
---|---|---|
279 | 279 |
if (lines.containsKey(name)) return null; |
280 | 280 |
QueryResult[] qresults; |
281 | 281 |
if (partition != null) { |
282 |
qresults = new QueryResult[partition.getNPart()];
|
|
282 |
qresults = new QueryResult[partition.getPartsCount()];
|
|
283 | 283 |
List<Part> parts = partition.getParts(); |
284 | 284 |
for (int i = 0 ; i < parts.size() ; i++) { |
285 | 285 |
qresults[i] = parts.get(i).query(query, "tmp", true); //$NON-NLS-1$ |
... | ... | |
299 | 299 |
public LexicalTable toLexicalTable() { |
300 | 300 |
if (partition == null) return null; |
301 | 301 |
|
302 |
int npart = partition.getNPart();
|
|
302 |
int npart = partition.getPartsCount();
|
|
303 | 303 |
int[][] freqs = new int[lines.size()][npart]; |
304 | 304 |
String[] rownames = new String[lines.size()]; |
305 | 305 |
String[] colnames = new String[npart]; |
tmp/org.txm.queryindex.rcp/src/org/txm/queryindex/core/functions/QueryIndex.java (revision 1138) | ||
---|---|---|
279 | 279 |
if (lines.containsKey(name)) return null; |
280 | 280 |
QueryResult[] qresults; |
281 | 281 |
if (partition != null) { |
282 |
qresults = new QueryResult[partition.getNPart()];
|
|
282 |
qresults = new QueryResult[partition.getPartsCount()];
|
|
283 | 283 |
List<Part> parts = partition.getParts(); |
284 | 284 |
for (int i = 0 ; i < parts.size() ; i++) { |
285 | 285 |
qresults[i] = parts.get(i).query(query, "tmp", true); //$NON-NLS-1$ |
... | ... | |
299 | 299 |
public LexicalTable toLexicalTable() { |
300 | 300 |
if (partition == null) return null; |
301 | 301 |
|
302 |
int npart = partition.getNPart();
|
|
302 |
int npart = partition.getPartsCount();
|
|
303 | 303 |
int[][] freqs = new int[lines.size()][npart]; |
304 | 304 |
String[] rownames = new String[lines.size()]; |
305 | 305 |
String[] colnames = new String[npart]; |
tmp/org.txm.partition.core/src/org/txm/partition/core/functions/PartitionDimensions.java (revision 1138) | ||
---|---|---|
60 | 60 |
*/ |
61 | 61 |
public PartitionDimensions(Partition partition) { |
62 | 62 |
super(partition); |
63 |
System.err.println("PartitionDimensions.PartitionDimensions(): tesstttttttttttttttttttt"); |
|
64 | 63 |
} |
65 | 64 |
|
66 | 65 |
/** |
... | ... | |
88 | 87 |
|
89 | 88 |
@Override |
90 | 89 |
protected boolean _compute() throws Exception { |
91 |
// parts |
|
90 |
// retrieve the parts
|
|
92 | 91 |
this.parts = this.getPartition().getParts(); |
93 |
// for (Part part : parts) { // no more needed since TXMResult.compute is deep computing |
|
94 |
// part.compute(); |
|
95 |
// } |
|
96 | 92 |
|
97 |
// parts sorted by size |
|
93 |
// store a copy of parts sorted by size
|
|
98 | 94 |
List<Part> sortedParts = new ArrayList<Part>(this.parts); |
99 | 95 |
Collections.sort(sortedParts, new Comparator<Part>() { |
100 | 96 |
@Override |
... | ... | |
121 | 117 |
return this.getPartition() != null; |
122 | 118 |
} |
123 | 119 |
|
124 |
|
|
125 |
|
|
126 | 120 |
@Override |
127 | 121 |
public boolean setParameters(TXMParameters parameters) { |
128 | 122 |
try { |
tmp/org.txm.partition.rcp/plugin.xml (revision 1138) | ||
---|---|---|
69 | 69 |
style="push"> |
70 | 70 |
<visibleWhen |
71 | 71 |
checkEnabled="false"> |
72 |
<or> |
|
73 |
<reference |
|
74 |
definitionId="OneChartResultSelected"> |
|
75 |
</reference> |
|
76 |
</or> |
|
72 |
<test |
|
73 |
property="org.txm.partition.rcp.test1"> |
|
74 |
</test> |
|
77 | 75 |
</visibleWhen> |
78 | 76 |
</command> |
79 | 77 |
</menuContribution> |
tmp/org.txm.ahc.rcp/src/org/txm/ahc/rcp/handlers/ComputeAHC.java (revision 1138) | ||
---|---|---|
90 | 90 |
else if (selection instanceof Partition) { |
91 | 91 |
//System.out.println("Compute CAH with Partition : "+((Partition)selection.getFirstElement()).getName()); |
92 | 92 |
Partition partition = (Partition)selection; |
93 |
if (partition.getNPart() < 4) {
|
|
93 |
if (partition.getPartsCount() < 4) {
|
|
94 | 94 |
MessageDialog d = new MessageDialog(window.getShell(), TXMCoreMessages.error_error2, null, |
95 |
NLS.bind(AHCUIMessages.error_canNotComputeAHCWith, partition.getNPart()), 0, new String[] { TXMCoreMessages.common_ok}, 0);
|
|
95 |
NLS.bind(AHCUIMessages.error_canNotComputeAHCWith, partition.getPartsCount()), 0, new String[] { TXMCoreMessages.common_ok}, 0);
|
|
96 | 96 |
d.open(); |
97 | 97 |
return null; |
98 | 98 |
} |
Formats disponibles : Unified diff