Révision 1399

tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 1399)
886 886
		queryWidget = new AssistedQueryWidget(getMainParametersComposite(), SWT.DROP_DOWN, concordance.getCorpus());
887 887
		queryWidget.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
888 888
		queryWidget.addKeyListener(new ComputeKeyListener(this));
889
		// FIXME: to compute when changing the query from history combo box
890
		// FIXME: commented because it doesn't work, the computing is launched as soon as we clic on the arrow of the combo box
891
		//queryWidget.getQueryWidget().addSelectionListener(new ComputeSelectionListener(this));
889 892

  
890 893
		// hide the parameters panel
891 894
		getTopToolbar().setVisible(TXMEditor.COMPUTING_PARAMETERS_GROUP_ID, false); // the settings are not necessary to compute the concordance
tmp/org.txm.rcp/src/main/java/org/txm/rcp/testers/PersistenceEnabled.java (revision 1399)
1
package org.txm.rcp.testers;
2

  
3
import org.eclipse.core.expressions.PropertyTester;
4
import org.txm.core.preferences.TBXPreferences;
5

  
6
/**
7
 * Checks if the results persistence is enabled.
8
 * 
9
 * @author sjacquot
10
 *
11
 */
12
public class PersistenceEnabled extends PropertyTester {
13

  
14
	public static final String PROPERTY_NAMESPACE = "org.txm.rcp.testers"; //$NON-NLS-1$
15
	
16
	public static final String PROPERTY_STATE_ENGINE_READY = "PersistenceEnabled"; //$NON-NLS-1$
17

  
18

  
19
	@Override
20
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
21

  
22
		boolean enabled = TBXPreferences.getInstance().getBoolean(TBXPreferences.AUTO_PERSISTENCE_ENABLED);
23
		System.err.println("IS results persistence enabled: " + enabled);
24
		return enabled;
25
	}
26

  
27
}
0 28

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/preferences/UserPreferencePage.java (revision 1399)
30 30
import org.eclipse.jface.preference.BooleanFieldEditor;
31 31
import org.txm.core.preferences.TBXPreferences;
32 32
import org.txm.rcp.messages.TXMUIMessages;
33

  
33 34
/**
34 35
 * User preferences page.
35 36
 * 
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 1399)
65 65
import org.txm.rcp.TXMWindows;
66 66
import org.txm.rcp.handlers.BaseAbstractHandler;
67 67
import org.txm.rcp.messages.TXMUIMessages;
68
import org.txm.rcp.preferences.RCPPreferences;
68 69
import org.txm.rcp.swt.GLComposite;
69 70
import org.txm.rcp.swt.widget.AssistedChoiceQueryWidget;
70 71
import org.txm.rcp.swt.widget.AssistedQueryWidget;
......
653 654
					monitor.beginTask(TXMUIMessages.computing_3, 100);
654 655

  
655 656
					notifyExtensions("notifyStartOfCompute"); //$NON-NLS-1$
656
					if (!TXMEditor.this.getResult().compute(monitor)) {
657
						Log.severe("TXMEditor.compute(): " + TXMEditor.this.getClass().getSimpleName() + ": computing failed.");
658
					}
657
					//if (!update || RCPPreferences.getInstance().getBoolean(RCPPreferences.AUTO_UPDATE_EDITOR)) {
658
						if (!TXMEditor.this.getResult().compute(monitor)) {
659
							Log.severe("TXMEditor.compute(): " + TXMEditor.this.getClass().getSimpleName() + ": computing failed.");
660
						}
661
					//}
659 662
					notifyExtensions("notifyEndOfCompute"); //$NON-NLS-1$
660 663

  
661 664
					monitor.worked(50);
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/listeners/ComputeListener.java (revision 1399)
2 2

  
3 3
import org.eclipse.swt.widgets.Event;
4 4
import org.eclipse.swt.widgets.Listener;
5
import org.txm.core.preferences.TXMPreferences;
6 5
import org.txm.rcp.editors.TXMEditor;
7 6
import org.txm.rcp.preferences.RCPPreferences;
8 7

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/listeners/ComputeSelectionListener.java (revision 1399)
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.eclipse.swt.widgets.Combo;
7 8
import org.eclipse.swt.widgets.Spinner;
8 9
import org.txm.core.results.TXMResult;
9 10
import org.txm.rcp.editors.TXMEditor;
......
26 27

  
27 28
	@Override
28 29
	public void widgetSelected(SelectionEvent e) {
30
		// tests for QueryWidget computing from history
31
//		System.err.println("ComputeSelectionListener.widgetSelected() " + ((Combo)e.getSource()).getText());
29 32
		// 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 33
		if(RCPPreferences.getInstance().getBoolean(RCPPreferences.AUTO_UPDATE_EDITOR) && (!(e.getSource() instanceof Spinner) || e.stateMask != 0))	{
31
			this.editor.compute(true);	
34
			this.editor.compute(true);
32 35
		}
33 36
	}
34 37

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/listeners/ComputeKeyListener.java (revision 1399)
8 8
import org.eclipse.swt.events.KeyListener;
9 9
import org.txm.core.results.TXMResult;
10 10
import org.txm.rcp.editors.TXMEditor;
11
import org.txm.rcp.preferences.RCPPreferences;
11 12

  
12 13
/**
13 14
 * Key listener that calls TXMEditor.compute() when the Enter key is pressed.
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedQueryWidget.java (revision 1399)
170 170
	public Query getQuery() {
171 171
		return this.querywidget.getQuery();
172 172
	}
173

  
174
	/**
175
	 * @return the querywidget
176
	 */
