Bug 336012 - Automate required namespace/package user interaction on c++ import
Summary: Automate required namespace/package user interaction on c++ import
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: 2.13.1
Platform: unspecified Linux
: NOR wishlist
Target Milestone: 2.14 (KDE Applications 4.14)
Assignee: Ralf Habacker
URL:
Keywords:
: 338634 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-06-09 19:32 UTC by Ralf Habacker
Modified: 2017-11-12 21:01 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.14.1


Attachments
Hack to prevent manual package/class choose request (1.50 KB, patch)
2014-06-09 19:34 UTC, Ralf Habacker
Details
c++ test file (109 bytes, text/x-chdr)
2014-07-26 08:49 UTC, Ralf Habacker
Details
c++ test case (including all relevant cases) (433 bytes, text/x-chdr)
2014-07-26 18:28 UTC, Ralf Habacker
Details
c++ test case (minor syntax fix) (433 bytes, text/x-chdr)
2014-07-28 09:45 UTC, Ralf Habacker
Details
c++ test case (add D4) (528 bytes, text/x-chdr)
2014-07-28 09:52 UTC, Ralf Habacker
Details
xmi file with affected use cases (72.69 KB, application/x-uml)
2014-08-18 08:01 UTC, Ralf Habacker
Details
xmi file with verified use cases (32.81 KB, application/x-uml)
2014-08-23 04:33 UTC, Ralf Habacker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Habacker 2014-06-09 19:32:29 UTC
On cpp imports umbrello shows a manual package/class type request for cases, where a parsed class or namespace name could not be resolved. On importing foreign code this means to inspect the code to find an answer for this question. 
Because these requests may be shown on large code bases very often, cpp import of a large project is very unhandy. (This has recognized while working on bug 335914 with the qt 4 source)

When users are able to give an answer by inspecting the code, why does umbrello not can do this too by itself without these annoying requests.


Reproducible: Always

Steps to Reproduce:
1. open umbrello 
2. import large c++ project

Actual Results:  
There are many namespace/class choose requests. 

Expected Results:  
There should be no such requests shown.


Instead of the mentioned request it may be possible to create  a "may be class or package" uml object with a related graphical icon to indicate this state in the tree view. 

On importing the real class/namespace this uml object can be retyped.
Comment 1 Ralf Habacker 2014-06-09 19:34:09 UTC
Created attachment 87090 [details]
Hack to prevent manual package/class choose request

The appended patch could be used as a workaround until this features has been implemented. It creates classes by default for all such cases.
Comment 2 Ralf Habacker 2014-07-26 08:49:39 UTC
Created attachment 87957 [details]
c++ test file
Comment 3 Ralf Habacker 2014-07-26 18:28:34 UTC
Created attachment 87968 [details]
c++ test case (including all relevant cases)
Comment 4 Ralf Habacker 2014-07-28 07:45:24 UTC
Here is one proposal how to solve this issue:

Initial situation: 
1. On importing Bxx classes the related type Dxx is not known, which has currently to be solved by an user action raised through the "namespace or class" dialog. 
2. In umbrello code uml class objects and package objects are represented by an UMLClassifier and UMLPackage instance. 
3. Class UMLClassifier is derived from UMLPackage. 
4. Class widgets are represented by a ClassifierWidget instance and package widgets by a PackageWidget instance. 

