Version: 1.5.61 (using KDE KDE 3.5.5) Installed from: Gentoo Packages OS: Linux I havec some case where a class participation to a class diagramm is not writed to xmi file. Each time i open this xmi , i have to drag-and-drop my class from left menu to right pane. Association are saved.
Created attachment 20245 [details] xmi file for umbrello open this file, and then open model class diagramm. Then drag and drop the ClassActivite Class. You'll see association. I can't manage so save this class in Model Diagramm
Created attachment 20252 [details] same xmi file, cleaned I removed the redundant <UML:Stareotype>s from your file. With this file, the ClassActivite is shown in the diagram. However, as soon as you save the file again, the class again disappears. Analysis: The diagram "model" is saved in a folder "implementation" and appears in the XMI file before the actual model objects referenced by the diagram. However, all model objects must be known before any diagram in which they appear.
SVN commit 653599 by okellogg: UMLWidget::activate(): If the widget has a UMLObject representation but m_pObject is NULL then attempt UMLDoc::findObjectById(m_nId). With this change, the ClassActivite widget from the XMI attachment does show up in the diagram. However, the association widgets connected to ClassActivite are still missing. Up next: Apply the same fix to AssociationWidget. CCBUG:144119 M +4 -3 actorwidget.cpp M +10 -9 artifactwidget.cpp M +11 -6 componentwidget.cpp M +8 -4 datatypewidget.cpp M +11 -9 entitywidget.cpp M +11 -9 enumwidget.cpp M +5 -3 floatingtextwidget.cpp M +2 -1 floatingtextwidget.h M +4 -3 messagewidget.cpp M +2 -2 messagewidget.h M +12 -6 nodewidget.cpp M +4 -2 objectwidget.cpp M +1 -1 objectwidget.h M +13 -8 packagewidget.cpp M +6 -2 umlview.cpp M +11 -2 umlwidget.cpp M +3 -2 umlwidget.h M +3 -2 widget_factory.cpp
SVN commit 653641 by okellogg: Apply the plot of commit 653599 to AssociationWidget. BUG:144119 M +1 -0 ChangeLog M +30 -28 umbrello/associationwidget.cpp M +3 -1 umbrello/associationwidget.h M +14 -14 umbrello/umlview.cpp M +1 -18 umbrello/umlwidget.cpp M +0 -17 umbrello/umlwidget.h M +18 -1 umbrello/widgetbase.cpp M +18 -1 umbrello/widgetbase.h --- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #653640:653641 @@ -29,6 +29,7 @@ * Operation Properties "Type" combo box too small (143319) * Support duplication of diagrams (143581) * Crash on changing multiplicity in an association in ERD (143909) +* Class diagram in folder not loaded correctly from xmi (144119) Version 1.5.61 --- branches/KDE/3.5/kdesdk/umbrello/umbrello/associationwidget.cpp #653640:653641 @@ -560,11 +560,30 @@ } } -void AssociationWidget::activate() { - if(isActivated()) - return; +bool AssociationWidget::activate() { + if (m_pObject == NULL && + UMLAssociation::assocTypeHasUMLRepresentation(m_AssocType)) { + UMLObject *myObj = m_umldoc->findObjectById(m_nId); + if (myObj == NULL) { + kError() << "AssociationWidget::activate: cannot find UMLObject " + << ID2STR(m_nId) << endl; + return false; + } else { + const Uml::Object_Type ot = myObj->getBaseType(); + if (ot == ot_Association) { + UMLAssociation * myAssoc = static_cast<UMLAssociation*>(myObj); + setUMLAssociation(myAssoc); + m_LinePath.setAssocType( myAssoc->getAssocType() ); + } else { + setUMLObject(myObj); + setAssocType(m_AssocType); + } + } + } - bool status = true; + if (m_bActivated) + return true; + Association_Type type = getAssocType(); if (m_role[A].m_pWidget == NULL) @@ -574,7 +593,7 @@ if(!m_role[A].m_pWidget || !m_role[B].m_pWidget) { kDebug() << "Can't make association" << endl; - return; + return false; } calculateEndingPoints(); @@ -651,9 +670,8 @@ createAssocClassLine(); } - if(status) { - m_bActivated = true; - } + m_bActivated = true; + return true; } /** This function calculates which role should be set for the m_pName FloatingTextWidget */ @@ -3277,8 +3295,8 @@ if (m_pObject) { assocElement.setAttribute( "xmi.id", ID2STR(m_pObject->getID()) ); } + assocElement.setAttribute( "type", m_AssocType ); if (getAssociation() == NULL) { - assocElement.setAttribute( "type", m_AssocType ); assocElement.setAttribute( "visibilityA", m_role[A].m_Visibility); assocElement.setAttribute( "visibilityB", m_role[B].m_Visibility); assocElement.setAttribute( "changeabilityA", m_role[A].m_Changeability); @@ -3407,8 +3425,6 @@ setRoleDoc( qElement.attribute("roleAdoc", ""), A ); setRoleDoc( qElement.attribute("roleBdoc", ""), B ); - setAssocType(aType); - // visibilty defaults to Public if it cant set it here.. QString visibilityA = qElement.attribute( "visibilityA", "0"); if (visibilityA.toInt() > 0) @@ -3438,25 +3454,11 @@ } // New style: The xmi.id is a reference to the UMLAssociation. - Uml::IDType nId = STR2ID(id); - UMLObject *myObj = m_umldoc->findObjectById(nId); - if (myObj == NULL) { - kError() << "AssociationWidget::loadFromXMI: cannot find UMLObject " - << ID2STR(nId) << endl; - return false; - } else { - const Uml::Object_Type ot = myObj->getBaseType(); - if (ot != ot_Association) { - setUMLObject(myObj); - setAssocType(aType); - } else { - UMLAssociation * myAssoc = static_cast<UMLAssociation*>(myObj); - setUMLAssociation(myAssoc); - m_LinePath.setAssocType( myAssoc->getAssocType() ); - } - } + m_nId = STR2ID(id); } + setAssocType(aType); + QString indexa = qElement.attribute( "indexa", "0" ); QString indexb = qElement.attribute( "indexb", "0" ); QString totalcounta = qElement.attribute( "totalcounta", "0" ); --- branches/KDE/3.5/kdesdk/umbrello/umbrello/associationwidget.h #653640:653641 @@ -107,8 +107,10 @@ /** * Activates the AssociationWidget after a load. + * + * @return true for success */ - void activate(); + bool activate(); /** * Set the widget of the given role. --- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlview.cpp #653640:653641 @@ -1383,21 +1383,21 @@ }//end while - //Activate All associationswidgets - AssociationWidgetListIt assoc_it( m_AssociationList ); - AssociationWidget *assocwidget; - //first get total count - while((assocwidget = assoc_it.current())) { - ++assoc_it; - if( assocwidget->isActivated() ) - continue; - assocwidget->activate(); - if( m_PastePoint.x() != 0 ) { - int x = m_PastePoint.x() - m_Pos.x(); - int y = m_PastePoint.y() - m_Pos.y(); - assocwidget -> moveEntireAssoc( x, y ); + // Activate all association widgets + AssociationWidget *aw; + for (AssociationWidgetListIt ait(m_AssociationList); + (aw = ait.current()); ++ait) { + if (aw->activate()) { + if (m_PastePoint.x() != 0) { + int x = m_PastePoint.x() - m_Pos.x(); + int y = m_PastePoint.y() - m_Pos.y(); + aw->moveEntireAssoc(x, y); + } + } else { + m_AssociationList.remove(aw); + delete aw; } - }//end while + } } int UMLView::getSelectCount(bool filterText) const { --- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlwidget.cpp #653640:653641 @@ -5,7 +5,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * copyright (C) 2002-2006 * + * copyright (C) 2002-2007 * * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> * ***************************************************************************/ @@ -167,23 +167,6 @@ */ } -void UMLWidget::setID(Uml::IDType id) { - if (m_Type != wt_Text && m_pObject && m_pObject->getBaseType() == ot_Association) { - if (m_pObject->getID() != Uml::id_None) - kWarning() << "UMLWidget::setID(): changing old UMLObject " - << ID2STR(m_pObject->getID()) << " to " - << ID2STR(id) << endl; - m_pObject->setID( id ); - } - m_nId = id; -} - -Uml::IDType UMLWidget::getID() const { - if (m_Type != wt_Text && m_pObject && m_pObject->getBaseType() == ot_Association) - return m_pObject->getID(); - return m_nId; -} - void UMLWidget::mouseMoveEvent(QMouseEvent* me) { m_widgetController->mouseMoveEvent(me); } --- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlwidget.h #653640:653641 @@ -83,16 +83,6 @@ virtual bool operator==(const UMLWidget& other); /** - * Write property of m_nId. - */ - void setID( Uml::IDType id ); - - /** - * Read property of m_nId. - */ - Uml::IDType getID() const; - - /** * Calls the method with the same name in UMLWidgetController. * @see UMLWidgetController#mouseReleaseEvent * @@ -594,13 +584,6 @@ ///////////////// Data Loaded/Saved ///////////////////////////////// /** - * This ID is only used when the UMLWidget does not have a - * corresponding UMLObject (i.e. the m_pObject pointer is NULL.) - * For UML objects, the ID from the UMLObject is used. - */ - Uml::IDType m_nId; - - /** * This flag indicates if the UMLWidget uses the Diagram FillColour */ bool m_bUseFillColour; --- branches/KDE/3.5/kdesdk/umbrello/umbrello/widgetbase.cpp #653640:653641 @@ -5,7 +5,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * copyright (C) 2004-2006 * + * copyright (C) 2004-2007 * * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> * ***************************************************************************/ @@ -55,6 +55,23 @@ m_pObject = o; } +void WidgetBase::setID(Uml::IDType id) { + if (m_pObject) { + if (m_pObject->getID() != Uml::id_None) + kWarning() << "WidgetBase::setID(): changing old UMLObject " + << ID2STR(m_pObject->getID()) << " to " + << ID2STR(id) << endl; + m_pObject->setID(id); + } + m_nId = id; +} + +Uml::IDType WidgetBase::getID() const { + if (m_pObject) + return m_pObject->getID(); + return m_nId; +} + QString WidgetBase::getDoc() const { if (m_pObject != NULL) return m_pObject->getDoc(); --- branches/KDE/3.5/kdesdk/umbrello/umbrello/widgetbase.h #653640:653641 @@ -5,7 +5,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * copyright (C) 2004-2006 * + * copyright (C) 2004-2007 * * Umbrello UML Modeller Authors <uml-devel@uml.sf.net> * ***************************************************************************/ @@ -143,6 +143,16 @@ m_bUsesDiagramLineWidth = usesDiagramLineWidth; } + /** + * Write property of m_nId. + */ + void setID( Uml::IDType id ); + + /** + * Read property of m_nId. + */ + Uml::IDType getID() const; + virtual void saveToXMI( QDomDocument & qDoc, QDomElement & qElement ); virtual bool loadFromXMI( QDomElement & qElement ); @@ -163,6 +173,13 @@ QString m_Doc; ///< Only used if m_pObject is not set. /** + * This ID is only used when the widget does not have a + * corresponding UMLObject (i.e. the m_pObject pointer is NULL.) + * For UMLObjects, the ID from the UMLObject is used. + */ + Uml::IDType m_nId; + + /** * Color of the lines of the widget. Is saved to XMI. */ QColor m_LineColour;