from xml.sax.handler import *
from omniidl import idlast, idltype, idlvisitor, idlutil, output
-#values of this map are used in some nodes defenition
-common_data={"AUTHOR" : "",
- "ICON" : "",
- "VERSION" : "",
- "COMP_TYPE": "",
- "COMP_NAME": "",
- "COMP_MULT": "1"
+# parameters not found in IDL file, user's specified in optional parameters
+common_data={"AUTHOR" : "",
+ "ICON" : "",
+ "VERSION" : "",
+ "COMP_TYPE" : "",
+ "COMP_NAME" : "",
+ "COMP_UNAME" : "",
+ "COMP_MULT" : ""
}
+nb_components = 0
+
+#--------------------------------------------------
+# extract value of <param_name> from <args> list
+# it's proposed that the matching <args> item
+# looks like <param_name>=<value>, for example,
+# catalog=/tmp/myxml.xml
+#--------------------------------------------------
+def getParamValue( param_name, default_value, args ):
+ pattern=param_name+"="
+
+ res = default_value #initial value
+ for opt in args:
+ s = re.compile(pattern).search(opt)
+ if s:
+ res = opt[s.end():]
+ break #found
+
+ return res
+
+
#--------------------------------------------------
# print error message
#--------------------------------------------------
#--------------------------------------------------
class inParameter(Tree):
- def __init__(self, name=None, type='', comment=''):
+ def __init__(self, name=None, type='', comment='unknown'):
Tree.__init__(self, 'inParameter')
if name is None: return
#--------------------------------------------------
class outParameter(Tree):
- def __init__(self, name=None, type='', comment = ''):
+ def __init__(self, name=None, type='', comment = 'unknown'):
Tree.__init__(self, 'outParameter')
if name is None: return
#--------------------------------------------------
class Service(Tree):
- def __init__(self, name=None):
+ def __init__(self, name=None, comment = 'unknown'):
Tree.__init__(self, 'component-service')
if name is None: return
self.addNamedChild('service-name', name)
self.addNamedChild('service-author',common_data["AUTHOR"])
self.addNamedChild('service-version',common_data["VERSION"])
- self.addNamedChild('service-comment')
+ self.addNamedChild('service-comment', comment)
self.addNamedChild('service-by-default', "0")
self.addNamedChild('inParameter-list')
self.addNamedChild('outParameter-list')
#--------------------------------------------------
class Interface(Tree):
- def __init__(self, name=None):
+ def __init__(self, name=None, comment='unknown'):
Tree.__init__(self)
if name is None: return
self.addNamedChild('component-interface-name', name)
- self.addNamedChild('component-interface-comment');
+ self.addNamedChild('component-interface-comment', comment);
self.addNamedChild('component-service-list')
def createService(self, name):
# implements Component tree
#--------------------------------------------------
class Component(Tree):
- def __init__(self, name=None):
+ def __init__(self):
Tree.__init__(self, 'component')
-
- if name is None: return
-
- self.addNamedChild('component-name', name)
- self.addNamedChild('component-type',common_data["COMP_TYPE"])
- self.addNamedChild('component-author',common_data["AUTHOR"])
- self.addNamedChild('component-version',common_data["VERSION"])
- self.addNamedChild('component-comment')
+
+ self.addNamedChild('component-name', common_data["COMP_NAME"])
+ self.addNamedChild('component-username', common_data["COMP_UNAME"])
+ self.addNamedChild('component-type', common_data["COMP_TYPE"])
+ self.addNamedChild('component-author', common_data["AUTHOR"])
+ self.addNamedChild('component-version', common_data["VERSION"])
+ self.addNamedChild('component-comment', 'unknown')
self.addNamedChild('component-multistudy', common_data["COMP_MULT"])
- self.addNamedChild('component-icone',common_data["ICON"])
+ self.addNamedChild('component-icone', common_data["ICON"])
self.addNamedChild('constraint')
self.addNamedChild('component-interface-list')
return i
def merge(self, C):
- ext=C.getChild('component-author')
- int=self.getChild('component-author')
- if int is not None and ext is not None and len(ext.content):
- int.content = ext.content
-
- ext=C.getChild('component-type')
- int=self.getChild('component-type')
- if int is not None and ext is not None and len(ext.content):
- int.content = ext.content
-
- ext=C.getChild('component-icone')
- int=self.getChild('component-icone')
- if int is not None and ext is not None and len(ext.content):
- int.content = ext.content
-
- ext=C.getChild('component-version')
- int=self.getChild('component-version')
- if int is not None and ext is not None and len(ext.content):
- int.content = ext.content
-
- ext=C.getChild('component-comment')
- int=self.getChild('component-comment')
- if int is not None and ext is not None and len(ext.content):
- int.content = ext.content
-
- ext=C.getChild('component-multistudy')
- int=self.getChild('component-multistudy')
- if int is not None and ext is not None and len(ext.content):
- int.content = ext.content
-
- ext=C.getChild('constraint')
- int=self.getChild('constraint')
- if int is not None and ext is not None and len(ext.content):
- int.content = ext.content
-
+
+ for i in ['component-username', 'component-author',
+ 'component-type', 'component-icone', 'component-version',
+ 'component-comment', 'component-multistudy', 'constraint']:
+ ext = C.getChild(i)
+ int = self.getChild(i)
+ if int is None:
+ int = ext
+ elif ext is not None and len(ext.content):
+ int.content = ext.content
+
L_ext = C.getChild('component-interface-list')
L_int = self.getChild('component-interface-list')
if L_ext is None or L_int is None:
if ((s[0] == "Engines") & (s[1] == "Component")):
self.EngineType = 1; break
- if common_data["COMP_NAME"] : Comp = Component(common_data["COMP_NAME"])
- else : Comp = Component(node.identifier())
+ Comp = Component()
self.currentInterface = Comp.createInterface(node.identifier())
c.accept(self)
if (self.EngineType):
+ global nb_components
+ nb_components = nb_components + 1
self.catalog.mergeComponent(Comp)
self.EngineType = 0
self.currentService.createOutParameter \
(node.identifier(), self.currentType)
-#--------------------------------------------------
-# extract value of <param_name> from <args> list
-# it's proposed that the matching <args> item
-# looks like <param_name>=<value>, for example,
-# catalog=/tmp/myxml.xml
-#--------------------------------------------------
-def getParamValue( param_name, args ):
- pattern="^"+param_name+"="
-
- res = "" #initial value
- for opt in args:
- s = re.compile(pattern).search(opt)
- if s:
- res = opt[s.end():]
- break #found
-
- return res
-
#--------------------------------------------------
# parse idl and store xml file
#--------------------------------------------------
def run(tree, args):
- CatalogFileName=getParamValue("catalog",args)
- if CatalogFileName is None:
- CatalogFileName = 'CatalogModulePersonnel.xml'
+ print args
- if (re.compile(".*?.xml$").match(CatalogFileName, 1) is None):
+ CatalogFileName=getParamValue("catalog", "CatalogModulePersonnel.xml", args)
+ print CatalogFileName
+ if re.compile(".*?.xml$").match(CatalogFileName, 1) is None:
CatalogFileName = CatalogFileName + '.xml'
#========= Read parameters ======================
- common_data["ICON"] = getParamValue("icon",args) # get icon file
-
- common_data["AUTHOR"] = getParamValue("author",args) # get author name
- if common_data["AUTHOR"] is None: common_data["AUTHOR"] = os.getenv("USER");
+ common_data["ICON"] = getParamValue("icon", "", args)
+ common_data["AUTHOR"] = getParamValue("author", os.getenv("USER"), args)
+ common_data["VERSION"] = getParamValue("version", "1", args)
+ common_data["COMP_NAME"] = getParamValue("name", "", args)
+ common_data["COMP_UNAME"] = getParamValue("username", "", args)
+ common_data["COMP_TYPE"] = getParamValue("type", "OTHER", args)
+ common_data["COMP_MULT"] = getParamValue("multistudy", "1", args)
+
+ print common_data
- common_data["VERSION"] = getParamValue("version",args) # get version
-
- common_data["COMP_NAME"] = getParamValue("name",args) # get icon file
-
- val = getParamValue("type",args) # get icon file
- if val: common_data["COMP_TYPE"] = val
-
- val = getParamValue("multistudy",args) # get icon file
- if val : common_data["COMP_MULT"] = val
-
- remove_comp = getParamValue("remove", args)
+ remove_comp = getParamValue("remove", "", args)
#==================================================
print "Importing", CatalogFileName
C = Catalog(CatalogFileName)
else:
- print "Warning : ",CatalogFileName, " was not found."
+ print "Creating ",CatalogFileName
C = Catalog()
-
+
print "Reading idl file"
visitor = ModuleCatalogVisitor(C)
if __name__ == "__main__":
print
- print "Usage : omniidl -bIDLparser -Wbcatalog=<my_catalog.xml>[,icon=<pngfile>][,version=<num>][,author=<name>][,name=<component_name>][,multistudy=<component_multistudy>][,remove=component_name] <file.idl>"
+ print "Usage : omniidl -bIDLparser [-I<catalog files directory>]* -Wbcatalog=<my_catalog.xml>[,icon=<pngfile>][,version=<num>][,author=<name>][,name=<component_name>][,username=<component_username>][,multistudy=<component_multistudy>] <file.idl>"
print
//
// File : ToolsGUI_CatalogGeneratorDlg.cxx
// Author : Nicolas REJNERI
+// Modified : Marc TAJCHMAN
// Module : SALOME
// $Header$
#include "QAD_Desktop.h"
#include "QAD_FileDlg.h"
#include "QAD_MessageBox.h"
+#include "QAD_Tools.h"
#include <stdlib.h>
#include <qlabel.h>
#include <qlineedit.h>
supplGrpLayout->setSpacing( SPACING_SIZE );
supplGrpLayout->setMargin( MARGIN_SIZE );
+ QSize myMinimumSize(int(MIN_EDIT_SIZE*0.3), 0);
+
myAuthorEdit = new QLineEdit( supplGrp , "myAuthorEdit" );
myAuthorEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myAuthorEdit->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 );
+ myAuthorEdit->setMinimumSize( myMinimumSize );
OSD_Process aProcess;
myAuthorEdit->setText(aProcess.UserName().ToCString());
myVersionEdit = new QLineEdit(supplGrp , "myVersion" );
myVersionEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myVersionEdit->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 );
+ myVersionEdit->setMinimumSize( myMinimumSize );
QStringList aList = QStringList::split(QRegExp("\\s+"),tr( "INF_VERSION" ));
myVersionEdit->setText(aList.last());
QDoubleValidator *validator = new QDoubleValidator(myVersionEdit);
myCompName = new QLineEdit(supplGrp , "myCompName");
myCompName->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myCompName->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 );
+ myCompName->setMinimumSize( myMinimumSize );
+
+ myCompUserName = new QLineEdit(supplGrp , "myCompUserName");
+ myCompUserName->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myCompUserName->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 );
myCompType = new QLineEdit(supplGrp , "myCompType");
myCompType->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myCompType->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 );
+ myCompType->setMinimumSize( myMinimumSize );
myCompType->setText("OTHER");
myCompMultiStd = new QLineEdit(supplGrp , "myCompMultiStd");
myCompMultiStd->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myCompMultiStd->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 );
+ myCompMultiStd->setMinimumSize( myMinimumSize );
myCompMultiStd->setText("1");
QIntValidator *ivalidator = new QIntValidator(myVersionEdit);
myCompMultiStd->setValidator(ivalidator);
supplGrpLayout->addWidget( myAuthorEdit, 0, 1 );
supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_NAME" ), supplGrp ), 0, 2);
supplGrpLayout->addWidget(myCompName,0,3);
- supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_TYPE" ), supplGrp ), 0, 4);
- supplGrpLayout->addWidget(myCompType,0,5);
+ supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_USERNAME" ), supplGrp ), 0, 4);
+ supplGrpLayout->addWidget(myCompUserName,0,5);
supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_VERSION" ), supplGrp ), 1, 0);
supplGrpLayout->addWidget( myVersionEdit, 1, 1);
supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_MULTISTD" ), supplGrp ), 1, 2);
supplGrpLayout->addWidget(myCompMultiStd,1,3);
+ supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_TYPE" ), supplGrp ), 1, 4);
+ supplGrpLayout->addWidget(myCompType,1,5);
supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_PNG_FILE" ), supplGrp ), 2, 0);
supplGrpLayout->addMultiCellWidget( myPngEdit, 2,2,1,4 );
supplGrpLayout->addWidget( myBrowsePngBtn, 2, 5 );
return myCompName->text().stripWhiteSpace();
}
+//=================================================================================
+// function : getCompUserName()
+// purpose : gets username of the component
+//=================================================================================
+QString ToolsGUI_CatalogGeneratorDlg::getCompUserName()
+{
+ return myCompUserName->text().stripWhiteSpace();
+}
+
//=================================================================================
// function : getCompType()
// purpose : gets type of the component
return myCompType->text().stripWhiteSpace();
}
+//=================================================================================
+// function : getIdlPath()
+// purpose : gets IDL path of modules
+//=================================================================================
+QString ToolsGUI_CatalogGeneratorDlg::getIdlPath()
+{
+ SALOME_ModuleCatalog::ModuleCatalog_var aCatalog =
+ SALOME_ModuleCatalog::ModuleCatalog::_narrow( QAD_Application::getDesktop()->getCatalogue());
+
+ SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants =
+ aCatalog->GetComponentIconeList();
+
+ QString IDLpath = "";
+
+ for (unsigned int ind = 0; ind < list_composants->length();ind++) {
+ QString modulename = strdup(list_composants[ind].modulename) ;
+
+ QCString dir;
+ if (dir = getenv( modulename + "_ROOT_DIR")) {
+ IDLpath = IDLpath + "-I" + QAD_Tools::addSlash( QAD_Tools::addSlash(dir) +
+ QAD_Tools::addSlash("idl") +
+ QAD_Tools::addSlash("salome")) + " ";
+ }
+ }
+
+ // MESSAGE ( " IDLpath = " << IDLpath);
+
+ return IDLpath;
+}
+
//=================================================================================
// function : onBrowseBtnClicked()
// purpose : <...> (Browse) buttons slot
//=================================================================================
void ToolsGUI_CatalogGeneratorDlg::onApply()
{
+ QString IDLpath = getIdlPath();
QString XmlFile = getXmlFile();
QString IdlFile = getIdlFile();
QString Author = getAuthor();
QString Version = getVersion();
QString PngFile = getPngFile();
QString CompName = getCompName(); //gets component name
+ QString CompUserName = getCompUserName(); //gets component username
QString CompType = getCompType(); //gets component type
QString CompMultiStd = getCompMultiStd();
else {
QString command = "";
if ( getenv("KERNEL_ROOT_DIR") )
- command = QString( getenv( "KERNEL_ROOT_DIR" ) ) + "/bin/runIDLparser -Wbcatalog=" + XmlFile;
+ command = QString( getenv( "KERNEL_ROOT_DIR" ) ) + "/bin/salome/runIDLparser " + IDLpath + " -Wbcatalog=" + XmlFile;
else {
QAD_MessageBox::error1( this,
tr("TOOLS_ERR_ERROR"),
tr("KERNEL_ROOT_DIR variable is not defined"),
tr("TOOLS_BUT_OK") );
}
+
if (!Author.isEmpty()) command += ",author=" + Author;
if (!Version.isEmpty()) command += ",version=" + Version;
if (!PngFile.isEmpty()) {
command += QString(",icon=") + QString(aFile.ToCString());
}
if (!CompName.isEmpty()) command += ",name=" + CompName;
+ if (!CompUserName.isEmpty()) command += ",username=" + CompUserName;
if (!CompType.isEmpty()) command += ",type=" + CompType;
if (!CompMultiStd.isEmpty()) command += ",multistudy=" + CompMultiStd;
command += " " + IdlFile;