rubyclassdeclarationblock.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "rubyclassdeclarationblock.h"
00021 #include "rubycodedocumentation.h"
00022 #include "rubycodegenerator.h"
00023 #include "../uml.h"
00024
00025
00026
00027
00028 RubyClassDeclarationBlock::RubyClassDeclarationBlock
00029 ( RubyClassifierCodeDocument * parentDoc, const QString &startText, const QString &endText, const QString &comment)
00030 : OwnedHierarchicalCodeBlock(parentDoc->getParentClassifier(), parentDoc, startText, endText, comment)
00031 {
00032 init(parentDoc, comment);
00033 }
00034
00035 RubyClassDeclarationBlock::~RubyClassDeclarationBlock ( ) { }
00036
00037
00038
00039
00040
00044 void RubyClassDeclarationBlock::saveToXMI ( QDomDocument & doc, QDomElement & root ) {
00045 QDomElement blockElement = doc.createElement( "rubyclassdeclarationblock" );
00046
00047 setAttributesOnNode(doc, blockElement);
00048
00049 root.appendChild( blockElement );
00050 }
00051
00055 void RubyClassDeclarationBlock::loadFromXMI ( QDomElement & root )
00056 {
00057 setAttributesFromNode(root);
00058 }
00059
00060
00061
00062
00063
00064
00065
00069 void RubyClassDeclarationBlock::updateContent ( )
00070 {
00071
00072 RubyClassifierCodeDocument *parentDoc = dynamic_cast<RubyClassifierCodeDocument*>(getParentDocument());
00073 UMLClassifier *c = parentDoc->getParentClassifier();
00074 CodeGenerationPolicy * p = UMLApp::app()->getCommonPolicy();
00075 QString endLine = p->getNewLineEndingChars();
00076 bool isInterface = parentDoc->parentIsInterface();
00077 QString RubyClassName = parentDoc->getRubyClassName(c->getName());
00078 bool forceDoc = p->getCodeVerboseDocumentComments();
00079
00080
00081 QString comment = c->getDoc();
00082 comment.replace("@ref ", "");
00083 comment.replace("@see", "_See_");
00084 comment.replace("@short", "_Summary_");
00085 comment.replace("@author", "_Author_");
00086
00087 if (isInterface)
00088 getComment()->setText("Module " + RubyClassName + endLine + comment);
00089 else
00090 getComment()->setText("Class " + RubyClassName + endLine + comment);
00091
00092 if(forceDoc || !c->getDoc().isEmpty())
00093 getComment()->setWriteOutText(true);
00094 else
00095 getComment()->setWriteOutText(false);
00096
00097
00098
00099 QString startText = "";
00100
00101 if (parentDoc->parentIsInterface()) {
00102 startText.append("module ");
00103 } else {
00104 startText.append("class ");
00105 }
00106
00107 UMLClassifierList superclasses = c->findSuperClassConcepts(UMLClassifier::CLASS);
00108 UMLClassifierList superinterfaces = c->findSuperClassConcepts(UMLClassifier::INTERFACE);
00109
00110
00111 startText.append(RubyClassName);
00112
00113 int i = 0;
00114 for (UMLClassifier * concept= superclasses.first(); concept; concept = superclasses.next()) {
00115 if (i == 0) {
00116 startText.append(QString(" < ") + RubyCodeGenerator::cppToRubyType(concept->getName()) + endLine);
00117 } else {
00118
00119
00120 startText.append("include " + RubyCodeGenerator::cppToRubyType(concept->getName()) + endLine);
00121 }
00122 i++;
00123 }
00124
00125
00126 for (UMLClassifier * concept= superinterfaces.first(); concept; concept = superinterfaces.next()) {
00127 startText.append(QString("include ") + RubyCodeGenerator::cppToRubyType(concept->getName()) + endLine);
00128 }
00129
00130
00131 setStartText(startText);
00132 }
00133
00134 void RubyClassDeclarationBlock::init (RubyClassifierCodeDocument *parentDoc, const QString &comment)
00135 {
00136
00137 setComment(new RubyCodeDocumentation(parentDoc));
00138 getComment()->setText(comment);
00139
00140 setEndText("end");
00141
00142 updateContent();
00143
00144 }
00145
00146
00147 #include "rubyclassdeclarationblock.moc"
This file is part of the documentation for umbrello Version 3.1.0.