Required changes:
1. On creating unknown type Dxx we need to mark this "class-or-package" condition somewhere in the uml object
2. On importing Class D2 we need to find the already created object with the "class-or-package" flag and retype it to a class. 
3. On importing namespace D3 we need to find the already created object with the "class-or-package" flag and retype it to a namespace. 
4. After import has been finished there may still be uml objects with the "class-or-package" flag for which a gui action is req
Comment 5 Ralf Habacker 2014-07-28 07:54:01 UTC
(In reply to Ralf Habacker from comment #4)
> Here is one proposal how to solve this issue:
> 
> Initial situation: 
> 1. On importing Bxx classes the related type Dxx is not known, which has
> currently to be solved by an user action raised through the "namespace or
> class" dialog. 
> 2. In umbrello code uml class objects and package objects are represented by
> an UMLClassifier and UMLPackage instance. 
> 3. Class UMLClassifier is derived from UMLPackage. 
> 4. Class widgets are represented by a ClassifierWidget instance and package
> widgets by a PackageWidget instance. 
> 
> Required changes:
> 1. On creating unknown type Dxx we need to mark this "class-or-package"
> condition somewhere in the uml object
> 2. On importing Class D2 we need to find the already created object with the
> "class-or-package" flag and retype it to a class. 
> 3. On importing namespace D3 we need to find the already created object with
> the "class-or-package" flag and retype it to a namespace. 
> 4. After import has been finished there may still be uml objects with the
> "class-or-package" flag for which a gui action is req
[sorry for sending not complete comment, I pressed accidently send]

uired from the context menu and property dialog to retype the  "class-or-package" flagged object to be a real class or package.

to discuss: 
1. Because class and package widgets uses different classes it may be useful to extend class ClassifierWidget to handle package widgets too, otherwise the ClassifierWidget instance has to be recreated as PackageWidget and reassigned to all parents/childs

2. How to flag "class-or-package" ? Using "class-or-package" as stereotype has the advantage, that such widgets are flagged on diagrams out of the box.

Any comment, suggestions or better implementation ?
Comment 6 Ralf Habacker 2014-07-28 09:45:46 UTC
Created attachment 87991 [details]
c++ test case (minor syntax fix)
Comment 7 Ralf Habacker 2014-07-28 09:52:46 UTC
Created attachment 87992 [details]
c++ test case (add D4)

add namespace D4 to see if icon display in non retyped case works
Comment 8 Oliver Kellogg 2014-07-29 05:39:36 UTC
(In reply to Ralf Habacker from comment #5)
> [...]
> Required changes:
> 1. On creating unknown type Dxx we need to mark this "class-or-package"
> condition somewhere in the uml object

See also http://bugs.kde.org/79433 : This was done similarly for the former UMLClass, UMLInterface, and UMLDatatype which were dissolved into UMLClassifier, and analogously for {Class,Interface,Datatype}Widget which were dissolved into ClassifierWidget.

UMLClassifier enum ClassifierType could be extended by PACKAGE and a corresponding accessor, bool isPackage(). When ClassifierType is ALL (or none of the is{Class,Interface,Datatype,Package} accessors returns true) it means that the actual type was not yet discovered.

Dissolving UMLPackage into UMLClassifier would be very heavy weight change, however.
Comment 9 Ralf Habacker 2014-08-18 06:34:39 UTC
Git commit 801d607aa6016340d1fcf3cbfa96353505210f21 by Ralf Habacker.
Committed on 25/07/2014 at 11:33.
Pushed by habacker into branch 'work/336012'.

Automate required namespace/package user interaction on c++ import.

If the type of an imported uml object could not be determined the import
creates an uml class object and flags the stereotype to be "class-or-package".
Such uml objects are displayed in the tree view by a dedicated icon.

If the real type of the related uml object is determined later as a class,
the flag is removed and the uml object is usable as a generic class.

If the real object is a namespace, the flag is removed and the uml object
is set to a package type and could be used as regular created package.
This is possible because the initial created object of type UMLClassifier
is derived from UMLPackage. In the latter case ClassifierWidget paints
the object as Package.

The tree view and classifier widget context menu has been extended to
provide functions to convert a "class or package" uml object to a class
or package.

Because the "class or package" state is flagged in the stereotype, saving
and loading of an umbrello project containing "class or package"
flagged uml objects is completly transparent.

M  +5    -0    umbrello/classifier.cpp
M  +8    -0    umbrello/codeimport/import_utils.cpp
M  +28   -6    umbrello/codeimport/kdevcppparser/cpptree2uml.cpp
M  +2    -0    umbrello/icon_utils.cpp
M  +1    -0    umbrello/icon_utils.h
M  +11   -0    umbrello/listpopupmenu.cpp
M  +1    -0    umbrello/listpopupmenu.h
M  +1    -1    umbrello/pics/CMakeLists.txt
A  +-    --    umbrello/pics/class-or-package.png
A  +166  -0    umbrello/pics/sources/class-or-package.svg
M  +16   -0    umbrello/umllistview.cpp
M  +7    -0    umbrello/umllistviewitem.cpp
M  +130  -1    umbrello/widgets/classifierwidget.cpp
M  +7    -1    umbrello/widgets/classifierwidget.h
M  +2    -2    umbrello/widgets/widget_factory.cpp

http://commits.kde.org/umbrello/801d607aa6016340d1fcf3cbfa96353505210f21
Comment 10 Ralf Habacker 2014-08-18 08:01:29 UTC
Created attachment 88291 [details]
xmi file with affected use cases

xmi file with affected use cases
Comment 11 Ralf Habacker 2014-08-18 10:25:23 UTC
Git commit 74741f1629b5a7f7ad1316f378b946cc75e7a466 by Ralf Habacker.
Committed on 18/08/2014 at 10:25.
Pushed by habacker into branch 'work/336012'.

Save imported "class-or-package" uml object, which has been later retyped as package into the xmi file as UMLPackage.

On next xmi file load this package is a regular UMLPackage.

M  +4    -0    umbrello/classifier.cpp

http://commits.kde.org/umbrello/74741f1629b5a7f7ad1316f378b946cc75e7a466
Comment 12 Ralf Habacker 2014-08-22 15:43:25 UTC
Git commit 006ea150fc3b5eed7414014f6dc68b302dcad176 by Ralf Habacker.
Committed on 22/08/2014 at 15:44.
Pushed by habacker into branch 'work/336012'.

Initialize missing class member to avoid crash on destruction.

M  +2    -1    umbrello/widgets/classifierwidget.cpp

http://commits.kde.org/umbrello/006ea150fc3b5eed7414014f6dc68b302dcad176
Comment 13 Ralf Habacker 2014-08-23 03:57:40 UTC
Git commit 24e75a383d7a166c2fad21bd2eabf6b6de475c5e by Ralf Habacker.
Committed on 23/08/2014 at 03:59.
Pushed by habacker into branch 'work/336012'.

Use 'class-or-package' icon in tree view on loading uml object class with stereotype 'class-or-package'.

M  +5    -2    umbrello/model_utils.cpp
M  +1    -1    umbrello/model_utils.h

http://commits.kde.org/umbrello/24e75a383d7a166c2fad21bd2eabf6b6de475c5e
Comment 14 Ralf Habacker 2014-08-23 04:16:22 UTC
Git commit 4ad7eb8b102f8653f81494c7648fa2ae1409dd16 by Ralf Habacker.
Committed on 23/08/2014 at 04:20.
Pushed by habacker into branch 'work/336012'.

Use Model_Utils::convert_LVT_IT() for setting tree view icon on uml class objects stereotyped to 'class-or-package'..

M  +3    -5    umbrello/umllistviewitem.cpp

http://commits.kde.org/umbrello/4ad7eb8b102f8653f81494c7648fa2ae1409dd16
Comment 15 Ralf Habacker 2014-08-23 04:21:04 UTC
Git commit 45168af373914a10ca33617a8c8b794737cb75a0 by Ralf Habacker.
Committed on 23/08/2014 at 04:22.
Pushed by habacker into branch 'work/336012'.

Automated 'class or package' import support is working now; drop 'class or package' user request.

M  +0    -16   umbrello/codeimport/import_utils.cpp

http://commits.kde.org/umbrello/45168af373914a10ca33617a8c8b794737cb75a0
Comment 16 Ralf Habacker 2014-08-23 04:33:41 UTC
Created attachment 88382 [details]
xmi file with verified use cases
Comment 17 Oliver Kellogg 2014-08-28 19:06:11 UTC
*** Bug 338634 has been marked as a duplicate of this bug. ***
Comment 18 Ralf Habacker 2014-08-31 07:48:42 UTC
Git commit 1de0459dc7fb87b0dcba82cdd175bd085aba35a3 by Ralf Habacker.
Committed on 25/07/2014 at 11:33.
Pushed by habacker into branch 'master'.

Automate required namespace/package user interaction on c++ import.

If the type of an imported uml object could not be determined the import
creates an uml class object and flags the stereotype to be "class-or-package".
Such uml objects are displayed in the tree view by a dedicated icon.

If the real type of the related uml object is determined later as a class,
the flag is removed and the uml object is usable as a generic class.

If the real object is a namespace, the flag is removed and the uml object
is set to a package type and could be used as regular created package.
This is possible because the initial created object of type UMLClassifier
is derived from UMLPackage. In the latter case ClassifierWidget paints
the object as Package.

The tree view and classifier widget context menu has been extended to
provide functions to convert a "class or package" uml object to a class
or package.

Because the "class or package" state is flagged in the stereotype, saving
and loading of an umbrello project containing "class or package"
flagged uml objects is completly transparent.

M  +5    -0    umbrello/classifier.cpp
M  +8    -0    umbrello/codeimport/import_utils.cpp
M  +28   -6    umbrello/codeimport/kdevcppparser/cpptree2uml.cpp
M  +2    -0    umbrello/icon_utils.cpp
M  +1    -0    umbrello/icon_utils.h
M  +11   -0    umbrello/listpopupmenu.cpp
M  +1    -0    umbrello/listpopupmenu.h
M  +1    -1    umbrello/pics/CMakeLists.txt
A  +-    --    umbrello/pics/class-or-package.png
A  +166  -0    umbrello/pics/sources/class-or-package.svg
M  +16   -0    umbrello/umllistview.cpp
M  +7    -0    umbrello/umllistviewitem.cpp
M  +131  -1    umbrello/widgets/classifierwidget.cpp
M  +7    -1    umbrello/widgets/classifierwidget.h
M  +2    -2    umbrello/widgets/widget_factory.cpp

http://commits.kde.org/umbrello/1de0459dc7fb87b0dcba82cdd175bd085aba35a3
Comment 19 Ralf Habacker 2014-08-31 07:48:42 UTC
Git commit 4be3031283a7ea43ad6ece4dedb27b30e53ab987 by Ralf Habacker.
Committed on 18/08/2014 at 10:25.
Pushed by habacker into branch 'master'.

Save imported "class-or-package" uml object, which has been later retyped as package into the xmi file as UMLPackage.

On next xmi file load this package is a regular UMLPackage.

M  +4    -0    umbrello/classifier.cpp

http://commits.kde.org/umbrello/4be3031283a7ea43ad6ece4dedb27b30e53ab987
Comment 20 Ralf Habacker 2014-08-31 07:48:43 UTC
Git commit 0a25cc14f633c9c64fa0d069c5b3a860e0c8ba76 by Ralf Habacker.
Committed on 23/08/2014 at 03:59.
Pushed by habacker into branch 'master'.

Use 'class-or-package' icon in tree view on loading uml object class with stereotype 'class-or-package'.

M  +5    -2    umbrello/model_utils.cpp
M  +1    -1    umbrello/model_utils.h

http://commits.kde.org/umbrello/0a25cc14f633c9c64fa0d069c5b3a860e0c8ba76
Comment 21 Ralf Habacker 2014-08-31 07:48:44 UTC
Git commit dd6b3bf6437c14dfd9e6afa611fc58e930bb1a5c by Ralf Habacker.
Committed on 23/08/2014 at 04:20.
Pushed by habacker into branch 'master'.

Use Model_Utils::convert_LVT_IT() for setting tree view icon on uml class objects stereotyped to 'class-or-package'..

M  +3    -5    umbrello/umllistviewitem.cpp

http://commits.kde.org/umbrello/dd6b3bf6437c14dfd9e6afa611fc58e930bb1a5c
Comment 22 Ralf Habacker 2014-08-31 07:48:45 UTC
Git commit a542a080a2da199dde65f68fdc8ebe54eb529dad by Ralf Habacker.
Committed on 23/08/2014 at 04:22.
Pushed by habacker into branch 'master'.

Automated 'class or package' import support is working now; drop 'class or package' user request.

M  +0    -16   umbrello/codeimport/import_utils.cpp

http://commits.kde.org/umbrello/a542a080a2da199dde65f68fdc8ebe54eb529dad
Comment 23 Ralf Habacker 2014-09-02 07:03:54 UTC
Git commit a6e8b2e4d6d021b6bb689820d0ae4a3edcee6eb1 by Ralf Habacker.
Committed on 02/09/2014 at 06:21.
Pushed by habacker into branch 'KDE/4.14'.

Merge remote branch 'origin/work/336012' into KDE/4.14
FIXED-IN:4.14.1
GUI

M  +5    -2    umbrello/model_utils.cpp

http://commits.kde.org/umbrello/a6e8b2e4d6d021b6bb689820d0ae4a3edcee6eb1
Comment 24 Ralf Habacker 2015-09-14 16:14:08 UTC
Git commit cd350fa7b2c0283331ec15cb784323930511b532 by Ralf Habacker.
Committed on 14/09/2015 at 16:13.
Pushed by habacker into branch 'Applications/15.08'.

Write package widgets into the xmi file using a "packagewidget" tag.

This commit is a fixup of commit a6e8b2e4d6d021b6bb689820d0ae4a3edcee6eb1.
Thanks to Oliver Kellogg for pointing out.
Related: bug 352597

M  +7    -1    umbrello/widgets/classifierwidget.cpp
M  +2    -0    umbrello/widgets/widget_factory.cpp

http://commits.kde.org/umbrello/cd350fa7b2c0283331ec15cb784323930511b532
Comment 25 Oliver Kellogg 2015-10-08 05:16:12 UTC
(In reply to Ralf Habacker from comment #18)
> Git commit 1de0459dc7fb87b0dcba82cdd175bd085aba35a3 by Ralf Habacker.
> Committed on 25/07/2014 at 11:33.
> Pushed by habacker into branch 'master'.
> 
> Automate required namespace/package user interaction on c++ import.
> [...]
> M  +28   -6    umbrello/codeimport/kdevcppparser/cpptree2uml.cpp

The hunk @@ -84,9 +92,18 @@ contains this code:

+    else
+        o = Import_Utils::createUMLObject(UMLObject::ot_Package, nsName,
+                                          m_currentNamespace[m_nsCnt],
+                                          ast->comment());

and similarly, the hunk @@ -339,9 +356,19 @@ contains this code:

+    else
+        o = Import_Utils::createUMLObject(UMLObject::ot_Class, className,
+                                          m_currentNamespace[m_nsCnt],
+                                          ast->comment(), QString(), true);

This is the 'else' part of 'if (!o)'.
Out of curiosity: Why do you re-create 'o' although is was returned non NULL?
I would have expected to just continue using the existing object.
Comment 26 Oliver Kellogg 2015-10-08 05:20:55 UTC
(In reply to Oliver Kellogg from comment #25)
> [...]
> This is the 'else' part of 'if (!o)'.
> Out of curiosity: Why do you re-create 'o' although is was returned non NULL?
> I would have expected to just continue using the existing object.

Ouch! I misread - 'else' of 'if (!o)' of course means we are in the (o == NULL) case.
Sorry for the noise - forget the previous comment, please.
Comment 27 Ralf Habacker 2015-12-16 18:50:30 UTC
Git commit 896cce0d0c8e6b53af190619a94cb9933da9e410 by Ralf Habacker.
Committed on 16/12/2015 at 18:15.
Pushed by habacker into branch 'frameworks'.

Write package widgets into the xmi file using a "packagewidget" tag.

This commit is a fixup of commit a6e8b2e4d6d021b6bb689820d0ae4a3edcee6eb1.
Thanks to Oliver Kellogg for pointing out.
Related: bug 352597

M  +7    -1    umbrello/widgets/classifierwidget.cpp
M  +2    -0    umbrello/widgets/widget_factory.cpp

http://commits.kde.org/umbrello/896cce0d0c8e6b53af190619a94cb9933da9e410
Comment 28 Lays Rodrigues 2016-10-27 11:47:07 UTC
Git commit b006b7e76d981824de094c656170140f9ddeb78e by Lays Rodrigues, on behalf of Ralf Habacker.
Committed on 27/10/2016 at 11:44.
Pushed by laysrodrigues into branch 'frameworks'.

Write package widgets into the xmi file using a "packagewidget" tag.

This commit is a fixup of commit a6e8b2e4d6d021b6bb689820d0ae4a3edcee6eb1.
Thanks to Oliver Kellogg for pointing out.
Related: bug 352597

M  +1    -1    umbrello/umlwidgets/widget_factory.cpp

http://commits.kde.org/umbrello/b006b7e76d981824de094c656170140f9ddeb78e
Comment 29 Ralf Habacker 2017-11-12 21:01:09 UTC
Git commit d273fd556ae1baf2b9735da7046c0ea140eb3df7 by Ralf Habacker.
Committed on 12/11/2017 at 21:00.
Pushed by habacker into branch 'master'.

Fixup of 1de0459dc

Limit manual updating of tree view item to "document in loading state"
because calling setStereotypeCmd() triggers tree view item update by
default if document is not in loading state.

M  +6    -3    umbrello/codeimport/import_utils.cpp

https://commits.kde.org/umbrello/d273fd556ae1baf2b9735da7046c0ea140eb3df7