177
	public QueryWidget getQueryWidget() {
178
		return querywidget;
179
	}
173 180
}
tmp/org.txm.rcp/plugin.xml (revision 1399)
2002 2002
                           property="org.txm.rcp.testers.persistable"
2003 2003
                           value="true">
2004 2004
                     </test>
2005
                     <test
2006
                           property="org.txm.rcp.testers.PersistenceEnabled"
2007
                           value="true">
2008
                     </test>
2005 2009
                  </and>
2006 2010
               </visibleWhen>
2007 2011
            </command>
......
2927 2931
            properties="xtzCorpus"
2928 2932
            type="java.lang.Object">
2929 2933
      </propertyTester>
2934
      <propertyTester
2935
            class="org.txm.rcp.testers.PersistenceEnabled"
2936
            id="org.txm.rcp.testers.PersistenceEnabled"
2937
            namespace="org.txm.rcp.testers"
2938
            properties="PersistenceEnabled"
2939
            type="java.lang.Object">
2940
      </propertyTester>
2930 2941
   </extension>
2931 2942
   <extension
2932 2943
         point="org.eclipse.ui.bindings">
tmp/org.txm.internalview.core/src/org/txm/internalview/core/functions/InternalView.java (revision 1399)
112 112
	protected boolean _compute() throws Exception {
113 113

  
114 114
		if(this.hasParameterChanged(InternalViewPreferences.STRUCTURAL_UNIT))	{
115
			this.pCurrentPage = 0;
115
			
116
			// reset the current page (only if the result has been computed at least once otherwise it breaks the deserialization)
117
			if(this.hasBeenComputedOnce)	{
118
				this.pCurrentPage = 0;
119
			}
120
			
116 121
			//find struct start-end
117 122
			CQLQuery query = new CQLQuery("<" + pStructuralUnit.getName() + "> [] expand to " + pStructuralUnit); //$NON-NLS-1$ //$NON-NLS-2$
118 123
			//System.out.println(query);
......
354 359
			for (Property p : pWordProperties) {
355 360
				writer.println(StringUtils.join(page.get(p), colseparator));
356 361
			}
357
			writer.println("\n\n");
362
			writer.println("\n\n"); //$NON-NLS-1$
358 363
		}
359 364
		writer.close();
360 365
		return false;
......
395 400
		this.pCurrentPage = currentPage;
396 401

  
397 402
		if(this.pCurrentPage < 0 || this.pCurrentPage > (this.nmatches - 1))	 {
398
			System.err.println("InternalView.canCompute(): current page (" + this.pCurrentPage + ") is outside matches range (" + this.nmatches + ").");
403
			System.err.println("InternalView.setCurrentPage(): current page (" + this.pCurrentPage + ") is outside matches range (" + this.nmatches + ").");
399 404
			this.pCurrentPage = 0;
400 405
		}
401 406
	}
tmp/org.txm.internalview.rcp/src/org/txm/internalview/rcp/editors/InternalViewEditor.java (revision 1399)
132 132
			Log.printStackTrace(e);
