This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Java code is not generated for 'Unnamed' elements. (see issue 87140) Nevertheless the java code is generated for unnamed elements when I change the default element name. Steps to reproduce: - Create a Java-Platform Model UML project - Create a Class diagram - Put a Class element on the diagram The element has 'Unnamed' name - Generate code for the project Java code is not generated for the 'Unnamed' element - Go to 'Tools|Options|Advanced Options|UML|New Project' Change the 'Default Element Name' from 'Unnamed' to 'NewElement' - Put a Class element on the diagram The element has 'NewClass' name - Generate code for the project Issue: Java code is generated for element with default name 'NewClass' ------------------------------------------------------------ Code Generation selected options: UMLProject1Sources\src Processing element 1 of 2: Skipping element with default element name:Unnamed Processing element 2 of 2: Class NewClass ================================ Task Successful (total time: 1 seconds) ------------------------------------------------------------ - Put a Class element on the diagram The element has 'NewClass' name The exception pops up: ClassCastException: uml.ui.controls.drawingarea.UIStructuralDiagram cannot be cast to uml.core.metamodel.core.foundation.NamedElement See attached IDE log file.
Created attachment 35271 [details] ClassCastException in IDE log file
I have created a separate issue 87285 for the exception: [Issue 87285] Right-click on diagram throws ClassCastException
I've made some changes to make this more dynamic to reflect the latest preference setting without restarting the IDE. I was reading the pref value once and caching for the entire NB session (as is done for many prefs) but now the Default Element Name pref is fetched everytime so it will pick up changes made immediately. This is both good and bad. If you create an element and don't rename it and leave it as "Unnamed", then you will not be able to Gen Code for it. If you change the pref to "NewElement" or anything else, then any element that is still named "Unnamed" will now get code generated for it because "Unnamed" is no longer the Default Element Name. We can't keep a list of default element names so this is how it will work. If you change the preference, then you are responsible for renaming any "unnamed" elements to use the new default element name, if you wish them to remain in "stealth" mode. ClassCastException is fixed as well.
verified