I’m working on my first URCap, and, for the most part, it’s going smoothly, but I have stumbled upon something I don’t quite know how to solve.
I would like to add a bunch of my Program Nodes to the Program Tree in PolyScope. When I add a new node (all of them are the same URCap, just diferent instances) I would like to add a number at the end of the node title displayed in the Program Tree. Something similar to how the Thread node works - when you add the first Thread, its title is “Thread_1”, then the next one will get “Thread_2”, and so on.
Now, I have tried to achieve this functionality by creating an integer variable in the Program Node View, which I would increment every time a new Contribution is created, and then use that variable in the getTitle() function of the contribution. That works, but I don’t know how to decrease my counter when I delete a node from the Program Tree. So, if I add 10 of my nodes, they do have numbers 1-10 in their titles, but when I delete any one of them, I don’t have a way of changing that number in the title of each node.
I have a feeling my approach is not even the right way to go about this, I came up with that partial solution, since I wasn’t able to find anything that would help in the API reference or the, otherwise very helpful, samples.
Let me also mention, that I would like to use the number of the particular node in my Data Model for generating variable names in my generateScript() method.
Any help is much appreciated. If I manage to find a solution to this on my own, I’ll make sure to post it in this thread as well.
Regards