Ken Webb 2010-05-20T16:51:51Z
JavaScript is a good choice if you would like to manipulate your Xholon applications at runtime. If you are using Java 6, then the Rhino JavaScript engine is already built-in and ready to use.
For example, the following script can be applied to any Xholon application at runtime. It will display a sorted list of all Xholon classes (types) currently in use.
var app = applicationKey; // Xholon application var rootNode = app.getRoot(); // root node in the Xholon application var typeSet = new java.util.HashSet(); // a Java set /* * Add a node and its children to the type set. */ function addNode(node, typeSet) { typeSet.add(node.getXhcName()); node = node.getFirstChild(); while (node) { addNode(node, typeSet); node = node.getNextSibling(); } } addNode(rootNode, typeSet); var typeArray = typeSet.toArray().sort(); for(var i in typeArray) { println(typeArray[i]); }
If the above script is in the file script/javascript/ShowNodeTypes.js, then it can be pasted into any node in the running app as:
<script implName="lang:javascript:./script/javascript/ShowNodeTypes.js"/>
If it's pasted into the Xholon Cell model, then the output would be:
Aldolase CellBilayer CellMembrane Cytoplasm Cytosol DihydroxyacetonePhosphate Enolase EukaryoticCell ExtraCellularSolution ExtraCellularSpace Fructose_1x6_Biphosphate Fructose_6_Phosphate Glucose Glucose_6_Phosphate Glyceraldehyde_3_Phosphate Glyceraldehyde_3_phosphateDehydrogenase Hexokinase PhosphoEnolPyruvate PhosphoFructokinase PhosphoGlucoIsomerase PhosphoGlycerokinase PhosphoGlyceromutase Pyruvate PyruvateKinase TriosePhosphateIsomerase X1x3_BisphosphoGlycerate X2_PhosphoGlycerate X3_PhosphoGlycerate
It's not necessary for the script to be in a file. As an alternative, you can open a Xholon Console window on any node in the app, and write the script by typing in the console. The text must be contained within a <script> or similar tag. Press the submit button to apply the script.