133 133
		}
134 134
		// Listener
135
		propertiesSelector.addSelectionListener(new ComputeSelectionListener(this));
135
		propertiesSelector.addSelectionListener(computeSelectionListener);
136 136
		
137 137
		// Structural unit properties selector
138 138
		structuralUnitPropertiesSelector = new PropertiesSelector<StructuralUnitProperty>(parametersArea);
tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/LexiconEditor.java (revision 1399)
8 8
 * - set the number of property to 1 
9 9
 * - hide the query field
10 10
 * 
11
 *  @author mdecorde.
11
 *  @author mdecorde
12 12
 */
13 13
public class LexiconEditor extends IndexEditor {
14 14
	
......
28 28
		this.queryLabel.dispose();
29 29
		
30 30
		// no query field -> no need to expand the zone
31
		getMainParametersComposite().setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
31
		this.getMainParametersComposite().setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
32 32
	}
33 33
}
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1399)
24 24
import org.osgi.framework.FrameworkUtil;
25 25
import org.osgi.service.prefs.BackingStoreException;
26 26
import org.txm.Toolbox;
27
import org.txm.core.messages.TXMCoreMessages;
27 28
import org.txm.core.preferences.TBXPreferences;
28 29
import org.txm.core.preferences.TXMPreferences;
29 30
import org.txm.objects.Project;
......
72 73
	public static final Pattern FILE_NAME_PATTERN = Pattern.compile("[^a-zA-Z0-9\\.-]+"); //$NON-NLS-1$
73 74
	public static final String UNDERSCORE = "_";
74 75

  
76
	private static int next = 0;
77
	
78

  
79
	
75 80
//	/**
76 81
//	 * Unique ID of the result.
77 82
//	 */
......
197 202
	 */
