Revision 1145

tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 1145)
608 608
	 * @param resetView
609 609
	 * @param clearChartItemsSelection
610 610
	 */
611
	public synchronized JobHandler compute(final boolean update)	{
611
	public JobHandler compute(final boolean update)	{
612 612
		
613 613
		StatusLine.setMessage(TXMUIMessages.TXMEditor_0 + this.getResult().getName());
614 614

  
......
681 681
				return Status.OK_STATUS;
682 682
			}
683 683
		};
684
		job.setPriority(Job.INTERACTIVE);
684
		job.setPriority(Job.DECORATE);
685 685
		// FIXME: SJ tests
686 686
		//job.setPriority(Job.INTERACTIVE);
687
		//job.setUser(false);
687
		job.setUser(true);
688 688
		job.schedule();
689 689
		
690 690
		return job;
......
851 851
			try {
852 852
				f.setAccessible(true);
853 853
				Object object = f.get(this);
854
				Object value = this.getResult().getParameter(parameter.key(), true); // get the parent value if necessary
854
				Object value = this.getResult().getParameter(parameter.key(), true); // propagate to parent one time
855 855
				if(object instanceof ToolItem)	{
856 856
					((ToolItem)object).setSelection((Boolean) value); 
857 857
				}
......
1035 1035

  
1036 1036
				// FIXME: need to extend this list of managed Widgets
1037 1037

  
1038
				this.getResult().setParameter(parameter.key(), value, true); // bubble one time
1038
				this.getResult().setParameter(parameter.key(), value, true); // propagate to parent one time
1039 1039
			}
1040 1040
			catch (IllegalArgumentException e) {
1041 1041
				// TODO Auto-generated catch block
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1145)
99 99
	/**
100 100
	 * Children results.
101 101
	 */
102
	protected ArrayList<TXMResult> children;
102
	protected List<TXMResult> children;
103 103

  
104 104
	/**
105 105
	 * The visibility state.
......
177 177
	public TXMResult(String parametersNodePath) {
178 178
		this(parametersNodePath, null);
179 179
	}
180

  
181 180
	
182
	
183 181
	/**
184 182
	 * Creates a new TXMResult, child of the specified parent.
185 183
	 * If the parameters node path is null, a new path is generated from the project root path ending by a new generated UUID.
......
219 217
		this.weight = 0;
220 218

  
221 219
		this.children = new ArrayList<TXMResult>(1);
220
		//this.children = Collections.synchronizedList(new ArrayList<TXMResult>()); // FIXME: SJ: can fix the conccurent excpetion if needed
222 221

  
223 222
		this.commandPreferencesNodePath = FrameworkUtil.getBundle(getClass()).getSymbolicName(); //$NON-NLS-1$
224 223
//		if(parametersNodePath == null)	{
......
361 360
	 * @param parameterType
362 361
	 * @return
363 362
	 */
