Utility methods to get result and their editors
add utility methods available in TXM macros to :
- get a result by its path
- get a result editor by its path
- get a result by its name in its editor
Plus, to help the user pinpoint a result, add the path to the Properties General tab
The methods to get the associated editor already exists : SWTEditorsUtils.getEditors(result) (needs import org.txm.rcp.utils.SWTEditorsUtils)
A method to get a direct child result already exists : r.getChildrenBySimpleName()
A new method to get children by path is needed : r.getChildrenByPath()
A new method to get editor by name is needed : SWTEditorsUtils.getEditor(String name)
Example:
import org.txm.rcp.utils.SWTEditorsUtils
// path: corpus project / corpus name / partition / lexical table
// path = "VOEUX/VOEUX/text@loc/@frlemma ≥2 ≤80 519 \\/200" // chemin dans une String avec / comme séparateur, \\ pour échaper le / dans le nom de la table lexicale
path = ["VOEUX", "VOEUX", ".+", "@frlemma ≥2 ≤80 519 /200"] //path with regex
def found = Toolbox.workspace.getChildrenByPath(path) // Toolbox.workspace is the root result of all results
if (found.size() > 0) {
for (def o : found) {
println "$o"
println " class="+o.getClass()
println " editor="+SWTEditorsUtils.getEditors(o)
}
} else {
println "No result: $path found."
}
println SWTEditorsUtils.getEditor("VOEUX/text@loc/@frlemma ≥2 ≤80 519 /200")
Validation Test
- (get TXM last test build : https://groupes.renater.fr/wiki/txm-info/public/creation_txm_standalone#txm_standalone_de_test_journaliere\\\_-\\\_ubuntu )
- create a result from a Partition
- open the result Properties
- copy paste the path from the General tab
- replace the path variable in the above test