Bug 144346 - No synchronisation of comments for Java/UML templates when round-tripping
Summary: No synchronisation of comments for Java/UML templates when round-tripping
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR wishlist
Target Milestone: ---
Assignee: Oliver Kellogg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-17 16:35 UTC by Ian Stokes-Rees
Modified: 2007-04-18 21:00 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Stokes-Rees 2007-04-17 16:35:21 UTC
Version:           1.5.7 (using KDE KDE 3.5.5)
Installed from:    Fedora RPMs
OS:                Linux

I use Umbrello to prototype my Java interface, adding comments to the interface and to the methods.  I then generate the code and augment it with the expected customisations.  I start using it with Eclipse to do an implementation, and discover I need to change this bit or that bit in the interface definition.  I then want to go back to Umbrello and re-import the updated Java Interface and keep building on it.  The comments on each of the methods do not appear, so when I'm done the exported Interface will lack all the comments (except the new ones) meaning I need to cut and paste the new bits into the previously generated file.  Not nice.
Comment 1 Oliver Kellogg 2007-04-18 06:01:31 UTC
> [...] Not nice.

You have a point there :)
Comment 2 Oliver Kellogg 2007-04-18 06:05:08 UTC
SVN commit 655249 by okellogg:

showDocumentation(UMLObject*, bool): Calling updateDocumentation() ruins the object->m_Doc.
CCBUG:144346


 M  +1 -2      docwindow.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/docwindow.cpp #655248:655249
@@ -50,8 +50,7 @@
 void DocWindow::showDocumentation( UMLObject * object, bool overwrite ) {
     if( object == m_pUMLObject && !overwrite )
         return;
-    if( object != m_pUMLObject )
-        updateDocumentation( true );
+
     m_Showing = st_UMLObject;
     if( !object ) {
         m_pDocMLE->setText( m_pUMLDoc->getDocumentation() );
Comment 3 Oliver Kellogg 2007-04-18 06:11:11 UTC
SVN commit 655250 by okellogg:

insertMethod(): Call UMLClassifier::checkOperationSignature() on the new op.
 If it exists then copy the properties of the new op to the existing op.
All code: Do not call DocWindow::showDocumentation(), it spoils the UMLObject::m_Doc.
BUG:144346


 M  +1 -0      ChangeLog  
 M  +29 -6     umbrello/codeimport/import_utils.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #655249:655250
@@ -30,6 +30,7 @@
 * Crash on changing multiplicity in an association in ERD (143909)
 * Class diagram in folder not loaded correctly from xmi (144119)
 * Sequence diagram crashes during message inserting (144293)
+* No synchronisation of comments when round-tripping (144346)
 
 Version 1.5.61
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/import_utils.cpp #655249:655250
@@ -244,7 +244,7 @@
     QString strippedComment = formatComment(comment);
     if (! strippedComment.isEmpty()) {
         o->setDoc(strippedComment);
-        UMLApp::app()->getDocWindow()->showDocumentation(o, true);
+        //UMLApp::app()->getDocWindow()->showDocumentation(o, true);
     }
     if (!stereotype.isEmpty()) {
         o->setStereotype(stereotype);
@@ -304,7 +304,7 @@
     QString strippedComment = formatComment(comment);
     if (! strippedComment.isEmpty()) {
         attr->setDoc(strippedComment);
-        UMLApp::app()->getDocWindow()->showDocumentation(attr, true);
+        //UMLApp::app()->getDocWindow()->showDocumentation(attr, true);
     }
 
     UMLApp::app()->getDocument()->setModified(true);
@@ -362,14 +362,37 @@
     if (isConstructor)
         op->setStereotype("constructor");
 
-    klass->addOperation(op);
-    //umldoc->signalUMLObjectCreated(op);
     QString strippedComment = formatComment(comment);
     if (! strippedComment.isEmpty()) {
         op->setDoc(strippedComment);
-        UMLApp::app()->getDocWindow()->showDocumentation(op, true);
     }
-    //setModified(true);
+
+    UMLAttributeList params = op->getParmList();
+    UMLOperation *exist = klass->checkOperationSignature(op->getName(), params);
+    if (exist) {
+        // copy contents to existing operation
+        exist->setVisibility(scope);
+        exist->setStatic(isStatic);
+        exist->setAbstract(isAbstract);
+        if (! strippedComment.isEmpty())
+            exist->setDoc(strippedComment);
+        UMLAttributeList exParams = exist->getParmList();
+        UMLAttribute *param, *exParam = exParams.first();
+        for (UMLAttributeListIt it(params); (param = it.current()) != NULL;
+                                            ++it, exParam = exParams.next()) {
+            exParam->setName(param->getName());
+            exParam->setVisibility(param->getVisibility());
+            exParam->setStatic(param->getStatic());
+            exParam->setAbstract(param->getAbstract());
+            exParam->setDoc(param->getDoc());
+            exParam->setInitialValue(param->getInitialValue());
+            exParam->setParmKind(param->getParmKind());
+        }
+        // delete temporary UMLOperation
+        delete op;
+    } else {
+        klass->addOperation(op);
+    }
 }
 
 UMLAttribute* addMethodParameter(UMLOperation *method,
Comment 4 Oliver Kellogg 2007-04-18 21:00:42 UTC
SVN commit 655558 by okellogg:

showDocumentation(UMLObject*, bool): Revert r655249.
The real fix was to remove the calls to showDocumentation() from Import_Utils.
CCBUG:144346


 M  +2 -0      docwindow.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/docwindow.cpp #655557:655558
@@ -50,6 +50,8 @@
 void DocWindow::showDocumentation( UMLObject * object, bool overwrite ) {
     if( object == m_pUMLObject && !overwrite )
         return;
+    if( object != m_pUMLObject )
+        updateDocumentation( true );
 
     m_Showing = st_UMLObject;
     if( !object ) {