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 |
|