xmlelementcodeblock.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "xmlelementcodeblock.h"
00020
00021
00022 #include <kdebug.h>
00023
00024
00025 #include "xmlcodecomment.h"
00026 #include "../attribute.h"
00027 #include "../codedocument.h"
00028
00029
00030
00031
00032 XMLElementCodeBlock::XMLElementCodeBlock ( CodeDocument * parentDoc, const QString & nodeName, const QString & comment)
00033 : HierarchicalCodeBlock(parentDoc)
00034 {
00035 init(parentDoc, nodeName, comment);
00036 }
00037
00038 XMLElementCodeBlock::~XMLElementCodeBlock ( ) { }
00039
00040
00041
00042
00043
00047 void XMLElementCodeBlock::saveToXMI ( QDomDocument & doc, QDomElement & root ) {
00048 QDomElement blockElement = doc.createElement( "xmlelementblock" );
00049
00050 setAttributesOnNode(doc, blockElement);
00051
00052 root.appendChild( blockElement );
00053 }
00054
00058 void XMLElementCodeBlock::loadFromXMI ( QDomElement & root )
00059 {
00060 setAttributesFromNode(root);
00061 }
00062
00066 void XMLElementCodeBlock::setAttributesOnNode ( QDomDocument & doc, QDomElement & docElement)
00067 {
00068
00069
00070 HierarchicalCodeBlock::setAttributesOnNode(doc,docElement);
00071
00072
00073 docElement.setAttribute("nodeName",getNodeName());
00074
00075 }
00076
00080 void XMLElementCodeBlock::setAttributesFromNode ( QDomElement & root) {
00081
00082
00083 HierarchicalCodeBlock::setAttributesFromNode(root);
00084
00085
00086 setNodeName(root.attribute("nodeName","UNKNOWN"));
00087
00088 }
00089
00090
00091
00092
00093 void XMLElementCodeBlock::setNodeName (const QString &name) {
00094 m_nodeName = name;
00095 }
00096
00097 QString XMLElementCodeBlock::getNodeName () {
00098 return m_nodeName;
00099 }
00100
00101 void XMLElementCodeBlock::addAttribute (UMLAttribute * at) {
00102 m_attList.append(at);
00103 }
00104
00105 UMLAttributeList * XMLElementCodeBlock::getAttributeList() {
00106 return & m_attList;
00107 }
00108
00109
00110
00111
00112
00116 void XMLElementCodeBlock::updateContent ( )
00117 {
00118
00119 QString endLine = getNewLineEndingChars();
00120
00121 QString nodeName = getNodeName();
00122
00123
00124 QString startText = '<' + nodeName;
00125 QString endText = "";
00126
00127 UMLAttributeList * alist = getAttributeList();
00128 for (UMLAttribute *at = alist->first(); at; at=alist->next())
00129 {
00130 if(at->getInitialValue().isEmpty())
00131 kWarning()<<" XMLElementCodeBlock : cant print out attribute that lacks an initial value"<<endl;
00132 else {
00133 startText.append(" " +at->getName()+"=\"");
00134 startText.append(at->getInitialValue()+"\"");
00135 }
00136 }
00137
00138
00139 if(getTextBlockList()->count())
00140 {
00141 startText.append(">");
00142 endText = "</" + nodeName + '>';
00143 } else {
00144 startText.append("/>");
00145 endText = "";
00146 }
00147
00148 setStartText(startText);
00149 setEndText(endText);
00150
00151 }
00152
00153 void XMLElementCodeBlock::init (CodeDocument *parentDoc, const QString &nodeName, const QString &comment)
00154 {
00155
00156 setComment(new XMLCodeComment(parentDoc));
00157 getComment()->setText(comment);
00158
00159 m_nodeName = nodeName;
00160
00161 updateContent();
00162
00163 }
00164
00165
00166 #include "xmlelementcodeblock.moc"
This file is part of the documentation for umbrello Version 3.1.0.