198 203
	public TXMResult(String parametersNodePath, TXMResult parent) {
199 204
		if (parent == this) {
200
			throw new IllegalArgumentException("A result can not be parent of itself.");
205
			throw new IllegalArgumentException("A result can not be parent of itself."); //$NON-NLS-1$
201 206
		}
202 207
		if (parent != null) {
203 208
			parent.addChild(this);
......
215 220
			this.parametersNodePath = parametersNodePath;
216 221
		}
217 222

  
218
		Log.finest("TXMResult.TXMResult(): parameters node path: " + this.parametersNodePath);
223
		Log.finest("TXMResult.TXMResult(): parameters node path: " + this.parametersNodePath + "."); //$NON-NLS-1$ //$NON-NLS-2$
219 224

  
220 225
		this.weight = 0;
221 226

  
......
223 228
		//this.children = Collections.synchronizedList(new ArrayList<TXMResult>()); // FIXME: SJ: can fix the conccurent excpetion if needed
224 229

  
225 230
		this.commandPreferencesNodePath = FrameworkUtil.getBundle(getClass()).getSymbolicName(); //$NON-NLS-1$
226
		Log.finest("TXMResult.TXMResult(): command preferences node path: " + this.commandPreferencesNodePath);
231
		Log.finest("TXMResult.TXMResult(): command preferences node path: " + this.commandPreferencesNodePath + "."); //$NON-NLS-1$ //$NON-NLS-2$
227 232

  
228 233

  
229 234
		this.visible = true;
......
241 246
				parent == null && 
242 247
				this.parametersNodePath != null && 
243 248
				!parentNodePath.isEmpty()) {
244
			Log.warning("Searching parent with UUID: " + parentNodePath + "...");
249
			Log.finest("Searching parent with UUID: " + parentNodePath + "..."); //$NON-NLS-1$ //$NON-NLS-2$
245 250
			TXMResult retrievedParent = TXMResult.getResult(parentNodePath);
246 251
			if (retrievedParent != null) {
247
				Log.warning("Parent retrieved from UUID: " + retrievedParent + ".");
252
				Log.finest("Parent retrieved from UUID: " + retrievedParent + "."); //$NON-NLS-1$ //$NON-NLS-2$
248 253
				retrievedParent.addChild(this);
249 254
			}
250 255
			else {
251
				Log.severe("Warning: no parent was found in project for path=" + parametersNodePath + " and puuid=" + parentNodePath + " preferences=" + this.dumpParameters());
256
				Log.severe("Warning: no parent was found in project for path=" + parametersNodePath + " and puuid=" + parentNodePath + " preferences=" + this.dumpParameters()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
252 257
				// FIXME: commented for now
253 258
				//TBXPreferences.delete(this);
254 259
				return;
......
260 265
			this.autoLoadParametersFromAnnotations(); // auto fill from Parameter annotations
261 266
			this.loadParameters();  // subclasses manual settings
262 267
		} catch (Exception e) {
263
			Log.severe("Fail to load " + parametersNodePath + "result: " + e);
268
			Log.severe("Fail to load " + parametersNodePath + "result: " + e); //$NON-NLS-1$ //$NON-NLS-2$
264 269
			Log.printStackTrace(e);
265 270
		}
266 271

  
267 272
		// Log
268 273
		if (this.parent == null)	{
269
			Log.warning("Warning: the TXMResult of " + this.getClass() + " is attached to no parent. (uuid = " + this.parametersNodePath + ")");
274
			Log.finest("Warning: the TXMResult of " + this.getClass() + " is attached to no parent. (uuid = " + this.parametersNodePath + ")");//$NON-NLS-1$ //$NON-NLS-2$
270 275
		}
271 276

  
272 277
		try {
......
288 293
	}
289 294

  
290 295
	/**
291
	 * Froze the result -> cannot be recomputed
296
	 * Freezes the result -> cannot be recomputed.
292 297
	 */
293
	public void froze() {
298
	public void freeze() {
294 299
		this.frozen = true;
295 300
	}
296 301
	
297 302
	/**
298
	 * Un-Froze the result -> can be recomputed
303
	 * Unfreezes the result -> can be recomputed.
299 304
	 */
300
	public void unfroze() {
305
	public void unfreeze() {
301 306
		this.frozen = false;
302 307
	}
303 308

  
304 309
	/**
305
	 * Froze/Un-Froze the result
310
	 * Freezes/unfreezes the result.
306 311
	 */
307 312
	public void setFrozen(boolean frozen) {
308 313
		this.frozen = frozen;
......
325 330
		return UUID_PREFIX + ID_TIME_FORMAT.format(new Date(System.currentTimeMillis())) + "_" + nextInt();
326 331
	}
327 332
	
328
	private static int next = 0;
329 333
	/**
330 334
	 * 
331 335
	 * @return the next integer in the current session of TXM
332 336
	 */
333 337
	private static synchronized String nextInt() {
334
		return String.format("%04d", next++);
338
		return String.format("%04d", next++); //$NON-NLS-1$
335 339
	}
336 340

  
337 341
	/**
......
926 930
			this.saveParameter(TXMPreferences.PARENT_PARAMETERS_NODE_PATH, this.parent.getParametersNodePath());
927 931
		}
928 932

  
929
		this.lazyName = this.getSimpleName();
933
		if(this.hasBeenComputedOnce)	{
934
			this.lazyName = this.getSimpleName();
935
		}
930 936

  
931 937
		List<Field> fields = this.getAllFields();
932 938

  
......
1035 1041
			if (parameter == null || parameter.type() != parameterType) {
1036 1042
				continue;
1037 1043
			}
1044
			
1038 1045
			String key = parameter.key();
1039 1046

  
1040 1047
			if (key.isEmpty()) {
......
1902 1909
	 */
1903 1910
	protected boolean compute(IProgressMonitor monitor, boolean deepComputing) {
1904 1911

  
1905
		if (hasBeenComputedOnce && frozen) return true; // no changes to do
1912
		// no changes to do
1913
		// FIXME: SJ: we need to do do some actions even if the object is frozen, eg. updating parameters, saving parameters, etc.
1914
		if (hasBeenComputedOnce && frozen) {
1915
			return true;
1916
		}
1906 1917
		
1918
		
1907 1919
		try {
1908 1920

  
1909 1921
			Log.finest("*** TXMResult.compute(): " + this.getClass().getSimpleName() + ": starting computing process...");
1910 1922

  
1911 1923
			// FIXME: see if this skipComputing tests is still useful? is it possible to directly return instead?
1912
			// 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é 
1924
			// 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é
1925
			// il faudrait retourner un état: skipped, computed, error, etc. 
1913 1926
			boolean skipComputing = false;
1914 1927

  
1915 1928
			this.monitor = monitor;
1916 1929

  
1917
			// TODO THIS IS FUCKING LAZY LINE CODES OH YEAH YOU MAD BRO
1918
			// TODO where do we put this parent compute ? :o
1919
			//		if (parent != null && !parent.getHasBeenComputedOnce()) { // parent must be computed at least one time
1920
			// SJ: other way, test the object itself
1921
			// FIXME: this code should be moved back in the !skipComputing section ?
1930
			// Compute the parent if needed
1922 1931
			if (this.parent != null && !(this.parent instanceof Project) && !(this.parent instanceof Workspace)) {
1923 1932

  
1924 1933
				Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": starting parent (" + this.parent.getClass().getSimpleName() + ") computing process...");
......
1940 1949

  
1941 1950
			if(!skipComputing)	{
1942 1951

  
1943
				// FIXME: Debug
1952
				// Debug
1944 1953
				Log.finest("+++ TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing result of type " + this.getClass() + "...");
1945 1954

  
1946
				// TODO THIS IS FUCKING LAZY LINE CODES OH YEAH YOU MAD BRO
1947
				// TODO where do we put this parent compute ? :o
1948
				//		if (parent != null && !parent.getHasBeenComputedOnce()) { // parent must be computed at least one time
1949
				// SJ: other way, test the object itself
1950
				//				if (this.parent != null && !(this.parent instanceof Project)) {
1951
				//					if (!this.parent.compute(monitor, true)) {
1952
				//						Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to compute parent result.");
1953
				//
1954
				//						//return false;
1955
				//					}
1956
				//				}
1957

  
1958

  
1959 1955
				// Computing requirements test
1960 1956
				if (!this.canCompute()) {
1961
					Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": can not compute, missing or wrong parameters or error with parent computing, computing aborted.");
1957
					Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": can not compute, missing or wrong parameters or error with parent computing, computing aborted.");
1962 1958
					return false;
1963 1959
				}
1964 1960

  
1965 1961
				// Computing
1966 1962
				if (!this._compute()) {
1967
					Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing failed.");
1963
					Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing failed.");
1968 1964
					return false;
1969 1965
				}
1970 1966
			}
......
1978 1974

  
1979 1975
			if(!skipComputing)	{
1980 1976

  
1981
				// store last used parameters
1982
				//				this.updateLastParameters();
1983

  
1984 1977
				if (!this.autoSaveParametersFromAnnotations()) {
1985 1978
					Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to save parameters from annotations for " + this.getName() + ".");
1986 1979
				}
......
2009 2002
					Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": cascade computing of " + this.children.size() + " child(ren).");
2010 2003

  
2011 2004
					for (int i = 0; i < this.children.size(); i++) {
2012
						// FIXME: may be better to add a member needFullRecomputing in TXMResult?
2013
						//					this.getChild(i).setDirty(); // force recomputing even if some parameters of the result itself have not changed
2014

  
2015
						// FIXME: SJ: need to try again to stop to use this parameter
2016
						//this.children.get(i).setNeedsFullRecomputing(true); // force recomputing even if some parameters of the result itself have not changed
2017

  
2018
						// recompute only children that has been opened once
2019
						//if (child.hasBeenComputedOnce()) {
2020 2005
						this.children.get(i).compute(monitor, deepComputing);
2021
						//}
2022 2006
					}
2023 2007

  
2024 2008
					// FIXME: SJ: this code generates concurrent modification exceptions when deep computing
2025
					// here for tests purpose
2009
					// here for tests purpose, the code above does not generates exceptions
2026 2010
					//				for (TXMResult child : this.getChildren()) {
2027
					//					child.setNeedsFullRecomputing(true); // force recomputing even if some parameters of the result itself have not changed
2028 2011
					//					// recompute only children that has been opened once
2029 2012
					//					child.compute(monitor, deepComputing);
2030 2013
					//				}
......
2035 2018
		catch (Exception e) {
2036 2019
			// TODO Auto-generated catch block
2037 2020
			e.printStackTrace();
2038
			Log.severe("TXMResult.compute(): Exception occurs during computing: "+e);
2021
			Log.severe(TXMCoreMessages.bind("TXMResult.compute(): Exception occurs during computing: {0}.", e));
2039 2022
			return false;
2040 2023
		}
2041 2024

  

Formats disponibles : Unified diff