Révision 1158

tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java (revision 1158)
118 118
	private CQPCorpus subCorpus = null;
119 119

  
120 120

  
121
	
122
	
123
//	/**
124
//	 * Unit property.
125
//	 */
126
//	@Parameter(key=TXMPreferences.UNIT_PROPERTY)
127
//	protected Property unitProperty;
128
	
129 121
	/**
130 122
	 * Maximum score.
131 123
	 */
......
169 161
	@Override
170 162
	public boolean loadParameters() {
171 163
		this.lexicalTable = (LexicalTable) this.parent;
172
		//this.unitProperty = this.lexicalTable.getProperty();
173
		this.lexicalTable.setVMaxFilter(Integer.MAX_VALUE);
164
		this.lexicalTable.setVMaxFilter(Integer.MAX_VALUE); // FIXME: useless?
174 165
		return true;
175 166
	}
176 167

  
......
188 179

  
189 180
		this.frequencies = null;
190 181

  
191
		
192
		// recompute the lexical table
193
//		if(this.hasParameterChanged(TBXPreferences.UNIT_PROPERTY))	{
194
//			this.lexicalTable.setUnitProperty(this.unitProperty);
195
//			this.lexicalTable.compute(this);
196
//		}
197
		
198 182
		// delete the specificities selection chart children since they can not be valid anymore
199 183
		if (this.needsFullRecomputing || this.hasParameterChanged(TBXPreferences.UNIT_PROPERTY))	{
200 184
			this.deleteChildren(SpecificitiesSelection.class);
201 185
		}
202 186
		
203

  
204
		// essentially for cascade computing from the parent lexical table
205
//		this.unitProperty = this.lexicalTable.getProperty();
206
		
