示例#1
0
void TEST_pythonwriter::test_writeClass()
{
    PythonWriterTest* py = new PythonWriterTest();
    UMLClassifier* c = new UMLClassifier("Customer", "12345678");
    UMLAttribute* attr;
    attr = c->createAttribute("name_");
    attr = c->createAttribute("address_");

    py->writeClass(c);
    // does the just created file exist?
    QFile file(temporaryPath() + py->findFileName(c, QLatin1String(".py")));
    QCOMPARE(file.exists(), true);
}
示例#2
0
void TEST_cppwriter::test_writeClass()
{
    CppWriterTest* cpp = new CppWriterTest();
    UMLClassifier* c = new UMLClassifier("Customer", "12345678");
    UMLAttribute* attr;
    attr = c->createAttribute("name_");
    attr = c->createAttribute("address_");
    UMLOperation* op;
    op = c->createOperation("getName");
    op = c->createOperation("getAddress");

    cpp->writeClass(c);
    // does the just created file exist?
    QFile fileHeader(temporaryPath() + cpp->findFileName(c, QLatin1String(".h")));
    QFile fileCPP(temporaryPath() + cpp->findFileName(c, QLatin1String(".cpp")));
    QCOMPARE(fileHeader.exists(), true);
    QCOMPARE(fileCPP.exists(), true);
}
void RefactoringAssistant::createAttribute()
{
    QListViewItem *item = selectedItem();
    if(!item)
    {
        kWarning()<<"RefactoringAssistant::createAttribute() "
        <<"called with no item selected"<<endl;
        return;
    }
    UMLClassifier *c = dynamic_cast<UMLClassifier*>(findUMLObject( item ));
    if( !c )
        return;
    c->createAttribute();
}
/**
 * Create new attribute.
 */
void RefactoringAssistant::createAttribute()
{
    QTreeWidgetItem *item = currentItem();
    if (!item) {
        uWarning() << "Called with no item selected.";
        return;
    }
    UMLClassifier *c = dynamic_cast<UMLClassifier*>(findUMLObject(item));
    if (!c) {  // find parent
        QTreeWidgetItem *parent = item->parent();
        c = dynamic_cast<UMLClassifier*>(findUMLObject(parent));
        if (!c) {
            uWarning() << "No classifier - cannot create!";
            return;
        }
    }
    c->createAttribute();
}