364
	public Object getParameter(String key, boolean bubble) {
363
	public Object getParameter(String key, boolean propagateToParent) {
365 364
		try {
366 365
			Field field = this.getField(key); 
367 366
			if(field != null)	{
368 367
				field.setAccessible(true);
369 368
				return field.get(this);	
370
			} else if (bubble) {
371
				return parent.getParameter(key, false);
372 369
			}
370
			else if (propagateToParent) {
371
				return this.parent.getParameter(key);
372
			}
373 373
		}
374 374
		catch (IllegalArgumentException e) {
375 375
			// TODO Auto-generated catch block
......
852 852
		this.saveParameter("class", this.getClass().getName()); //$NON-NLS-1$
853 853
		// store the user name if exists, otherwise the simple name as lazy name (to display something at reloading otherwise the simple name can leads to error because the result is not computed until it will be reopen)
854 854
		if (this.userName != null)	{
855
			this.saveParameter(TXMPreferences.USER_NAME, this.userName);	
855
			this.saveParameter(TXMPreferences.USER_NAME, this.userName);
856 856
		}
857
		this.saveParameter(TXMPreferences.LAZY_NAME, this.getSimpleName());	
857
		this.saveParameter(TXMPreferences.LAZY_NAME, this.getSimpleName());
858 858
		this.saveParameter(TXMPreferences.VISIBLE, this.visible);	
859 859
		
860 860
		this.saveParameter(TXMPreferences.RESULT_PARAMETERS_NODE_PATH, this.parametersNodePath);
......
1027 1027
	 * Sets a parameters from its parameter annotation "key".
1028 1028
	 * @param key
1029 1029
	 * @param value
1030
	 * @param bubble propagate the key=value to parent if the result has no field=key
1030
	 * @param propagateToParent propagate the key=value to parent if the result has no field=key
1031 1031
	 * 
1032 1032
	 * @return
1033 1033
	 * @throws Exception
1034 1034
	 */
1035
	public boolean setParameter(String key, Object value, boolean bubble) throws Exception	{
1035
	public boolean setParameter(String key, Object value, boolean propagateToParent) throws Exception	{
1036 1036

  
1037 1037
		List<Field> fields = this.getAllFields();
1038 1038

  
......
1058 1058
			//}
1059 1059

  
1060 1060
			targetField.set(this, value);
1061
			
1062
			//this.dirty = this.dirty || hasParameterChanged(key);
1063
			
1064
		} else if (this.parent != null && bubble) {
1061
		}
1062
		else if (this.parent != null && propagateToParent) {
1065 1063
			this.parent.setParameter(key, value);
1066 1064
		}
1067 1065

  
......
1112 1110
	 * Deletes all non persistent results.
1113 1111
	 */
1114 1112
	public static void deleteAllNonPersistentResults() {
1115
		ArrayList<TXMResult> results = Toolbox.workspace.getDeepChildren();
1113
		List<TXMResult> results = Toolbox.workspace.getDeepChildren();
1116 1114
		for (int i = 0; i < results.size(); i++) {
1117 1115
			TXMResult r = results.get(i);
1118 1116
			if (r.mustBePersisted())	{ 
......
1242 1240
	 * 
1243 1241
	 * @return
1244 1242
	 */
1245
	public ArrayList<TXMResult> getChildren() {
1243
	public List<TXMResult> getChildren() {
1246 1244
		return this.children;
1247 1245
	}
1248 1246

  
......
1251 1249
	 * 
1252 1250
	 * @return
1253 1251
	 */
1254
	public ArrayList<TXMResult> getChildren(boolean onlyVisible) {
1252
	public List<TXMResult> getChildren(boolean onlyVisible) {
1255 1253
		return this.getChildren(null, onlyVisible);
1256 1254
	}
1257 1255

  
......
1261 1259
	 * @param type
1262 1260
	 * @return
1263 1261
	 */
1264
	public ArrayList<? extends TXMResult> getChildren(Class type) {
1262
	public List<? extends TXMResult> getChildren(Class type) {
1265 1263
		return TXMResult.getNodes(this.children, type, false);
1266 1264
	}
1267 1265

  
......
1271 1269
	 * @param type
1272 1270
	 * @return
1273 1271
	 */
1274
	public ArrayList<TXMResult> getChildren(Class type, boolean onlyVisible) {
1272
	public List<TXMResult> getChildren(Class type, boolean onlyVisible) {
1275 1273
		return TXMResult.getNodes(this.children, type, onlyVisible);
1276 1274
	}
1277 1275

  
......
1281 1279
	 * @return the first child if exists otherwise null
1282 1280
	 */
1283 1281
	public TXMResult getFirstChild(Class type) {
1284
		ArrayList<TXMResult> children = this.getChildren(type, false);
1282
		List<TXMResult> children = this.getChildren(type, false);
1285 1283
		try {
1286 1284
			return children.get(0);
1287 1285
		}
......
1295 1293
	 * @param type
1296 1294
	 * @return
1297 1295
	 */
1298
	synchronized public void deleteChildren(Class type) {
1299
		ArrayList<TXMResult> children = (ArrayList<TXMResult>) this.getChildren(type);
1296
	public void deleteChildren(Class type) {
1297
		List<TXMResult> children = (List<TXMResult>) this.getChildren(type);
1300 1298
		for (int i = 0; i < children.size(); i++) {
1301 1299
			children.get(i).delete();
1302 1300
		}
......
1323 1321
	 * 
1324 1322
	 * @return
1325 1323
	 */
1326
	protected ArrayList<TXMResult> getDeepChildren(TXMResult parent) {
1324
	protected List<TXMResult> getDeepChildren(TXMResult parent) {
1327 1325

  
1328
		ArrayList<TXMResult> results = new ArrayList<TXMResult>();
1326
		List<TXMResult> results = new ArrayList<TXMResult>();
1329 1327
		for (int i = 0; i < parent.getChildren().size(); i++) {
1330 1328
			results.add(parent.getChildren().get(i));
1331 1329
			results.addAll(parent.getChildren().get(i).getDeepChildren());
......
1338 1336
	 * 
1339 1337
	 * @return
1340 1338
	 */
1341
	public ArrayList<TXMResult> getDeepChildren() {
1339
	public List<TXMResult> getDeepChildren() {
1342 1340
		return this.getDeepChildren(this);
1343 1341
	}
1344 1342

  
......
1354 1352
			result = root;
1355 1353
		}
1356 1354
		else	{
1357
			ArrayList<TXMResult> results = root.getDeepChildren();
1355
			List<TXMResult> results = root.getDeepChildren();
1358 1356
			for (int i = 0; i < results.size(); i++) {
1359 1357
				if(results.get(i).getUUID().equals(UUID))	{
1360 1358
					result = results.get(i);
......
1380 1378
	 * @param type
1381 1379
	 * @return
1382 1380
	 */
1383
	protected static ArrayList<TXMResult> getNodes(ArrayList<TXMResult> srcNodes, Class type, boolean onlyVisible) {
1384
		ArrayList<TXMResult> nodes = new ArrayList<TXMResult>();
1381
	protected static List<TXMResult> getNodes(List<TXMResult> srcNodes, Class type, boolean onlyVisible) {
1382
		List<TXMResult> nodes = new ArrayList<TXMResult>();
1385 1383
		for (TXMResult child : srcNodes) {
1386 1384
			try {
1387 1385
				if ((type == null || 
......
1392 1390
				
1393 1391
				// add children of a non visible result
1394 1392
				else if (!child.isVisible() && child.hasChildren())	{
1395
					ArrayList<TXMResult> subChidlren = child.getChildren(type, onlyVisible);
1393
					List<TXMResult> subChidlren = child.getChildren(type, onlyVisible);
1396 1394
					nodes.addAll(subChidlren);
1397 1395
				}
1398 1396
			} catch (Exception e) {
......
1483 1481
	/**
1484 1482
	 * Gets the sibling nodes of this node result.
1485 1483
	 */
1486
	public ArrayList<TXMResult> getSiblings() {
1487
		ArrayList<TXMResult> sibling = new ArrayList<TXMResult>();
1484
	public List<TXMResult> getSiblings() {
1485
		List<TXMResult> sibling = new ArrayList<TXMResult>();
1488 1486
		if (this.parent != null) {
1489 1487
			sibling.addAll(this.parent.getChildren());
1490 1488
			sibling.remove(this);
......
1495 1493
	/**
1496 1494
	 * Gets the sibling nodes of this node result, specified by their class.
1497 1495
	 */
1498
	public ArrayList<TXMResult> getSiblings(Class type) {
1499
		ArrayList<TXMResult> sibling = new ArrayList<TXMResult>();
1496
	public List<TXMResult> getSiblings(Class type) {
1497
		List<TXMResult> sibling = new ArrayList<TXMResult>();
1500 1498
		if (this.parent != null) {
1501 1499
			sibling.addAll(TXMResult.getNodes(this.parent.getChildren(), type, true));
1502 1500
			sibling.remove(this);
......
1623 1621
	public String getFullPathSimpleName() {
1624 1622

  
1625 1623
		// fill the branch
1626
		ArrayList<TXMResult> branch = new ArrayList<TXMResult>();
1624
		List<TXMResult> branch = new ArrayList<TXMResult>();
1627 1625
		TXMResult node = this;
1628 1626
		do {
1629 1627
			branch.add(node);
......
1767 1765
	 * @throws CqiClientExceptio
1768 1766
	 * @throws IOException
1769 1767
	 */
1770
	public boolean compute(IProgressMonitor monitor, boolean deepComputing) throws Exception {
1768
	protected boolean compute(IProgressMonitor monitor, boolean deepComputing) throws Exception {
1771 1769

  
1772 1770
		// FIXME: see if this skipComputing tests is still useful? is it possible to directly return instead?
1773 1771
		// 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é 
......
1787 1785
			}
1788 1786
		}
1789 1787
		
1790
		if (!this.needsFullRecomputing && !this.isDirtyFromHistory() && !this.isDirty()) {
1788
		if (
1789
				!this.needsFullRecomputing && 
1790
				!this.isDirtyFromHistory() && !this.isDirty()) {
1791 1791
			// needsFullRecomputing == true && isDirtyFromHistory == true && isDirty == true
1792 1792
			Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": result parameters have not changed since last computing, computing skipped.");
1793 1793
			skipComputing = true;
......
1859 1859
			
1860 1860
			// set the children as dirty since the result has changed
1861 1861
			for (int i = 0; i < this.children.size(); i++) {
1862
				this.getChild(i).setDirty();
1862
				this.children.get(i).setDirty();
1863 1863
			}
1864 1864
			
1865 1865
			// Children cascade computing
......
1867 1867

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

  
1870
				for (TXMResult child : this.getChildren()) {
1870
				
1871
				for (int i = 0; i < this.children.size(); i++) {
1871 1872
					// FIXME: may be better to add a member needFullRecomputing in TXMResult?
1872 1873
//					this.getChild(i).setDirty(); // force recomputing even if some parameters of the result itself have not changed
1873
					child.setNeedsFullRecomputing(true); // force recomputing even if some parameters of the result itself have not changed
1874
					this.children.get(i).setNeedsFullRecomputing(true); // force recomputing even if some parameters of the result itself have not changed
1874 1875
					
1875 1876
					// recompute only children that has been opened once
1876 1877
					//if (child.hasBeenComputedOnce()) {
1877
						child.compute(monitor, deepComputing);
1878
					this.children.get(i).compute(monitor, deepComputing);
1878 1879
					//}
1879 1880
				}
1881
				
1882
				// FIXME: SJ: this code generates concurrent modification excpetions when deep computing
1883
				// here for tests purpose
1884
//				for (TXMResult child : this.getChildren()) {
1885
//					child.setNeedsFullRecomputing(true); // force recomputing even if some parameters of the result itself have not changed
1886
//					// recompute only children that has been opened once
1887
//					child.compute(monitor, deepComputing);
1888
//				}
1889
				
1880 1890
			}
1881 1891
		}
1882 1892
			
tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 1145)
32 32
import java.io.IOException;
33 33
import java.lang.reflect.Constructor;
34 34
import java.util.ArrayList;
35
import java.util.Collection;
36 35
import java.util.Date;
37 36
import java.util.HashMap;
38 37
import java.util.List;
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/ComputePartitionIndex.java (revision 1145)
34 34
import org.txm.index.rcp.editors.PartitionIndexEditor;
35 35
import org.txm.rcp.editors.TXMEditor;
36 36
import org.txm.rcp.handlers.BaseAbstractHandler;
37
import org.txm.searchengine.cqp.corpus.CQPCorpus;
38 37
import org.txm.searchengine.cqp.corpus.Partition;
39 38

  
40 39
/**
......
57 56

  
58 57
		PartitionIndex index = null;
59 58

  
59
		// FIXME: SJ: is this command need to be linked? or only the corpus index command? 
60 60
		// From link: creating from parameters node
61 61
		String parametersNodePath = event.getParameter(TXMPreferences.RESULT_PARAMETERS_NODE_PATH);
62 62
		if (parametersNodePath != null && !parametersNodePath.isEmpty()) {
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java (revision 1145)
117 117
		super(parametersNodePath);
118 118
	}
119 119
	
120
	public CQPCorpus getCorpus() {
121
		return (CQPCorpus) parent;
122
	}
123
	
120

  
124 121
	/**
125 122
	 * Instantiates a new partition.
126 123
	 *
......
148 145
			if (partName.trim().length() == 0) {
149 146
				partName = "-"; //$NON-NLS-1$
150 147
			}
151

  
152 148
			new Part(this, partName, queryS);
153
			//this.addChild();
154 149
		}
155 150
		long end = System.currentTimeMillis();
156 151
		Log.info(NLS.bind(TXMCoreMessages.info_partitionCreatedInXMs, this.userName, (end - start)));
......
744 739
	public String getName() {
745 740
		return this.userName;
746 741
	}
742
	
743
	public CQPCorpus getCorpus() {
744
		return (CQPCorpus) parent;
745
	}
746
	
747 747
}
tmp/org.txm.index.core/src/org/txm/index/core/functions/PartitionIndex.java (revision 1145)
317 317

  
318 318
	@Override
319 319
	public boolean canCompute() {
320
		if (getCorpus() == null && getPartition() == null) {
321
			Log.severe("Corpus or partition not set."); //$NON-NLS-1$
320
		if (this.getPartition() == null) {
321
			Log.severe("Partition not set."); //$NON-NLS-1$
322 322
			return false;
323 323
		}
324 324

  

Also available in: Unified diff