Version: (using KDE Devel) Installed from: Compiled sources Brian and Jonathan says: >It's implemented to allow each > "Active Language" to have a list of datatypes then you can ask > Umbrello to add the datatypes for that language. Well, I more or less like the current software. Even if the C++ and Java lists are the same, the shouldnt have to be. Rather, they can be extended, if needed. So, what I would change is : 1. Create a "universal" list for all languages. These datatypes always appear in the pull down menu. These are probably the list of data types we currently have. 2. Allow individual languages to extend the list of datatypes, as needed. 3. Allow the user to extend the list of datatypes, as desired. 2 and 3 more or less already exist. 1 is just an internal detail that would take minimal coding I think.
*** Bug 75462 has been marked as a duplicate of this bug. ***
I would say making a generel list of datatypes is impossible. E.g, I'm currently doing a Perl project, where I suppose the datatypes would be scalar array hash scalarref arrayref hashref (object) I vote for either having no default datatypes, or let them depend entirely on the language.
Still, it should be possible to edit the list of datatypes, and add your own. For example, Java has type "String", not "string". That's just a picky example of where editing them would be nice But Java also has "List", "Map", "Set" and other such types that it would be nice to be able to add.
Yes editing should be possible but the default types like string should be translated by the code generator into something appropriate (String for java, QString for KDE programmers).
For Java, it would be useful if Umbrello could look up the Java installation and allow selection of the built in classes: like java.util.Date and java.sql.Date.
For Python it would be nice if it didn't try to make classes for standard datatypes. Perhaps an option to not do this?
It also creates classes for primitive and standard Java datatypes - I suspect it is true for other languages as well.
SVN commit 443597 by okellogg: Umbrello::isCommonDataType(): New. SimpleCodeGenerator::writeCodeToFile() uses this for avoiding generation of classes for common data types. This is a fairly primitive approach and I'm sure someone will come up with a better solution. At the least, the selected active programming language should be considered. Candidate for JJ. CCBUG:74429 M +2 -15 classifierlistitem.cpp M +5 -2 codegenerators/simplecodegenerator.cpp M +19 -0 model_utils.cpp M +7 -0 model_utils.h M +9 -20 umlobject.cpp --- branches/KDE/3.5/kdesdk/umbrello/umbrello/classifierlistitem.cpp #443596:443597 @@ -19,6 +19,7 @@ #include "classifier.h" #include "uml.h" #include "umldoc.h" +#include "model_utils.h" UMLClassifierListItem::UMLClassifierListItem(const UMLObject *parent, QString Name, Uml::IDType id) : UMLObject(parent, Name, id) { @@ -79,21 +80,7 @@ m_pSecondary = pDoc->findUMLObject(type); if (m_pSecondary == NULL) { // Make data type for easily identified cases - const int n_types = 12; - const char *types[] = { - "void", "bool", - "char", "unsigned char", - "short", "unsigned short", - "int", "unsigned int", - "long", "unsigned long", - "float", "double" - }; - int i = 0; - for (; i < n_types; i++) { - if (type == types[i]) - break; - } - if (i < n_types || type.contains('*')) { + if (Umbrello::isCommonDataType(type) || type.contains('*')) { m_pSecondary = pDoc->createUMLObject(Uml::ot_Datatype, type); kdDebug() << "UMLClassifierListItem::setTypeName: " << "created datatype for " << type << endl; --- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/simplecodegenerator.cpp #443596:443597 @@ -29,6 +29,7 @@ #include <kapplication.h> // app includes #include "../dialogs/overwritedialogue.h" +#include "../model_utils.h" #include "../attribute.h" #include "../umloperationlist.h" #include "../umlattributelist.h" @@ -233,8 +234,10 @@ void SimpleCodeGenerator::writeCodeToFile ( ) { m_fileMap->clear(); // yeah, need to do this, if not, just keep getting same damn directory to write to. UMLClassifierList concepts = m_doc->getClassesAndInterfaces(); - for (UMLClassifier *c = concepts.first(); c; c = concepts.next()) - this->writeClass(c); // call the writer for each class. + for (UMLClassifier *c = concepts.first(); c; c = concepts.next()) { + if (! Umbrello::isCommonDataType(c->getName())) + this->writeClass(c); // call the writer for each class. + } } // write only selected concepts to file --- branches/KDE/3.5/kdesdk/umbrello/umbrello/model_utils.cpp #443596:443597 @@ -212,6 +212,25 @@ return retval; } +bool isCommonDataType(QString type) { + const int n_types = 12; + const char *types[] = { "void", "string", + "bool", "boolean", + "char", "unsigned char", + "short", "unsigned short", + "int", "unsigned int", + "long", "unsigned long", + "float", "double" + }; + const QString lcType = type.lower(); + int i = 0; + for (; i < n_types; i++) { + if (lcType == types[i]) + return true; + } + return false; +} + QString scopeToString(Uml::Scope scope, bool mnemonic) { switch (scope) { case Uml::Protected: --- branches/KDE/3.5/kdesdk/umbrello/umbrello/model_utils.h #443596:443597 @@ -80,6 +80,13 @@ bool isCommonXMIAttribute(const QString &tag); /** + * Return true if the given type is common among the majority + * of programming languages, such as "bool" or "boolean". + * TODO: Make this depend on the active programming language. + */ +bool isCommonDataType(QString type); + +/** * Convert Scope value into QString representation. * * @param scope The Scope enum value to convert. --- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlobject.cpp #443596:443597 @@ -405,14 +405,18 @@ // Work around UMLDoc::createUMLObject()'s incapability // of on-the-fly scope creation: if (m_SecondaryId.contains("::")) { - m_SecondaryId.replace("::", "."); // TODO: Merge ClassImport::createUMLObject() into UMLDoc::createUMLObject() m_pSecondary = ClassImport::createUMLObject(Uml::ot_UMLObject, m_SecondaryId, NULL); if (m_pSecondary) { + if (ClassImport::newUMLObjectWasCreated()) { + maybeSignalObjectCreated(); + kdDebug() << "UMLObject::resolveRef: ClassImport::createUMLObject() " + << "created a new type for " << m_SecondaryId << endl; + } else { + kdDebug() << "UMLObject::resolveRef: ClassImport::createUMLObject() " + << "returned an existing type for " << m_SecondaryId << endl; + } m_SecondaryId = ""; - maybeSignalObjectCreated(); - kdDebug() << "UMLObject::resolveRef: Created a new type for " << m_SecondaryId - << " using ClassImport::createUMLObject()" << endl; return true; } kdError() << "UMLObject::resolveRef: ClassImport::createUMLObject() " @@ -430,22 +434,7 @@ if (isReferenceType) { ot = Uml::ot_Datatype; } else { - // Make data type for easily identified cases - const int n_types = 12; - const char *types[] = { - "void", "bool", - "char", "unsigned char", - "short", "unsigned short", - "int", "unsigned int", - "long", "unsigned long", - "float", "double" - }; - int i = 0; - for (; i < n_types; i++) { - if (m_SecondaryId == types[i]) - break; - } - if (i < n_types) + if (Umbrello::isCommonDataType(m_SecondaryId)) ot = Uml::ot_Datatype; } m_pSecondary = pDoc->createUMLObject(ot, m_SecondaryId, NULL);
that could be very interestingif all java type was supported by umbrello (vector, list...)
UML standardizes the available data types, they are the UML Primitive Types. The UML primitive types are being integrated into Umbrello, see https://bugs.kde.org/show_bug.cgi?id=73847#c20 > Stereotype attributes cannot be of arbitrary type but they can use the UML > primitive types, see > https://www.omg.org/spec/UML/20161101/PrimitiveTypes.xmi > I.e. the possible attribute types are: > - Boolean > - UnlimitedNatural > - Integer > - Real > - String For implementation see https://invent.kde.org/sdk/umbrello/commit/c7fdfefc7df721f2f167e1b52bae9e07f68cb439
Enough progress has been made so that the original wish is more or less addressed. In view of the fact that the code base has changed significantly since the original request, I propose making more specific requests based on the current implementation.