Hello,
I’m creating a new URCap and I’ve faced a problem, which seems to be in URCaps SDK. This problem is reproduciable with “Hello World Swing” sample from the sdk.
Steps to reproduce:
- Download the SDK 1.3.55
- Go to the
samples/swingfolder and installhelloworldswingURCap on URSim 3.6. (To do this you can just specifyursim.homeat project’s pom.xml and runmvn install -P ursim) - Run URSim, select Program Robot, Empty Program.
- Go to the Installation tab, Hello World Swing and enter a Popup title.
- Go to the Program tab, add Hello World Swing node to program.
- Save program to file.
- Close URSim.
- Start URSim again.
- Load the saved program.
- Click on text input in Hello World Swing node’s interface.
You’ve got the following exception:
ERROR [AWT-EventQueue-0] 11:32:43 13/08/18: Caught an unhandled exception
java.lang.IllegalStateException: No node currently selected.
at com.ur.urcap.contribution.program.SwingProgramNodeViewProviderImpl$1.get(SwingProgramNodeViewProviderImpl.java:99)
at com.ur.urcap.examples.helloworldswing.impl.HelloWorldProgramNodeView$1.mousePressed(HelloWorldProgramNodeView.java:60)
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:280)
at java.awt.Component.processMouseEvent(Component.java:6536)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6304)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4532)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
The exception is thrown then provider.get() is called.
It seems to me, that there is a bug in SDK, because in debug I can see, that the reference to Contribution is null, but the node is selected:
Proper working state, when there are no errors:
As a workaround, you can implement setContribution in your View and call it in Contribution.openView method view.setContribution(this). And in closeView - view.setContribution(null).
But it was expected to call provider.get() on ContributionProvider object and the example illustrates it.
Am I doing everything right?
Is there a bug in the SDK?
How can I fix it? Should I use the workaround I have described?
Related topics:

