1) Create Java project and UML project by reverse engineering Java project
2) Create a Java class named Foo in the Java project
3) Open Foo class in editor
4) Fully expand the Foo class element in the UML project
5) In Foo Java source file, right click the class name (in source code) and
select Refactor->Rename action
6) Change name from Foo to Bar
7) Follow through with refactoring (yes to all dialogs)
Result: The Java source class for Foo is renamed to Bar and all refactoring
tasks succeed as expected. Class element node is refreshed and therefore, node
structure is collapsed. Expand fully to inspect the Source File Artifact node.
Notice that is is still pointing to Foo.java and not the new Bar.java.
A fix has been found. More testing before integration and the details will be
posted here on what was wrong, assuming additional testing will succeed.
In MetaDataRChangeListener's method handleNameChange(AttributeEvent)
(in org.netbeans.modules.uml.integration.netbeans.listeners), a call to
JavaClassUtils.findElement(String) is only passing in the "simple" name of the
element (IElement) that is needed. Even when it is found, there is a follow up
comparison of the found IElement's fully qualified name with this simple name
and so it never matches (except for default package case, perhaps) and the
return is always null. So the solution is to pass in the fully qualified name of
the element with dot delimiters. The ".java" extension must be stripped off the
end of it as well.
And now that the element is being found properly, the new class file can be
found for this class in the Java project, and set as the new source file
artifact for this element.
Verified in Netbeans 5.5 Dev (build 2006.07.17)