umbrello API Documentation

codeclassfielddeclarationblock.cpp

00001 
00002 /***************************************************************************
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  *                                                                         *
00009  ***************************************************************************/
00010 
00011 /*  This code generated by:
00012  *      Author : thomas
00013  *      Date   : Fri Jul 25 2003
00014  */
00015 
00019 #include "codeclassfielddeclarationblock.h"
00020 
00021 #include "codeclassfield.h"
00022 #include "umlrole.h"
00023 
00024 // Constructors/Destructors
00025 //
00026 
00027 CodeClassFieldDeclarationBlock::CodeClassFieldDeclarationBlock ( CodeClassField * parentCF )
00028         : CodeBlockWithComments ( (CodeDocument*) parentCF->getParentDocument() ),
00029         OwnedCodeBlock ((UMLObject*) parentCF->getParentObject())
00030 {
00031     init(parentCF);
00032 }
00033 
00034 CodeClassFieldDeclarationBlock::~CodeClassFieldDeclarationBlock ( ) {
00035     // Q: is this needed??
00036     //      m_parentclassfield->getParentObject()->disconnect(this);
00037 }
00038 
00039 //
00040 // Methods
00041 //
00042 
00043 // Accessor methods
00044 //
00045 
00050 CodeClassField * CodeClassFieldDeclarationBlock::getParentClassField ( ) {
00051     return m_parentclassfield;
00052 }
00053 
00056 UMLObject * CodeClassFieldDeclarationBlock::getParentObject ( ) {
00057     return m_parentclassfield->getParentObject();
00058 }
00059 
00060 CodeDocument * CodeClassFieldDeclarationBlock::getParentDocument ( ) {
00061     return TextBlock::getParentDocument();
00062 }
00063 
00064 // Other methods
00065 //
00066 
00067 // this type of textblock is special
00068 // we DONT release it when resetTextBlocks is
00069 // called because we re-use it over and over
00070 // until the codeclassfield is released.
00071 void CodeClassFieldDeclarationBlock::release () {
00072     // do nothing
00073 }
00074 
00075 void CodeClassFieldDeclarationBlock::forceRelease () {
00076     if(m_parentclassfield)
00077     {
00078         //              m_parentclassfield->getParentObject()->disconnect(this);
00079         m_parentclassfield->disconnect(this);
00080     }
00081     m_parentclassfield = 0;
00082     OwnedCodeBlock::release();
00083     TextBlock::release();
00084 }
00085 
00089 void CodeClassFieldDeclarationBlock::saveToXMI ( QDomDocument & doc, QDomElement & elem)
00090 {
00091     QDomElement docElement = doc.createElement( "ccfdeclarationcodeblock" );
00092 
00093     setAttributesOnNode(doc, docElement);
00094 
00095     elem.appendChild( docElement );
00096 }
00097 
00098 void CodeClassFieldDeclarationBlock::loadFromXMI ( QDomElement & root )
00099 {
00100     setAttributesFromNode(root);
00101 }
00102 
00103 void CodeClassFieldDeclarationBlock::setAttributesOnNode (QDomDocument & doc, QDomElement & elem ) {
00104 
00105     // set super-class attributes
00106     CodeBlockWithComments::setAttributesOnNode(doc, elem);
00107     OwnedCodeBlock::setAttributesOnNode(doc, elem);
00108 
00109 }
00110 
00114 void CodeClassFieldDeclarationBlock::setAttributesFromNode( QDomElement & root ) {
00115 
00116     // set attributes from the XMI
00117     CodeBlockWithComments::setAttributesFromNode(root); // superclass load
00118     OwnedCodeBlock::setAttributesFromNode(root); // superclass load
00119 
00120     syncToParent();
00121 }
00122 
00125 void CodeClassFieldDeclarationBlock::setAttributesFromObject (TextBlock * obj) {
00126 
00127     CodeBlockWithComments::setAttributesFromObject(obj);
00128 
00129     CodeClassFieldDeclarationBlock * ccb = dynamic_cast<CodeClassFieldDeclarationBlock*>(obj);
00130     if(ccb)
00131     {
00132         m_parentclassfield->disconnect(this);
00133         init(ccb->getParentClassField());
00134 
00135         syncToParent();
00136     }
00137 
00138 }
00139 
00140 void CodeClassFieldDeclarationBlock::syncToParent () {
00141 
00142     // for role-based accessors, we DONT write ourselves out when
00143     // the name of the role is not defined.
00144     if(!(getParentClassField()->parentIsAttribute()))
00145     {
00146         UMLRole * parent = dynamic_cast<UMLRole*>(getParentObject());
00147         if (parent == NULL)
00148             return;
00149         if(parent->getName().isEmpty())
00150         {
00151             getComment()->setWriteOutText(false);
00152             setWriteOutText(false);
00153         } else {
00154             getComment()->setWriteOutText(true);
00155             setWriteOutText(true);
00156         }
00157     }
00158 
00159     // only update IF we are NOT AutoGenerated
00160     if(getContentType() != AutoGenerated)
00161         return;
00162 
00163     updateContent();
00164 
00165 }
00166 
00167 void CodeClassFieldDeclarationBlock::init (CodeClassField * parentCF)
00168 {
00169     m_parentclassfield = parentCF;
00170     m_canDelete = false;
00171     connect(m_parentclassfield,SIGNAL(modified()),this,SLOT(syncToParent()));
00172 }
00173 
00174 #include "codeclassfielddeclarationblock.moc"
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:07:55 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003