I am creating a program node to perform a scan and retrieve a result. I would like to have two sub-programs that will be executed according to the status of the scan (Valid scan will execute the first branch, and Invalid will execute the second).
The way I chose to implement this is this: I actually have 3 program node services: “Scan”, “Valid”, “Invalid”.
When “Scan” initialized, it creates the 2 children nodes “Valid” and “Invalid”, and after performing a scan, it saves a global variable to the status of the scan.
Valid and Invalid check the value of that variable and choose whether to perform.
The problem with this method, is that “Valid” and “Invalid” are visible in Structure->URCap, and the user can instantiate them wherever he wants. Is there a way to make them hidden in this list?
Alternatively is there a better way of performing my goal?
Hi Ocohen,
to hide your Programnodes in the Structure -> URCaps window you can add the NonUserINsertable interface to the corresponding ProgramnodeService.
public class MyProgramNodeService implements ProgramNodeService, NonUserInsertable { }
But I think you can combine the functionality in one Programnode, depending on what behavior you want to further add. For example just use different <div>-Containers in your UI and set them visible/invisble depending what your test results are.
Thanks Stefan!
I have thought about reducing to a single Program node, and change its functionality based on the state. But that would require me to change it’s state from the parent node.
I would need something like this:
ProgramModel programModel = api.getProgramModel();
ProgramNodeFactory nf = programModel.getProgramNodeFactory();
TreeNode root = programModel.getRootTreeNode(this);
try
{
validNode = root.addChild(nf.createURCapProgramNode(ValidProgramNodeService.class));
validNode.SetType(Valid) // HOW IS THIS POSSIBLE?
invalidNode = root.addChild(nf.createURCapProgramNode(ValidProgramNodeService.class));
invalidNode.SetType(Invalid) // HOW IS THIS POSSIBLE?
}
catch (TreeStructureException localTreeStructureException) {
LOGGER.severe("Failed to add child nodes: " + localTreeStructureException);
}
I can create the SetType function in the Program’s Contribution class, but i couldn’t find a way to access it from the TreeNode object.