Bug 140669 - Java 5 generics support
Summary: Java 5 generics support
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Oliver Kellogg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-26 16:30 UTC by Serhiy
Modified: 2007-03-16 07:23 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch for #140669 (12.55 KB, patch)
2007-03-11 12:11 UTC, Antoine Dopffer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Serhiy 2007-01-26 16:30:14 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources

As far as I can see in the documentation umbrello currently supports java 5. But the problem is that when you import sources it doesn't draw correct classes diagram for generics. For example, if one class (ComplexBean) has list of SimpleBeans (List<SimpleBean>) it means that there is an aggregation relationship between these classes. But umbrello identifies "List<SimpleBean>" as new data type and adds this to the list of data types but it doesn't draw any relationship between SimpleBean and ComplexBean classes. If it is difficult to display correct type of relationship umbrello should draw at least association relation between classes. Can we expect this fixed?
Comment 1 Antoine Dopffer 2007-03-04 23:25:10 UTC
The problem is identical in C++.
If you import a class with an attribut of type QList<SimpleBean>, Umbrello doesn't draw any association.

But IMHO the problem isn't with the import.
You can design a class ComplexBean in Umbrello with a attribut of type List<SimpleBean>. The aggregation isn't drawn.

Perhaps the problem is with the function UMLView::createAutoAttributeAssociations that doesn't handle such a case.
As you said, List<SimpleBean> is identified as a new data type.

A quick and dirty hack could update this function.
When the attribute type matches the pattern A<B>, the updated function may look for types B in the current diagram instead of looking for A<B> in the current diagram.

Is this solution OK ? 

 
Comment 2 Oliver Kellogg 2007-03-07 06:47:03 UTC
> Perhaps the problem is with the function
> UMLView::createAutoAttributeAssociations that doesn't handle
> such a case.

Yes, that could work.
You would need to analyze the name of each UMLDataType encountered
while iterating over the attributes of the class: Take apart the
"<template_param>" syntax, search the model for each of the
template params, and generate a Dependency to the UMLAttribute found.
Comment 3 Antoine Dopffer 2007-03-11 12:11:24 UTC
Created attachment 19935 [details]
patch for #140669

This patch is against branches/3.5, I haven't tested it in trunk.

Now, if one class (ComplexBean) has list of SimpleBeans (List<SimpleBean>),
umbrello draws a relationship between SimpleBean and ComplexBean classes. 
It works also with C++.
This patch also adds a data type  "List<SimpleBean>" and a class "List" in the
logical view when you add an attribute List<SimpleBean> inside the umbrello
designer. Before in such a case, a class List<SimpleBean> was added.

C++ namespaces and Java packages are better handled when you add an attribute
with namespaces or package inside the umbrello designer.
Comment 4 Oliver Kellogg 2007-03-13 06:53:20 UTC
> This patch is against branches/3.5, I haven't tested it in trunk. 
 
Nice work.

> Now, if one class (ComplexBean) has list of SimpleBeans (List<SimpleBean>),
> umbrello draws a relationship between SimpleBean and ComplexBean classes.

You draw the relationship as composition/aggregation.
However, on generating code, this means that an extra member of type
SimpleBean will be created in ComplexBean.
(The aggregation/composition is already drawn correctly to the datatype
"List<SimpleBean>".)

IMHO we would need an indication on the association that shows the
template-parameter-of relationship.
IMHO we could create a Dependency instead of Aggregation/Composition.

 
Comment 5 Antoine Dopffer 2007-03-13 11:27:43 UTC
>However, on generating code, this means that an extra member of type
>SimpleBean will be created in ComplexBean. 
No, because this composition/agregation is added in the view (UMLView) not in the concept (Classifier).
I have tested it, no extra member is generated.

>IMHO we could create a Dependency instead of Aggregation/Composition.
I will try to have a look at it but I won't be able to do it before few weeks. 


 
Comment 6 Oliver Kellogg 2007-03-14 06:56:51 UTC
> No, because this composition/agregation is added in the view (UMLView)
> not in the concept (Classifier).

Ah, okay. I overlooked that.
It's interesting that this usage survives a save/load cycle.
Anyway, I'm adding the parsing of template instantiations and creation
of UMLAssociation(at_Dependency) at Import_Utils::createUMLObject().
Comment 7 Oliver Kellogg 2007-03-16 07:23:22 UTC
SVN commit 643026 by okellogg:

Apply attachment 19935 [details] from Antoine Dopffer with enhancement of Import_Utils::
createUMLObject() for creating UMLAssociation(at_Dependency) from the related
classifier to known classifiers mentioned in a template instantiation.
FEATURE:140669


 M  +1 -0      ChangeLog  
 M  +68 -0     umbrello/attribute.cpp  
 M  +13 -0     umbrello/attribute.h  
 M  +50 -7     umbrello/codeimport/import_utils.cpp  
 M  +6 -0      umbrello/codeimport/import_utils.h  
 M  +14 -5     umbrello/dialogs/umlattributedialog.cpp  
 M  +49 -35    umbrello/umlview.cpp  
 M  +10 -0     umbrello/umlview.h