I’ve been building my first URCap, and it is working wunderfull when there is only one instance of it.
It’s basicly a complicated UI for setting parameters, and creating the programTree.
My problem is that the UI is ghosting. I’ve read about using the DataModel for saving values, which solved the value loss problems, i had, but the UI still behaves strangely. It always uses the last position it was in. I’ve tried to reset it in the ProgramNodeView.buildUI() method, as i thought it would run any time i opened the view but i was wrong. Is there a way to reset the UI every time you open it(possibly reload the previous values if i saved them in the DataModel)?
I suspect i should use the installationNode for setting up the UI, and the ProgramNode to set those values in it(based on the HelloWorldSwing example)?
Will i be able to access the Labels, etc from the ProgramNode i created in the istallationNode?
but how can i reload the UI every time i change to a different Node in the Tree?
Thanks for all the help cleaning up my confusion,
Regarding your “ghosting” issue, this is something i encountered when first developping a URCap, and you’ll be pleased to hear there is a method that does exactly what you seak.
buildUI() only adds components to the views main panel, and is run when the robot is booting. The method which is run every time a program node is opened is in the contribution class, named
closeView() is called whenever you switch to something other than the program node). The ghosting is experienced because a URCap only uses a single instance of the view class, and each program node has its own instance of the contributiuon class, and thus its own
DataModel. It is this
DataModel that should store information in order to configure program nodes when they are opened.
The installation node needs not hold any information about the program node’s UI, this should be handled between the contribution and the view class of the program node. Likewise the installation node has its own contribution and view class which functions very similarly to the program nodes.
URCaps generally store information in the installation node’s
DataModel that is used by all instances of a program node. Say each program node needed to change to a user defined TCP, that is the type of information that would be stored in the installation node.
This is great to hear. The only difficulty of this is the following:
My URCap uses a class called “Parameter” this class stores values tied together. Is there a way I could store the “parameter” in the dataModel? I didn’t find any other way than to store each value of the “parameter” individually in the data model. This creates massive getter-setter divisions which are pretty ugly.
Thanks for all the help,
Unfortunately there is no way of storing custom objects in the data model. you will have to have a method somewhere in your program/installation contribution which saves any necessary parameters requred for a
Parameter to be defined, be they waypoints, strings or numbers, and also a method that reverse engineers these parameters back into a
If you look up the
DataModel in the API, it’ll list all the
set methods which show you the various types of objects that can be saved to the data model.
Yeah, that’s what I thought!
Thanks Sam this was extremely helpful.
Future request could be to store custom objects bit that’s besides the point of this article.