A very nice enhancement would be to have the controller updated when changes are made in scenebuilder. I realize the I can display the generated controller from scenebuilder and then copy/paste the changes to the live java source. However, if there have been many changes made keeping the code in sync is pain unless I run diffs and then merge the changes. The ability to generate the @FXML with the control declarations and the stub @FXML action methods would be a great time saving feature.
This is indeed something that would help.
However performing that in SB involves parsing and updating java source code controlled by the user.
Which is pretty substantial for a standalone tool like SB.
On the other hand, IDEs are very good at that.
The latest builds of Netbeans now provide the "Make Controller" command
which scans an FXML file and updates the associated controller accordingly.
I'm sure Eclipse will get something like that soon if not already done.
I don't think it is a good idea that SceneBuilder starts changing files it does not control itself and it fact it has to have access to your complete project structure to not modify code in a way that it does not compile anymore! e(fx)clipse currently provides Quick Fixes to generate the needed controller classes. e(fx)clipse currently doesn't support refactor/rename support but that's only a matter of time and priority. I'd say the one responsible for such features are the IDEs (Netbeans, Eclipse, ...) and not SceneBuilder.
Yes. At least it should be something that detects when you change the name of a component which is used in the controller java class, and updates it accordingly. Something similar should be for deleting also. That's not so hard. Adding may not be always desired to work automatically, but at least update and delete.
You should definitively try Netbeans 7.3 and its "Make Controller" new feature, as mentioned by Eric above.
Even if Netbeans 7.3 is not yet officially out, Netbeans team just released a Release Candidate. I'm working with a dev build from early January (so earlier then the RC), and didn't get any issue with it.
When an FXML file is edited in Netbeans, the "Make Controller" feature (from the Source menu) just does what you are requesting :
- From Scene Builder, I add a new Button, set the fx:id and the onAction method, and save.
- From Netbeans 7.3, I right-click the fxml file and edit it. Then I select "Source->Make Controller" : the @FXML private variable of the Button is added in the existing controller, as well as the new method.
- Same thing if I delete a node, or update an fx:id or a method name in Scene Builder : "Make Controller" make the trick :-)