Exemplo n.º 1
0
void UmlPackage::fileControl(bool ci) {
  UmlPackage * prj = getProject();
  Q3CString prjfile = prj->supportFile();
  BooL rec;
  BooL reload;
  Q3CString cmd;
  
  if (! prj->propertyValue((ci) ? "check-in-cmd" : "check-out-cmd", cmd))
    cmd = "specify the command containing %file and %dir or %dironly";
  
  Dialog dialog(ci, cmd, rec, reload);	// the dialog execution set 'cmd' and 'rec'
  
  if (dialog.exec() == QDialog::Accepted) {
    // save the command for a future usage
    prj->set_PropertyValue((ci) ? "check-in-cmd" : "check-out-cmd", cmd);
    
    if (reload)
      saveProject();
    
    // get files list
    Q3Dict<void> files;
  
    getFiles(files, (rec) ? ~0u : 1);
    if (this == prj)
      getAuxFiles(files);
  
    // apply the command on each file
    Q3DictIterator<void> it(files);
    QFileInfo prjpath(prjfile);
    QString dir = prjpath.dirPath(TRUE);
    QString dironly = dir;
    int index;
    
    if ((dironly.length() > 3) &&
        (((const char *) dironly)[1] == ':') &&
        (((const char *) dironly)[2] == '/'))
      dironly = dironly.mid(2);
  
    while ((index = cmd.find("%dironly")) != -1)
      cmd.replace(index, 8, dironly);
    
    while ((index = cmd.find("%dir")) != -1)
      cmd.replace(index, 4, dir);
      
    while (it.current()) {
      QString s = cmd;
  
      while ((index = s.find("%file")) != -1)
        s.replace(index, 5, it.currentKey());
      
      system((const char *) s);
      ++it;
    }
    
    UmlCom::trace("Done.");
  
    if (reload)
      loadProject(prjfile);
  }
}
Exemplo n.º 2
0
void UmlPackage::importIt(FileIn & in, Token & token, UmlItem * where)
{
    while (where->kind() != aPackage)
        where = where->parent();

    WrapperStr s = token.valueOf("name");

    if (s.isEmpty()) {
        static unsigned n = 0;

        s.sprintf("anonymous %u", ++n);
    }

    UmlPackage * pack = create((UmlPackage *) where, s);

    if (pack == 0)
        in.error("cannot create package '" + s + "' in '" + where->name() + "'");

    bool profile =
        (token.what() == "uml:profile") || (token.xmiType() == "uml:Profile");

    if (profile) {
        pack->set_Stereotype("profile");
        pack->set_PropertyValue("xmiId", token.xmiId());
        NumberOf -= 1;
        NumberOfProfile += 1;

        if (!(s = token.valueOf("metamodelreference")).isEmpty())
            pack->set_PropertyValue("metamodelReference", s);

        if (!(s = token.valueOf("metaclassreference")).isEmpty())
            pack->set_PropertyValue("metaclassReference", s);
    }

    s = token.xmiId();

    if (!s.isEmpty()) {
        pack->addItem(s, in);

        if (! token.closed()) {
            WrapperStr k = token.what();
            const char * kstr = k;

            if (profile) {
                while (in.read(), !token.close(kstr)) {
                    if ((token.what() == "packagedelement") &&
                        (token.xmiType() == "uml:Extension")) {
                        if (! token.closed())
                            in.finish(token.what());
                    }
                    else if (token.what() == "packageimport")
                        pack->packageImport(in, token);
                    else
                        pack->UmlItem::import(in, token);
                }

                updateProfiles();
            }
            else
                while (in.read(), !token.close(kstr))
                    pack->UmlItem::import(in, token);
        }
    }
    else if (! token.valueOf("href", s))
        in.error("xmi:id is missing"); // doesn't return
    else {
        in.warning("bypass external package " + s);

        if (! token.closed())
            in.finish(token.what());
    }

    pack->unload(TRUE, FALSE);
}
Exemplo n.º 3
0
void UmlPackage::fileControl(bool ci)
{
    UmlPackage * prj = getProject();
    QByteArray prjfile = prj->supportFile();
    BooL rec;
    BooL reload;
    QByteArray cmd;

    if (! prj->propertyValue((ci) ? "check-in-cmd" : "check-out-cmd", cmd))
        cmd = "specify the command containing %file and %dir or %dironly";

    Dialog dialog(ci, cmd, rec, reload);	// the dialog execution set 'cmd' and 'rec'

    if (dialog.exec() == QDialog::Accepted) {
        // save the command for a future usage
        prj->set_PropertyValue((ci) ? "check-in-cmd" : "check-out-cmd", cmd);

        if (reload)
            saveProject();

        // get files list
        QHash<QString,void*> files;

        getFiles(files, (rec) ? ~0u : 1);

        if (this == prj)
            getAuxFiles(files);

        // apply the command on each file
        QHashIterator<QString,void*> it(files);
        QFileInfo prjpath(prjfile);
        QString dir = prjpath.path();
        QString dironly = dir;
        int index;

        if ((dironly.length() > 3) &&
            (dironly[1] == ':') &&
            (dironly[2] == '/'))
            dironly = dironly.mid(2);

        while ((index = cmd.indexOf("%dironly")) != -1)
            cmd.replace(index, 8, dironly.toLatin1());

        while ((index = cmd.indexOf("%dir")) != -1)
            cmd.replace(index, 4, dir.toLatin1());

        while (it.hasNext()) {
            it.next();
            QString s = cmd;

            while ((index = s.indexOf("%file")) != -1)
                s.replace(index, 5, it.key().toLatin1());

            system((const char *) s.toLatin1().constData());
            //++it;
        }

        UmlCom::trace("Done.");

        if (reload)
            loadProject(prjfile);
    }
}