[Uml-devel] branches/work/isi-umbrello/umbrello/umbrello

Florence Mattler florence.mattler at libertysurf.fr
Thu Feb 15 23:46:33 UTC 2007


SVN commit 633994 by mattler:

save and load the floating dash line in the combined fragments alternative and parallel


 M  +36 -16    combinedfragmentwidget.cpp  
 M  +0 -12     combinedfragmentwidget.h  
 M  +22 -0     floatingdashlinewidget.cpp  
 M  +10 -0     floatingdashlinewidget.h  
 M  +1 -1      widget_factory.cpp  


--- branches/work/isi-umbrello/umbrello/umbrello/combinedfragmentwidget.cpp #633993:633994
@@ -232,27 +232,19 @@
     return true;
 }
 
-// bool CombinedFragmentWidget::isCombinedFragment(WorkToolBar::ToolBar_Buttons tbb, CombinedFragmentType& resultType)
-// {
-//     bool status = true;
-//     switch (tbb) {
-// ;
-//     case WorkToolBar::tbb_Seq_Combined_Fragment:
-//         resultType = m_CombinedFragment;
-//         break;
-//     default:
-//         status = false;
-//         break;
-//     }
-//     return status;
-// }
-
 void CombinedFragmentWidget::saveToXMI( QDomDocument & qDoc, QDomElement & qElement ) {
     QDomElement combinedFragmentElement = qDoc.createElement( "combinedFragmentwidget" );
     UMLWidget::saveToXMI( qDoc, combinedFragmentElement );
     combinedFragmentElement.setAttribute( "combinedFragmentname", m_Text );
     combinedFragmentElement.setAttribute( "documentation", m_Doc );
     combinedFragmentElement.setAttribute( "CombinedFragmenttype", m_CombinedFragment );
+
+    // save the corresponding floating dash line
+    if (m_dashLine) {
+        combinedFragmentElement.setAttribute( "dashlineId", ID2STR(m_dashLine->getID()) );
+        m_dashLine -> saveToXMI( qDoc, combinedFragmentElement );
+    }
+
     qElement.appendChild( combinedFragmentElement );
 }
 
@@ -262,8 +254,36 @@
     m_Text = qElement.attribute( "combinedFragmentname", "" );
     m_Doc = qElement.attribute( "documentation", "" );
     QString type = qElement.attribute( "CombinedFragmenttype", "");
-    //KMessageBox::error(0, i18n(" type %1",type),i18n("type"));
+    
+    QString dashId = qElement.attribute( "dashlineId", "");
+    Uml::IDType dashlineId = STR2ID(dashId);
+    if (dashlineId != Uml::id_None) {
+        UMLWidget *flotdashline = m_pView -> findWidget( dashlineId );
+        if (flotdashline != NULL) {
+            m_dashLine = static_cast<FloatingDashLineWidget*>(flotdashline);
+            return true;
+        }
+    } 
+
+    //now load child elements
+    QDomNode node = qElement.firstChild();
+    QDomElement element = node.toElement();
+    if ( !element.isNull() ) {
+        QString tag = element.tagName();
+        if (tag == "floatingdashlinewidget") {
+            m_dashLine = new FloatingDashLineWidget( m_pView , dashlineId );
+            if( ! m_dashLine->loadFromXMI(element) ) {
+                // Most likely cause: The FloatingTextWidget is empty.
+                delete m_dashLine;
+                m_dashLine = NULL;
+            }
+        } else {
+            kError() << "MessageWidget::loadFromXMI: unknown tag "
+            << tag << endl;
+        }
+    }
     setCombinedFragmentType( (CombinedFragmentType)type.toInt() );
+    
     return true;
 }
 
--- branches/work/isi-umbrello/umbrello/umbrello/combinedfragmentwidget.h #633993:633994
@@ -88,18 +88,6 @@
     bool showProperties();
 
     /**
-     * Determines whether a toolbar button represents a combined fragment.
-     * CHECK: currently unused - can this be removed?
-     *
-     * @param tbb               The toolbar button enum input value.
-     * @param resultType        The CombinedFragmentType corresponding to tbb.
-     *                  This is only set if tbb is a CombinedFragment.
-     * @return  True if tbb represents a CombinedFragment.
-     */
-    static bool isCombinedFragment( WorkToolBar::ToolBar_Buttons tbb,
-                            CombinedFragmentType& resultType );
-
-    /**
      * Saves the widget to the <combinedFragmentwidget> XMI element.
      */
     void saveToXMI( QDomDocument & qDoc, QDomElement & qElement );
--- branches/work/isi-umbrello/umbrello/umbrello/floatingdashlinewidget.cpp #633993:633994
@@ -72,4 +72,26 @@
     return (getY() - m_yMin);
 }
 
+void FloatingDashLineWidget::saveToXMI( QDomDocument & qDoc, QDomElement & qElement ) {
+    QDomElement textElement = qDoc.createElement( "floatingdashlinewidget" );
+    UMLWidget::saveToXMI( qDoc, textElement );
+    textElement.setAttribute( "text", m_Text );
+    textElement.setAttribute( "y", m_y );
+    textElement.setAttribute( "minY", m_yMin );
+    textElement.setAttribute( "maxY", m_yMax );
+
+    qElement.appendChild( textElement );
+}
+
+bool FloatingDashLineWidget::loadFromXMI( QDomElement & qElement ) {
+    if( !UMLWidget::loadFromXMI( qElement ) )
+        return false;
+
+    m_yMax = qElement.attribute( "maxY", "" ).toInt();
+    m_yMin = qElement.attribute( "minY", "" ).toInt();
+    m_y = qElement.attribute( "y", "" ).toInt();
+    m_Text = qElement.attribute( "text", "" );
+
+}
+
 #include "floatingdashlinewidget.moc"
--- branches/work/isi-umbrello/umbrello/umbrello/floatingdashlinewidget.h #633993:633994
@@ -80,6 +80,16 @@
      */
     int getDiffY();
 
+     /**
+     * Creates the <floatingdashline> XMI element.
+     */
+    void saveToXMI( QDomDocument & qDoc, QDomElement & qElement );
+
+    /**
+     * Loads the <floatingdashline> XMI element.
+     */
+    bool loadFromXMI( QDomElement & qElement );
+
 private:
     /**
      * Text associated to the dash line
--- branches/work/isi-umbrello/umbrello/umbrello/widget_factory.cpp #633993:633994
@@ -163,7 +163,7 @@
     UMLWidget *widget = NULL;
     if (tag == "statewidget" || tag == "notewidget" || tag == "boxwidget" ||
         tag == "floatingtext" || tag == "activitywidget" || tag == "forkjoin" || tag == "preconditionwidget" || tag == "endoflifewidget" ||
-        tag == "combinedFragmentwidget"  || tag == "signalwidget"  ||
+        tag == "combinedFragmentwidget"  || tag == "signalwidget"  || "floatingdashdinewidget" ||
             // tests for backward compatibility:
             tag == "UML:StateWidget" || tag == "UML:NoteWidget" ||
             tag=="UML:CombinedFragmentWidget" || tag == "UML:FloatingTextWidget" || tag == "UML:SignalWidget" || tag == "UML:ActivityWidget") {




More information about the umbrello-devel mailing list