umbrello API Documentation

javacodegenerationpolicy.cpp

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2004-2006                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 /*  This code generated by:
00013  *      Author : thomas
00014  *      Date   : Mon Jun 23 2003
00015  */
00016 
00017 // own header
00018 #include "javacodegenerationpolicy.h"
00019 // qt/kde includes
00020 #include <kconfig.h>
00021 // app includes
00022 #include "javacodegenerationpolicypage.h"
00023 #include "javacodegenerator.h"
00024 #include "../uml.h"
00025 
00026 const bool JavaCodeGenerationPolicy::DEFAULT_AUTO_GEN_ATTRIB_ACCESSORS = true;
00027 const bool JavaCodeGenerationPolicy::DEFAULT_AUTO_GEN_ASSOC_ACCESSORS = true;
00028 
00029 // Constructors/Destructors
00030 /*
00031 
00032 JavaCodeGenerationPolicy::JavaCodeGenerationPolicy(CodeGenerationPolicy *defaults)
00033         : CodeGenerationPolicy(defaults)
00034 {
00035     init();
00036     setDefaults(defaults,false);
00037 }
00038  */
00039 
00040 JavaCodeGenerationPolicy::JavaCodeGenerationPolicy(KConfig *config)
00041   //      : CodeGenerationPolicy(config)
00042 {
00043     init();
00044     setDefaults(config,false);
00045 }
00046 
00047 JavaCodeGenerationPolicy::~JavaCodeGenerationPolicy ( ) { }
00048 
00049 //
00050 // Methods
00051 //
00052 
00053 // Accessor methods
00054 //
00055 
00056 // Public attribute accessor methods
00057 //
00058 
00063 void JavaCodeGenerationPolicy::setAutoGenerateAttribAccessors( bool var ) {
00064     m_autoGenerateAttribAccessors = var;
00065     m_commonPolicy->emitModifiedCodeContentSig();
00066 }
00067 
00072 void JavaCodeGenerationPolicy::setAutoGenerateAssocAccessors( bool var ) {
00073     m_autoGenerateAssocAccessors = var;
00074     m_commonPolicy->emitModifiedCodeContentSig();
00075 }
00076 
00081 bool JavaCodeGenerationPolicy::getAutoGenerateAttribAccessors( ){
00082     return m_autoGenerateAttribAccessors;
00083 }
00084 
00089 bool JavaCodeGenerationPolicy::getAutoGenerateAssocAccessors( ){
00090     return m_autoGenerateAssocAccessors;
00091 }
00092 
00093 // Other methods
00094 //
00095 
00096 void JavaCodeGenerationPolicy::writeConfig ( KConfig * config )
00097 {
00098 
00099     // write ONLY the Java specific stuff
00100     config->setGroup("Java Code Generation");
00101 
00102     config->writeEntry("autoGenAccessors",getAutoGenerateAttribAccessors());
00103     config->writeEntry("autoGenAssocAccessors",getAutoGenerateAssocAccessors());
00104 
00105     CodeGenerator *codegen = UMLApp::app()->getGenerator();
00106     JavaCodeGenerator *javacodegen = dynamic_cast<JavaCodeGenerator*>(codegen);
00107     if (javacodegen)
00108         config->writeEntry("buildANTDocument", javacodegen->getCreateANTBuildFile());
00109 
00110 }
00111 
00112 void JavaCodeGenerationPolicy::setDefaults ( CodeGenPolicyExt * clone, bool emitUpdateSignal )
00113 {
00114 
00115     JavaCodeGenerationPolicy * jclone;
00116     if (!clone)
00117         return;
00118 
00119     // NOW block signals for java param setting
00120     blockSignals(true); // we need to do this because otherwise most of these
00121     // settors below will each send the modifiedCodeContent() signal
00122     // needlessly (we can just make one call at the end).
00123 
00124 
00125     // now do java-specific stuff IF our clone is also a JavaCodeGenerationPolicy object
00126     if((jclone = dynamic_cast<JavaCodeGenerationPolicy*>(clone)))
00127     {
00128         setAutoGenerateAttribAccessors(jclone->getAutoGenerateAttribAccessors());
00129         setAutoGenerateAssocAccessors(jclone->getAutoGenerateAssocAccessors());
00130     }
00131 
00132     blockSignals(false); // "as you were citizen"
00133 
00134     if(emitUpdateSignal)
00135         m_commonPolicy->emitModifiedCodeContentSig();
00136 
00137 }
00138 
00139 void JavaCodeGenerationPolicy::setDefaults( KConfig * config, bool emitUpdateSignal )
00140 {
00141 
00142     if(!config)
00143         return;
00144 
00145     // call method at the common policy to init default stuff
00146     m_commonPolicy->setDefaults(config, false);
00147 
00148     // NOW block signals (because call to super-class method will leave value at "true")
00149     blockSignals(true); // we need to do this because otherwise most of these
00150     // settors below will each send the modifiedCodeContent() signal
00151     // needlessly (we can just make one call at the end).
00152 
00153     // now do java specific stuff
00154     config -> setGroup("Java Code Generation");
00155 
00156     setAutoGenerateAttribAccessors(config->readBoolEntry("autoGenAccessors",DEFAULT_AUTO_GEN_ATTRIB_ACCESSORS));
00157     setAutoGenerateAssocAccessors(config->readBoolEntry("autoGenAssocAccessors",DEFAULT_AUTO_GEN_ASSOC_ACCESSORS));
00158 
00159     CodeGenerator *codegen = UMLApp::app()->getGenerator();
00160     JavaCodeGenerator *javacodegen = dynamic_cast<JavaCodeGenerator*>(codegen);
00161     if (javacodegen) {
00162         bool mkant = config->readBoolEntry("buildANTDocument", JavaCodeGenerator::DEFAULT_BUILD_ANT_DOC);
00163         javacodegen->setCreateANTBuildFile(mkant);
00164     }
00165 
00166     blockSignals(false); // "as you were citizen"
00167 
00168     if(emitUpdateSignal)
00169         m_commonPolicy->emitModifiedCodeContentSig();
00170 }
00171 
00172 
00177 CodeGenerationPolicyPage * JavaCodeGenerationPolicy::createPage ( QWidget *parent, const char *name ) {
00178     return new JavaCodeGenerationPolicyPage ( parent, name, this );
00179 }
00180 
00181 void JavaCodeGenerationPolicy::init() {
00182     m_commonPolicy = UMLApp::app()->getCommonPolicy();
00183     m_autoGenerateAttribAccessors = DEFAULT_AUTO_GEN_ATTRIB_ACCESSORS;
00184     m_autoGenerateAssocAccessors = DEFAULT_AUTO_GEN_ASSOC_ACCESSORS;
00185 }
00186 
00187 
00188 #include "javacodegenerationpolicy.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:57 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003