Exemplo n.º 1
0
WrapperStr UmlPackage::php_path(const WrapperStr & f)
{
    if (!dir.read) {
        dir.src = phpDir();

        QDir d_root(rootDir(phpLanguage));

        if (dir.src.isEmpty())
            dir.src = RootDir;
        else if (QDir::isRelativePath(dir.src))
            dir.src = d_root.filePath(dir.src);

        if (dir.src.isEmpty()) {
            UmlCom::trace(WrapperStr("<font color=\"red\"><b><b> The generation directory "
                                    "must be specified for the package<i> ") + name()
                          + "</i>, edit the <i> generation settings</i> (tab 'directory') "
                          "or edit the package (tab 'php')</b></font><br>");
            UmlCom::bye(n_errors() + 1);
            UmlCom::fatal_error("UmlPackage::php_path");
        }

        dir.read = TRUE;
    }

    QDir d(dir.src);

    return WrapperStr(d.filePath(f).toLatin1().constData()) + WrapperStr(".") + PhpSettings::sourceExtension();
}
Exemplo n.º 2
0
UmlClassView * UmlPackage::get_classview(const WrapperStr & nmsp)
{
    UmlPackage * pack;

    if (nmsp != phpNamespace()) {
        if (namespace_fixedp) {
            if ((pack = findPhpNamespace(nmsp)) == 0) {
                WrapperStr s = nmsp;

                if (s.isEmpty())
                    s = name();
                else {
                    int index = 0;

                    while ((index = s.find("::", index)) != -1)
                        s.replace(index++, 2, " ");
                }

                if (((pack = UmlBasePackage::create(this, s)) == 0) &&
                    ((pack = UmlBasePackage::create(this, s += "_")) == 0) &&
                    ((pack = UmlBasePackage::create(this, s += "_")) == 0) &&
                    ((pack = UmlBasePackage::create(this, s += "_")) == 0) &&
                    ((pack = UmlBasePackage::create(this, s += "_")) == 0)) {
#ifdef REVERSE
                    UmlCom::trace(WrapperStr("<font face=helvetica><b>cannot create package <i>")
                                  + s + "</i> under package <i>"
                                  + name() + "</b></font><br>");
                    UmlCom::message("");
                    throw 0;
#else
                    QMessageBox::critical(0, "Fatal Error",
                                          WrapperStr("<font face=helvetica><b>cannot create package <i>")
                                          + s + "</i> under package <i>"
                                          + Name() + "</b></font><br>");
                    QApplication::exit(1);
#endif
                }

                pack->set_PhpNamespace(nmsp);
                pack->set_PhpDir(phpDir());
                pack->namespace_fixedp = TRUE;
            }
        }
        else {
            pack = this;
            pack->set_PhpNamespace(nmsp);
            pack->namespace_fixedp = TRUE;
        }
    }
    else
        pack = this;

    if (pack->classview == 0) {
        Q3PtrVector<UmlItem> ch = pack->children();

        for (unsigned index = 0; index != ch.size(); index += 1)

            // return the first class view find
            if (ch[index]->kind() == aClassView)
                return pack->classview = (UmlClassView *) ch[index];

        if ((pack->classview = UmlBaseClassView::create(pack, name())) == 0) {
#ifdef REVERSE
            UmlCom::trace(WrapperStr("<font face=helvetica><b>cannot create class view <i>")
                          + name() + "</i> under package <i>"
                          + pack->name() + "</b></font><br>");
            UmlCom::message("");
            throw 0;
#else
            QMessageBox::critical(0, "Fatal Error",
                                  WrapperStr("<font face=helvetica><b>cannot create class view <i>")
                                  + name() + "</i> under package <i>"
                                  + pack->name() + "</b></font><br>");
            QApplication::exit(1);
#endif
        }
    }

    return pack->classview;
}
Exemplo n.º 3
0
Q3CString UmlPackage::file_path(const Q3CString & f, Q3CString relto) {
  if (!dir.read) {
    dir.file = phpDir();
    dir.file_absolute = FALSE;
    
    QDir d_root(rootDir());
    
    if (dir.file.isEmpty())
      dir.file = RootDir;
    else if (QDir::isRelativePath(dir.file))
      dir.file = d_root.filePath(dir.file);
    else
      dir.file_absolute = TRUE;
   
    if (dir.file.isEmpty()) {
      UmlCom::trace(Q3CString("<font color=\"red\"><b><b> The generation directory "
			    "must be specified for the package<i> ") + name()
			    + "</i>, edit the <i> generation settings</i> (tab 'directory') "
			    "or edit the package (tab 'Php')</b></font><br>");
      UmlCom::bye(n_errors() + 1);
      UmlCom::fatal_error("UmlPackage::file_path");
    }
    
    dir.read = TRUE;
  }
  
  if (f.isEmpty())
    return dir.file;
  
  QDir d(dir.file);
  
  if (! d.exists()) {
    // create directory including the intermediates
    Q3CString s = dir.file;
    int index = 0;
    QChar sep = QDir::separator();
    
    if (sep != '/') {
      while ((index = s.find(sep, index)) != -1)
	s.replace(index++, 1, "/");
    }
    
    s = QDir::cleanDirPath(s) + "/";
    index = s.find("/");

    int index2;
    
    while ((index2 = s.find("/", index + 1)) != -1) {
      Q3CString s2 = s.left(index2);
      QDir sd(s2);
      
      if (!sd.exists()) {
	if (!sd.mkdir(s2)) {
	  UmlCom::trace(Q3CString("<font color=\"red\"><b> cannot create directory <i>")
			+ s2 + "</i></b></font><br>");
	  UmlCom::bye(n_errors() + 1);
	  UmlCom::fatal_error("UmlPackage::file_path");
	}
      }
      index = index2;
    }
  }
  
  Q3CString df = (dir.file_absolute || relto.isEmpty())
    ? Q3CString(d.filePath(f).toAscii().constData())
    : relative_path(d, relto) + f;
  
  if (PhpSettings::isRelativePath() && (df[0] != '/') && (df[0] != '.'))
    df = "./" + df;
  
  return df + Q3CString(".") + PhpSettings::sourceExtension();
}