207 187
		if (this.lexicalTable.hasBeenComputedOnce())	{
208 188
			SpecificitiesR rSpecificities = new SpecificitiesR(this.lexicalTable.getData());
209 189
			double[][] specIndex = rSpecificities.getScores();
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/FloatSpinner.java (revision 1158)
38 38
	 * Gets the selection as a float number.
39 39
	 * @return
40 40
	 */
41
	public double getSelectionAsFloat() {
42
		return (double) (super.getSelection() / Math.pow(10, this.getDigits()));
41
	public float getSelectionAsFloat() {
42
		return (float) (super.getSelection() / Math.pow(10, this.getDigits()));
43 43
	}
44 44
	
45 45
	/**
tmp/org.txm.rcp/src/main/java/org/txm/rcp/adapters/TXMResultAdapter.java (revision 1158)
63 63

  
64 64
	@Override
65 65
    public RGB getForeground(Object element) {
66
//		if(element instanceof TXMResult && !((TXMResult)element).hasBeenComputedOnce())	{
67
//	    	Display display = Display.getCurrent();
68
//	    	Color color = display.getSystemColor(SWT.COLOR_DARK_GRAY);
69
//	    	return color.getRGB();
70
//		}
66
		if(TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER) && element instanceof TXMResult && !((TXMResult)element).hasBeenComputedOnce())	{
67
	    	Display display = Display.getCurrent();
68
	    	Color color = display.getSystemColor(SWT.COLOR_DARK_GRAY);
69
	    	return color.getRGB();
70
		}
71 71
		// FIXME: DEbug
72 72
//		else if(element instanceof TXMResult && ((TXMResult)element).isDirty())	{
73 73
//	    	Display display = Display.getCurrent();
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/listeners/ComputeSelectionListener.java (revision 1158)
4 4
import org.eclipse.jface.viewers.SelectionChangedEvent;
5 5
import org.eclipse.swt.events.SelectionEvent;
6 6
import org.eclipse.swt.events.SelectionListener;
7
import org.txm.core.preferences.TXMPreferences;
7
import org.eclipse.swt.widgets.Spinner;
8 8
import org.txm.core.results.TXMResult;
9 9
import org.txm.rcp.editors.TXMEditor;
10 10
import org.txm.rcp.preferences.RCPPreferences;
......
26 26

  
27 27
	@Override
28 28
	public void widgetSelected(SelectionEvent e) {
29
		this.editor.compute(true);
29
		// this method is called on a Spinner even when a key is pressed, that's not what we want, so this test breaks the behavior
30
		if(!(e.getSource() instanceof Spinner) || e.stateMask != 0)	{
31
			this.editor.compute(true);	
32
		}
30 33
	}
31 34

  
32 35
	@Override
tmp/org.txm.rcp/OSGI-INF/l10n/bundle_fr.properties (revision 1158)
242 242
command.name.3          = Convertir ancien fichier binaire
243 243
command.name.30         = IndexToConcordances
244 244
command.name.31         = Changer la langue
245
command.name.32         = Progression
245
command.name.32         = Calculer
246 246
command.name.33         = Conserver
247 247
command.name.34         = ExportSVG
248 248
command.name.35         = ComputeCooccurrences
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/results/ChartResult.java (revision 1158)
161 161
	}
162 162
	
163 163
	@Override
164
	public boolean compute(IProgressMonitor monitor) throws Exception {
164
	public boolean compute(IProgressMonitor monitor) {
165 165

  
166
		Log.finest("ChartResult.compute(): computing result of type " + this.getClass() + "...");
166
		try {
167
			Log.finest("ChartResult.compute(): computing result of type " + this.getClass() + "...");
167 168

  
168
		// compute the result if needed
169
		if(super.compute(monitor, true))	{
170
			// compute the chart
171
			return renderChart();
169
			// compute the result if needed
170
			if(super.compute(monitor, true))	{
171
				// compute the chart
172
				return renderChart();
173
			}
174
			else	{
175
				return false;
176
			}
172 177
		}
173
		else	{
178
		catch (Exception e) {
179
			e.printStackTrace();
180
			Log.severe("ChartResult.compute(): Exception occurs during computing.");
174 181
			return false;
175 182
		}
176

  
177 183
	}
178 184
	
179 185
	
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1158)
1009 1009
				//					value = new Property(this.getStringParameterValue(key), Corpus.getCorpus(this));
1010 1010
				//				}
1011 1011
				// MD: nope should be done via adapter or extension point "org.txm.searchengine.cqp.core" contributes to
1012
				// SJ: or better, when the abstraction of Property, etc. will be done, we could implement some extensions as in ChartCreator model to other engines, eg. SearchEngine, that will return
1013
				// the right class here
1012 1014
				f.set(this, value);
1013 1015

  
1014 1016
				// FIXME: Debug
......
1771 1773
	 * @return
1772 1774
	 * @throws Exception
1773 1775
	 */
1774
	public boolean compute() throws Exception {
1776
	public boolean compute() {
1775 1777
		return this.compute(null);
1776 1778
	}
1777 1779

  
......
1782 1784
	 * @return
1783 1785
	 * @throws Exception
1784 1786
	 */
1785
	public boolean compute(IProgressMonitor monitor) throws Exception {
1787
	public boolean compute(IProgressMonitor monitor) {
1786 1788
		return this.compute(monitor, true);
1787 1789
	}
1788 1790

  
......
1802 1804
	 * @throws CqiClientExceptio
1803 1805
	 * @throws IOException
1804 1806
	 */
1805
	protected boolean compute(IProgressMonitor monitor, boolean deepComputing) throws Exception {
1807
	protected boolean compute(IProgressMonitor monitor, boolean deepComputing) {
1806 1808

  
1807
		// FIXME: see if this skipComputing tests is still useful? is it possible to directly return instead?
1808
		// 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é 
1809
		boolean skipComputing = false;
1809
		try {
1810
			// FIXME: see if this skipComputing tests is still useful? is it possible to directly return instead?
1811
			// 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é 
1812
			boolean skipComputing = false;
1810 1813

  
1811
		this.monitor = monitor;
1814
			this.monitor = monitor;
1812 1815

  
1813
		// TODO THIS IS FUCKING LAZY LINE CODES OH YEAH YOU MAD BRO
1814
		// TODO where do we put this parent compute ? :o
1815
		//		if (parent != null && !parent.getHasBeenComputedOnce()) { // parent must be computed at least one time
1816
		// SJ: other way, test the object itself
1817
		if (this.parent != null && !(this.parent instanceof Project)) {
1818
			if (!this.parent.compute(monitor, true)) {
1819
				Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to compute parent result.");
1816
			// TODO THIS IS FUCKING LAZY LINE CODES OH YEAH YOU MAD BRO
1817
			// TODO where do we put this parent compute ? :o
1818
			//		if (parent != null && !parent.getHasBeenComputedOnce()) { // parent must be computed at least one time
1819
			// SJ: other way, test the object itself
1820
			if (this.parent != null && !(this.parent instanceof Project)) {
1821
				if (!this.parent.compute(monitor, true)) {
1822
					Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to compute parent result.");
1820 1823

  
1821
				return false;
1824
					return false;
1825
				}
1822 1826
			}
1823
		}
1824
		
1825
		boolean d0 = this.isDirty();
1826
		boolean d1 = this.needsFullRecomputing;
1827
		boolean d2 = this.isDirtyFromHistory();
1828
		boolean d3 = this.isDirty();
1829
		if (!d1 && 
1830
				!d2 && !d3) {
1831
			// needsFullRecomputing == true && isDirtyFromHistory == true && isDirty == true
1832
			Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": result parameters have not changed since last computing, computing skipped.");
1833
			skipComputing = true;
1834
		}
1827
			
1828
			boolean d0 = this.isDirty();
1829
			boolean d1 = this.needsFullRecomputing;
1830
			boolean d2 = this.isDirtyFromHistory();
1831
			boolean d3 = this.isDirty();
1832
			if (!d1 && 
1833
					!d2 && !d3) {
1834
				// needsFullRecomputing == true && isDirtyFromHistory == true && isDirty == true
1835
				Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": result parameters have not changed since last computing, computing skipped.");
1836
				skipComputing = true;
1837
			}
1835 1838

  
1836
		if(!skipComputing)	{
1839
			if(!skipComputing)	{
1837 1840

  
1838
			// FIXME: Debug
1839
			Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing result of type " + this.getClass() + "...");
1841
				// FIXME: Debug
1842
				Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing result of type " + this.getClass() + "...");
1840 1843

  
1841 1844

  
1842
			// Computing requirements test
1843
			if (!this.canCompute()) {
1844
				Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": missing or wrong parameters, computing aborted.");
1845
				return false;
1846
			}
1845
				// Computing requirements test
1846
				if (!this.canCompute()) {
1847
					Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": missing or wrong parameters, computing aborted.");
1848
					return false;
1849
				}
1847 1850

  
1848
			// Computing
1849
			if (!this._compute()) {
1850
				Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing failed.");
1851
				return false;
1851
				// Computing
1852
				if (!this._compute()) {
1853
					Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing failed.");
1854
					return false;
1855
				}
1852 1856
			}
1853
		}
1854 1857

  
1855
		// clear the lazy name, no more needed since the object has been computed and getSimpleName() can now work
1856
		this.lazyName = null;
1858
			// clear the lazy name, no more needed since the object has been computed and getSimpleName() can now work
1859
			this.lazyName = null;
1857 1860

  
1858 1861
//		// store last used parameters
1859 1862
//		if (updateLastParameters)	{
......
1873 1876
//			TXMPreferences.flush(this);
1874 1877
//		}
1875 1878

  
1876
		if(!skipComputing)	{
1877
			
1878
			// store last used parameters
1879
			this.updateLastParameters();
1879
			if(!skipComputing)	{
1880
				
1881
				// store last used parameters
1882
				this.updateLastParameters();
1880 1883

  
1881
			if (!this.autoSaveParametersFromAnnotations()) {
1882
				Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to save parameters from annotations for " + this.getName() + ".");
1883
			}
1884
			if (!this.saveParameters()) {
1885
				Log.severe("TXMResult.compute():" + this.getClass().getSimpleName() + ": failed to save parameters for " + this.getName() + ".");
1886
			}
1884
				if (!this.autoSaveParametersFromAnnotations()) {
1885
					Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to save parameters from annotations for " + this.getName() + ".");
1886
				}
1887
				if (!this.saveParameters()) {
1888
					Log.severe("TXMResult.compute():" + this.getClass().getSimpleName() + ": failed to save parameters for " + this.getName() + ".");
1889
				}
1887 1890

  
1888
			// file persistence flush
1889
			if (this.mustBePersisted()) {
1890
				TXMPreferences.flush(this);
1891
			}
1892
			
1893
			
1894
			this.dirty = false; // the computing was successful, the result is no more dirty
1895
			this.hasBeenComputedOnce = true; 
1896
			this.needsFullRecomputing = false;
1897
			
1898
			Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing of result type " + this.getClass() + " done.");
1899
			
1900
			// set the children as dirty since the result has changed
1901
			for (int i = 0; i < this.children.size(); i++) {
1902
				this.children.get(i).setDirty();
1903
			}
1904
			
1905
			// Children cascade computing ; if parent == null this is the Workspace
1906
			if (deepComputing && parent != null) {
1907

  
1908
				Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": cascade computing of " + this.children.size() + " children.");
1909

  
1891
				// file persistence flush
1892
				if (this.mustBePersisted()) {
1893
					TXMPreferences.flush(this);
1894
				}
1910 1895
				
1896
				
1897
				this.dirty = false; // the computing was successful, the result is no more dirty
1898
				this.hasBeenComputedOnce = true; 
1899
				this.needsFullRecomputing = false;
1900
				
1901
				Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing of result type " + this.getClass() + " done.");
1902
				
1903
				// set the children as dirty since the result has changed
1911 1904
				for (int i = 0; i < this.children.size(); i++) {
1912
					// FIXME: may be better to add a member needFullRecomputing in TXMResult?
1913
//					this.getChild(i).setDirty(); // force recomputing even if some parameters of the result itself have not changed
1914
					this.children.get(i).setNeedsFullRecomputing(true); // force recomputing even if some parameters of the result itself have not changed
1915
					
1916
					// recompute only children that has been opened once
1917
					//if (child.hasBeenComputedOnce()) {
1918
					this.children.get(i).compute(monitor, deepComputing);
1919
					//}
1905
					this.children.get(i).setDirty();
1920 1906
				}
1921 1907
				
1922
				// FIXME: SJ: this code generates concurrent modification excpetions when deep computing
1923
				// here for tests purpose
1908
				// Children cascade computing ; if parent == null this is the Workspace
1909
				if (deepComputing && parent != null) {
1910

  
1911
					Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": cascade computing of " + this.children.size() + " children.");
1912

  
1913
					
1914
					for (int i = 0; i < this.children.size(); i++) {
1915
						// FIXME: may be better to add a member needFullRecomputing in TXMResult?
1916
//					this.getChild(i).setDirty(); // force recomputing even if some parameters of the result itself have not changed
1917
						this.children.get(i).setNeedsFullRecomputing(true); // force recomputing even if some parameters of the result itself have not changed
1918
						
1919
						// recompute only children that has been opened once
1920
						//if (child.hasBeenComputedOnce()) {
1921
						this.children.get(i).compute(monitor, deepComputing);
1922
						//}
1923
					}
1924
					
1925
					// FIXME: SJ: this code generates concurrent modification excpetions when deep computing
1926
					// here for tests purpose
1924 1927
//				for (TXMResult child : this.getChildren()) {
1925 1928
//					child.setNeedsFullRecomputing(true); // force recomputing even if some parameters of the result itself have not changed
1926 1929
//					// recompute only children that has been opened once
1927 1930
//					child.compute(monitor, deepComputing);
1928 1931
//				}
1929
				
1932
					
1933
				}
1930 1934
			}
1931 1935
		}
1932
			
1936
		catch (Exception e) {
1937
			// TODO Auto-generated catch block
1938
			e.printStackTrace();
1939
			Log.severe("TXMResult.compute(): Exception occurs during computing.");
1940
			return false;
1941
		}
1933 1942

  
1934 1943
		return true;
1935 1944
	}
......
2244 2253
	public ArrayList<HashMap<String, Object>> getParametersHistory() {
2245 2254
		return parametersHistory;
2246 2255
	}
2247
	
2248
	/**
2249
	 * 
2250
	 * @return the first parent which visible state is true
2251
	 */
2252
	public TXMResult getFirstVisibleParent() {
2253
		if (parent == null) return null;
2254
		else if (parent.isVisible()) return parent;
2255
		else return parent.getFirstVisibleParent();
2256
	}
2257 2256
}
tmp/org.txm.index.core/src/org/txm/index/core/functions/Lexicon.java (revision 1158)
127 127
	}
128 128

  
129 129
	@Override
130
	public CQPCorpus getParent() {
131
		return (CQPCorpus)super.getParent();
132

  
133
	}
134

  
135
	@Override
136 130
	public boolean loadParameters() throws Exception {
137 131
		try {
138 132
			String p = this.getStringParameterValue(TXMPreferences.UNIT_PROPERTY);
......
647 641
		}
648 642
		
649 643
		// creating new Lexicon
650
		if(lexicon == null || lexicon.getProperty() != property)	{
644
		if(lexicon == null || !lexicon.getProperty().getFullName().equals(property.getFullName()))	{
651 645
			lexicon = new Lexicon(corpus);
652 646
			lexicon.setProperty(property);
653 647
		}
......
701 695
//		}
702 696
//	}
703 697

  
698
	@Override
699
	public CQPCorpus getParent() {
700
		return (CQPCorpus)super.getParent();
704 701

  
702
	}
705 703

  
704

  
705

  
706 706
	@Override
707 707
	public String getResultype() {
708 708
		return IndexCoreMessages.LEXICON_RESULT_TYPE;
tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java (revision 1158)
553 553
			} catch (Exception e) {
554 554
				// TODO Auto-generated catch block
555 555
				e.printStackTrace();
556
				return this.getEmptyName();
556 557
			}
557 558
			return strb.toString();
558 559
			

Formats disponibles : Unified diff